blob: 6d2cf32a9e8f880eeaf7439e874ef4640f3ec7dc [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#include <linux/init.h>
2#include <linux/console.h>
3
4#include "chan_user.h"
5
6/* ----------------------------------------------------------------------------- */
7/* trivial console driver -- simply dump everything to stderr */
8
9/*
10 * Don't register by default -- as this registeres very early in the
Jeff Dike6edb0862006-06-30 01:55:55 -070011 * boot process it becomes the default console.
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 */
13static int use_stderr_console = 0;
14
15static void stderr_console_write(struct console *console, const char *string,
16 unsigned len)
17{
18 generic_write(2 /* stderr */, string, len, NULL);
19}
20
21static struct console stderr_console = {
Jeff Dikeda00d9a2005-06-08 15:48:01 -070022 .name = "stderr",
23 .write = stderr_console_write,
24 .flags = CON_PRINTBUFFER,
Linus Torvalds1da177e2005-04-16 15:20:36 -070025};
26
27static int __init stderr_console_init(void)
28{
29 if (use_stderr_console)
30 register_console(&stderr_console);
31 return 0;
32}
33console_initcall(stderr_console_init);
34
35static int stderr_setup(char *str)
36{
37 if (!str)
38 return 0;
39 use_stderr_console = simple_strtoul(str,&str,0);
40 return 1;
41}
42__setup("stderr=", stderr_setup);
Jeff Dike6edb0862006-06-30 01:55:55 -070043
44/* The previous behavior of not unregistering led to /dev/console being
45 * impossible to open. My FC5 filesystem started having init die, and the
46 * system panicing because of this. Unregistering causes the real
47 * console to become the default console, and /dev/console can then be
48 * opened. Making this an initcall makes this happen late enough that
49 * there is no added value in dumping everything to stderr, and the
50 * normal console is good enough to show you all available output.
51 */
52static int __init unregister_stderr(void)
53{
54 unregister_console(&stderr_console);
55
56 return 0;
57}
58
59__initcall(unregister_stderr);