Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 444574

Summary: sys-kernel/genkernel-3.4.49.2: genkernel/defaults/linuxrc does not handle init opts
Product: Gentoo Hosted Projects Reporter: Toralf Förster <toralf>
Component: genkernelAssignee: Gentoo Genkernel Maintainers <genkernel>
Status: RESOLVED FIXED    
Severity: normal CC: floppym, zerochaos
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: screen shot
Use init_opts from the environment

Description Toralf Förster gentoo-dev 2012-11-24 14:29:54 UTC
That script doesn't parse arguments right.
The following diff tggether w/ the attached screen shot illustrates is:


n22 ~ # diff /usr/share/genkernel/defaults/linuxrc.orig /usr/share/genkernel/defaults/linuxrc
39a40
> INIT_OPTS=''
64a66
>                       INIT_OPTS_NEW="$(echo $init_opts | cut -f2- -d=)"
939c941,944
< exec /sbin/switch_root -c "/dev/console" "${CHROOT}" "${REAL_INIT:-/sbin/init}" "${INIT_OPTS}" "$@"
---
> echo ">>${INIT_OPTS}<<"
> echo ">>${INIT_OPTS_NEW}<<"
> sleep 20
> exec /sbin/switch_root -c "/dev/console" "${CHROOT}" "${REAL_INIT:-/sbin/init}" "\"${INIT_OPTS_NEW}\"" 


FWIW - even with the patched version I was unsuccessful in getting init_opts="init 2" working the grub kernel command line.

If I add "init 2" to tje switch_root line in linuxrc - it works.

*shrug*

Unfortunately I do not have a virtual machine to test it further and now I'm really annoyed about that and me and the world ... grrrr

BTW
yep - "$@" circumvent/hide the bug but now /I'm really wondering about that wired (busybox ?) behaviour .
Comment 1 Toralf Förster gentoo-dev 2012-11-24 14:30:29 UTC
Created attachment 330452 [details]
screen shot
Comment 2 Toralf Förster gentoo-dev 2012-11-24 15:59:54 UTC
Applying this diff now it works :

n22 ~ # diff /usr/share/genkernel/defaults/linuxrc.orig /usr/share/genkernel/defaults/linuxrc
39a40
> INIT_OPTS=''
64c65
<                       INIT_OPTS=${x#*=}
---
>                       INIT_OPTS="$(echo $init_opts | cut -f2- -d=)"
939c940
< exec /sbin/switch_root -c "/dev/console" "${CHROOT}" "${REAL_INIT:-/sbin/init}" "${INIT_OPTS}" 
---
> exec /sbin/switch_root -c "/dev/console" "${CHROOT}" "${REAL_INIT:-/sbin/init}" ${INIT_OPTS}




happy root cause analysis :-)
Comment 3 Mike Gilbert gentoo-dev 2012-11-24 18:15:41 UTC
Created attachment 330482 [details, diff]
Use init_opts from the environment

It looks like you are using $init_opts as passed in the environment, rather than the value obtained from /proc/cmdline.

If we do that, we can remove the logic in the case statement and just pass it along directly.

Give this patch a try.

Also, it should not be necessary to pass init_opts="init 2" in the command line; just init_opts="2" should do the trick. It does make a nice test case, however.
Comment 4 Toralf Förster gentoo-dev 2012-11-24 18:40:17 UTC
(In reply to comment #3)
> Created attachment 330482 [details, diff] [details, diff]

works
:-)

> line; just init_opts="2" should do the trick. It does make a nice test case,

I used init_opts=2 because this construct ${x#*=} doesn't work with quoted arguments and/or spaces - see attachement in comment #1
Comment 5 Toralf Förster gentoo-dev 2013-06-27 18:25:18 UTC
/me assumes that the fix went into unstable versions only b/c 3.4.45.1 does not contain it, or ?
Comment 6 Toralf Förster gentoo-dev 2014-06-22 11:01:19 UTC
still an issue in latest genkernel version , this helps :

# diff /usr/share/genkernel/defaults/linuxrc.orig /usr/share/genkernel/defaults/linuxrc941c941
< exec /sbin/switch_root -c "/dev/console" "${CHROOT}" "${REAL_INIT:-/sbin/init}" "${INIT_OPTS}"
---
> exec /sbin/switch_root -c "/dev/console" "${CHROOT}" "${REAL_INIT:-/sbin/init}" $init_opts


Please note that "init 2" doesn't have a "=" therefore the usually argument parsing INIT_OPTS=${x#*=} won't work


(BTW I'm the only one who "uses genkernel" && "sometimes boots a kernel with 'init 2'" ?). I'm wondering b/c no other seems to suffer from this issue, or ?
Comment 7 Mike Gilbert gentoo-dev 2014-06-22 13:55:12 UTC
This bug has been ignored by the genkernel maintainers. Don't expect to see the fix in a release until you hear from one of them.
Comment 8 Rick Farina (Zero_Chaos) gentoo-dev 2015-08-20 16:07:00 UTC
patch accepted, thanks!