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