blob: ee783638fd6a80f21c879ccdeb28c61da9fd9d37 [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"
Koushik Duttafef77c02010-11-09 20:03:42 -080023#include "mmcutils/mmcutils.h"
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080024
Koushik Duttafef77c02010-11-09 20:03:42 -080025#ifndef BOARD_USES_MMCUTILS
Koushik Dutta7a77aec2010-11-09 09:23:15 -080026#define DEFAULT_DEVICE g_mtd_device
Koushik Duttafef77c02010-11-09 20:03:42 -080027#define DEFAULT_FILESYSTEM "yaffs2"
Koushik Dutta7a77aec2010-11-09 09:23:15 -080028#else
29#define DEFAULT_DEVICE g_mmc_device
Koushik Duttafef77c02010-11-09 20:03:42 -080030#define DEFAULT_FILESYSTEM "ext3"
Koushik Dutta7a77aec2010-11-09 09:23:15 -080031#endif
32
Koushik Duttaa6522b32010-06-20 13:16:06 -070033#ifndef SDCARD_DEVICE_PRIMARY
Koushik Duttaceddcd52010-08-23 16:13:14 -070034#define SDCARD_DEVICE_PRIMARY "/dev/block/mmcblk0p1"
Koushik Duttaa6522b32010-06-20 13:16:06 -070035#endif
36
37#ifndef SDCARD_DEVICE_SECONDARY
Koushik Duttaceddcd52010-08-23 16:13:14 -070038#define SDCARD_DEVICE_SECONDARY "/dev/block/mmcblk0"
Koushik Duttaa6522b32010-06-20 13:16:06 -070039#endif
40
41#ifndef SDEXT_DEVICE
42#define SDEXT_DEVICE "/dev/block/mmcblk0p2"
43#endif
44
45#ifndef SDEXT_FILESYSTEM
Koushik Dutta1bf4f692010-07-14 18:37:33 -070046#define SDEXT_FILESYSTEM "auto"
Koushik Duttaa6522b32010-06-20 13:16:06 -070047#endif
48
49#ifndef DATA_DEVICE
Koushik Dutta7a77aec2010-11-09 09:23:15 -080050#define DATA_DEVICE DEFAULT_DEVICE
Koushik Duttaa6522b32010-06-20 13:16:06 -070051#endif
52
53#ifndef DATA_FILESYSTEM
Koushik Duttafef77c02010-11-09 20:03:42 -080054#define DATA_FILESYSTEM DEFAULT_FILESYSTEM
Koushik Duttaa6522b32010-06-20 13:16:06 -070055#endif
56
57#ifndef DATADATA_DEVICE
Koushik Dutta7a77aec2010-11-09 09:23:15 -080058#define DATADATA_DEVICE DEFAULT_DEVICE
Koushik Duttaa6522b32010-06-20 13:16:06 -070059#endif
60
61#ifndef DATADATA_FILESYSTEM
Koushik Duttafef77c02010-11-09 20:03:42 -080062#define DATADATA_FILESYSTEM DEFAULT_FILESYSTEM
Koushik Duttaa6522b32010-06-20 13:16:06 -070063#endif
64
65#ifndef CACHE_DEVICE
Koushik Dutta7a77aec2010-11-09 09:23:15 -080066#define CACHE_DEVICE DEFAULT_DEVICE
Koushik Duttaa6522b32010-06-20 13:16:06 -070067#endif
68
69#ifndef CACHE_FILESYSTEM
Koushik Duttafef77c02010-11-09 20:03:42 -080070#define CACHE_FILESYSTEM DEFAULT_FILESYSTEM
Koushik Duttaa6522b32010-06-20 13:16:06 -070071#endif
72
Koushik Dutta5aaa8232010-07-20 16:23:18 -070073#ifndef SYSTEM_DEVICE
Koushik Dutta7a77aec2010-11-09 09:23:15 -080074#define SYSTEM_DEVICE DEFAULT_DEVICE
Koushik Dutta5aaa8232010-07-20 16:23:18 -070075#endif
76
77#ifndef SYSTEM_FILESYSTEM
Koushik Duttafef77c02010-11-09 20:03:42 -080078#define SYSTEM_FILESYSTEM DEFAULT_FILESYSTEM
Koushik Dutta5aaa8232010-07-20 16:23:18 -070079#endif
80
Koushik Duttad4060c32010-07-22 20:14:44 -070081#ifndef DATA_FILESYSTEM_OPTIONS
82#define DATA_FILESYSTEM_OPTIONS NULL
83#endif
84
85#ifndef CACHE_FILESYSTEM_OPTIONS
86#define CACHE_FILESYSTEM_OPTIONS NULL
87#endif
88
89#ifndef DATADATA_FILESYSTEM_OPTIONS
90#define DATADATA_FILESYSTEM_OPTIONS NULL
91#endif
92
93#ifndef SYSTEM_FILESYSTEM_OPTIONS
94#define SYSTEM_FILESYSTEM_OPTIONS NULL
95#endif
96
97
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080098/* Any of the "root_path" arguments can be paths with relative
99 * components, like "SYSTEM:a/b/c".
100 */
101
102/* Associate this package with the package root "PKG:".
103 */
104int register_package_root(const ZipArchive *package, const char *package_path);
105
106/* Returns non-zero iff root_path points inside a package.
107 */
108int is_package_root_path(const char *root_path);
109
110/* Takes a string like "SYSTEM:lib" and turns it into a string
111 * like "/system/lib". The translated path is put in out_buf,
112 * and out_buf is returned if the translation succeeded.
113 */
114const char *translate_root_path(const char *root_path,
115 char *out_buf, size_t out_buf_len);
116
117/* Takes a string like "PKG:lib/libc.so" and returns a pointer to
118 * the containing zip file and a path like "lib/libc.so".
119 */
120const char *translate_package_root_path(const char *root_path,
121 char *out_buf, size_t out_buf_len, const ZipArchive **out_package);
122
123/* Returns negative on error, positive if it's mounted, zero if it isn't.
124 */
125int is_root_path_mounted(const char *root_path);
126
127int ensure_root_path_mounted(const char *root_path);
128
129int ensure_root_path_unmounted(const char *root_path);
130
131const MtdPartition *get_root_mtd_partition(const char *root_path);
Koushik Duttafef77c02010-11-09 20:03:42 -0800132const MmcPartition *get_root_mmc_partition(const char *root_path);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800133
134/* "root" must be the exact name of the root; no relative path is permitted.
135 * If the named root is mounted, this will attempt to unmount it first.
136 */
137int format_root_device(const char *root);
138
Koushik Dutta14239d22010-06-14 15:02:48 -0700139typedef struct {
140 const char *name;
141 const char *device;
142 const char *device2; // If the first one doesn't work (may be NULL)
143 const char *partition_name;
144 const char *mount_point;
145 const char *filesystem;
Koushik Duttad4060c32010-07-22 20:14:44 -0700146 const char *filesystem_options;
Koushik Dutta14239d22010-06-14 15:02:48 -0700147} RootInfo;
148
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800149#endif // RECOVERY_ROOTS_H_