Linux 4.18.10
[linux/fpc-iii.git] / arch / um / kernel / kmsg_dump.c
blob98bdf69e4c2e59445d3ac0dcc1b4f9f99a09bcf4
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/kmsg_dump.h>
3 #include <linux/console.h>
4 #include <shared/init.h>
5 #include <shared/kern.h>
6 #include <os.h>
8 static void kmsg_dumper_stdout(struct kmsg_dumper *dumper,
9 enum kmsg_dump_reason reason)
11 static char line[1024];
13 size_t len = 0;
14 bool con_available = false;
16 /* only dump kmsg when no console is available */
17 if (!console_trylock())
18 return;
20 if (console_drivers != NULL)
21 con_available = true;
23 console_unlock();
25 if (con_available == true)
26 return;
28 printf("kmsg_dump:\n");
29 while (kmsg_dump_get_line(dumper, true, line, sizeof(line), &len)) {
30 line[len] = '\0';
31 printf("%s", line);
35 static struct kmsg_dumper kmsg_dumper = {
36 .dump = kmsg_dumper_stdout
39 int __init kmsg_dumper_stdout_init(void)
41 return kmsg_dump_register(&kmsg_dumper);
44 __uml_postsetup(kmsg_dumper_stdout_init);