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
This commit is contained in:
Bowgo Tsai 2017-03-09 23:11:33 +08:00
parent b3715cf3af
commit e8fb6c3000
4 changed files with 4 additions and 14 deletions

View file

@ -65,10 +65,10 @@ TrimTask::~TrimTask() {
}
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 @@ void TrimTask::addFromFstab() {
mPaths.push_back(fstab->recs[i].mount_point);
prev_rec = &fstab->recs[i];
}
fs_mgr_free_fstab(fstab);
}
void TrimTask::start() {

View file

@ -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;

View file

@ -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);

View file

@ -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;
}