blob: 833c1b5fdd04dc4e22fd28f4beb4ab629d5cb2ea [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"
Steve Kondik4123b582010-11-14 03:18:40 -050022#include "flashutils/flashutils.h"
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080023#include "mtdutils/mtdutils.h"
Koushik Duttafef77c02010-11-09 20:03:42 -080024#include "mmcutils/mmcutils.h"
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080025
Koushik Duttafef77c02010-11-09 20:03:42 -080026#ifndef BOARD_USES_MMCUTILS
Koushik Duttafef77c02010-11-09 20:03:42 -080027#define DEFAULT_FILESYSTEM "yaffs2"
Koushik Dutta7a77aec2010-11-09 09:23:15 -080028#else
Koushik Duttafef77c02010-11-09 20:03:42 -080029#define DEFAULT_FILESYSTEM "ext3"
Koushik Dutta7a77aec2010-11-09 09:23:15 -080030#endif
31
Koushik Dutta19447c02010-11-10 10:40:44 -080032#ifndef BOARD_SDCARD_DEVICE_PRIMARY
33#define BOARD_SDCARD_DEVICE_PRIMARY "/dev/block/mmcblk0p1"
Koushik Duttaa6522b32010-06-20 13:16:06 -070034#endif
35
Koushik Dutta19447c02010-11-10 10:40:44 -080036#ifndef BOARD_SDCARD_DEVICE_SECONDARY
37#define BOARD_SDCARD_DEVICE_SECONDARY "/dev/block/mmcblk0"
Koushik Duttaa6522b32010-06-20 13:16:06 -070038#endif
39
Brint E. Kriebeld3522332010-12-11 20:52:06 -070040#ifndef BOARD_SDCARD_DEVICE_INTERNAL
41#define BOARD_SDCARD_DEVICE_INTERNAL g_default_device
42#endif
43
Koushik Dutta19447c02010-11-10 10:40:44 -080044#ifndef BOARD_SDEXT_DEVICE
45#define BOARD_SDEXT_DEVICE "/dev/block/mmcblk0p2"
Koushik Duttaa6522b32010-06-20 13:16:06 -070046#endif
47
Koushik Dutta19447c02010-11-10 10:40:44 -080048#ifndef BOARD_SDEXT_FILESYSTEM
49#define BOARD_SDEXT_FILESYSTEM "auto"
Koushik Duttaa6522b32010-06-20 13:16:06 -070050#endif
51
Koushik Dutta19447c02010-11-10 10:40:44 -080052#ifndef BOARD_DATA_DEVICE
53#define BOARD_DATA_DEVICE g_default_device
Koushik Duttaa6522b32010-06-20 13:16:06 -070054#endif
55
Koushik Dutta19447c02010-11-10 10:40:44 -080056#ifndef BOARD_DATA_FILESYSTEM
57#define BOARD_DATA_FILESYSTEM DEFAULT_FILESYSTEM
Koushik Duttaa6522b32010-06-20 13:16:06 -070058#endif
59
Koushik Dutta19447c02010-11-10 10:40:44 -080060#ifndef BOARD_DATADATA_DEVICE
61#define BOARD_DATADATA_DEVICE g_default_device
Koushik Duttaa6522b32010-06-20 13:16:06 -070062#endif
63
Koushik Dutta19447c02010-11-10 10:40:44 -080064#ifndef BOARD_DATADATA_FILESYSTEM
65#define BOARD_DATADATA_FILESYSTEM DEFAULT_FILESYSTEM
Koushik Duttaa6522b32010-06-20 13:16:06 -070066#endif
67
Koushik Dutta19447c02010-11-10 10:40:44 -080068#ifndef BOARD_CACHE_DEVICE
69#define BOARD_CACHE_DEVICE g_default_device
Koushik Duttaa6522b32010-06-20 13:16:06 -070070#endif
71
Koushik Dutta19447c02010-11-10 10:40:44 -080072#ifndef BOARD_CACHE_FILESYSTEM
73#define BOARD_CACHE_FILESYSTEM DEFAULT_FILESYSTEM
Koushik Duttaa6522b32010-06-20 13:16:06 -070074#endif
75
Koushik Dutta19447c02010-11-10 10:40:44 -080076#ifndef BOARD_SYSTEM_DEVICE
77#define BOARD_SYSTEM_DEVICE g_default_device
Koushik Dutta5aaa8232010-07-20 16:23:18 -070078#endif
79
Koushik Dutta19447c02010-11-10 10:40:44 -080080#ifndef BOARD_SYSTEM_FILESYSTEM
81#define BOARD_SYSTEM_FILESYSTEM DEFAULT_FILESYSTEM
Koushik Dutta5aaa8232010-07-20 16:23:18 -070082#endif
83
Koushik Dutta19447c02010-11-10 10:40:44 -080084#ifndef BOARD_DATA_FILESYSTEM_OPTIONS
85#define BOARD_DATA_FILESYSTEM_OPTIONS NULL
Koushik Duttad4060c32010-07-22 20:14:44 -070086#endif
87
Koushik Dutta19447c02010-11-10 10:40:44 -080088#ifndef BOARD_CACHE_FILESYSTEM_OPTIONS
89#define BOARD_CACHE_FILESYSTEM_OPTIONS NULL
Koushik Duttad4060c32010-07-22 20:14:44 -070090#endif
91
Koushik Dutta19447c02010-11-10 10:40:44 -080092#ifndef BOARD_DATADATA_FILESYSTEM_OPTIONS
93#define BOARD_DATADATA_FILESYSTEM_OPTIONS NULL
Koushik Duttad4060c32010-07-22 20:14:44 -070094#endif
95
Koushik Dutta19447c02010-11-10 10:40:44 -080096#ifndef BOARD_SYSTEM_FILESYSTEM_OPTIONS
97#define BOARD_SYSTEM_FILESYSTEM_OPTIONS NULL
Koushik Duttad4060c32010-07-22 20:14:44 -070098#endif
99
100
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800101/* Any of the "root_path" arguments can be paths with relative
102 * components, like "SYSTEM:a/b/c".
103 */
104
105/* Associate this package with the package root "PKG:".
106 */
107int register_package_root(const ZipArchive *package, const char *package_path);
108
109/* Returns non-zero iff root_path points inside a package.
110 */
111int is_package_root_path(const char *root_path);
112
113/* Takes a string like "SYSTEM:lib" and turns it into a string
114 * like "/system/lib". The translated path is put in out_buf,
115 * and out_buf is returned if the translation succeeded.
116 */
117const char *translate_root_path(const char *root_path,
118 char *out_buf, size_t out_buf_len);
119
120/* Takes a string like "PKG:lib/libc.so" and returns a pointer to
121 * the containing zip file and a path like "lib/libc.so".
122 */
123const char *translate_package_root_path(const char *root_path,
124 char *out_buf, size_t out_buf_len, const ZipArchive **out_package);
125
126/* Returns negative on error, positive if it's mounted, zero if it isn't.
127 */
128int is_root_path_mounted(const char *root_path);
129
130int ensure_root_path_mounted(const char *root_path);
131
132int ensure_root_path_unmounted(const char *root_path);
133
134const MtdPartition *get_root_mtd_partition(const char *root_path);
Koushik Dutta19447c02010-11-10 10:40:44 -0800135int get_root_partition_device(const char *root_path, char *device);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800136
137/* "root" must be the exact name of the root; no relative path is permitted.
138 * If the named root is mounted, this will attempt to unmount it first.
139 */
140int format_root_device(const char *root);
141
Koushik Dutta14239d22010-06-14 15:02:48 -0700142typedef struct {
143 const char *name;
144 const char *device;
145 const char *device2; // If the first one doesn't work (may be NULL)
146 const char *partition_name;
147 const char *mount_point;
148 const char *filesystem;
Koushik Duttad4060c32010-07-22 20:14:44 -0700149 const char *filesystem_options;
Koushik Dutta14239d22010-06-14 15:02:48 -0700150} RootInfo;
151
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800152#endif // RECOVERY_ROOTS_H_