blob: bc847ea676de152dafa2fe60bfdedb0e566df3d7 [file] [log] [blame]
The Android Open Source Project23580ca2008-10-21 07:00:00 -07001/*
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 */
29int register_package_root(const ZipArchive *package, const char *package_path);
30
31/* Returns non-zero iff root_path points inside a package.
32 */
33int 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 */
39const 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 */
45const 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 */
50int is_root_path_mounted(const char *root_path);
51
52int ensure_root_path_mounted(const char *root_path);
53
54int ensure_root_path_unmounted(const char *root_path);
55
56const 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 */
61int format_root_device(const char *root);
62
63#endif // RECOVERY_ROOTS_H_