On (20/11/11 14:54), Petr Mladek wrote:
[..]
> diff --git a/init/main.c b/init/main.c
> index 130376ec10ba..24413c055a85 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -1470,8 +1470,14 @@ void __init console_on_rootfs(void)
>       struct file *file = filp_open("/dev/console", O_RDWR, 0);
>  
>       if (IS_ERR(file)) {
> -             pr_err("Warning: unable to open an initial console.\n");
> -             return;
> +             pr_err("Warning: unable to open an initial console. Fallback to 
> ttynull.\n");
> +             register_ttynull_console();
> +

A nit, this probably can be done in console_device() function.

For several reasons:

- we will get covered all the future cases when something other than
  console_on_rootfs() will filp_open("/dev/console")

- filp_open() failure does not necessarily mean that we have console=
  and hence must register null-tty driver

- this will keep low level printk/tty details within the printk

Something like this?

---
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 08c50d8ba110..202fa87eb991 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2633,6 +2633,12 @@ struct tty_driver *console_device(int *index)
        struct tty_driver *driver = NULL;
 
        console_lock();
+       if (unlikely(!console_drivers)) {
+               console_unlock();
+               register_ttynull_console();
+               console_lock();
+       }
+
        for_each_console(c) {
                if (!c->device)
                        continue;

Reply via email to