Merge "fs_mgr: adding fs_mgr_get_slot_suffix() public API"
am: b26f48f135
Change-Id: I201aa8370395eca0ce63c6912df977019c2c2f3b
This commit is contained in:
commit
4c96971cee
5 changed files with 45 additions and 37 deletions
|
@ -489,15 +489,9 @@ int fs_mgr_load_vbmeta_images(struct fstab* fstab) {
|
|||
// Sets requested_partitions to nullptr as it's to copy the contents
|
||||
// of HASH partitions into fs_mgr_avb_verify_data, which is not required as
|
||||
// fs_mgr only deals with HASHTREE partitions.
|
||||
const char *requested_partitions[] = {nullptr};
|
||||
std::string ab_suffix;
|
||||
std::string slot;
|
||||
if (fs_mgr_get_boot_config("slot", &slot)) {
|
||||
ab_suffix = "_" + slot;
|
||||
} else {
|
||||
// remove slot_suffix once bootloaders update to new androidboot.slot param
|
||||
fs_mgr_get_boot_config("slot_suffix", &ab_suffix);
|
||||
}
|
||||
const char* requested_partitions[] = {nullptr};
|
||||
std::string ab_suffix = fs_mgr_get_slot_suffix();
|
||||
|
||||
AvbSlotVerifyResult verify_result =
|
||||
avb_slot_verify(fs_mgr_avb_ops, requested_partitions, ab_suffix.c_str(),
|
||||
fs_mgr_vbmeta_prop.allow_verification_error, &fs_mgr_avb_verify_data);
|
||||
|
|
|
@ -526,7 +526,7 @@ static struct fstab *fs_mgr_read_fstab_file(FILE *fstab_file)
|
|||
cnt++;
|
||||
}
|
||||
/* If an A/B partition, modify block device to be the real block device */
|
||||
if (fs_mgr_update_for_slotselect(fstab) != 0) {
|
||||
if (!fs_mgr_update_for_slotselect(fstab)) {
|
||||
LERROR << "Error updating for slotselect";
|
||||
goto err;
|
||||
}
|
||||
|
|
|
@ -41,8 +41,6 @@
|
|||
#define PWARNING PLOG(WARNING) << FS_MGR_TAG
|
||||
#define PERROR PLOG(ERROR) << FS_MGR_TAG
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define CRYPTO_TMPFS_OPTIONS "size=256m,mode=0771,uid=1000,gid=1000"
|
||||
|
||||
#define WAIT_TIMEOUT 20
|
||||
|
@ -114,10 +112,8 @@ __BEGIN_DECLS
|
|||
|
||||
int fs_mgr_set_blk_ro(const char *blockdev);
|
||||
int fs_mgr_test_access(const char *device);
|
||||
int fs_mgr_update_for_slotselect(struct fstab *fstab);
|
||||
bool fs_mgr_update_for_slotselect(struct fstab *fstab);
|
||||
bool is_dt_compatible();
|
||||
bool is_device_secure();
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __CORE_FS_MGR_PRIV_H */
|
||||
|
|
|
@ -16,37 +16,47 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "fs_mgr.h"
|
||||
#include "fs_mgr_priv.h"
|
||||
|
||||
// Updates |fstab| for slot_suffix. Returns 0 on success, -1 on error.
|
||||
int fs_mgr_update_for_slotselect(struct fstab *fstab)
|
||||
{
|
||||
// Returns "_a" or "_b" based on two possible values in kernel cmdline:
|
||||
// - androidboot.slot = a or b OR
|
||||
// - androidboot.slot_suffix = _a or _b
|
||||
// TODO: remove slot_suffix once it's deprecated.
|
||||
std::string fs_mgr_get_slot_suffix() {
|
||||
std::string slot;
|
||||
std::string ab_suffix;
|
||||
|
||||
if (fs_mgr_get_boot_config("slot", &slot)) {
|
||||
ab_suffix = "_" + slot;
|
||||
} else if (!fs_mgr_get_boot_config("slot_suffix", &ab_suffix)) {
|
||||
ab_suffix = "";
|
||||
}
|
||||
return ab_suffix;
|
||||
}
|
||||
|
||||
// Updates |fstab| for slot_suffix. Returns true on success, false on error.
|
||||
bool fs_mgr_update_for_slotselect(struct fstab *fstab) {
|
||||
int n;
|
||||
int got_suffix = 0;
|
||||
std::string suffix;
|
||||
std::string ab_suffix;
|
||||
|
||||
for (n = 0; n < fstab->num_entries; n++) {
|
||||
if (fstab->recs[n].fs_mgr_flags & MF_SLOTSELECT) {
|
||||
char *tmp;
|
||||
|
||||
if (!got_suffix) {
|
||||
std::string slot;
|
||||
if (fs_mgr_get_boot_config("slot", &slot)) {
|
||||
suffix = "_" + slot;
|
||||
} else if (!fs_mgr_get_boot_config("slot_suffix", &suffix)) {
|
||||
// remove slot_suffix once bootloaders update to new androidboot.slot param
|
||||
return -1;
|
||||
}
|
||||
if (ab_suffix.empty()) {
|
||||
ab_suffix = fs_mgr_get_slot_suffix();
|
||||
// Returns false as non A/B devices should not have MF_SLOTSELECT.
|
||||
if (ab_suffix.empty()) return false;
|
||||
}
|
||||
|
||||
if (asprintf(&tmp, "%s%s", fstab->recs[n].blk_device, suffix.c_str()) > 0) {
|
||||
if (asprintf(&tmp, "%s%s", fstab->recs[n].blk_device, ab_suffix.c_str()) > 0) {
|
||||
free(fstab->recs[n].blk_device);
|
||||
fstab->recs[n].blk_device = tmp;
|
||||
} else {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,12 @@
|
|||
#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
|
||||
|
||||
// Magic number at start of verity metadata
|
||||
#define VERITY_METADATA_MAGIC_NUMBER 0xb001b001
|
||||
|
||||
|
@ -29,9 +35,7 @@
|
|||
// turn verity off in userdebug builds.
|
||||
#define VERITY_METADATA_MAGIC_DISABLE 0x46464f56 // "VOFF"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
__BEGIN_DECLS
|
||||
|
||||
// Verity modes
|
||||
enum verity_mode {
|
||||
|
@ -139,8 +143,12 @@ int fs_mgr_do_format(struct fstab_rec *fstab, bool reserve_footer);
|
|||
#define FS_MGR_SETUP_VERITY_SUCCESS 0
|
||||
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 */
|
||||
|
|
Loading…
Reference in a new issue