Path: blob/master/arch/um/drivers/stderr_console.c
10817 views
#include <linux/kernel.h>1#include <linux/init.h>2#include <linux/console.h>34#include "chan_user.h"56/* ----------------------------------------------------------------------------- */7/* trivial console driver -- simply dump everything to stderr */89/*10* Don't register by default -- as this registers very early in the11* boot process it becomes the default console.12*13* Initialized at init time.14*/15static int use_stderr_console = 0;1617static void stderr_console_write(struct console *console, const char *string,18unsigned len)19{20generic_write(2 /* stderr */, string, len, NULL);21}2223static struct console stderr_console = {24.name = "stderr",25.write = stderr_console_write,26.flags = CON_PRINTBUFFER,27};2829static int __init stderr_console_init(void)30{31if (use_stderr_console)32register_console(&stderr_console);33return 0;34}35console_initcall(stderr_console_init);3637static int stderr_setup(char *str)38{39if (!str)40return 0;41use_stderr_console = simple_strtoul(str,&str,0);42return 1;43}44__setup("stderr=", stderr_setup);4546/* The previous behavior of not unregistering led to /dev/console being47* impossible to open. My FC5 filesystem started having init die, and the48* system panicing because of this. Unregistering causes the real49* console to become the default console, and /dev/console can then be50* opened. Making this an initcall makes this happen late enough that51* there is no added value in dumping everything to stderr, and the52* normal console is good enough to show you all available output.53*/54static int __init unregister_stderr(void)55{56unregister_console(&stderr_console);5758return 0;59}6061__initcall(unregister_stderr);626364