2009-10-16 20:09:18 +08:00
|
|
|
/*
|
|
|
|
* linux/include/kmsg_dump.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Net Insight AB
|
|
|
|
*
|
|
|
|
* Author: Simon Kagstrom <simon.kagstrom@netinsight.net>
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file COPYING in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
#ifndef _LINUX_KMSG_DUMP_H
|
|
|
|
#define _LINUX_KMSG_DUMP_H
|
|
|
|
|
2011-06-16 06:08:17 +08:00
|
|
|
#include <linux/errno.h>
|
2009-10-16 20:09:18 +08:00
|
|
|
#include <linux/list.h>
|
|
|
|
|
2012-03-06 06:59:10 +08:00
|
|
|
/*
|
|
|
|
* Keep this list arranged in rough order of priority. Anything listed after
|
|
|
|
* KMSG_DUMP_OOPS will not be logged by default unless printk.always_kmsg_dump
|
|
|
|
* is passed to the kernel.
|
|
|
|
*/
|
2009-10-16 20:09:18 +08:00
|
|
|
enum kmsg_dump_reason {
|
2012-06-15 20:07:51 +08:00
|
|
|
KMSG_DUMP_UNDEF,
|
2009-10-16 20:09:18 +08:00
|
|
|
KMSG_DUMP_PANIC,
|
2012-03-06 06:59:10 +08:00
|
|
|
KMSG_DUMP_OOPS,
|
|
|
|
KMSG_DUMP_EMERG,
|
2020-05-16 02:05:43 +08:00
|
|
|
KMSG_DUMP_SHUTDOWN,
|
2020-05-05 23:45:06 +08:00
|
|
|
KMSG_DUMP_MAX
|
2009-10-16 20:09:18 +08:00
|
|
|
};
|
|
|
|
|
2021-03-03 18:15:25 +08:00
|
|
|
/**
|
|
|
|
* struct kmsg_dump_iter - iterator for retrieving kernel messages
|
|
|
|
* @cur_seq: Points to the oldest message to dump
|
|
|
|
* @next_seq: Points after the newest message to dump
|
|
|
|
*/
|
|
|
|
struct kmsg_dump_iter {
|
|
|
|
u64 cur_seq;
|
|
|
|
u64 next_seq;
|
|
|
|
};
|
|
|
|
|
2009-10-16 20:09:18 +08:00
|
|
|
/**
|
|
|
|
* struct kmsg_dumper - kernel crash message dumper structure
|
|
|
|
* @list: Entry in the dumper list (private)
|
2012-06-15 20:07:51 +08:00
|
|
|
* @dump: Call into dumping code which will retrieve the data with
|
|
|
|
* through the record iterator
|
|
|
|
* @max_reason: filter for highest reason number that should be dumped
|
2009-10-16 20:09:18 +08:00
|
|
|
* @registered: Flag that specifies if this is already registered
|
|
|
|
*/
|
|
|
|
struct kmsg_dumper {
|
|
|
|
struct list_head list;
|
2012-06-15 20:07:51 +08:00
|
|
|
void (*dump)(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason);
|
|
|
|
enum kmsg_dump_reason max_reason;
|
|
|
|
bool registered;
|
2009-10-16 20:09:18 +08:00
|
|
|
};
|
|
|
|
|
2009-12-02 02:52:02 +08:00
|
|
|
#ifdef CONFIG_PRINTK
|
2009-10-16 20:09:18 +08:00
|
|
|
void kmsg_dump(enum kmsg_dump_reason reason);
|
|
|
|
|
2021-03-03 18:15:25 +08:00
|
|
|
bool kmsg_dump_get_line(struct kmsg_dump_iter *iter, bool syslog,
|
2012-06-15 20:07:51 +08:00
|
|
|
char *line, size_t size, size_t *len);
|
|
|
|
|
2021-03-03 18:15:25 +08:00
|
|
|
bool kmsg_dump_get_buffer(struct kmsg_dump_iter *iter, bool syslog,
|
2021-03-03 18:15:18 +08:00
|
|
|
char *buf, size_t size, size_t *len_out);
|
2012-06-15 20:07:51 +08:00
|
|
|
|
2021-03-03 18:15:25 +08:00
|
|
|
void kmsg_dump_rewind(struct kmsg_dump_iter *iter);
|
2012-06-15 20:07:51 +08:00
|
|
|
|
2009-10-16 20:09:18 +08:00
|
|
|
int kmsg_dump_register(struct kmsg_dumper *dumper);
|
|
|
|
|
|
|
|
int kmsg_dump_unregister(struct kmsg_dumper *dumper);
|
2020-05-08 10:36:22 +08:00
|
|
|
|
|
|
|
const char *kmsg_dump_reason_str(enum kmsg_dump_reason reason);
|
2009-12-02 02:52:02 +08:00
|
|
|
#else
|
|
|
|
static inline void kmsg_dump(enum kmsg_dump_reason reason)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-03-03 18:15:25 +08:00
|
|
|
static inline bool kmsg_dump_get_line(struct kmsg_dump_iter *iter, bool syslog,
|
2012-06-19 06:32:57 +08:00
|
|
|
const char *line, size_t size, size_t *len)
|
2012-06-15 20:07:51 +08:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-03-03 18:15:25 +08:00
|
|
|
static inline bool kmsg_dump_get_buffer(struct kmsg_dump_iter *iter, bool syslog,
|
2012-06-19 06:32:57 +08:00
|
|
|
char *buf, size_t size, size_t *len)
|
2012-06-15 20:07:51 +08:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-03-03 18:15:25 +08:00
|
|
|
static inline void kmsg_dump_rewind(struct kmsg_dump_iter *iter)
|
2012-06-15 20:07:51 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-12-02 02:52:02 +08:00
|
|
|
static inline int kmsg_dump_register(struct kmsg_dumper *dumper)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int kmsg_dump_unregister(struct kmsg_dumper *dumper)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2020-05-08 10:36:22 +08:00
|
|
|
|
|
|
|
static inline const char *kmsg_dump_reason_str(enum kmsg_dump_reason reason)
|
|
|
|
{
|
|
|
|
return "Disabled";
|
|
|
|
}
|
2009-12-02 02:52:02 +08:00
|
|
|
#endif
|
2009-10-16 20:09:18 +08:00
|
|
|
|
|
|
|
#endif /* _LINUX_KMSG_DUMP_H */
|