patch-2.4.23 linux-2.4.23/init/main.c
Next file: linux-2.4.23/kernel/fork.c
Previous file: linux-2.4.23/init/do_mounts.c
Back to the patch index
Back to the overall index
- Lines: 83
- Date:
2003-11-28 10:26:21.000000000 -0800
- Orig file:
linux-2.4.22/init/main.c
- Orig date:
2003-08-25 04:44:44.000000000 -0700
diff -urN linux-2.4.22/init/main.c linux-2.4.23/init/main.c
@@ -26,6 +26,7 @@
#include <linux/hdreg.h>
#include <linux/iobuf.h>
#include <linux/bootmem.h>
+#include <linux/file.h>
#include <linux/tty.h>
#include <asm/io.h>
@@ -424,9 +425,6 @@
#ifdef CONFIG_PROC_FS
proc_root_init();
#endif
-#if defined(CONFIG_SYSVIPC)
- ipc_init();
-#endif
check_bugs();
printk("POSIX conformance testing by UNIFIX\n");
@@ -436,6 +434,9 @@
* make syscalls (and thus be locked).
*/
smp_init();
+#if defined(CONFIG_SYSVIPC)
+ ipc_init();
+#endif
rest_init();
}
@@ -544,10 +545,17 @@
#endif
}
+static void run_init_process(char *init_filename)
+{
+ argv_init[0] = init_filename;
+ execve(init_filename, argv_init, envp_init);
+}
+
extern void prepare_namespace(void);
static int init(void * unused)
{
+ struct files_struct *files;
lock_kernel();
do_basic_setup();
@@ -560,7 +568,17 @@
*/
free_initmem();
unlock_kernel();
-
+
+ /*
+ * Right now we are a thread sharing with a ton of kernel
+ * stuff. We don't want to end up in user space in that state
+ */
+
+ files = current->files;
+ if(unshare_files())
+ panic("unshare");
+ put_files_struct(files);
+
if (open("/dev/console", O_RDWR, 0) < 0)
printk("Warning: unable to open an initial console.\n");
@@ -575,10 +593,12 @@
*/
if (execute_command)
- execve(execute_command,argv_init,envp_init);
- execve("/sbin/init",argv_init,envp_init);
- execve("/etc/init",argv_init,envp_init);
- execve("/bin/init",argv_init,envp_init);
- execve("/bin/sh",argv_init,envp_init);
+ run_init_process(execute_command);
+
+ run_init_process("/sbin/init");
+ run_init_process("/etc/init");
+ run_init_process("/bin/init");
+ run_init_process("/bin/sh");
+
panic("No init found. Try passing init= option to kernel.");
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)