public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* 2.6 early userspace init
@ 2003-11-12 11:50 Michael Schroeder
  2003-11-12 16:45 ` Bryan O'Sullivan
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Schroeder @ 2003-11-12 11:50 UTC (permalink / raw)
  To: linux-kernel


Hi folks,

how about adding something like this to init/do_mounts.c?

--- do_mounts.c.orig	2003-11-12 12:49:12.000000000 +0100
+++ do_mounts.c	2003-11-12 12:02:05.000000000 +0100
@@ -14,6 +14,7 @@
 #include "do_mounts.h"
 
 extern int get_filesystem_list(char * buf);
+extern asmlinkage long sys_access(const char * filename, int mode);
 
 int __initdata rd_doload;	/* 1 = load RAM disk, 0 = don't load */
 
@@ -393,6 +394,13 @@
 	if (initrd_load())
 		goto out;
 
+	/*
+	 * check if there is an early userspace init, if yes
+	 * let it do all the work
+	 */
+	if (sys_access("/sbin/init", 0) == 0)
+		goto out;
+
 	if (is_floppy && rd_doload && rd_load_disk(0))
 		ROOT_DEV = Root_RAM0;
 
I wont to be able to fetch the boot= parameter via /proc/cmdline
in kinit and choose the boot devices, so I dislike the boot=0:0
suggestion.

Also, should the above code clear the init= parameter, i.e.
main.c:execute_command?

Cheers,
  Michael.

-- 
Michael Schroeder                                   mls@suse.de
main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: 2.6 early userspace init
  2003-11-12 11:50 2.6 early userspace init Michael Schroeder
@ 2003-11-12 16:45 ` Bryan O'Sullivan
  2003-11-12 16:53   ` Michael Schroeder
  2003-11-13 21:32   ` H. Peter Anvin
  0 siblings, 2 replies; 5+ messages in thread
From: Bryan O'Sullivan @ 2003-11-12 16:45 UTC (permalink / raw)
  To: Michael Schroeder; +Cc: linux-kernel

On Wed, 2003-11-12 at 03:50, Michael Schroeder wrote:

> how about adding something like this to init/do_mounts.c?

It's not a bad idea, but surely you should be using the init= boot
parameter instead of hard-coding a path.

In any case, I don't think you should expect a patch to be accepted. 
There's not much point in further crufting up do_mounts.c in generic
kernels during 2.6, until do_mounts moves completely out of the kernel. 
Some people are happy enough with root=0:0, so there's not obviously a
consensus about which stopgap measure will do for now.

	<b


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: 2.6 early userspace init
  2003-11-12 16:45 ` Bryan O'Sullivan
@ 2003-11-12 16:53   ` Michael Schroeder
  2003-11-13 21:32   ` H. Peter Anvin
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Schroeder @ 2003-11-12 16:53 UTC (permalink / raw)
  To: Bryan O'Sullivan; +Cc: linux-kernel

On Wed, Nov 12, 2003 at 08:45:19AM -0800, Bryan O'Sullivan wrote:
> On Wed, 2003-11-12 at 03:50, Michael Schroeder wrote:
> 
> > how about adding something like this to init/do_mounts.c?
> 
> It's not a bad idea, but surely you should be using the init= boot
> parameter instead of hard-coding a path.

I'm not so sure about this. One can argue that the init= parameter
should be evaluated by kinit when calling the real init.

> In any case, I don't think you should expect a patch to be accepted. 
> There's not much point in further crufting up do_mounts.c in generic
> kernels during 2.6, until do_mounts moves completely out of the kernel. 
> Some people are happy enough with root=0:0, so there's not obviously a
> consensus about which stopgap measure will do for now.

Well, root=0:0 also needs a kernel patch and has the disadvantage
that one cannot specify the desired root as a boot option.

The point is that it is impossible to use initramfs as a
initrd replacement with the current code (2.6-test9), so one 
of the patches should go in, either the 0:0 patch or my patch.

Cheers,
  Michael.

-- 
Michael Schroeder                                   mls@suse.de
main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: 2.6 early userspace init
  2003-11-12 16:45 ` Bryan O'Sullivan
  2003-11-12 16:53   ` Michael Schroeder
@ 2003-11-13 21:32   ` H. Peter Anvin
  2003-11-14 16:39     ` Michael Schroeder
  1 sibling, 1 reply; 5+ messages in thread
From: H. Peter Anvin @ 2003-11-13 21:32 UTC (permalink / raw)
  To: linux-kernel

Followup to:  <1068655518.14435.37.camel@camp4.serpentine.com>
By author:    "Bryan O'Sullivan" <bos@serpentine.com>
In newsgroup: linux.dev.kernel
>
> On Wed, 2003-11-12 at 03:50, Michael Schroeder wrote:
> 
> > how about adding something like this to init/do_mounts.c?
> 
> It's not a bad idea, but surely you should be using the init= boot
> parameter instead of hard-coding a path.
> 
> In any case, I don't think you should expect a patch to be accepted. 
> There's not much point in further crufting up do_mounts.c in generic
> kernels during 2.6, until do_mounts moves completely out of the kernel. 
> Some people are happy enough with root=0:0, so there's not obviously a
> consensus about which stopgap measure will do for now.
> 

I think it's useful to maintain bass-ackwards compatibility with
root=, especially since if any hack is put it now, it creates new
legacy.

Looking for init, or linuxrc, inside the initramfs makes sense.  It
should *NOT* be tied to the init= option, though... consider when all
of this is pulled out of kernel space; you don't want "init=" to break
finding your RAID volumes when you're trying to find a different
"real" init binary.

Having a kinit= option (or earlyinit= or whatever, kinit seems to be
the term we have been using) would be another matter, of course.

	-hpa
-- 
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
If you send me mail in HTML format I will assume it's spam.
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: 2.6 early userspace init
  2003-11-13 21:32   ` H. Peter Anvin
