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 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* 28 * The entries must be kept in the same order as they were seen in the fstab. 29 * Unless explicitly requested, a lookup on mount point should always 30 * return the 1st one. 31 */ 32 struct fstab { 33 int num_entries; 34 struct fstab_rec *recs; 35 char *fstab_filename; 36 }; 37 38 struct fstab_rec { 39 char *blk_device; 40 char *mount_point; 41 char *fs_type; 42 unsigned long flags; 43 char *fs_options; 44 int fs_mgr_flags; 45 char *key_loc; 46 char *verity_loc; 47 long long length; 48 char *label; 49 int partnum; 50 int swap_prio; 51 unsigned int zram_size; 52 }; 53 54 struct fstab *fs_mgr_read_fstab(const char *fstab_path); 55 void fs_mgr_free_fstab(struct fstab *fstab); 56 57 #define FS_MGR_MNTALL_DEV_NEEDS_RECOVERY 3 58 #define FS_MGR_MNTALL_DEV_NEEDS_ENCRYPTION 2 59 #define FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED 1 60 #define FS_MGR_MNTALL_DEV_NOT_ENCRYPTED 0 61 int fs_mgr_mount_all(struct fstab *fstab); 62 63 #define FS_MGR_DOMNT_FAILED -1 64 #define FS_MGR_DOMNT_BUSY -2 65 int fs_mgr_do_mount(struct fstab *fstab, char *n_name, char *n_blk_device, 66 char *tmp_mount_point); 67 int fs_mgr_do_tmpfs_mount(char *n_name); 68 int fs_mgr_unmount_all(struct fstab *fstab); 69 int fs_mgr_get_crypt_info(struct fstab *fstab, char *key_loc, 70 char *real_blk_device, int size); 71 int fs_mgr_add_entry(struct fstab *fstab, 72 const char *mount_point, const char *fs_type, 73 const char *blk_device); 74 struct fstab_rec *fs_mgr_get_entry_for_mount_point(struct fstab *fstab, const char *path); 75 int fs_mgr_is_voldmanaged(struct fstab_rec *fstab); 76 int fs_mgr_is_nonremovable(struct fstab_rec *fstab); 77 int fs_mgr_is_encryptable(struct fstab_rec *fstab); 78 int fs_mgr_is_noemulatedsd(struct fstab_rec *fstab); 79 int fs_mgr_swapon_all(struct fstab *fstab); 80 #ifdef __cplusplus 81 } 82 #endif 83 84 #endif /* __CORE_FS_MGR_H */ 85 86