1
2
3
4
5
6
7
8
9
10
11
12#ifndef _LINUX_KMSG_DUMP_H
13#define _LINUX_KMSG_DUMP_H
14
15#include <linux/errno.h>
16#include <linux/list.h>
17
18
19
20
21
22
23enum kmsg_dump_reason {
24 KMSG_DUMP_UNDEF,
25 KMSG_DUMP_PANIC,
26 KMSG_DUMP_OOPS,
27 KMSG_DUMP_EMERG,
28 KMSG_DUMP_SHUTDOWN,
29 KMSG_DUMP_MAX
30};
31
32
33
34
35
36
37struct kmsg_dump_iter {
38 u64 cur_seq;
39 u64 next_seq;
40};
41
42
43
44
45
46
47
48
49
50struct kmsg_dumper {
51 struct list_head list;
52 void (*dump)(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason);
53 enum kmsg_dump_reason max_reason;
54 bool registered;
55};
56
57#ifdef CONFIG_PRINTK
58void kmsg_dump(enum kmsg_dump_reason reason);
59
60bool kmsg_dump_get_line(struct kmsg_dump_iter *iter, bool syslog,
61 char *line, size_t size, size_t *len);
62
63bool kmsg_dump_get_buffer(struct kmsg_dump_iter *iter, bool syslog,
64 char *buf, size_t size, size_t *len_out);
65
66void kmsg_dump_rewind(struct kmsg_dump_iter *iter);
67
68int kmsg_dump_register(struct kmsg_dumper *dumper);
69
70int kmsg_dump_unregister(struct kmsg_dumper *dumper);
71
72const char *kmsg_dump_reason_str(enum kmsg_dump_reason reason);
73#else
74static inline void kmsg_dump(enum kmsg_dump_reason reason)
75{
76}
77
78static inline bool kmsg_dump_get_line(struct kmsg_dump_iter *iter, bool syslog,
79 const char *line, size_t size, size_t *len)
80{
81 return false;
82}
83
84static inline bool kmsg_dump_get_buffer(struct kmsg_dump_iter *iter, bool syslog,
85 char *buf, size_t size, size_t *len)
86{
87 return false;
88}
89
90static inline void kmsg_dump_rewind(struct kmsg_dump_iter *iter)
91{
92}
93
94static inline int kmsg_dump_register(struct kmsg_dumper *dumper)
95{
96 return -EINVAL;
97}
98
99static inline int kmsg_dump_unregister(struct kmsg_dumper *dumper)
100{
101 return -EINVAL;
102}
103
104static inline const char *kmsg_dump_reason_str(enum kmsg_dump_reason reason)
105{
106 return "Disabled";
107}
108#endif
109
110#endif
111