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>
8 static void kmsg_dumper_stdout(struct kmsg_dumper
*dumper
,
9 enum kmsg_dump_reason reason
)
11 static char line
[1024];
14 bool con_available
= false;
16 /* only dump kmsg when no console is available */
17 if (!console_trylock())
20 if (console_drivers
!= NULL
)
25 if (con_available
== true)
28 printf("kmsg_dump:\n");
29 while (kmsg_dump_get_line(dumper
, true, line
, sizeof(line
), &len
)) {
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
);