diff options
Diffstat (limited to 'init/main.c')
-rw-r--r-- | init/main.c | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/init/main.c b/init/main.c index 379090fadac9..67ee8ef0a669 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -124,7 +124,6 @@ EXPORT_SYMBOL(system_state); | |||
124 | extern void time_init(void); | 124 | extern void time_init(void); |
125 | /* Default late time init is NULL. archs can override this later. */ | 125 | /* Default late time init is NULL. archs can override this later. */ |
126 | void (*__initdata late_time_init)(void); | 126 | void (*__initdata late_time_init)(void); |
127 | extern void softirq_init(void); | ||
128 | 127 | ||
129 | /* Untouched command line saved by arch-specific code. */ | 128 | /* Untouched command line saved by arch-specific code. */ |
130 | char __initdata boot_command_line[COMMAND_LINE_SIZE]; | 129 | char __initdata boot_command_line[COMMAND_LINE_SIZE]; |
@@ -811,10 +810,26 @@ static int run_init_process(const char *init_filename) | |||
811 | (const char __user *const __user *)envp_init); | 810 | (const char __user *const __user *)envp_init); |
812 | } | 811 | } |
813 | 812 | ||
813 | static int try_to_run_init_process(const char *init_filename) | ||
814 | { | ||
815 | int ret; | ||
816 | |||
817 | ret = run_init_process(init_filename); | ||
818 | |||
819 | if (ret && ret != -ENOENT) { | ||
820 | pr_err("Starting init: %s exists but couldn't execute it (error %d)\n", | ||
821 | init_filename, ret); | ||
822 | } | ||
823 | |||
824 | return ret; | ||
825 | } | ||
826 | |||
814 | static noinline void __init kernel_init_freeable(void); | 827 | static noinline void __init kernel_init_freeable(void); |
815 | 828 | ||
816 | static int __ref kernel_init(void *unused) | 829 | static int __ref kernel_init(void *unused) |
817 | { | 830 | { |
831 | int ret; | ||
832 | |||
818 | kernel_init_freeable(); | 833 | kernel_init_freeable(); |
819 | /* need to finish all async __init code before freeing the memory */ | 834 | /* need to finish all async __init code before freeing the memory */ |
820 | async_synchronize_full(); | 835 | async_synchronize_full(); |
@@ -826,9 +841,11 @@ static int __ref kernel_init(void *unused) | |||
826 | flush_delayed_fput(); | 841 | flush_delayed_fput(); |
827 | 842 | ||
828 | if (ramdisk_execute_command) { | 843 | if (ramdisk_execute_command) { |
829 | if (!run_init_process(ramdisk_execute_command)) | 844 | ret = run_init_process(ramdisk_execute_command); |
845 | if (!ret) | ||
830 | return 0; | 846 | return 0; |
831 | pr_err("Failed to execute %s\n", ramdisk_execute_command); | 847 | pr_err("Failed to execute %s (error %d)\n", |
848 | ramdisk_execute_command, ret); | ||
832 | } | 849 | } |
833 | 850 | ||
834 | /* | 851 | /* |
@@ -838,18 +855,19 @@ static int __ref kernel_init(void *unused) | |||
838 | * trying to recover a really broken machine. | 855 | * trying to recover a really broken machine. |
839 | */ | 856 | */ |
840 | if (execute_command) { | 857 | if (execute_command) { |
841 | if (!run_init_process(execute_command)) | 858 | ret = run_init_process(execute_command); |
859 | if (!ret) | ||
842 | return 0; | 860 | return 0; |
843 | pr_err("Failed to execute %s. Attempting defaults...\n", | 861 | pr_err("Failed to execute %s (error %d). Attempting defaults...\n", |
844 | execute_command); | 862 | execute_command, ret); |
845 | } | 863 | } |
846 | if (!run_init_process("/sbin/init") || | 864 | if (!try_to_run_init_process("/sbin/init") || |
847 | !run_init_process("/etc/init") || | 865 | !try_to_run_init_process("/etc/init") || |
848 | !run_init_process("/bin/init") || | 866 | !try_to_run_init_process("/bin/init") || |
849 | !run_init_process("/bin/sh")) | 867 | !try_to_run_init_process("/bin/sh")) |
850 | return 0; | 868 | return 0; |
851 | 869 | ||
852 | panic("No init found. Try passing init= option to kernel. " | 870 | panic("No working init found. Try passing init= option to kernel. " |
853 | "See Linux Documentation/init.txt for guidance."); | 871 | "See Linux Documentation/init.txt for guidance."); |
854 | } | 872 | } |
855 | 873 | ||