2009-10-16 08:09:18 -04: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-15 18:08:17 -04:00
|
|
|
#include <linux/errno.h>
|
2009-10-16 08:09:18 -04:00
|
|
|
#include <linux/list.h>
|
|
|
|
|
2012-03-05 17:59:10 -05: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 08:09:18 -04:00
|
|
|
enum kmsg_dump_reason {
|
2012-06-15 08:07:51 -04:00
|
|
|
KMSG_DUMP_UNDEF,
|
2009-10-16 08:09:18 -04:00
|
|
|
KMSG_DUMP_PANIC,
|
2012-03-05 17:59:10 -05:00
|
|
|
KMSG_DUMP_OOPS,
|
|
|
|
KMSG_DUMP_EMERG,
|
2020-05-15 14:05:43 -04:00
|
|
|
KMSG_DUMP_SHUTDOWN,
|
2020-05-05 11:45:06 -04:00
|
|
|
KMSG_DUMP_MAX
|
2009-10-16 08:09:18 -04:00
|
|
|
};
|
|
|
|
|
2021-03-03 05:15:25 -05: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 08:09:18 -04:00
|
|
|
/**
|
|
|
|
* struct kmsg_dumper - kernel crash message dumper structure
|
|
|
|
* @list: Entry in the dumper list (private)
|
2012-06-15 08:07:51 -04: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 08:09:18 -04:00
|
|
|
* @registered: Flag that specifies if this is already registered
|
|
|
|
*/
|
|
|
|
struct kmsg_dumper {
|
|
|
|
struct list_head list;
|
2012-06-15 08:07:51 -04:00
|
|
|
void (*dump)(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason);
|
|
|
|
enum kmsg_dump_reason max_reason;
|
|
|
|
bool registered;
|
2009-10-16 08:09:18 -04:00
|
|
|
};
|
|
|
|
|
2009-12-01 13:52:02 -05:00
|
|
|
#ifdef CONFIG_PRINTK
|
2009-10-16 08:09:18 -04:00
|
|
|
void kmsg_dump(enum kmsg_dump_reason reason);
|
|
|
|
|
2021-03-03 05:15:25 -05:00
|
|
|
bool kmsg_dump_get_line(struct kmsg_dump_iter *iter, bool syslog,
|
2012-06-15 08:07:51 -04:00
|
|
|
char *line, size_t size, size_t *len);
|
|
|
|
|
2021-03-03 05:15:25 -05:00
|
|
|
bool kmsg_dump_get_buffer(struct kmsg_dump_iter *iter, bool syslog,
|
2021-03-03 05:15:18 -05:00
|
|
|
char *buf, size_t size, size_t *len_out);
|
2012-06-15 08:07:51 -04:00
|
|
|
|
2021-03-03 05:15:25 -05:00
|
|
|
void kmsg_dump_rewind(struct kmsg_dump_iter *iter);
|
2012-06-15 08:07:51 -04:00
|
|
|
|
2009-10-16 08:09:18 -04:00
|
|
|
int kmsg_dump_register(struct kmsg_dumper *dumper);
|
|
|
|
|
|
|
|
int kmsg_dump_unregister(struct kmsg_dumper *dumper);
|
2020-05-07 22:36:22 -04:00
|
|
|
|
|
|
|
const char *kmsg_dump_reason_str(enum kmsg_dump_reason reason);
|
2009-12-01 13:52:02 -05:00
|
|
|
#else
|
|
|
|
static inline void kmsg_dump(enum kmsg_dump_reason reason)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-03-03 05:15:25 -05:00
|
|
|
static inline bool kmsg_dump_get_line(struct kmsg_dump_iter *iter, bool syslog,
|
2012-06-18 18:32:57 -04:00
|
|
|
const char *line, size_t size, size_t *len)
|
2012-06-15 08:07:51 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-03-03 05:15:25 -05:00
|
|
|
static inline bool kmsg_dump_get_buffer(struct kmsg_dump_iter *iter, bool syslog,
|
2012-06-18 18:32:57 -04:00
|
|
|
char *buf, size_t size, size_t *len)
|
2012-06-15 08:07:51 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-03-03 05:15:25 -05:00
|
|
|
static inline void kmsg_dump_rewind(struct kmsg_dump_iter *iter)
|
2012-06-15 08:07:51 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-12-01 13:52:02 -05: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-07 22:36:22 -04:00
|
|
|
|
|
|
|
static inline const char *kmsg_dump_reason_str(enum kmsg_dump_reason reason)
|
|
|
|
{
|
|
|
|
return "Disabled";
|
|
|
|
}
|
2009-12-01 13:52:02 -05:00
|
|
|
#endif
|
2009-10-16 08:09:18 -04:00
|
|
|
|
|
|
|
#endif /* _LINUX_KMSG_DUMP_H */
|