blob: 02ec2fb1a665d54c75b5f17eb108ae612c031436 [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
Koushik Dutta19447c02010-11-10 10:40:44 -080040#ifndef BOARD_SDEXT_DEVICE
41#define BOARD_SDEXT_DEVICE "/dev/block/mmcblk0p2"
Koushik Duttaa6522b32010-06-20 13:16:06 -070042#endif
43
Koushik Dutta19447c02010-11-10 10:40:44 -080044#ifndef BOARD_SDEXT_FILESYSTEM
45#define BOARD_SDEXT_FILESYSTEM "auto"
Koushik Duttaa6522b32010-06-20 13:16:06 -070046#endif
47
Koushik Dutta19447c02010-11-10 10:40:44 -080048#ifndef BOARD_DATA_DEVICE
49#define BOARD_DATA_DEVICE g_default_device
Koushik Duttaa6522b32010-06-20 13:16:06 -070050#endif
51
Koushik Dutta19447c02010-11-10 10:40:44 -080052#ifndef BOARD_DATA_FILESYSTEM
53#define BOARD_DATA_FILESYSTEM DEFAULT_FILESYSTEM
Koushik Duttaa6522b32010-06-20 13:16:06 -070054#endif
55
Koushik Dutta19447c02010-11-10 10:40:44 -080056#ifndef BOARD_DATADATA_DEVICE
57#define BOARD_DATADATA_DEVICE g_default_device
Koushik Duttaa6522b32010-06-20 13:16:06 -070058#endif
59
Koushik Dutta19447c02010-11-10 10:40:44 -080060#ifndef BOARD_DATADATA_FILESYSTEM
61#define BOARD_DATADATA_FILESYSTEM DEFAULT_FILESYSTEM
Koushik Duttaa6522b32010-06-20 13:16:06 -070062#endif
63
Koushik Dutta19447c02010-11-10 10:40:44 -080064#ifndef BOARD_CACHE_DEVICE
65#define BOARD_CACHE_DEVICE g_default_device
Koushik Duttaa6522b32010-06-20 13:16:06 -070066#endif
67
Koushik Dutta19447c02010-11-10 10:40:44 -080068#ifndef BOARD_CACHE_FILESYSTEM
69#define BOARD_CACHE_FILESYSTEM DEFAULT_FILESYSTEM
Koushik Duttaa6522b32010-06-20 13:16:06 -070070#endif
71
Koushik Dutta19447c02010-11-10 10:40:44 -080072#ifndef BOARD_SYSTEM_DEVICE
73#define BOARD_SYSTEM_DEVICE g_default_device
Koushik Dutta5aaa8232010-07-20 16:23:18 -070074#endif
75
Koushik Dutta19447c02010-11-10 10:40:44 -080076#ifndef BOARD_SYSTEM_FILESYSTEM
77#define BOARD_SYSTEM_FILESYSTEM DEFAULT_FILESYSTEM
Koushik Dutta5aaa8232010-07-20 16:23:18 -070078#endif
79
Koushik Dutta19447c02010-11-10 10:40:44 -080080#ifndef BOARD_DATA_FILESYSTEM_OPTIONS
81#define BOARD_DATA_FILESYSTEM_OPTIONS NULL
Koushik Duttad4060c32010-07-22 20:14:44 -070082#endif
83
Koushik Dutta19447c02010-11-10 10:40:44 -080084#ifndef BOARD_CACHE_FILESYSTEM_OPTIONS
85#define BOARD_CACHE_FILESYSTEM_OPTIONS NULL
Koushik Duttad4060c32010-07-22 20:14:44 -070086#endif
87
Koushik Dutta19447c02010-11-10 10:40:44 -080088#ifndef BOARD_DATADATA_FILESYSTEM_OPTIONS
89#define BOARD_DATADATA_FILESYSTEM_OPTIONS NULL
Koushik Duttad4060c32010-07-22 20:14:44 -070090#endif
91
Koushik Dutta19447c02010-11-10 10:40:44 -080092#ifndef BOARD_SYSTEM_FILESYSTEM_OPTIONS
93#define BOARD_SYSTEM_FILESYSTEM_OPTIONS NULL
Koushik Duttad4060c32010-07-22 20:14:44 -070094#endif
95
96
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080097/* Any of the "root_path" arguments can be paths with relative
98 * components, like "SYSTEM:a/b/c".
99 */
100
101/* Associate this package with the package root "PKG:".
102 */
103int register_package_root(const ZipArchive *package, const char *package_path);
104
105/* Returns non-zero iff root_path points inside a package.
106 */
107int is_package_root_path(const char *root_path);
108
109/* Takes a string like "SYSTEM:lib" and turns it into a string
110 * like "/system/lib". The translated path is put in out_buf,
111 * and out_buf is returned if the translation succeeded.
112 */
113const char *translate_root_path(const char *root_path,
114 char *out_buf, size_t out_buf_len);
115
116/* Takes a string like "PKG:lib/libc.so" and returns a pointer to
117 * the containing zip file and a path like "lib/libc.so".
118 */
119const char *translate_package_root_path(const char *root_path,
120 char *out_buf, size_t out_buf_len, const ZipArchive **out_package);
121
122/* Returns negative on error, positive if it's mounted, zero if it isn't.
123 */
124int is_root_path_mounted(const char *root_path);
125
126int ensure_root_path_mounted(const char *root_path);
127
128int ensure_root_path_unmounted(const char *root_path);
129
130const MtdPartition *get_root_mtd_partition(const char *root_path);
Koushik Dutta19447c02010-11-10 10:40:44 -0800131int get_root_partition_device(const char *root_path, char *device);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800132
133/* "root" must be the exact name of the root; no relative path is permitted.
134 * If the named root is mounted, this will attempt to unmount it first.
135 */
136int format_root_device(const char *root);
137
Koushik Dutta14239d22010-06-14 15:02:48 -0700138typedef struct {
139 const char *name;
140 const char *device;
141 const char *device2; // If the first one doesn't work (may be NULL)
142 const char *partition_name;
143 const char *mount_point;
144 const char *filesystem;
Koushik Duttad4060c32010-07-22 20:14:44 -0700145 const char *filesystem_options;
Koushik Dutta14239d22010-06-14 15:02:48 -0700146} RootInfo;
147
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800148#endif // RECOVERY_ROOTS_H_