Re: [PATCH] Console: fall back to /dev/null when no console is availlable

Greg KH
2004-10-06T17:42:13Z

On Tue, Oct 05, 2004 at 08:52:14PM +0200, J?rn Engel wrote:
> --- linux-2.6.8cow/init/main.c~console 2004-10-05 20:46:40.000000000 +0200
> +++ linux-2.6.8cow/init/main.c 2004-10-05 20:46:08.000000000 +0200
> @@ -695,8 +695,11 @@
> system_state = SYSTEM_RUNNING;
> numa_default_policy();
>
> - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
> + if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) {
> printk("Warning: unable to open an initial console.\n");
> + if (open("/dev/null", O_RDWR, 0) == 0)
> + printk(" Falling back to /dev/null.\n");
> + }

Your printk() calls need the proper KERN_* level.

And what happens if you can't open /dev/null? (hint, udev enabled boxes
usually do not have a /dev/null this early in the boot process). Does
this mean we should add a /dev/null to the initramfs image, like the
/dev/console node we currently have there?

thanks,

greg k-h