early userspace init loses init= kernel parameter

phil-news-nospam_at_ipal.net
Date: 04/20/05


Date: 20 Apr 2005 02:37:44 GMT

I am investigating various methods to perform namespace initialization
prior to running the normal init program. Currently I have a preinit
program that is specified by init= in lieu of running the normal init.
It performs the custom setup, and then executes init in the same process
with the same search order the kernel already does. One problem with
this is that it takes over an ability for an alternate init to be
specified by taking the init= parameter. To get around that, my preinit
program recognizes a parameter of init2= to take a specification of what
program it should exec in lieu of the normal search order.

I'm now looking at trying out using the early userspace init as a means
to do the same thing. Eventually I want to have experience trying each
of the approaches (the third being literally adding code to the kernel
itself). But I think the early userspace init has the most promise.
But even it has the problem with messing up init= though it does so in
a different manner.

The logic in init/main.c makes the decision to run early userspace init
strictly on whether or not it exists under the name "/init" in the files
that are loaded into the initial ramfs (with a type alias of "rootfs").
There is no kernel parameter to make an alternate choice at boot time.
Maybe there should be, but it could be argued that if such a facility is
desired, then "/init" should specifically be coded to carry it out and
execute whatever program is specified. Another parameter name would be
required. The logic in init/main.c also overrides the execute_command
variable, which was previous assigned from the value of init=, replacing
it with the string "/init".

So regardless of whether it is done in kernel space or user space, there
needs to be a parameter that allows a choice of what regular init program
is to be run after the early userspace init has completed its work. So
the question is, what should that parameter be called? What I would do
in the early userspace init I'll write is check this parameter and execute
whatever is specified. Would the name "init2=" be a good choice? Or
should it be something else?

Now I need to decide what library to use for this. I am currently using
dietlibc for my preinit program, and I would think it should be fine for
the early userspace init program, too. I know there is klibc targeted
for this kind of thing. But I have no experience with it. Presumably
if done well, it should plug right it, if it's needed. But I am hopeful
dietlibc will work just fine.

Among the things I eventually want to do in early userspace is to build
the /dev directory from sysfs at that point. I'm looking at the udev
code to see what all needs to be done (but I won't be using that code as
is since it leaves out the other stuff I'm working on).

-- 
-----------------------------------------------------------------------------
| Phil Howard KA9WGN       | http://linuxhomepage.com/      http://ham.org/ |
| (first name) at ipal.net | http://phil.ipal.org/   http://ka9wgn.ham.org/ |
-----------------------------------------------------------------------------


Relevant Pages

  • Re: early userspace init loses init= kernel parameter
    ... > | Keep params the same. ... So use preinit= for the zeroth program to be run. ... > really is the init program. ... Peter ...
    (comp.os.linux.development.system)
  • Re: early userspace init loses init= kernel parameter
    ... Use preinit= for your new one. ... As far as the kernel knows, my preinit program ... really is the init program. ... I could choose that if I'm willing to make kernel mods. ...
    (comp.os.linux.development.system)
  • Re: Moving controls, viewstate problem
    ... ViewState is set during Init, so perhaps override OnInit or PreInit? ... perhaps waiting until after init to move your div would work as well. ...
    (microsoft.public.dotnet.framework.aspnet)