Home | History | Annotate | Download | only in fstab
      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_TAB_H
     18 #define __CORE_FS_TAB_H
     19 
     20 #include <linux/dm-ioctl.h>
     21 #include <stdbool.h>
     22 #include <stdint.h>
     23 #include <stdio.h>
     24 
     25 #include <set>
     26 #include <string>
     27 
     28 /*
     29  * The entries must be kept in the same order as they were seen in the fstab.
     30  * Unless explicitly requested, a lookup on mount point should always
     31  * return the 1st one.
     32  */
     33 struct fstab {
     34     int num_entries;
     35     struct fstab_rec* recs;
     36     char* fstab_filename;
     37 };
     38 
     39 struct fstab_rec {
     40     char* blk_device;
     41     char* mount_point;
     42     char* fs_type;
     43     unsigned long flags;
     44     char* fs_options;
     45     int fs_mgr_flags;
     46     char* key_loc;
     47     char* key_dir;
     48     char* verity_loc;
     49     long long length;
     50     char* label;
     51     int partnum;
     52     int swap_prio;
     53     int max_comp_streams;
     54     unsigned int zram_size;
     55     uint64_t reserved_size;
     56     unsigned int file_contents_mode;
     57     unsigned int file_names_mode;
     58     unsigned int erase_blk_size;
     59     unsigned int logical_blk_size;
     60     char* sysfs_path;
     61 };
     62 
     63 struct fstab* fs_mgr_read_fstab_default();
     64 struct fstab* fs_mgr_read_fstab_dt();
     65 struct fstab* fs_mgr_read_fstab(const char* fstab_path);
     66 void fs_mgr_free_fstab(struct fstab* fstab);
     67 
     68 int fs_mgr_add_entry(struct fstab* fstab, const char* mount_point, const char* fs_type,
     69                      const char* blk_device);
     70 struct fstab_rec* fs_mgr_get_entry_for_mount_point(struct fstab* fstab, const std::string& path);
     71 int fs_mgr_is_voldmanaged(const struct fstab_rec* fstab);
     72 int fs_mgr_is_nonremovable(const struct fstab_rec* fstab);
     73 int fs_mgr_is_verified(const struct fstab_rec* fstab);
     74 int fs_mgr_is_verifyatboot(const struct fstab_rec* fstab);
     75 int fs_mgr_is_avb(const struct fstab_rec* fstab);
     76 int fs_mgr_is_encryptable(const struct fstab_rec* fstab);
     77 int fs_mgr_is_file_encrypted(const struct fstab_rec* fstab);
     78 void fs_mgr_get_file_encryption_modes(const struct fstab_rec* fstab, const char** contents_mode_ret,
     79                                       const char** filenames_mode_ret);
     80 int fs_mgr_is_convertible_to_fbe(const struct fstab_rec* fstab);
     81 int fs_mgr_is_noemulatedsd(const struct fstab_rec* fstab);
     82 int fs_mgr_is_notrim(const struct fstab_rec* fstab);
     83 int fs_mgr_is_formattable(const struct fstab_rec* fstab);
     84 int fs_mgr_is_slotselect(const struct fstab_rec* fstab);
     85 int fs_mgr_is_nofail(const struct fstab_rec* fstab);
     86 int fs_mgr_is_latemount(const struct fstab_rec* fstab);
     87 int fs_mgr_is_quota(const struct fstab_rec* fstab);
     88 int fs_mgr_has_sysfs_path(const struct fstab_rec* fstab);
     89 
     90 std::string fs_mgr_get_slot_suffix();
     91 std::set<std::string> fs_mgr_get_boot_devices();
     92 
     93 #endif /* __CORE_FS_TAB_H */
     94