includecheck fix: x86, traps.c
[safe/jmp/linux-2.6] / kernel / printk.c
index 41fe609..602033a 100644 (file)
@@ -67,6 +67,8 @@ int console_printk[4] = {
        DEFAULT_CONSOLE_LOGLEVEL,       /* default_console_loglevel */
 };
 
+static int saved_console_loglevel = -1;
+
 /*
  * Low level drivers may need that to know if they can schedule in
  * their unblank() callback or not. So let's export it.
@@ -378,10 +380,15 @@ int do_syslog(int type, char __user *buf, int len)
                logged_chars = 0;
                break;
        case 6:         /* Disable logging to console */
+               if (saved_console_loglevel == -1)
+                       saved_console_loglevel = console_loglevel;
                console_loglevel = minimum_console_loglevel;
                break;
        case 7:         /* Enable logging to console */
-               console_loglevel = default_console_loglevel;
+               if (saved_console_loglevel != -1) {
+                       console_loglevel = saved_console_loglevel;
+                       saved_console_loglevel = -1;
+               }
                break;
        case 8:         /* Set level of messages printed to console */
                error = -EINVAL;
@@ -390,6 +397,8 @@ int do_syslog(int type, char __user *buf, int len)
                if (len < minimum_console_loglevel)
                        len = minimum_console_loglevel;
                console_loglevel = len;
+               /* Implicitly re-enable logging to console */
+               saved_console_loglevel = -1;
                error = 0;
                break;
        case 9:         /* Number of chars in the log buffer */
@@ -1066,12 +1075,6 @@ void __sched console_conditional_schedule(void)
 }
 EXPORT_SYMBOL(console_conditional_schedule);
 
-void console_print(const char *s)
-{
-       printk(KERN_EMERG "%s", s);
-}
-EXPORT_SYMBOL(console_print);
-
 void console_unblank(void)
 {
        struct console *c;
@@ -1240,22 +1243,14 @@ void register_console(struct console *newcon)
        if (!(newcon->flags & CON_ENABLED))
                return;
 
-       if (bcon && ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV)) {
-               /* we need to iterate through twice, to make sure we print
-                * everything out, before we unregister the console(s)
-                */
-               printk(KERN_INFO "console handover:");
-               for_each_console(bcon)
-                       printk("boot [%s%d] ", bcon->name, bcon->index);
-               printk(" -> real [%s%d]\n", newcon->name, newcon->index);
-               for_each_console(bcon)
-                       unregister_console(bcon);
+       /*
+        * If we have a bootconsole, and are switching to a real console,
+        * don't print everything out again, since when the boot console, and
+        * the real console are the same physical device, it's annoying to
+        * see the beginning boot messages twice
+        */
+       if (bcon && ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV))
                newcon->flags &= ~CON_PRINTBUFFER;
-       } else {
-               printk(KERN_INFO "%sconsole [%s%d] enabled\n",
-                       (newcon->flags & CON_BOOT) ? "boot" : "" ,
-                       newcon->name, newcon->index);
-       }
 
        /*
         *      Put this console in the list - keep the
@@ -1281,6 +1276,28 @@ void register_console(struct console *newcon)
                spin_unlock_irqrestore(&logbuf_lock, flags);
        }
        release_console_sem();
+
+       /*
+        * By unregistering the bootconsoles after we enable the real console
+        * we get the "console xxx enabled" message on all the consoles -
+        * boot consoles, real consoles, etc - this is to ensure that end
+        * users know there might be something in the kernel's log buffer that
+        * went to the bootconsole (that they do not see on the real console)
+        */
+       if (bcon && ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV)) {
+               /* we need to iterate through twice, to make sure we print
+                * everything out, before we unregister the console(s)
+                */
+               printk(KERN_INFO "console [%s%d] enabled, bootconsole disabled\n",
+                       newcon->name, newcon->index);
+               for_each_console(bcon)
+                       if (bcon->flags & CON_BOOT)
+                               unregister_console(bcon);
+       } else {
+               printk(KERN_INFO "%sconsole [%s%d] enabled\n",
+                       (newcon->flags & CON_BOOT) ? "boot" : "" ,
+                       newcon->name, newcon->index);
+       }
 }
 EXPORT_SYMBOL(register_console);
 
@@ -1329,7 +1346,7 @@ static int __init disable_boot_consoles(void)
                if (con->flags & CON_BOOT) {
                        printk(KERN_INFO "turn off boot console %s%d\n",
                                con->name, con->index);
-                       return unregister_console(con);
+                       unregister_console(con);
                }
        }
        return 0;