diff options
author | Tom Cherry <tomcherry@google.com> | 2019-01-29 18:02:10 -0800 |
---|---|---|
committer | Tom Cherry <tomcherry@google.com> | 2019-01-29 18:02:10 -0800 |
commit | bdd51fd31c1d4d5c2940b775d6959c030a135a84 (patch) | |
tree | cdf06e4f3bd84a449565ce0a3e7f193747dc23d6 /libavb_user | |
parent | e947cb63b3610dc6df86ec97af1695bd27bff631 (diff) | |
download | avb-bdd51fd31c1d4d5c2940b775d6959c030a135a84.tar.gz |
Move to new Fstab class
Test: treehugger
Change-Id: I2eb3587dae73c96ddb4013fc9cc5c7cdd461cfb8
Diffstat (limited to 'libavb_user')
-rw-r--r-- | libavb_user/avb_ops_user.cpp | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/libavb_user/avb_ops_user.cpp b/libavb_user/avb_ops_user.cpp index 3e9956f..3f9b9b0 100644 --- a/libavb_user/avb_ops_user.cpp +++ b/libavb_user/avb_ops_user.cpp @@ -42,22 +42,13 @@ /* Open the appropriate fstab file and fallback to /fstab.device if * that's what's being used. */ -static struct fstab* open_fstab(void) { - struct fstab* fstab = fs_mgr_read_fstab_default(); - - if (fstab != NULL) { - return fstab; - } - - fstab = fs_mgr_read_fstab("/fstab.device"); - return fstab; +static bool open_fstab(Fstab* fstab) { + return ReadDefaultFstab(fstab) || ReadFstabFromFile("/fstab.device", fstab); } static int open_partition(const char* name, int flags) { char* path; int fd; - struct fstab* fstab; - struct fstab_rec* record; /* Per https://android-review.googlesource.com/c/platform/system/core/+/674989 * Android now supports /dev/block/by-name/<partition_name> ... try that @@ -93,31 +84,28 @@ static int open_partition(const char* name, int flags) { * 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); |