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" |
| 22 | #include "mtdutils/mtdutils.h" |
Koushik Dutta | fef77c0 | 2010-11-09 20:03:42 -0800 | [diff] [blame^] | 23 | #include "mmcutils/mmcutils.h" |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 24 | |
Koushik Dutta | fef77c0 | 2010-11-09 20:03:42 -0800 | [diff] [blame^] | 25 | #ifndef BOARD_USES_MMCUTILS |
Koushik Dutta | 7a77aec | 2010-11-09 09:23:15 -0800 | [diff] [blame] | 26 | #define DEFAULT_DEVICE g_mtd_device |
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 |
| 29 | #define DEFAULT_DEVICE g_mmc_device |
Koushik Dutta | fef77c0 | 2010-11-09 20:03:42 -0800 | [diff] [blame^] | 30 | #define DEFAULT_FILESYSTEM "ext3" |
Koushik Dutta | 7a77aec | 2010-11-09 09:23:15 -0800 | [diff] [blame] | 31 | #endif |
| 32 | |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 33 | #ifndef SDCARD_DEVICE_PRIMARY |
Koushik Dutta | ceddcd5 | 2010-08-23 16:13:14 -0700 | [diff] [blame] | 34 | #define SDCARD_DEVICE_PRIMARY "/dev/block/mmcblk0p1" |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 35 | #endif |
| 36 | |
| 37 | #ifndef SDCARD_DEVICE_SECONDARY |
Koushik Dutta | ceddcd5 | 2010-08-23 16:13:14 -0700 | [diff] [blame] | 38 | #define SDCARD_DEVICE_SECONDARY "/dev/block/mmcblk0" |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 39 | #endif |
| 40 | |
| 41 | #ifndef SDEXT_DEVICE |
| 42 | #define SDEXT_DEVICE "/dev/block/mmcblk0p2" |
| 43 | #endif |
| 44 | |
| 45 | #ifndef SDEXT_FILESYSTEM |
Koushik Dutta | 1bf4f69 | 2010-07-14 18:37:33 -0700 | [diff] [blame] | 46 | #define SDEXT_FILESYSTEM "auto" |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 47 | #endif |
| 48 | |
| 49 | #ifndef DATA_DEVICE |
Koushik Dutta | 7a77aec | 2010-11-09 09:23:15 -0800 | [diff] [blame] | 50 | #define DATA_DEVICE DEFAULT_DEVICE |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 51 | #endif |
| 52 | |
| 53 | #ifndef DATA_FILESYSTEM |
Koushik Dutta | fef77c0 | 2010-11-09 20:03:42 -0800 | [diff] [blame^] | 54 | #define DATA_FILESYSTEM DEFAULT_FILESYSTEM |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 55 | #endif |
| 56 | |
| 57 | #ifndef DATADATA_DEVICE |
Koushik Dutta | 7a77aec | 2010-11-09 09:23:15 -0800 | [diff] [blame] | 58 | #define DATADATA_DEVICE DEFAULT_DEVICE |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 59 | #endif |
| 60 | |
| 61 | #ifndef DATADATA_FILESYSTEM |
Koushik Dutta | fef77c0 | 2010-11-09 20:03:42 -0800 | [diff] [blame^] | 62 | #define DATADATA_FILESYSTEM DEFAULT_FILESYSTEM |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 63 | #endif |
| 64 | |
| 65 | #ifndef CACHE_DEVICE |
Koushik Dutta | 7a77aec | 2010-11-09 09:23:15 -0800 | [diff] [blame] | 66 | #define CACHE_DEVICE DEFAULT_DEVICE |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 67 | #endif |
| 68 | |
| 69 | #ifndef CACHE_FILESYSTEM |
Koushik Dutta | fef77c0 | 2010-11-09 20:03:42 -0800 | [diff] [blame^] | 70 | #define CACHE_FILESYSTEM DEFAULT_FILESYSTEM |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 71 | #endif |
| 72 | |
Koushik Dutta | 5aaa823 | 2010-07-20 16:23:18 -0700 | [diff] [blame] | 73 | #ifndef SYSTEM_DEVICE |
Koushik Dutta | 7a77aec | 2010-11-09 09:23:15 -0800 | [diff] [blame] | 74 | #define SYSTEM_DEVICE DEFAULT_DEVICE |
Koushik Dutta | 5aaa823 | 2010-07-20 16:23:18 -0700 | [diff] [blame] | 75 | #endif |
| 76 | |
| 77 | #ifndef SYSTEM_FILESYSTEM |
Koushik Dutta | fef77c0 | 2010-11-09 20:03:42 -0800 | [diff] [blame^] | 78 | #define SYSTEM_FILESYSTEM DEFAULT_FILESYSTEM |
Koushik Dutta | 5aaa823 | 2010-07-20 16:23:18 -0700 | [diff] [blame] | 79 | #endif |
| 80 | |
Koushik Dutta | d4060c3 | 2010-07-22 20:14:44 -0700 | [diff] [blame] | 81 | #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 Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 98 | /* 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 | */ |
| 104 | int register_package_root(const ZipArchive *package, const char *package_path); |
| 105 | |
| 106 | /* Returns non-zero iff root_path points inside a package. |
| 107 | */ |
| 108 | int 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 | */ |
| 114 | const 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 | */ |
| 120 | const 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 | */ |
| 125 | int is_root_path_mounted(const char *root_path); |
| 126 | |
| 127 | int ensure_root_path_mounted(const char *root_path); |
| 128 | |
| 129 | int ensure_root_path_unmounted(const char *root_path); |
| 130 | |
| 131 | const MtdPartition *get_root_mtd_partition(const char *root_path); |
Koushik Dutta | fef77c0 | 2010-11-09 20:03:42 -0800 | [diff] [blame^] | 132 | const MmcPartition *get_root_mmc_partition(const char *root_path); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 133 | |
| 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 | */ |
| 137 | int format_root_device(const char *root); |
| 138 | |
Koushik Dutta | 14239d2 | 2010-06-14 15:02:48 -0700 | [diff] [blame] | 139 | typedef 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 Dutta | d4060c3 | 2010-07-22 20:14:44 -0700 | [diff] [blame] | 146 | const char *filesystem_options; |
Koushik Dutta | 14239d2 | 2010-06-14 15:02:48 -0700 | [diff] [blame] | 147 | } RootInfo; |
| 148 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 149 | #endif // RECOVERY_ROOTS_H_ |