vold: replacing fs_mgr_read_fstab() with fs_mgr_read_fstab_default()
The original default /fstab.{ro.hardware} might be moved to /vendor/etc/.
or /odm/etc/. Use the new API to get the default fstab instead of using
the hard-coded /fstab.{ro.hardware}.
Bug: 35811655
Test: boot marlin with /vendor/etc/fstab.marlin
Change-Id: I92d6aefe6ff3433b7d1a671358d990bb7b1f2150
diff --git a/TrimTask.cpp b/TrimTask.cpp
index 6c141f2..08e6499 100644
--- a/TrimTask.cpp
+++ b/TrimTask.cpp
@@ -65,10 +65,10 @@
}
void TrimTask::addFromFstab() {
- struct fstab *fstab;
+ std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> 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 @@
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 @@
}
}
-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 @@
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 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;
}