Skip to content

Commit

Permalink
init: replacing fs_mgr_read_fstab() with fs_mgr_read_fstab_default()
Browse files Browse the repository at this point in the history
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: I8a9c70eda7f68b174ec355910d0fa1eb18a46e21
  • Loading branch information
bowgotsai committed Mar 9, 2017
1 parent 46c6dc1 commit c9a1842
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions init/property_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
using android::base::StringPrintf;

#define PERSISTENT_PROPERTY_DIR "/data/property"
#define FSTAB_PREFIX "/fstab."
#define RECOVERY_MOUNT_POINT "/recovery"

static int persistent_properties_loaded = 0;
Expand Down Expand Up @@ -613,21 +612,14 @@ void load_persist_props(void) {
}

void load_recovery_id_prop() {
std::string ro_hardware = property_get("ro.hardware");
if (ro_hardware.empty()) {
LOG(ERROR) << "ro.hardware not set - unable to load recovery id";
std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> fstab(fs_mgr_read_fstab_default(),
fs_mgr_free_fstab);
if (!fstab) {
PLOG(ERROR) << "unable to read default fstab";
return;
}
std::string fstab_filename = FSTAB_PREFIX + ro_hardware;

std::unique_ptr<fstab, void(*)(fstab*)> tab(fs_mgr_read_fstab(fstab_filename.c_str()),
fs_mgr_free_fstab);
if (!tab) {
PLOG(ERROR) << "unable to read fstab " << fstab_filename;
return;
}

fstab_rec* rec = fs_mgr_get_entry_for_mount_point(tab.get(), RECOVERY_MOUNT_POINT);
fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab.get(), RECOVERY_MOUNT_POINT);
if (rec == NULL) {
LOG(ERROR) << "/recovery not specified in fstab";
return;
Expand Down

0 comments on commit c9a1842

Please sign in to comment.