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