kmsg_dump.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. enum kmsg_dump_reason {
  17. KMSG_DUMP_OOPS,
  18. KMSG_DUMP_PANIC,
  19. KMSG_DUMP_KEXEC,
  20. KMSG_DUMP_RESTART,
  21. KMSG_DUMP_HALT,
  22. KMSG_DUMP_POWEROFF,
  23. KMSG_DUMP_EMERG,
  24. };
  25. /**
  26. * struct kmsg_dumper - kernel crash message dumper structure
  27. * @dump: The callback which gets called on crashes. The buffer is passed
  28. * as two sections, where s1 (length l1) contains the older
  29. * messages and s2 (length l2) contains the newer.
  30. * @list: Entry in the dumper list (private)
  31. * @registered: Flag that specifies if this is already registered
  32. */
  33. struct kmsg_dumper {
  34. void (*dump)(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason,
  35. const char *s1, unsigned long l1,
  36. const char *s2, unsigned long l2);
  37. struct list_head list;
  38. int registered;
  39. };
  40. #ifdef CONFIG_PRINTK
  41. void kmsg_dump(enum kmsg_dump_reason reason);
  42. int kmsg_dump_register(struct kmsg_dumper *dumper);
  43. int kmsg_dump_unregister(struct kmsg_dumper *dumper);
  44. #else
  45. static inline void kmsg_dump(enum kmsg_dump_reason reason)
  46. {
  47. }
  48. static inline int kmsg_dump_register(struct kmsg_dumper *dumper)
  49. {
  50. return -EINVAL;
  51. }
  52. static inline int kmsg_dump_unregister(struct kmsg_dumper *dumper)
  53. {
  54. return -EINVAL;
  55. }
  56. #endif
  57. #endif /* _LINUX_KMSG_DUMP_H */