diff --git a/TrimTask.cpp b/TrimTask.cpp index 6c141f2..08e6499 100644 --- a/TrimTask.cpp +++ b/TrimTask.cpp @@ -65,10 +65,10 @@ TrimTask::~TrimTask() { } void TrimTask::addFromFstab() { - struct fstab *fstab; + std::unique_ptr fstab(fs_mgr_read_fstab_default(), + fs_mgr_free_fstab); struct fstab_rec *prev_rec = NULL; - fstab = fs_mgr_read_fstab(android::vold::DefaultFstabPath().c_str()); for (int i = 0; i < fstab->num_entries; i++) { /* Skip raw partitions */ if (!strcmp(fstab->recs[i].fs_type, "emmc") || @@ -96,7 +96,6 @@ void TrimTask::addFromFstab() { mPaths.push_back(fstab->recs[i].mount_point); prev_rec = &fstab->recs[i]; } - fs_mgr_free_fstab(fstab); } void TrimTask::start() { diff --git a/Utils.cpp b/Utils.cpp index b4fc208..cc30d5d 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -635,12 +635,6 @@ dev_t GetDevice(const std::string& path) { } } -std::string DefaultFstabPath() { - char hardware[PROPERTY_VALUE_MAX]; - property_get("ro.hardware", hardware, ""); - return StringPrintf("/fstab.%s", hardware); -} - status_t RestoreconRecursive(const std::string& path) { LOG(VERBOSE) << "Starting restorecon of " << path; diff --git a/Utils.h b/Utils.h index ddabace..78e4618 100644 --- a/Utils.h +++ b/Utils.h @@ -111,8 +111,6 @@ std::string BuildDataUserDePath(const char* volumeUuid, userid_t userid); dev_t GetDevice(const std::string& path); -std::string DefaultFstabPath(); - status_t RestoreconRecursive(const std::string& path); status_t SaneReadLinkAt(int dirfd, const char* path, char* buf, size_t bufsiz); diff --git a/main.cpp b/main.cpp index 6754b0a..c106af9 100644 --- a/main.cpp +++ b/main.cpp @@ -215,10 +215,9 @@ static void coldboot(const char *path) { } static int process_config(VolumeManager *vm, bool* has_adoptable) { - std::string path(android::vold::DefaultFstabPath()); - fstab = fs_mgr_read_fstab(path.c_str()); + fstab = fs_mgr_read_fstab_default(); if (!fstab) { - PLOG(ERROR) << "Failed to open default fstab " << path; + PLOG(ERROR) << "Failed to open default fstab"; return -1; }