From: Olaf Hering <olh@suse.de>

initramfs can not be used in current 2.6 kernels, the files will never be
executed because prepare_namespace doesn't care about them.  The only way to
workaround that limitation is a root=0:0 cmdline option to force rootfs as
root filesystem.  This will break further booting because rootfs is not the
final root filesystem.

This patch checks for the presence of /sbin/init which comes from the cpio
archive (and thats the only way to store files into the rootfs).  This
binary/script has to do all the work of prepare_namespace().  One can specify
a different binary from the cpio archive via the kinit= option.  It does not
break current setups because initrd will not touch rootfs.

Any why would one want to do that?  After some thought, only 2 reasons come
to mind: the cpio archive can be built as user (no loop mount required), and
it should simplify migration to 2.7 (I hope the stuff behind
prepare_namespace will disappear).



---

 init/main.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+)

diff -puN init/main.c~initramfs-kinit_command init/main.c
--- 25/init/main.c~initramfs-kinit_command	2004-02-02 22:46:06.000000000 -0800
+++ 25-akpm/init/main.c	2004-02-02 22:46:06.000000000 -0800
@@ -289,6 +289,15 @@ static int __init init_setup(char *str)
 }
 __setup("init=", init_setup);
 
+static char *kinit_command;
+
+static int __init kinit_setup(char *str)
+{
+	kinit_command = str;
+	return 1;
+}
+__setup("kinit=", kinit_setup);
+
 extern void setup_arch(char **);
 extern void cpu_idle(void);
 
@@ -521,6 +530,7 @@ static void __init do_initcalls(void)
 	flush_scheduled_work();
 }
 
+asmlinkage long sys_access(const char __user * filename, int mode);
 /*
  * Ok, the machine is now initialized. None of the devices
  * have been touched yet, but the CPU subsystem is up and
@@ -584,6 +594,13 @@ static int init(void * unused)
 	sched_init_smp();
 	do_basic_setup();
 
+	/*
+	 * check if there is an early userspace init, if yes
+	 * let it do all the work
+	 */
+	if (kinit_command || sys_access("/sbin/init", 0) == 0)
+		execute_command = kinit_command ? kinit_command : 0;
+	else
 	prepare_namespace();
 
 	/*

_