diff options
-rw-r--r-- | init/Kconfig | 16 | ||||
-rw-r--r-- | init/main.c | 7 |
2 files changed, 22 insertions, 1 deletions
diff --git a/init/Kconfig b/init/Kconfig index 7e9fbd48e2ab..9afb971497f4 100644 --- a/init/Kconfig +++ b/init/Kconfig | |||
@@ -1280,6 +1280,22 @@ source "usr/Kconfig" | |||
1280 | 1280 | ||
1281 | endif | 1281 | endif |
1282 | 1282 | ||
1283 | config INIT_FALLBACK | ||
1284 | bool "Fall back to defaults if init= parameter is bad" | ||
1285 | default y | ||
1286 | help | ||
1287 | If enabled, the kernel will try the default init binaries if an | ||
1288 | explicit request from the init= parameter fails. | ||
1289 | |||
1290 | This can have unexpected effects. For example, booting | ||
1291 | with init=/sbin/kiosk_app will run /sbin/init or even /bin/sh | ||
1292 | if /sbin/kiosk_app cannot be executed. | ||
1293 | |||
1294 | The default value of Y is consistent with historical behavior. | ||
1295 | Selecting N is likely to be more appropriate for most uses, | ||
1296 | especially on kiosks and on kernels that are intended to be | ||
1297 | run under the control of a script. | ||
1298 | |||
1283 | config CC_OPTIMIZE_FOR_SIZE | 1299 | config CC_OPTIMIZE_FOR_SIZE |
1284 | bool "Optimize for size" | 1300 | bool "Optimize for size" |
1285 | help | 1301 | help |
diff --git a/init/main.c b/init/main.c index d2e4ead4891f..ca380ec685de 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -952,8 +952,13 @@ static int __ref kernel_init(void *unused) | |||
952 | ret = run_init_process(execute_command); | 952 | ret = run_init_process(execute_command); |
953 | if (!ret) | 953 | if (!ret) |
954 | return 0; | 954 | return 0; |
955 | #ifndef CONFIG_INIT_FALLBACK | ||
956 | panic("Requested init %s failed (error %d).", | ||
957 | execute_command, ret); | ||
958 | #else | ||
955 | pr_err("Failed to execute %s (error %d). Attempting defaults...\n", | 959 | pr_err("Failed to execute %s (error %d). Attempting defaults...\n", |
956 | execute_command, ret); | 960 | execute_command, ret); |
961 | #endif | ||
957 | } | 962 | } |
958 | if (!try_to_run_init_process("/sbin/init") || | 963 | if (!try_to_run_init_process("/sbin/init") || |
959 | !try_to_run_init_process("/etc/init") || | 964 | !try_to_run_init_process("/etc/init") || |