diff --git a/init/Kconfig b/init/Kconfig index fdb4f52609c6c3dfca87c89f88e5ff88396369f9..2d12d38cdd88a4f66ead444754fe67d704a604b5 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -260,6 +260,16 @@ config KERNEL_UNCOMPRESSED endchoice +config DEFAULT_INIT + string "Default init path" + default "" + help + This option determines the default init for the system if no init= + option is passed on the kernel command line. If the requested path is + not present, we will still then move on to attempting further + locations (e.g. /sbin/init, etc). If this is empty, we will just use + the fallback list when init= is not passed. + config DEFAULT_HOSTNAME string "Default hostname" default "(none)" diff --git a/init/main.c b/init/main.c index df32f67214d23e6bb45c1133134f4c4333a31a74..76df62fc3e2c55d939039ef42cf453743dbcb91b 100644 --- a/init/main.c +++ b/init/main.c @@ -1433,6 +1433,16 @@ static int __ref kernel_init(void *unused) panic("Requested init %s failed (error %d).", execute_command, ret); } + + if (CONFIG_DEFAULT_INIT[0] != '\0') { + ret = run_init_process(CONFIG_DEFAULT_INIT); + if (ret) + pr_err("Default init %s failed (error %d)\n", + CONFIG_DEFAULT_INIT, ret); + else + return 0; + } + if (!try_to_run_init_process("/sbin/init") || !try_to_run_init_process("/etc/init") || !try_to_run_init_process("/bin/init") ||