Support androidboot.fstab_suffix cmdline flag

Fix #3187
This commit is contained in:
topjohnwu 2020-10-08 03:04:12 -07:00
parent d4d837a562
commit 0499588107
3 changed files with 12 additions and 6 deletions

View File

@ -155,6 +155,8 @@ void load_kernel_info(cmdline *cmd) {
strcpy(cmd->hardware, value);
} else if (key == "androidboot.hardware.platform") {
strcpy(cmd->hardware_plat, value);
} else if (key == "androidboot.fstab_suffix") {
strcpy(cmd->fstab_suffix, value);
}
});

View File

@ -12,6 +12,7 @@ struct cmdline {
bool force_normal_boot;
char slot[3];
char dt_dir[64];
char fstab_suffix[32];
char hardware[32];
char hardware_plat[32];
};

View File

@ -44,7 +44,7 @@ void FirstStageInit::prepare() {
fstab_file[0] = '\0';
// Find existing fstab file
for (const char *hw : { cmd->hardware, cmd->hardware_plat }) {
for (const char *hw : { cmd->fstab_suffix, cmd->hardware, cmd->hardware_plat }) {
if (hw[0] == '\0')
continue;
sprintf(fstab_file, "fstab.%s", hw);
@ -98,14 +98,17 @@ void FirstStageInit::prepare() {
}
}
// Dump dt fstab to fstab file in rootfs
if (fstab_file[0] == '\0') {
const char *hw = cmd->hardware[0] ? cmd->hardware :
(cmd->hardware_plat[0] ? cmd->hardware_plat : nullptr);
if (hw == nullptr) {
LOGE("Cannot determine hardware name!\n");
const char *suffix =
cmd->fstab_suffix[0] ? cmd->fstab_suffix :
(cmd->hardware[0] ? cmd->hardware :
(cmd->hardware_plat[0] ? cmd->hardware_plat : nullptr));
if (suffix == nullptr) {
LOGE("Cannot determine fstab suffix!\n");
return;
}
sprintf(fstab_file, "fstab.%s", hw);
sprintf(fstab_file, "fstab.%s", suffix);
}
// Patch init to force IsDtFstabCompatible() return false