diff --git a/native/jni/init/getinfo.cpp b/native/jni/init/getinfo.cpp index dda89c6a4..a9da81a23 100644 --- a/native/jni/init/getinfo.cpp +++ b/native/jni/init/getinfo.cpp @@ -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); } }); diff --git a/native/jni/init/init.hpp b/native/jni/init/init.hpp index 43df4c518..23eca9c9b 100644 --- a/native/jni/init/init.hpp +++ b/native/jni/init/init.hpp @@ -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]; }; diff --git a/native/jni/init/twostage.cpp b/native/jni/init/twostage.cpp index fe5e04ee8..e802bdbd5 100644 --- a/native/jni/init/twostage.cpp +++ b/native/jni/init/twostage.cpp @@ -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