Index: main.c =================================================================== --- linux.org/init/main.c (revision 3297) +++ linux/init/main.c (revision 3935) @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -548,6 +549,7 @@ static int init(void * unused) { + struct files_struct *files; lock_kernel(); do_basic_setup(); @@ -560,7 +562,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");