kmsg_dump.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * linux/include/kmsg_dump.h
  3. *
  4. * Copyright (C) 2009 Net Insight AB
  5. *
  6. * Author: Simon Kagstrom <simon.kagstrom@netinsight.net>
  7. *
  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.
  11. */
  12. #ifndef _LINUX_KMSG_DUMP_H
  13. #define _LINUX_KMSG_DUMP_H
  14. #include <linux/errno.h>
  15. #include <linux/list.h>
  16. /*
  17. * Keep this list arranged in rough order of priority. Anything listed after
  18. * KMSG_DUMP_OOPS will not be logged by default unless printk.always_kmsg_dump
  19. * is passed to the kernel.
  20. */
  21. enum kmsg_dump_reason {
  22. KMSG_DUMP_PANIC,
  23. KMSG_DUMP_OOPS,
  24. KMSG_DUMP_EMERG,
  25. KMSG_DUMP_RESTART,
  26. KMSG_DUMP_HALT,
  27. KMSG_DUMP_POWEROFF,
  28. };
  29. /**
  30. * struct kmsg_dumper - kernel crash message dumper structure
  31. * @dump: The callback which gets called on crashes. The buffer is passed
  32. * as two sections, where s1 (length l1) contains the older
  33. * messages and s2 (length l2) contains the newer.
  34. * @list: Entry in the dumper list (private)
  35. * @registered: Flag that specifies if this is already registered
  36. */
  37. struct kmsg_dumper {
  38. void (*dump)(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason,
  39. const char *s1, unsigned long l1,
  40. const char *s2, unsigned long l2);
  41. struct list_head list;
  42. int registered;
  43. };
  44. #ifdef CONFIG_PRINTK
  45. void kmsg_dump(enum kmsg_dump_reason reason);
  46. int kmsg_dump_register(struct kmsg_dumper *dumper);
  47. int kmsg_dump_unregister(struct kmsg_dumper *dumper);
  48. #else
  49. static inline void kmsg_dump(enum kmsg_dump_reason reason)
  50. {
  51. }
  52. static inline int kmsg_dump_register(struct kmsg_dumper *dumper)
  53. {
  54. return -EINVAL;
  55. }
  56. static inline int kmsg_dump_unregister(struct kmsg_dumper *dumper)
  57. {
  58. return -EINVAL;
  59. }
  60. #endif
  61. #endif /* _LINUX_KMSG_DUMP_H */