diff options
Diffstat (limited to 'init')
-rw-r--r-- | init/main.c | 81 |
1 files changed, 45 insertions, 36 deletions
diff --git a/init/main.c b/init/main.c index 649ab5443d43..2421e1544127 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -726,7 +726,49 @@ static void run_init_process(char *init_filename) | |||
726 | kernel_execve(init_filename, argv_init, envp_init); | 726 | kernel_execve(init_filename, argv_init, envp_init); |
727 | } | 727 | } |
728 | 728 | ||
729 | static int init(void * unused) | 729 | /* This is a non __init function. Force it to be noinline otherwise gcc |
730 | * makes it inline to init() and it becomes part of init.text section | ||
731 | */ | ||
732 | static int noinline init_post(void) | ||
733 | { | ||
734 | free_initmem(); | ||
735 | unlock_kernel(); | ||
736 | mark_rodata_ro(); | ||
737 | system_state = SYSTEM_RUNNING; | ||
738 | numa_default_policy(); | ||
739 | |||
740 | if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) | ||
741 | printk(KERN_WARNING "Warning: unable to open an initial console.\n"); | ||
742 | |||
743 | (void) sys_dup(0); | ||
744 | (void) sys_dup(0); | ||
745 | |||
746 | if (ramdisk_execute_command) { | ||
747 | run_init_process(ramdisk_execute_command); | ||
748 | printk(KERN_WARNING "Failed to execute %s\n", | ||
749 | ramdisk_execute_command); | ||
750 | } | ||
751 | |||
752 | /* | ||
753 | * We try each of these until one succeeds. | ||
754 | * | ||
755 | * The Bourne shell can be used instead of init if we are | ||
756 | * trying to recover a really broken machine. | ||
757 | */ | ||
758 | if (execute_command) { | ||
759 | run_init_process(execute_command); | ||
760 | printk(KERN_WARNING "Failed to execute %s. Attempting " | ||
761 | "defaults...\n", execute_command); | ||
762 | } | ||
763 | run_init_process("/sbin/init"); | ||
764 | run_init_process("/etc/init"); | ||
765 | run_init_process("/bin/init"); | ||
766 | run_init_process("/bin/sh"); | ||
767 | |||
768 | panic("No init found. Try passing init= option to kernel."); | ||
769 | } | ||
770 | |||
771 | static int __init init(void * unused) | ||
730 | { | 772 | { |
731 | lock_kernel(); | 773 | lock_kernel(); |
732 | /* | 774 | /* |
@@ -774,39 +816,6 @@ static int init(void * unused) | |||
774 | * we're essentially up and running. Get rid of the | 816 | * we're essentially up and running. Get rid of the |
775 | * initmem segments and start the user-mode stuff.. | 817 | * initmem segments and start the user-mode stuff.. |
776 | */ | 818 | */ |
777 | free_initmem(); | 819 | init_post(); |
778 | unlock_kernel(); | 820 | return 0; |
779 | mark_rodata_ro(); | ||
780 | system_state = SYSTEM_RUNNING; | ||
781 | numa_default_policy(); | ||
782 | |||
783 | if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) | ||
784 | printk(KERN_WARNING "Warning: unable to open an initial console.\n"); | ||
785 | |||
786 | (void) sys_dup(0); | ||
787 | (void) sys_dup(0); | ||
788 | |||
789 | if (ramdisk_execute_command) { | ||
790 | run_init_process(ramdisk_execute_command); | ||
791 | printk(KERN_WARNING "Failed to execute %s\n", | ||
792 | ramdisk_execute_command); | ||
793 | } | ||
794 | |||
795 | /* | ||
796 | * We try each of these until one succeeds. | ||
797 | * | ||
798 | * The Bourne shell can be used instead of init if we are | ||
799 | * trying to recover a really broken machine. | ||
800 | */ | ||
801 | if (execute_command) { | ||
802 | run_init_process(execute_command); | ||
803 | printk(KERN_WARNING "Failed to execute %s. Attempting " | ||
804 | "defaults...\n", execute_command); | ||
805 | } | ||
806 | run_init_process("/sbin/init"); | ||
807 | run_init_process("/etc/init"); | ||
808 | run_init_process("/bin/init"); | ||
809 | run_init_process("/bin/sh"); | ||
810 | |||
811 | panic("No init found. Try passing init= option to kernel."); | ||
812 | } | 821 | } |