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// C++ only headers
26// TODO: move this into separate header files under include/fs_mgr/*.h
27#ifdef __cplusplus
28#include <string>
29#endif
30
31__BEGIN_DECLS
32
33/*
34 * The entries must be kept in the same order as they were seen in the fstab.
35 * Unless explicitly requested, a lookup on mount point should always
36 * return the 1st one.
37 */
38struct fstab {
39    int num_entries;
40    struct fstab_rec* recs;
41    char* fstab_filename;
42};
43
44struct fstab_rec {
45    char* blk_device;
46    char* mount_point;
47    char* fs_type;
48    unsigned long flags;
49    char* fs_options;
50    int fs_mgr_flags;
51    char* key_loc;
52    char* key_dir;
53    char* verity_loc;
54    long long length;
55    char* label;
56    int partnum;
57    int swap_prio;
58    int max_comp_streams;
59    unsigned int zram_size;
60    uint64_t reserved_size;
61    unsigned int file_contents_mode;
62    unsigned int file_names_mode;
63    unsigned int erase_blk_size;
64    unsigned int logical_blk_size;
65};
66
67struct fstab* fs_mgr_read_fstab_default();
68struct fstab* fs_mgr_read_fstab_dt();
69struct fstab* fs_mgr_read_fstab(const char* fstab_path);
70void fs_mgr_free_fstab(struct fstab* fstab);
71
72int fs_mgr_add_entry(struct fstab* fstab, const char* mount_point, const char* fs_type,
73                     const char* blk_device);
74struct fstab_rec* fs_mgr_get_entry_for_mount_point(struct fstab* fstab, const char* path);
75int fs_mgr_is_voldmanaged(const struct fstab_rec* fstab);
76int fs_mgr_is_nonremovable(const struct fstab_rec* fstab);
77int fs_mgr_is_verified(const struct fstab_rec* fstab);
78int fs_mgr_is_verifyatboot(const struct fstab_rec* fstab);
79int fs_mgr_is_avb(const struct fstab_rec* fstab);
80int fs_mgr_is_encryptable(const struct fstab_rec* fstab);
81int fs_mgr_is_file_encrypted(const struct fstab_rec* fstab);
82void fs_mgr_get_file_encryption_modes(const struct fstab_rec* fstab, const char** contents_mode_ret,
83                                      const char** filenames_mode_ret);
84int fs_mgr_is_convertible_to_fbe(const struct fstab_rec* fstab);
85int fs_mgr_is_noemulatedsd(const struct fstab_rec* fstab);
86int fs_mgr_is_notrim(const struct fstab_rec* fstab);
87int fs_mgr_is_formattable(const struct fstab_rec* fstab);
88int fs_mgr_is_slotselect(const struct fstab_rec* fstab);
89int fs_mgr_is_nofail(const struct fstab_rec* fstab);
90int fs_mgr_is_latemount(const struct fstab_rec* fstab);
91int fs_mgr_is_quota(const struct fstab_rec* fstab);
92
93__END_DECLS
94
95// C++ only functions
96// TODO: move this into separate header files under include/fs_mgr/*.h
97#ifdef __cplusplus
98std::string fs_mgr_get_slot_suffix();
99#endif
100
101#endif /* __CORE_FS_TAB_H */
102