blob: 64d7281b63b5b94f283c1acaa829c2f47c3bbfe4 [file] [log] [blame]
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
Shashank Mittal815ca5d2010-07-27 11:09:19 -07003 * Copyright (c) 2010, Code Aurora Forum. All rights reserved.
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -08004 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef RECOVERY_ROOTS_H_
19#define RECOVERY_ROOTS_H_
20
21#include "minzip/Zip.h"
22#include "mtdutils/mtdutils.h"
23
Koushik Duttaa6522b32010-06-20 13:16:06 -070024#ifndef SDCARD_DEVICE_PRIMARY
Koushik Duttaceddcd52010-08-23 16:13:14 -070025#define SDCARD_DEVICE_PRIMARY "/dev/block/mmcblk0p1"
Koushik Duttaa6522b32010-06-20 13:16:06 -070026#endif
27
28#ifndef SDCARD_DEVICE_SECONDARY
Koushik Duttaceddcd52010-08-23 16:13:14 -070029#define SDCARD_DEVICE_SECONDARY "/dev/block/mmcblk0"
Koushik Duttaa6522b32010-06-20 13:16:06 -070030#endif
31
32#ifndef SDEXT_DEVICE
33#define SDEXT_DEVICE "/dev/block/mmcblk0p2"
34#endif
35
36#ifndef SDEXT_FILESYSTEM
Koushik Dutta1bf4f692010-07-14 18:37:33 -070037#define SDEXT_FILESYSTEM "auto"
Koushik Duttaa6522b32010-06-20 13:16:06 -070038#endif
39
40#ifndef DATA_DEVICE
41#define DATA_DEVICE g_mtd_device
42#endif
43
44#ifndef DATA_FILESYSTEM
45#define DATA_FILESYSTEM "yaffs2"
46#endif
47
48#ifndef DATADATA_DEVICE
49#define DATADATA_DEVICE g_mtd_device
50#endif
51
52#ifndef DATADATA_FILESYSTEM
53#define DATADATA_FILESYSTEM "yaffs2"
54#endif
55
56#ifndef CACHE_DEVICE
57#define CACHE_DEVICE g_mtd_device
58#endif
59
60#ifndef CACHE_FILESYSTEM
61#define CACHE_FILESYSTEM "yaffs2"
62#endif
63
Koushik Dutta5aaa8232010-07-20 16:23:18 -070064#ifndef SYSTEM_DEVICE
65#define SYSTEM_DEVICE g_mtd_device
66#endif
67
68#ifndef SYSTEM_FILESYSTEM
69#define SYSTEM_FILESYSTEM "yaffs2"
70#endif
71
Koushik Duttad4060c32010-07-22 20:14:44 -070072#ifndef DATA_FILESYSTEM_OPTIONS
73#define DATA_FILESYSTEM_OPTIONS NULL
74#endif
75
76#ifndef CACHE_FILESYSTEM_OPTIONS
77#define CACHE_FILESYSTEM_OPTIONS NULL
78#endif
79
80#ifndef DATADATA_FILESYSTEM_OPTIONS
81#define DATADATA_FILESYSTEM_OPTIONS NULL
82#endif
83
84#ifndef SYSTEM_FILESYSTEM_OPTIONS
85#define SYSTEM_FILESYSTEM_OPTIONS NULL
86#endif
87
88
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080089/* Any of the "root_path" arguments can be paths with relative
90 * components, like "SYSTEM:a/b/c".
91 */
92
93/* Associate this package with the package root "PKG:".
94 */
95int register_package_root(const ZipArchive *package, const char *package_path);
96
97/* Returns non-zero iff root_path points inside a package.
98 */
99int is_package_root_path(const char *root_path);
100
101/* Takes a string like "SYSTEM:lib" and turns it into a string
102 * like "/system/lib". The translated path is put in out_buf,
103 * and out_buf is returned if the translation succeeded.
104 */
105const char *translate_root_path(const char *root_path,
106 char *out_buf, size_t out_buf_len);
107
108/* Takes a string like "PKG:lib/libc.so" and returns a pointer to
109 * the containing zip file and a path like "lib/libc.so".
110 */
111const char *translate_package_root_path(const char *root_path,
112 char *out_buf, size_t out_buf_len, const ZipArchive **out_package);
113
114/* Returns negative on error, positive if it's mounted, zero if it isn't.
115 */
116int is_root_path_mounted(const char *root_path);
117
118int ensure_root_path_mounted(const char *root_path);
119
120int ensure_root_path_unmounted(const char *root_path);
121
122const MtdPartition *get_root_mtd_partition(const char *root_path);
123
124/* "root" must be the exact name of the root; no relative path is permitted.
125 * If the named root is mounted, this will attempt to unmount it first.
126 */
127int format_root_device(const char *root);
128
Koushik Dutta14239d22010-06-14 15:02:48 -0700129typedef struct {
130 const char *name;
131 const char *device;
132 const char *device2; // If the first one doesn't work (may be NULL)
133 const char *partition_name;
134 const char *mount_point;
135 const char *filesystem;
Koushik Duttad4060c32010-07-22 20:14:44 -0700136 const char *filesystem_options;
Koushik Dutta14239d22010-06-14 15:02:48 -0700137} RootInfo;
138
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800139#endif // RECOVERY_ROOTS_H_