1 /* 2 * Copyright (C) 2012 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 __CORE_FS_MGR_H 18 #define __CORE_FS_MGR_H 19 20 #include <stdint.h> 21 #include <linux/dm-ioctl.h> 22 23 // Magic number at start of verity metadata 24 #define VERITY_METADATA_MAGIC_NUMBER 0xb001b001 25 26 // Replacement magic number at start of verity metadata to cleanly 27 // turn verity off in userdebug builds. 28 #define VERITY_METADATA_MAGIC_DISABLE 0x46464f56 // "VOFF" 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 /* 35 * The entries must be kept in the same order as they were seen in the fstab. 36 * Unless explicitly requested, a lookup on mount point should always 37 * return the 1st one. 38 */ 39 struct fstab { 40 int num_entries; 41 struct fstab_rec *recs; 42 char *fstab_filename; 43 }; 44 45 struct fstab_rec { 46 char *blk_device; 47 char *mount_point; 48 char *fs_type; 49 unsigned long flags; 50 char *fs_options; 51 int fs_mgr_flags; 52 char *key_loc; 53 char *verity_loc; 54 long long length; 55 char *label; 56 int partnum; 57 int swap_prio; 58 unsigned int zram_size; 59 }; 60 61 struct fstab *fs_mgr_read_fstab(const char *fstab_path); 62 void fs_mgr_free_fstab(struct fstab *fstab); 63 64 #define FS_MGR_MNTALL_DEV_NEEDS_RECOVERY 3 65 #define FS_MGR_MNTALL_DEV_NEEDS_ENCRYPTION 2 66 #define FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED 1 67 #define FS_MGR_MNTALL_DEV_NOT_ENCRYPTED 0 68 int fs_mgr_mount_all(struct fstab *fstab); 69 70 #define FS_MGR_DOMNT_FAILED -1 71 #define FS_MGR_DOMNT_BUSY -2 72 int fs_mgr_do_mount(struct fstab *fstab, char *n_name, char *n_blk_device, 73 char *tmp_mount_point); 74 int fs_mgr_do_tmpfs_mount(char *n_name); 75 int fs_mgr_unmount_all(struct fstab *fstab); 76 int fs_mgr_get_crypt_info(struct fstab *fstab, char *key_loc, 77 char *real_blk_device, int size); 78 int fs_mgr_add_entry(struct fstab *fstab, 79 const char *mount_point, const char *fs_type, 80 const char *blk_device); 81 struct fstab_rec *fs_mgr_get_entry_for_mount_point(struct fstab *fstab, const char *path); 82 int fs_mgr_is_voldmanaged(struct fstab_rec *fstab); 83 int fs_mgr_is_nonremovable(struct fstab_rec *fstab); 84 int fs_mgr_is_verified(struct fstab_rec *fstab); 85 int fs_mgr_is_encryptable(struct fstab_rec *fstab); 86 int fs_mgr_is_noemulatedsd(struct fstab_rec *fstab); 87 int fs_mgr_is_formattable(struct fstab_rec *fstab); 88 int fs_mgr_swapon_all(struct fstab *fstab); 89 90 int fs_mgr_do_format(struct fstab_rec *fstab); 91 92 #ifdef __cplusplus 93 } 94 #endif 95 96 #endif /* __CORE_FS_MGR_H */ 97 98