• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
23 /* Any of the "root_path" arguments can be paths with relative
24  * components, like "SYSTEM:a/b/c".
25  */
26 
27 /* Associate this package with the package root "PKG:".
28  */
29 int register_package_root(const ZipArchive *package, const char *package_path);
30 
31 /* Returns non-zero iff root_path points inside a package.
32  */
33 int is_package_root_path(const char *root_path);
34 
35 /* Takes a string like "SYSTEM:lib" and turns it into a string
36  * like "/system/lib".  The translated path is put in out_buf,
37  * and out_buf is returned if the translation succeeded.
38  */
39 const char *translate_root_path(const char *root_path,
40         char *out_buf, size_t out_buf_len);
41 
42 /* Takes a string like "PKG:lib/libc.so" and returns a pointer to
43  * the containing zip file and a path like "lib/libc.so".
44  */
45 const char *translate_package_root_path(const char *root_path,
46         char *out_buf, size_t out_buf_len, const ZipArchive **out_package);
47 
48 /* Returns negative on error, positive if it's mounted, zero if it isn't.
49  */
50 int is_root_path_mounted(const char *root_path);
51 
52 int ensure_root_path_mounted(const char *root_path);
53 
54 int ensure_root_path_unmounted(const char *root_path);
55 
56 const MtdPartition *get_root_mtd_partition(const char *root_path);
57 
58 /* "root" must be the exact name of the root; no relative path is permitted.
59  * If the named root is mounted, this will attempt to unmount it first.
60  */
61 int format_root_device(const char *root);
62 
63 #endif  // RECOVERY_ROOTS_H_
64