Linux 4.6-rc6
[cris-mirror.git] / include / linux / kmsg_dump.h
blob2e7a1e032c71a91e6a9dff98a0b637d621932a25
1 /*
2 * linux/include/kmsg_dump.h
4 * Copyright (C) 2009 Net Insight AB
6 * Author: Simon Kagstrom <simon.kagstrom@netinsight.net>
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive
10 * for more details.
12 #ifndef _LINUX_KMSG_DUMP_H
13 #define _LINUX_KMSG_DUMP_H
15 #include <linux/errno.h>
16 #include <linux/list.h>
19 * Keep this list arranged in rough order of priority. Anything listed after
20 * KMSG_DUMP_OOPS will not be logged by default unless printk.always_kmsg_dump
21 * is passed to the kernel.
23 enum kmsg_dump_reason {
24 KMSG_DUMP_UNDEF,
25 KMSG_DUMP_PANIC,
26 KMSG_DUMP_OOPS,
27 KMSG_DUMP_EMERG,
28 KMSG_DUMP_RESTART,
29 KMSG_DUMP_HALT,
30 KMSG_DUMP_POWEROFF,
33 /**
34 * struct kmsg_dumper - kernel crash message dumper structure
35 * @list: Entry in the dumper list (private)
36 * @dump: Call into dumping code which will retrieve the data with
37 * through the record iterator
38 * @max_reason: filter for highest reason number that should be dumped
39 * @registered: Flag that specifies if this is already registered
41 struct kmsg_dumper {
42 struct list_head list;
43 void (*dump)(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason);
44 enum kmsg_dump_reason max_reason;
45 bool active;
46 bool registered;
48 /* private state of the kmsg iterator */
49 u32 cur_idx;
50 u32 next_idx;
51 u64 cur_seq;
52 u64 next_seq;
55 #ifdef CONFIG_PRINTK
56 void kmsg_dump(enum kmsg_dump_reason reason);
58 bool kmsg_dump_get_line_nolock(struct kmsg_dumper *dumper, bool syslog,
59 char *line, size_t size, size_t *len);
61 bool kmsg_dump_get_line(struct kmsg_dumper *dumper, bool syslog,
62 char *line, size_t size, size_t *len);
64 bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
65 char *buf, size_t size, size_t *len);
67 void kmsg_dump_rewind_nolock(struct kmsg_dumper *dumper);
69 void kmsg_dump_rewind(struct kmsg_dumper *dumper);
71 int kmsg_dump_register(struct kmsg_dumper *dumper);
73 int kmsg_dump_unregister(struct kmsg_dumper *dumper);
74 #else
75 static inline void kmsg_dump(enum kmsg_dump_reason reason)
79 static inline bool kmsg_dump_get_line_nolock(struct kmsg_dumper *dumper,
80 bool syslog, const char *line,
81 size_t size, size_t *len)
83 return false;
86 static inline bool kmsg_dump_get_line(struct kmsg_dumper *dumper, bool syslog,
87 const char *line, size_t size, size_t *len)
89 return false;
92 static inline bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
93 char *buf, size_t size, size_t *len)
95 return false;
98 static inline void kmsg_dump_rewind_nolock(struct kmsg_dumper *dumper)
102 static inline void kmsg_dump_rewind(struct kmsg_dumper *dumper)
106 static inline int kmsg_dump_register(struct kmsg_dumper *dumper)
108 return -EINVAL;
111 static inline int kmsg_dump_unregister(struct kmsg_dumper *dumper)
113 return -EINVAL;
115 #endif
117 #endif /* _LINUX_KMSG_DUMP_H */