diff options
Diffstat (limited to 'init/main.c')
| -rw-r--r-- | init/main.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/init/main.c b/init/main.c index 313360fe1118..9cf77ab138a6 100644 --- a/init/main.c +++ b/init/main.c | |||
| @@ -69,6 +69,7 @@ | |||
| 69 | #include <linux/slab.h> | 69 | #include <linux/slab.h> |
| 70 | #include <linux/perf_event.h> | 70 | #include <linux/perf_event.h> |
| 71 | #include <linux/file.h> | 71 | #include <linux/file.h> |
| 72 | #include <linux/ptrace.h> | ||
| 72 | 73 | ||
| 73 | #include <asm/io.h> | 74 | #include <asm/io.h> |
| 74 | #include <asm/bugs.h> | 75 | #include <asm/bugs.h> |
| @@ -791,17 +792,17 @@ static void __init do_pre_smp_initcalls(void) | |||
| 791 | do_one_initcall(*fn); | 792 | do_one_initcall(*fn); |
| 792 | } | 793 | } |
| 793 | 794 | ||
| 794 | static void run_init_process(const char *init_filename) | 795 | static int run_init_process(const char *init_filename) |
| 795 | { | 796 | { |
| 796 | argv_init[0] = init_filename; | 797 | argv_init[0] = init_filename; |
| 797 | kernel_execve(init_filename, argv_init, envp_init); | 798 | return kernel_execve(init_filename, argv_init, envp_init); |
| 798 | } | 799 | } |
| 799 | 800 | ||
| 800 | /* This is a non __init function. Force it to be noinline otherwise gcc | 801 | static void __init kernel_init_freeable(void); |
| 801 | * makes it inline to init() and it becomes part of init.text section | 802 | |
| 802 | */ | 803 | static int __ref kernel_init(void *unused) |
| 803 | static noinline int init_post(void) | ||
| 804 | { | 804 | { |
| 805 | kernel_init_freeable(); | ||
| 805 | /* need to finish all async __init code before freeing the memory */ | 806 | /* need to finish all async __init code before freeing the memory */ |
| 806 | async_synchronize_full(); | 807 | async_synchronize_full(); |
| 807 | free_initmem(); | 808 | free_initmem(); |
| @@ -813,7 +814,8 @@ static noinline int init_post(void) | |||
| 813 | flush_delayed_fput(); | 814 | flush_delayed_fput(); |
| 814 | 815 | ||
| 815 | if (ramdisk_execute_command) { | 816 | if (ramdisk_execute_command) { |
| 816 | run_init_process(ramdisk_execute_command); | 817 | if (!run_init_process(ramdisk_execute_command)) |
| 818 | return 0; | ||
| 817 | printk(KERN_WARNING "Failed to execute %s\n", | 819 | printk(KERN_WARNING "Failed to execute %s\n", |
| 818 | ramdisk_execute_command); | 820 | ramdisk_execute_command); |
| 819 | } | 821 | } |
| @@ -825,20 +827,22 @@ static noinline int init_post(void) | |||
| 825 | * trying to recover a really broken machine. | 827 | * trying to recover a really broken machine. |
| 826 | */ | 828 | */ |
| 827 | if (execute_command) { | 829 | if (execute_command) { |
| 828 | run_init_process(execute_command); | 830 | if (!run_init_process(execute_command)) |
| 831 | return 0; | ||
| 829 | printk(KERN_WARNING "Failed to execute %s. Attempting " | 832 | printk(KERN_WARNING "Failed to execute %s. Attempting " |
| 830 | "defaults...\n", execute_command); | 833 | "defaults...\n", execute_command); |
| 831 | } | 834 | } |
| 832 | run_init_process("/sbin/init"); | 835 | if (!run_init_process("/sbin/init") || |
| 833 | run_init_process("/etc/init"); | 836 | !run_init_process("/etc/init") || |
| 834 | run_init_process("/bin/init"); | 837 | !run_init_process("/bin/init") || |
| 835 | run_init_process("/bin/sh"); | 838 | !run_init_process("/bin/sh")) |
| 839 | return 0; | ||
| 836 | 840 | ||
| 837 | panic("No init found. Try passing init= option to kernel. " | 841 | panic("No init found. Try passing init= option to kernel. " |
| 838 | "See Linux Documentation/init.txt for guidance."); | 842 | "See Linux Documentation/init.txt for guidance."); |
| 839 | } | 843 | } |
| 840 | 844 | ||
| 841 | static int __init kernel_init(void * unused) | 845 | static void __init kernel_init_freeable(void) |
| 842 | { | 846 | { |
| 843 | /* | 847 | /* |
| 844 | * Wait until kthreadd is all set-up. | 848 | * Wait until kthreadd is all set-up. |
| @@ -893,7 +897,4 @@ static int __init kernel_init(void * unused) | |||
| 893 | * we're essentially up and running. Get rid of the | 897 | * we're essentially up and running. Get rid of the |
| 894 | * initmem segments and start the user-mode stuff.. | 898 | * initmem segments and start the user-mode stuff.. |
| 895 | */ | 899 | */ |
| 896 | |||
| 897 | init_post(); | ||
| 898 | return 0; | ||
| 899 | } | 900 | } |
