1#include <linux/kernel.h>
2#include <linux/init.h>
3#include <linux/console.h>
4
5#include "chan_user.h"
6
7
8
9
10
11
12
13
14
15
16static int use_stderr_console = 0;
17
18static void stderr_console_write(struct console *console, const char *string,
19 unsigned len)
20{
21 generic_write(2 , string, len, NULL);
22}
23
24static struct console stderr_console = {
25 .name = "stderr",
26 .write = stderr_console_write,
27 .flags = CON_PRINTBUFFER,
28};
29
30static int __init stderr_console_init(void)
31{
32 if (use_stderr_console)
33 register_console(&stderr_console);
34 return 0;
35}
36console_initcall(stderr_console_init);
37
38static int stderr_setup(char *str)
39{
40 if (!str)
41 return 0;
42 use_stderr_console = simple_strtoul(str,&str,0);
43 return 1;
44}
45__setup("stderr=", stderr_setup);
46
47
48
49
50
51
52
53
54
55static int __init unregister_stderr(void)
56{
57 unregister_console(&stderr_console);
58
59 return 0;
60}
61
62__initcall(unregister_stderr);
63