first_stage_init: load modules in modules.load.recovery in recovery

In recovery mode, load modules from modules.load.recovery if it
exists. Otherwise load from modules.load as usual.

Bug: 150825361
Change-Id: I7636bb5958ed10ae9a66015f04f168129618272f
Merged-In: I7636bb5958ed10ae9a66015f04f168129618272f
This commit is contained in:
Steve Muckle 2020-04-03 17:47:10 -07:00
parent 282afacd3a
commit ae317c716b
3 changed files with 13 additions and 4 deletions

View file

@ -234,7 +234,16 @@ int FirstStageMain(int argc, char** argv) {
old_root_dir.reset();
}
Modprobe m({"/lib/modules"});
std::string module_load_file = "modules.load";
if (IsRecoveryMode() && !ForceNormalBoot(cmdline)) {
struct stat fileStat;
std::string recovery_load_path = "/lib/modules/modules.load.recovery";
if (!stat(recovery_load_path.c_str(), &fileStat)) {
module_load_file = "modules.load.recovery";
}
}
Modprobe m({"/lib/modules"}, module_load_file);
auto want_console = ALLOW_FIRST_STAGE_CONSOLE && FirstStageConsole(cmdline);
if (!m.LoadListedModules(!want_console)) {
if (want_console) {

View file

@ -24,7 +24,7 @@
class Modprobe {
public:
Modprobe(const std::vector<std::string>&);
Modprobe(const std::vector<std::string>&, const std::string load_file = "modules.load");
bool LoadListedModules(bool strict = true);
bool LoadWithAliases(const std::string& module_name, bool strict,

View file

@ -312,7 +312,7 @@ void Modprobe::ParseKernelCmdlineOptions(void) {
}
}
Modprobe::Modprobe(const std::vector<std::string>& base_paths) {
Modprobe::Modprobe(const std::vector<std::string>& base_paths, const std::string load_file) {
using namespace std::placeholders;
for (const auto& base_path : base_paths) {
@ -326,7 +326,7 @@ Modprobe::Modprobe(const std::vector<std::string>& base_paths) {
ParseCfg(base_path + "/modules.softdep", softdep_callback);
auto load_callback = std::bind(&Modprobe::ParseLoadCallback, this, _1);
ParseCfg(base_path + "/modules.load", load_callback);
ParseCfg(base_path + "/" + load_file, load_callback);
auto options_callback = std::bind(&Modprobe::ParseOptionsCallback, this, _1);
ParseCfg(base_path + "/modules.options", options_callback);