diff options
author | Tom Cherry <tomcherry@google.com> | 2019-01-29 17:54:07 -0800 |
---|---|---|
committer | Tom Cherry <tomcherry@google.com> | 2019-01-29 17:54:07 -0800 |
commit | d3153d8d4313d7d3455dc491513ba12c6ba19c22 (patch) | |
tree | 905753996d8c8236ce4e3d4b97fa8051add056e0 /boot_control_copy | |
parent | 58a4d50ece679525d1c3a7fcd1bfa04701041a08 (diff) | |
download | extras-d3153d8d4313d7d3455dc491513ba12c6ba19c22.tar.gz |
Move to new Fstab class
Test: treehugger
Change-Id: I1873022abde51b71b49e8d89bdaada044530987a
Diffstat (limited to 'boot_control_copy')
-rw-r--r-- | boot_control_copy/bootinfo.cpp | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/boot_control_copy/bootinfo.cpp b/boot_control_copy/bootinfo.cpp index aa7643a4..e4c58b0a 100644 --- a/boot_control_copy/bootinfo.cpp +++ b/boot_control_copy/bootinfo.cpp @@ -36,22 +36,15 @@ // Open the appropriate fstab file and fallback to /fstab.device if // that's what's being used. -static struct fstab *open_fstab(void) +static bool open_fstab(Fstab* fstab) { - struct fstab *fstab = fs_mgr_read_fstab_default(); - if (fstab != NULL) - return fstab; - - fstab = fs_mgr_read_fstab("/fstab.device"); - return fstab; + return ReadDefaultFstab(fstab) || ReadFstabFromFile("/fstab.device", fstab); } int boot_info_open_partition(const char *name, uint64_t *out_size, int flags) { char *path; int fd; - struct fstab *fstab; - struct fstab_rec *record; // We can't use fs_mgr to look up |name| because fstab doesn't list // every slot partition (it uses the slotselect option to mask the @@ -70,30 +63,28 @@ int boot_info_open_partition(const char *name, uint64_t *out_size, int flags) // by trawling /sys/block looking for the appropriate sibling of // misc and then finding an entry in /dev matching the sysfs entry. - fstab = open_fstab(); - if (fstab == NULL) + Fstab fstab; + if (!open_fstab(&fstab)) { return -1; - record = fs_mgr_get_entry_for_mount_point(fstab, "/misc"); - if (record == NULL) { - fs_mgr_free_fstab(fstab); + } + auto record = GetEntryForMountPoint(&fstab, "/misc"); + if (record == nullptr) { return -1; } if (strcmp(name, "misc") == 0) { - path = strdup(record->blk_device); + path = strdup(record->blk_device.c_str()); } else { size_t trimmed_len, name_len; - const char *end_slash = strrchr(record->blk_device, '/'); + const char *end_slash = strrchr(record->blk_device.c_str(), '/'); if (end_slash == NULL) { - fs_mgr_free_fstab(fstab); return -1; } - trimmed_len = end_slash - record->blk_device + 1; + trimmed_len = end_slash - record->blk_device.c_str() + 1; name_len = strlen(name); path = static_cast<char *>(calloc(trimmed_len + name_len + 1, 1)); - strncpy(path, record->blk_device, trimmed_len); + strncpy(path, record->blk_device.c_str(), trimmed_len); strncpy(path + trimmed_len, name, name_len); } - fs_mgr_free_fstab(fstab); fd = open(path, flags); free(path); |