blob: 40aef877067c2a689b625dee80ca52f32669b7cd [file] [log] [blame]
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef RECOVERY_ROOTS_H_
18#define RECOVERY_ROOTS_H_
19
20#include "minzip/Zip.h"
21#include "mtdutils/mtdutils.h"
22
Koushik Duttaa6522b32010-06-20 13:16:06 -070023#ifndef SDCARD_DEVICE_PRIMARY
24#define SDCARD_DEVICE_PRIMARY "/dev/block/mmcblk0"
25#endif
26
27#ifndef SDCARD_DEVICE_SECONDARY
28#define SDCARD_DEVICE_SECONDARY "/dev/block/mmcblk0p1"
29#endif
30
31#ifndef SDEXT_DEVICE
32#define SDEXT_DEVICE "/dev/block/mmcblk0p2"
33#endif
34
35#ifndef SDEXT_FILESYSTEM
36#define SDEXT_FILESYSTEM "ext4"
37#endif
38
39#ifndef DATA_DEVICE
40#define DATA_DEVICE g_mtd_device
41#endif
42
43#ifndef DATA_FILESYSTEM
44#define DATA_FILESYSTEM "yaffs2"
45#endif
46
47#ifndef DATADATA_DEVICE
48#define DATADATA_DEVICE g_mtd_device
49#endif
50
51#ifndef DATADATA_FILESYSTEM
52#define DATADATA_FILESYSTEM "yaffs2"
53#endif
54
55#ifndef CACHE_DEVICE
56#define CACHE_DEVICE g_mtd_device
57#endif
58
59#ifndef CACHE_FILESYSTEM
60#define CACHE_FILESYSTEM "yaffs2"
61#endif
62
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080063/* Any of the "root_path" arguments can be paths with relative
64 * components, like "SYSTEM:a/b/c".
65 */
66
67/* Associate this package with the package root "PKG:".
68 */
69int register_package_root(const ZipArchive *package, const char *package_path);
70
71/* Returns non-zero iff root_path points inside a package.
72 */
73int is_package_root_path(const char *root_path);
74
75/* Takes a string like "SYSTEM:lib" and turns it into a string
76 * like "/system/lib". The translated path is put in out_buf,
77 * and out_buf is returned if the translation succeeded.
78 */
79const char *translate_root_path(const char *root_path,
80 char *out_buf, size_t out_buf_len);
81
82/* Takes a string like "PKG:lib/libc.so" and returns a pointer to
83 * the containing zip file and a path like "lib/libc.so".
84 */
85const char *translate_package_root_path(const char *root_path,
86 char *out_buf, size_t out_buf_len, const ZipArchive **out_package);
87
88/* Returns negative on error, positive if it's mounted, zero if it isn't.
89 */
90int is_root_path_mounted(const char *root_path);
91
92int ensure_root_path_mounted(const char *root_path);
93
94int ensure_root_path_unmounted(const char *root_path);
95
96const MtdPartition *get_root_mtd_partition(const char *root_path);
97
98/* "root" must be the exact name of the root; no relative path is permitted.
99 * If the named root is mounted, this will attempt to unmount it first.
100 */
101int format_root_device(const char *root);
102
Koushik Dutta14239d22010-06-14 15:02:48 -0700103typedef struct {
104 const char *name;
105 const char *device;
106 const char *device2; // If the first one doesn't work (may be NULL)
107 const char *partition_name;
108 const char *mount_point;
109 const char *filesystem;
110} RootInfo;
111
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800112#endif // RECOVERY_ROOTS_H_