@ 2003-11-14 16:39     ` Michael Schroeder
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Schroeder @ 2003-11-14 16:39 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: linux-kernel

On Thu, Nov 13, 2003 at 01:32:34PM -0800, H. Peter Anvin wrote:
> I think it's useful to maintain bass-ackwards compatibility with
> root=, especially since if any hack is put it now, it creates new
> legacy.
> 
> Looking for init, or linuxrc, inside the initramfs makes sense.  It
> should *NOT* be tied to the init= option, though... consider when all
> of this is pulled out of kernel space; you don't want "init=" to break
> finding your RAID volumes when you're trying to find a different
> "real" init binary.

Exactly. People may want to change the root partition with a
root= option, so reserving root=0:0 to flag kinit booting is
IMHO a bad idea. And init=/bin/bash should provide the user
with a mounted root.

So, how's the following patch:

--- init/do_mounts.c.orig	2003-11-12 12:49:12.000000000 +0100
+++ init/do_mounts.c	2003-11-14 17:33:49.000000000 +0100
@@ -14,6 +14,7 @@
 #include "do_mounts.h"
 
 extern int get_filesystem_list(char * buf);
+extern asmlinkage long sys_access(const char * filename, int mode);
 
 int __initdata rd_doload;	/* 1 = load RAM disk, 0 = don't load */
 
@@ -370,6 +371,17 @@
 	mount_block_root("/dev/root", root_mountflags);
 }
 
+static char *kinit_command;
+
+static int __init kinit_setup(char *str)
+{
+	kinit_command = str;
+	return 1;
+}
+
+__setup("kinit=", kinit_setup);
+
+
 /*
  * Prepare the namespace - decide what/where to mount, load ramdisks, etc.
  */
@@ -393,6 +405,16 @@
 	if (initrd_load())
 		goto out;
 
+	/*
+	 * 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) {
+		extern char *execute_command;
+		execute_command = kinit_command ? kinit_command : 0;
+		goto out;
+	}
+
 	if (is_floppy && rd_doload && rd_load_disk(0))
 		ROOT_DEV = Root_RAM0;
 

It also adds a 'kinit' option for the brave users who really
want to specify a diffenent kinit, e.g. 'ash'.

Of course, the kinit program should also be changed to check
for a init=xxx parameter instead of kinit=xxx.

Cheers,
  Michael.

-- 
Michael Schroeder                                   mls@suse.de
main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);}

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-11-14 16:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-12 11:50 2.6 early userspace init Michael Schroeder
2003-11-12 16:45 ` Bryan O'Sullivan
2003-11-12 16:53   ` Michael Schroeder
2003-11-13 21:32   ` H. Peter Anvin
2003-11-14 16:39     ` Michael Schroeder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox