The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
Shashank Mittal | 815ca5d | 2010-07-27 11:09:19 -0700 | [diff] [blame] | 3 | * Copyright (c) 2010, Code Aurora Forum. All rights reserved. |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 4 | * |
| 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 Kondik | 4123b58 | 2010-11-14 03:18:40 -0500 | [diff] [blame] | 22 | #include "flashutils/flashutils.h" |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 23 | #include "mtdutils/mtdutils.h" |
Koushik Dutta | fef77c0 | 2010-11-09 20:03:42 -0800 | [diff] [blame] | 24 | #include "mmcutils/mmcutils.h" |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 25 | |
Koushik Dutta | fef77c0 | 2010-11-09 20:03:42 -0800 | [diff] [blame] | 26 | #ifndef BOARD_USES_MMCUTILS |
Koushik Dutta | fef77c0 | 2010-11-09 20:03:42 -0800 | [diff] [blame] | 27 | #define DEFAULT_FILESYSTEM "yaffs2" |
Koushik Dutta | 7a77aec | 2010-11-09 09:23:15 -0800 | [diff] [blame] | 28 | #else |
Koushik Dutta | fef77c0 | 2010-11-09 20:03:42 -0800 | [diff] [blame] | 29 | #define DEFAULT_FILESYSTEM "ext3" |
Koushik Dutta | 7a77aec | 2010-11-09 09:23:15 -0800 | [diff] [blame] | 30 | #endif |
| 31 | |
Koushik Dutta | 19447c0 | 2010-11-10 10:40:44 -0800 | [diff] [blame] | 32 | #ifndef BOARD_SDCARD_DEVICE_PRIMARY |
| 33 | #define BOARD_SDCARD_DEVICE_PRIMARY "/dev/block/mmcblk0p1" |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 34 | #endif |
| 35 | |
Koushik Dutta | 19447c0 | 2010-11-10 10:40:44 -0800 | [diff] [blame] | 36 | #ifndef BOARD_SDCARD_DEVICE_SECONDARY |
| 37 | #define BOARD_SDCARD_DEVICE_SECONDARY "/dev/block/mmcblk0" |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 38 | #endif |
| 39 | |
Brint E. Kriebel | d352233 | 2010-12-11 20:52:06 -0700 | [diff] [blame] | 40 | #ifndef BOARD_SDCARD_DEVICE_INTERNAL |
| 41 | #define BOARD_SDCARD_DEVICE_INTERNAL g_default_device |
| 42 | #endif |
| 43 | |
Koushik Dutta | 19447c0 | 2010-11-10 10:40:44 -0800 | [diff] [blame] | 44 | #ifndef BOARD_SDEXT_DEVICE |
| 45 | #define BOARD_SDEXT_DEVICE "/dev/block/mmcblk0p2" |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 46 | #endif |
| 47 | |
Koushik Dutta | 19447c0 | 2010-11-10 10:40:44 -0800 | [diff] [blame] | 48 | #ifndef BOARD_SDEXT_FILESYSTEM |
| 49 | #define BOARD_SDEXT_FILESYSTEM "auto" |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 50 | #endif |
| 51 | |
Koushik Dutta | 19447c0 | 2010-11-10 10:40:44 -0800 | [diff] [blame] | 52 | #ifndef BOARD_DATA_DEVICE |
| 53 | #define BOARD_DATA_DEVICE g_default_device |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 54 | #endif |
| 55 | |
Koushik Dutta | 19447c0 | 2010-11-10 10:40:44 -0800 | [diff] [blame] | 56 | #ifndef BOARD_DATA_FILESYSTEM |
| 57 | #define BOARD_DATA_FILESYSTEM DEFAULT_FILESYSTEM |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 58 | #endif |
| 59 | |
Koushik Dutta | 19447c0 | 2010-11-10 10:40:44 -0800 | [diff] [blame] | 60 | #ifndef BOARD_DATADATA_DEVICE |
| 61 | #define BOARD_DATADATA_DEVICE g_default_device |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 62 | #endif |
| 63 | |
Koushik Dutta | 19447c0 | 2010-11-10 10:40:44 -0800 | [diff] [blame] | 64 | #ifndef BOARD_DATADATA_FILESYSTEM |
| 65 | #define BOARD_DATADATA_FILESYSTEM DEFAULT_FILESYSTEM |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 66 | #endif |
| 67 | |
Koushik Dutta | 19447c0 | 2010-11-10 10:40:44 -0800 | [diff] [blame] | 68 | #ifndef BOARD_CACHE_DEVICE |
| 69 | #define BOARD_CACHE_DEVICE g_default_device |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 70 | #endif |
| 71 | |
Koushik Dutta | 19447c0 | 2010-11-10 10:40:44 -0800 | [diff] [blame] | 72 | #ifndef BOARD_CACHE_FILESYSTEM |
| 73 | #define BOARD_CACHE_FILESYSTEM DEFAULT_FILESYSTEM |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 74 | #endif |
| 75 | |
Koushik Dutta | 19447c0 | 2010-11-10 10:40:44 -0800 | [diff] [blame] | 76 | #ifndef BOARD_SYSTEM_DEVICE |
| 77 | #define BOARD_SYSTEM_DEVICE g_default_device |
Koushik Dutta | 5aaa823 | 2010-07-20 16:23:18 -0700 | [diff] [blame] | 78 | #endif |
| 79 | |
Koushik Dutta | 19447c0 | 2010-11-10 10:40:44 -0800 | [diff] [blame] | 80 | #ifndef BOARD_SYSTEM_FILESYSTEM |
| 81 | #define BOARD_SYSTEM_FILESYSTEM DEFAULT_FILESYSTEM |
Koushik Dutta | 5aaa823 | 2010-07-20 16:23:18 -0700 | [diff] [blame] | 82 | #endif |
| 83 | |
Koushik Dutta | 19447c0 | 2010-11-10 10:40:44 -0800 | [diff] [blame] | 84 | #ifndef BOARD_DATA_FILESYSTEM_OPTIONS |
| 85 | #define BOARD_DATA_FILESYSTEM_OPTIONS NULL |
Koushik Dutta | d4060c3 | 2010-07-22 20:14:44 -0700 | [diff] [blame] | 86 | #endif |
| 87 | |
Koushik Dutta | 19447c0 | 2010-11-10 10:40:44 -0800 | [diff] [blame] | 88 | #ifndef BOARD_CACHE_FILESYSTEM_OPTIONS |
| 89 | #define BOARD_CACHE_FILESYSTEM_OPTIONS NULL |
Koushik Dutta | d4060c3 | 2010-07-22 20:14:44 -0700 | [diff] [blame] | 90 | #endif |
| 91 | |
Koushik Dutta | 19447c0 | 2010-11-10 10:40:44 -0800 | [diff] [blame] | 92 | #ifndef BOARD_DATADATA_FILESYSTEM_OPTIONS |
| 93 | #define BOARD_DATADATA_FILESYSTEM_OPTIONS NULL |
Koushik Dutta | d4060c3 | 2010-07-22 20:14:44 -0700 | [diff] [blame] | 94 | #endif |
| 95 | |
Koushik Dutta | 19447c0 | 2010-11-10 10:40:44 -0800 | [diff] [blame] | 96 | #ifndef BOARD_SYSTEM_FILESYSTEM_OPTIONS |
| 97 | #define BOARD_SYSTEM_FILESYSTEM_OPTIONS NULL |
Koushik Dutta | d4060c3 | 2010-07-22 20:14:44 -0700 | [diff] [blame] | 98 | #endif |
| 99 | |
| 100 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 101 | /* 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 | */ |
| 107 | int register_package_root(const ZipArchive *package, const char *package_path); |
| 108 | |
| 109 | /* Returns non-zero iff root_path points inside a package. |
| 110 | */ |
| 111 | int 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 | */ |
| 117 | const 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 | */ |
| 123 | const 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 | */ |
| 128 | int is_root_path_mounted(const char *root_path); |
| 129 | |
| 130 | int ensure_root_path_mounted(const char *root_path); |
| 131 | |
| 132 | int ensure_root_path_unmounted(const char *root_path); |
| 133 | |
| 134 | const MtdPartition *get_root_mtd_partition(const char *root_path); |
Koushik Dutta | 19447c0 | 2010-11-10 10:40:44 -0800 | [diff] [blame] | 135 | int get_root_partition_device(const char *root_path, char *device); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 136 | |
| 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 | */ |
| 140 | int format_root_device(const char *root); |
| 141 | |
Koushik Dutta | 14239d2 | 2010-06-14 15:02:48 -0700 | [diff] [blame] | 142 | typedef 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 Dutta | d4060c3 | 2010-07-22 20:14:44 -0700 | [diff] [blame] | 149 | const char *filesystem_options; |
Koushik Dutta | 14239d2 | 2010-06-14 15:02:48 -0700 | [diff] [blame] | 150 | } RootInfo; |
| 151 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 152 | #endif // RECOVERY_ROOTS_H_ |