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 |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef RECOVERY_ROOTS_H_ |
| 18 | #define RECOVERY_ROOTS_H_ |
| 19 | |
| 20 | #include "minzip/Zip.h" |
| 21 | #include "mtdutils/mtdutils.h" |
| 22 | |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 23 | #ifndef SDCARD_DEVICE_PRIMARY |
| 24 | #define SDCARD_DEVICE_PRIMARY "/dev/block/mmcblk0" |
| 25 | #endif |
| 26 | |
| 27 | #ifndef SDCARD_DEVICE_SECONDARY |
| 28 | #define SDCARD_DEVICE_SECONDARY "/dev/block/mmcblk0p1" |
| 29 | #endif |
| 30 | |
| 31 | #ifndef SDEXT_DEVICE |
| 32 | #define SDEXT_DEVICE "/dev/block/mmcblk0p2" |
| 33 | #endif |
| 34 | |
| 35 | #ifndef SDEXT_FILESYSTEM |
Koushik Dutta | 1bf4f69 | 2010-07-14 18:37:33 -0700 | [diff] [blame] | 36 | #define SDEXT_FILESYSTEM "auto" |
Koushik Dutta | a6522b3 | 2010-06-20 13:16:06 -0700 | [diff] [blame] | 37 | #endif |
| 38 | |
| 39 | #ifndef DATA_DEVICE |
| 40 | #define DATA_DEVICE g_mtd_device |
| 41 | #endif |
| 42 | |
| 43 | #ifndef DATA_FILESYSTEM |
| 44 | #define DATA_FILESYSTEM "yaffs2" |
| 45 | #endif |
| 46 | |
| 47 | #ifndef DATADATA_DEVICE |
| 48 | #define DATADATA_DEVICE g_mtd_device |
| 49 | #endif |
| 50 | |
| 51 | #ifndef DATADATA_FILESYSTEM |
| 52 | #define DATADATA_FILESYSTEM "yaffs2" |
| 53 | #endif |
| 54 | |
| 55 | #ifndef CACHE_DEVICE |
| 56 | #define CACHE_DEVICE g_mtd_device |
| 57 | #endif |
| 58 | |
| 59 | #ifndef CACHE_FILESYSTEM |
| 60 | #define CACHE_FILESYSTEM "yaffs2" |
| 61 | #endif |
| 62 | |
Koushik Dutta | 5aaa823 | 2010-07-20 16:23:18 -0700 | [diff] [blame] | 63 | #ifndef SYSTEM_DEVICE |
| 64 | #define SYSTEM_DEVICE g_mtd_device |
| 65 | #endif |
| 66 | |
| 67 | #ifndef SYSTEM_FILESYSTEM |
| 68 | #define SYSTEM_FILESYSTEM "yaffs2" |
| 69 | #endif |
| 70 | |
Koushik Dutta | d4060c3 | 2010-07-22 20:14:44 -0700 | [diff] [blame^] | 71 | #ifndef DATA_FILESYSTEM_OPTIONS |
| 72 | #define DATA_FILESYSTEM_OPTIONS NULL |
| 73 | #endif |
| 74 | |
| 75 | #ifndef CACHE_FILESYSTEM_OPTIONS |
| 76 | #define CACHE_FILESYSTEM_OPTIONS NULL |
| 77 | #endif |
| 78 | |
| 79 | #ifndef DATADATA_FILESYSTEM_OPTIONS |
| 80 | #define DATADATA_FILESYSTEM_OPTIONS NULL |
| 81 | #endif |
| 82 | |
| 83 | #ifndef SYSTEM_FILESYSTEM_OPTIONS |
| 84 | #define SYSTEM_FILESYSTEM_OPTIONS NULL |
| 85 | #endif |
| 86 | |
| 87 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 88 | /* Any of the "root_path" arguments can be paths with relative |
| 89 | * components, like "SYSTEM:a/b/c". |
| 90 | */ |
| 91 | |
| 92 | /* Associate this package with the package root "PKG:". |
| 93 | */ |
| 94 | int register_package_root(const ZipArchive *package, const char *package_path); |
| 95 | |
| 96 | /* Returns non-zero iff root_path points inside a package. |
| 97 | */ |
| 98 | int is_package_root_path(const char *root_path); |
| 99 | |
| 100 | /* Takes a string like "SYSTEM:lib" and turns it into a string |
| 101 | * like "/system/lib". The translated path is put in out_buf, |
| 102 | * and out_buf is returned if the translation succeeded. |
| 103 | */ |
| 104 | const char *translate_root_path(const char *root_path, |
| 105 | char *out_buf, size_t out_buf_len); |
| 106 | |
| 107 | /* Takes a string like "PKG:lib/libc.so" and returns a pointer to |
| 108 | * the containing zip file and a path like "lib/libc.so". |
| 109 | */ |
| 110 | const char *translate_package_root_path(const char *root_path, |
| 111 | char *out_buf, size_t out_buf_len, const ZipArchive **out_package); |
| 112 | |
| 113 | /* Returns negative on error, positive if it's mounted, zero if it isn't. |
| 114 | */ |
| 115 | int is_root_path_mounted(const char *root_path); |
| 116 | |
| 117 | int ensure_root_path_mounted(const char *root_path); |
| 118 | |
| 119 | int ensure_root_path_unmounted(const char *root_path); |
| 120 | |
| 121 | const MtdPartition *get_root_mtd_partition(const char *root_path); |
| 122 | |
| 123 | /* "root" must be the exact name of the root; no relative path is permitted. |
| 124 | * If the named root is mounted, this will attempt to unmount it first. |
| 125 | */ |
| 126 | int format_root_device(const char *root); |
| 127 | |
Koushik Dutta | 14239d2 | 2010-06-14 15:02:48 -0700 | [diff] [blame] | 128 | typedef struct { |
| 129 | const char *name; |
| 130 | const char *device; |
| 131 | const char *device2; // If the first one doesn't work (may be NULL) |
| 132 | const char *partition_name; |
| 133 | const char *mount_point; |
| 134 | const char *filesystem; |
Koushik Dutta | d4060c3 | 2010-07-22 20:14:44 -0700 | [diff] [blame^] | 135 | const char *filesystem_options; |
Koushik Dutta | 14239d2 | 2010-06-14 15:02:48 -0700 | [diff] [blame] | 136 | } RootInfo; |
| 137 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 138 | #endif // RECOVERY_ROOTS_H_ |