Merge "fs_mgr: support reading fstab based on ro.boot.hardware.platform" am: 3d879b10d8

am: 45aa5ed89a

Change-Id: I71f449c2ae0a24a736f460cb64e501e09485bf30
This commit is contained in:
Oleg Matcovschi 2017-11-01 21:24:35 +00:00 committed by android-build-merger
commit 317ec5cf5b

View file

@ -700,25 +700,44 @@ struct fstab *fs_mgr_read_fstab_dt()
} }
/* /*
* tries to load default fstab.<hardware> file from /odm/etc, /vendor/etc * Identify path to fstab file. Lookup is based on pattern
* or /. loads the first one found and also combines fstab entries passed * fstab.<hardware>, fstab.<hardware.platform> in folders
* in from device tree. /odm/etc, vendor/etc, or /.
*/
static std::string get_fstab_path()
{
for (const char* prop : {"hardware", "hardware.platform"}) {
std::string hw;
if (!fs_mgr_get_boot_config(prop, &hw)) continue;
for (const char* prefix : {"/odm/etc/fstab.", "/vendor/etc/fstab.", "/fstab."}) {
std::string fstab_path = prefix + hw;
if (access(fstab_path.c_str(), F_OK) == 0) {
return fstab_path;
}
}
}
return std::string();
}
/*
* loads the fstab file and combines with fstab entries passed in from device tree.
*/ */
struct fstab *fs_mgr_read_fstab_default() struct fstab *fs_mgr_read_fstab_default()
{ {
std::string hw;
std::string default_fstab; std::string default_fstab;
// Use different fstab paths for normal boot and recovery boot, respectively // Use different fstab paths for normal boot and recovery boot, respectively
if (access("/sbin/recovery", F_OK) == 0) { if (access("/sbin/recovery", F_OK) == 0) {
default_fstab = "/etc/recovery.fstab"; default_fstab = "/etc/recovery.fstab";
} else if (fs_mgr_get_boot_config("hardware", &hw)) { // normal boot } else { // normal boot
for (const char *prefix : {"/odm/etc/fstab.","/vendor/etc/fstab.", "/fstab."}) { default_fstab = get_fstab_path();
default_fstab = prefix + hw; }
if (access(default_fstab.c_str(), F_OK) == 0) break;
} if (default_fstab.empty()) {
} else { LWARNING << __FUNCTION__ << "(): failed to find device default fstab";
LWARNING << __FUNCTION__ << "(): failed to find device hardware name";
} }
// combines fstab entries passed in from device tree with // combines fstab entries passed in from device tree with