fs_mgr: add libfstab for vendor
libfstab is a subset of libfs_mgr, intended for vendors to use. It exposes APIs for reading fstab. Note this 'visible to vendor' does not mean that the API should be stable forever. The API can be changed in later releases of Android, ,but the newer Android must not cause run-time error when there is an older version of this static library being used somewhere. Bug: 62990533 Test: BOARD_VNDK_VERSION=current m -j libfstab.vendor Change-Id: I371174fa1f6b4de6d6dd437b84ce4ed1e8740672 Merged-In: If8fc73e4ae4c2f8281c41a12f1c18079aab8baa2
This commit is contained in:
parent
c70bf5836c
commit
e7df1f7623
3 changed files with 131 additions and 83 deletions
|
@ -21,18 +21,6 @@ cc_defaults {
|
|||
},
|
||||
local_include_dirs: ["include/"],
|
||||
cppflags: ["-Werror"],
|
||||
static_libs: [
|
||||
"liblogwrap",
|
||||
"libfec",
|
||||
"libfec_rs",
|
||||
"libbase",
|
||||
"libcrypto_utils",
|
||||
"libcrypto",
|
||||
"libext4_utils",
|
||||
"libsquashfs_utils",
|
||||
"libselinux",
|
||||
"libavb",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
|
@ -44,12 +32,28 @@ cc_library_static {
|
|||
"fs_mgr.cpp",
|
||||
"fs_mgr_dm_ioctl.cpp",
|
||||
"fs_mgr_format.cpp",
|
||||
"fs_mgr_fstab.cpp",
|
||||
"fs_mgr_slotselect.cpp",
|
||||
"fs_mgr_verity.cpp",
|
||||
"fs_mgr_avb.cpp",
|
||||
"fs_mgr_avb_ops.cpp",
|
||||
"fs_mgr_boot_config.cpp",
|
||||
],
|
||||
static_libs: [
|
||||
"liblogwrap",
|
||||
"libfec",
|
||||
"libfec_rs",
|
||||
"libbase",
|
||||
"libcrypto_utils",
|
||||
"libcrypto",
|
||||
"libext4_utils",
|
||||
"libsquashfs_utils",
|
||||
"libselinux",
|
||||
"libavb",
|
||||
"libfstab",
|
||||
],
|
||||
export_static_lib_headers: [
|
||||
"libfstab",
|
||||
],
|
||||
whole_static_libs: [
|
||||
"libfstab",
|
||||
],
|
||||
product_variables: {
|
||||
debuggable: {
|
||||
|
@ -60,3 +64,16 @@ cc_library_static {
|
|||
},
|
||||
},
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
name: "libfstab",
|
||||
vendor_available: true,
|
||||
defaults: ["fs_mgr_defaults"],
|
||||
srcs: [
|
||||
"fs_mgr_fstab.cpp",
|
||||
"fs_mgr_boot_config.cpp",
|
||||
"fs_mgr_slotselect.cpp",
|
||||
],
|
||||
export_include_dirs: ["include_fstab"],
|
||||
header_libs: ["libbase_headers"],
|
||||
}
|
||||
|
|
|
@ -22,11 +22,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <linux/dm-ioctl.h>
|
||||
|
||||
// C++ only headers
|
||||
// TODO: move this into separate header files under include/fs_mgr/*.h
|
||||
#ifdef __cplusplus
|
||||
#include <string>
|
||||
#endif
|
||||
#include <fstab/fstab.h>
|
||||
|
||||
// Magic number at start of verity metadata
|
||||
#define VERITY_METADATA_MAGIC_NUMBER 0xb001b001
|
||||
|
@ -53,47 +49,10 @@ enum mount_mode {
|
|||
MOUNT_MODE_LATE = 2
|
||||
};
|
||||
|
||||
/*
|
||||
* The entries must be kept in the same order as they were seen in the fstab.
|
||||
* Unless explicitly requested, a lookup on mount point should always
|
||||
* return the 1st one.
|
||||
*/
|
||||
struct fstab {
|
||||
int num_entries;
|
||||
struct fstab_rec *recs;
|
||||
char *fstab_filename;
|
||||
};
|
||||
|
||||
struct fstab_rec {
|
||||
char *blk_device;
|
||||
char *mount_point;
|
||||
char *fs_type;
|
||||
unsigned long flags;
|
||||
char *fs_options;
|
||||
int fs_mgr_flags;
|
||||
char *key_loc;
|
||||
char *verity_loc;
|
||||
long long length;
|
||||
char *label;
|
||||
int partnum;
|
||||
int swap_prio;
|
||||
int max_comp_streams;
|
||||
unsigned int zram_size;
|
||||
uint64_t reserved_size;
|
||||
unsigned int file_encryption_mode;
|
||||
unsigned int erase_blk_size;
|
||||
unsigned int logical_blk_size;
|
||||
};
|
||||
|
||||
// Callback function for verity status
|
||||
typedef void (*fs_mgr_verity_state_callback)(struct fstab_rec *fstab,
|
||||
const char *mount_point, int mode, int status);
|
||||
|
||||
struct fstab *fs_mgr_read_fstab_default();
|
||||
struct fstab *fs_mgr_read_fstab_dt();
|
||||
struct fstab *fs_mgr_read_fstab(const char *fstab_path);
|
||||
void fs_mgr_free_fstab(struct fstab *fstab);
|
||||
|
||||
#define FS_MGR_MNTALL_DEV_FILE_ENCRYPTED 5
|
||||
#define FS_MGR_MNTALL_DEV_NEEDS_RECOVERY 4
|
||||
#define FS_MGR_MNTALL_DEV_NEEDS_ENCRYPTION 3
|
||||
|
@ -116,26 +75,6 @@ int fs_mgr_get_crypt_info(struct fstab *fstab, char *key_loc,
|
|||
char *real_blk_device, int size);
|
||||
bool fs_mgr_load_verity_state(int* mode);
|
||||
bool fs_mgr_update_verity_state(fs_mgr_verity_state_callback callback);
|
||||
int fs_mgr_add_entry(struct fstab *fstab,
|
||||
const char *mount_point, const char *fs_type,
|
||||
const char *blk_device);
|
||||
struct fstab_rec *fs_mgr_get_entry_for_mount_point(struct fstab *fstab, const char *path);
|
||||
int fs_mgr_is_voldmanaged(const struct fstab_rec *fstab);
|
||||
int fs_mgr_is_nonremovable(const struct fstab_rec *fstab);
|
||||
int fs_mgr_is_verified(const struct fstab_rec *fstab);
|
||||
int fs_mgr_is_verifyatboot(const struct fstab_rec *fstab);
|
||||
int fs_mgr_is_avb(const struct fstab_rec *fstab);
|
||||
int fs_mgr_is_encryptable(const struct fstab_rec *fstab);
|
||||
int fs_mgr_is_file_encrypted(const struct fstab_rec *fstab);
|
||||
const char* fs_mgr_get_file_encryption_mode(const struct fstab_rec *fstab);
|
||||
int fs_mgr_is_convertible_to_fbe(const struct fstab_rec *fstab);
|
||||
int fs_mgr_is_noemulatedsd(const struct fstab_rec *fstab);
|
||||
int fs_mgr_is_notrim(struct fstab_rec *fstab);
|
||||
int fs_mgr_is_formattable(struct fstab_rec *fstab);
|
||||
int fs_mgr_is_slotselect(struct fstab_rec *fstab);
|
||||
int fs_mgr_is_nofail(struct fstab_rec *fstab);
|
||||
int fs_mgr_is_latemount(struct fstab_rec *fstab);
|
||||
int fs_mgr_is_quota(struct fstab_rec *fstab);
|
||||
int fs_mgr_swapon_all(struct fstab *fstab);
|
||||
|
||||
int fs_mgr_do_format(struct fstab_rec *fstab, bool reserve_footer);
|
||||
|
@ -148,10 +87,4 @@ int fs_mgr_setup_verity(struct fstab_rec *fstab, bool wait_for_verity_dev);
|
|||
|
||||
__END_DECLS
|
||||
|
||||
// C++ only functions
|
||||
// TODO: move this into separate header files under include/fs_mgr/*.h
|
||||
#ifdef __cplusplus
|
||||
std::string fs_mgr_get_slot_suffix();
|
||||
#endif
|
||||
|
||||
#endif /* __CORE_FS_MGR_H */
|
||||
|
|
98
fs_mgr/include_fstab/fstab/fstab.h
Normal file
98
fs_mgr/include_fstab/fstab/fstab.h
Normal file
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright (C) 2012 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __CORE_FS_TAB_H
|
||||
#define __CORE_FS_TAB_H
|
||||
|
||||
#include <linux/dm-ioctl.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// C++ only headers
|
||||
// TODO: move this into separate header files under include/fs_mgr/*.h
|
||||
#ifdef __cplusplus
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* The entries must be kept in the same order as they were seen in the fstab.
|
||||
* Unless explicitly requested, a lookup on mount point should always
|
||||
* return the 1st one.
|
||||
*/
|
||||
struct fstab {
|
||||
int num_entries;
|
||||
struct fstab_rec* recs;
|
||||
char* fstab_filename;
|
||||
};
|
||||
|
||||
struct fstab_rec {
|
||||
char* blk_device;
|
||||
char* mount_point;
|
||||
char* fs_type;
|
||||
unsigned long flags;
|
||||
char* fs_options;
|
||||
int fs_mgr_flags;
|
||||
char* key_loc;
|
||||
char* verity_loc;
|
||||
long long length;
|
||||
char* label;
|
||||
int partnum;
|
||||
int swap_prio;
|
||||
int max_comp_streams;
|
||||
unsigned int zram_size;
|
||||
uint64_t reserved_size;
|
||||
unsigned int file_encryption_mode;
|
||||
unsigned int erase_blk_size;
|
||||
unsigned int logical_blk_size;
|
||||
};
|
||||
|
||||
struct fstab* fs_mgr_read_fstab_default();
|
||||
struct fstab* fs_mgr_read_fstab_dt();
|
||||
struct fstab* fs_mgr_read_fstab(const char* fstab_path);
|
||||
void fs_mgr_free_fstab(struct fstab* fstab);
|
||||
|
||||
int fs_mgr_add_entry(struct fstab* fstab, const char* mount_point, const char* fs_type,
|
||||
const char* blk_device);
|
||||
struct fstab_rec* fs_mgr_get_entry_for_mount_point(struct fstab* fstab, const char* path);
|
||||
int fs_mgr_is_voldmanaged(const struct fstab_rec* fstab);
|
||||
int fs_mgr_is_nonremovable(const struct fstab_rec* fstab);
|
||||
int fs_mgr_is_verified(const struct fstab_rec* fstab);
|
||||
int fs_mgr_is_verifyatboot(const struct fstab_rec* fstab);
|
||||
int fs_mgr_is_avb(const struct fstab_rec* fstab);
|
||||
int fs_mgr_is_encryptable(const struct fstab_rec* fstab);
|
||||
int fs_mgr_is_file_encrypted(const struct fstab_rec* fstab);
|
||||
const char* fs_mgr_get_file_encryption_mode(const struct fstab_rec* fstab);
|
||||
int fs_mgr_is_convertible_to_fbe(const struct fstab_rec* fstab);
|
||||
int fs_mgr_is_noemulatedsd(const struct fstab_rec* fstab);
|
||||
int fs_mgr_is_notrim(struct fstab_rec* fstab);
|
||||
int fs_mgr_is_formattable(struct fstab_rec* fstab);
|
||||
int fs_mgr_is_slotselect(struct fstab_rec* fstab);
|
||||
int fs_mgr_is_nofail(struct fstab_rec* fstab);
|
||||
int fs_mgr_is_latemount(struct fstab_rec* fstab);
|
||||
int fs_mgr_is_quota(struct fstab_rec* fstab);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
// C++ only functions
|
||||
// TODO: move this into separate header files under include/fs_mgr/*.h
|
||||
#ifdef __cplusplus
|
||||
std::string fs_mgr_get_slot_suffix();
|
||||
#endif
|
||||
|
||||
#endif /* __CORE_FS_TAB_H */
|
Loading…
Reference in a new issue