Skip to content

Commit 51abcc5

Browse files
Treehugger RobotGerrit Code Review
authored andcommitted
Merge "first_stage_init: load modules in modules.load.recovery in recovery"
2 parents 51de894 + 4c59323 commit 51abcc5

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

init/first_stage_init.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,16 @@ int FirstStageMain(int argc, char** argv) {
234234
old_root_dir.reset();
235235
}
236236

237-
Modprobe m({"/lib/modules"});
237+
std::string module_load_file = "modules.load";
238+
if (IsRecoveryMode() && !ForceNormalBoot(cmdline)) {
239+
struct stat fileStat;
240+
std::string recovery_load_path = "/lib/modules/modules.load.recovery";
241+
if (!stat(recovery_load_path.c_str(), &fileStat)) {
242+
module_load_file = "modules.load.recovery";
243+
}
244+
}
245+
246+
Modprobe m({"/lib/modules"}, module_load_file);
238247
auto want_console = ALLOW_FIRST_STAGE_CONSOLE && FirstStageConsole(cmdline);
239248
if (!m.LoadListedModules(!want_console)) {
240249
if (want_console) {

libmodprobe/include/modprobe/modprobe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
class Modprobe {
2626
public:
27-
Modprobe(const std::vector<std::string>&);
27+
Modprobe(const std::vector<std::string>&, const std::string load_file = "modules.load");
2828

2929
bool LoadListedModules(bool strict = true);
3030
bool LoadWithAliases(const std::string& module_name, bool strict,

libmodprobe/libmodprobe.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ void Modprobe::ParseKernelCmdlineOptions(void) {
312312
}
313313
}
314314

315-
Modprobe::Modprobe(const std::vector<std::string>& base_paths) {
315+
Modprobe::Modprobe(const std::vector<std::string>& base_paths, const std::string load_file) {
316316
using namespace std::placeholders;
317317

318318
for (const auto& base_path : base_paths) {
@@ -326,7 +326,7 @@ Modprobe::Modprobe(const std::vector<std::string>& base_paths) {
326326
ParseCfg(base_path + "/modules.softdep", softdep_callback);
327327

328328
auto load_callback = std::bind(&Modprobe::ParseLoadCallback, this, _1);
329-
ParseCfg(base_path + "/modules.load", load_callback);
329+
ParseCfg(base_path + "/" + load_file, load_callback);
330330

331331
auto options_callback = std::bind(&Modprobe::ParseOptionsCallback, this, _1);
332332
ParseCfg(base_path + "/modules.options", options_callback);

0 commit comments

Comments
 (0)