fs_mgr: support reading fstab file from /odm or /vendor partition

fstab contains device- and soc- specific content that should reside in
/odm or /vendor partition. This change searches the fstab.${ro.hardware}
file from /odm/etc, /vendor/etc and /, then use the first one found.

Bug: 35811655
Test: boot sailfish
Change-Id: I82f89b41a849faedb64072a7cfc52d7424e1aaa1
This commit is contained in:
Bowgo Tsai 2017-03-07 18:52:03 +08:00
parent 47d342739a
commit 46c6dc1a6f
2 changed files with 8 additions and 5 deletions

View file

@ -636,8 +636,10 @@ struct fstab *fs_mgr_read_fstab_with_dt(const char *fstab_path)
return in_place_merge(fstab_dt, fstab);
}
/* combines fstab entries passed in from device tree with
* the ones found in /fstab.<hardware>
/*
* tries to load default fstab.<hardware> file from /odm/etc, /vendor/etc
* or /. loads the first one found and also combines fstab entries passed
* in from device tree.
*/
struct fstab *fs_mgr_read_fstab_default()
{
@ -645,7 +647,10 @@ struct fstab *fs_mgr_read_fstab_default()
std::string default_fstab;
if (fs_mgr_get_boot_config("hardware", &hw)) {
default_fstab = FSTAB_PREFIX + hw;
for (const char *prefix : {"/odm/etc/fstab.","/vendor/etc/fstab.", "/fstab."}) {
default_fstab = prefix + hw;
if (access(default_fstab.c_str(), F_OK) == 0) break;
}
} else {
LWARNING << __FUNCTION__ << "(): failed to find device hardware name";
}

View file

@ -41,8 +41,6 @@
#define PWARNING PLOG(WARNING) << FS_MGR_TAG
#define PERROR PLOG(ERROR) << FS_MGR_TAG
const std::string FSTAB_PREFIX("/fstab.");
__BEGIN_DECLS
#define CRYPTO_TMPFS_OPTIONS "size=256m,mode=0771,uid=1000,gid=1000"