[Bug?] init.c: problems if kernel gets console=null via cmdline
Harald Küthe
harald-tuxbox at arcor.de
Wed Jul 4 18:58:11 UTC 2007
> ----- Original Message -----
> From: "Denis Vlasenko" <vda.linux at googlemail.com>
> To: <busybox at busybox.net>
> Cc: "Harald Küthe" <harald-tuxbox at arcor.de>
> Sent: Sunday, July 01, 2007 9:32 PM
> Subject: Re: [Bug?] init.c: problems if kernel gets console=null via cmdline
>
> On Sunday 01 July 2007 21:25, Harald Küthe wrote:
> > Hello list,
> >
> > we have problems with the recent versions of busybox (1.5 and 1.6) when we start our kernel (2.4.34) without console.
> > Some programs do not start e.g. samba server.
> > When we link init to an older version of busybox thing get working.
> > Debugging is difficult because the problem does not exist in a strace/gdb environement.
> > It seems to be ok if I hack console_init() that it uses /dev/null as the console.
> >
> > Any help / direction is appreciated.
>
> Try this: in init.c, add "else" clause as shown below:
>
> static void console_init(void)
> {
> struct serial_struct sr;
> char *s;
>
> s = getenv("CONSOLE");
> if (!s) s = getenv("console");
> if (s) {
> int fd = open(s, O_RDWR | O_NONBLOCK | O_NOCTTY);
> if (fd >= 0) {
> dup2(fd, 0);
> dup2(fd, 1);
> dup2(fd, 2);
> while (fd > 2) close(fd--);
> }
> messageD(L_LOG, "console='%s'", s);
> + } else {
> + /* Make sure fd 0,1,2 are not closed */
> + bb_sanitize_stdio();
> }
>
> If it helps, I will add it in 1.6.2.
> --
> vda
This works, thank you for your help.
I found out that in kernel 2.4.34 the kernel commandline argument "console=" is processed by the kernel itsself and therefore not transferred into the environment.
So getenv("CONSOLE"); and getenv("console"); always return null.
Linux-2.6.15 look similar
Best regards
Harald
More information about the busybox
mailing list