summaryrefslogtreecommitdiff
path: root/init/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'init/main.c')
-rw-r--r--init/main.c33
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 @@
#include <linux/slab.h>
#include <linux/perf_event.h>
#include <linux/file.h>
+#include <linux/ptrace.h>
#include <asm/io.h>
#include <asm/bugs.h>
@@ -791,17 +792,17 @@ static void __init do_pre_smp_initcalls(void)
do_one_initcall(*fn);
}
-static void run_init_process(const char *init_filename)
+static int run_init_process(const char *init_filename)
{
argv_init[0] = init_filename;
- kernel_execve(init_filename, argv_init, envp_init);
+ return kernel_execve(init_filename, argv_init, envp_init);
}
-/* This is a non __init function. Force it to be noinline otherwise gcc
- * makes it inline to init() and it becomes part of init.text section
- */
-static noinline int init_post(void)
+static void __init kernel_init_freeable(void);
+
+static int __ref kernel_init(void *unused)
{
+ kernel_init_freeable();
/* need to finish all async __init code before freeing the memory */
async_synchronize_full();
free_initmem();
@@ -813,7 +814,8 @@ static noinline int init_post(void)
flush_delayed_fput();
if (ramdisk_execute_command) {
- run_init_process(ramdisk_execute_command);
+ if (!run_init_process(ramdisk_execute_command))
+ return 0;
printk(KERN_WARNING "Failed to execute %s\n",
ramdisk_execute_command);
}
@@ -825,20 +827,22 @@ static noinline int init_post(void)
* trying to recover a really broken machine.
*/
if (execute_command) {
- run_init_process(execute_command);
+ if (!run_init_process(execute_command))
+ return 0;
printk(KERN_WARNING "Failed to execute %s. Attempting "
"defaults...\n", execute_command);
}
- run_init_process("/sbin/init");
- run_init_process("/etc/init");
- run_init_process("/bin/init");
- run_init_process("/bin/sh");
+ if (!run_init_process("/sbin/init") ||
+ !run_init_process("/etc/init") ||
+ !run_init_process("/bin/init") ||
+ !run_init_process("/bin/sh"))
+ return 0;
panic("No init found. Try passing init= option to kernel. "
"See Linux Documentation/init.txt for guidance.");
}
-static int __init kernel_init(void * unused)
+static void __init kernel_init_freeable(void)
{
/*
* Wait until kthreadd is all set-up.
@@ -893,7 +897,4 @@ static int __init kernel_init(void * unused)
* we're essentially up and running. Get rid of the
* initmem segments and start the user-mode stuff..
*/
-
- init_post();
- return 0;
}