trace_seq.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #ifndef _LINUX_TRACE_SEQ_H
  2. #define _LINUX_TRACE_SEQ_H
  3. #include <linux/fs.h>
  4. #include <asm/page.h>
  5. /*
  6. * Trace sequences are used to allow a function to call several other functions
  7. * to create a string of data to use (up to a max of PAGE_SIZE).
  8. */
  9. struct trace_seq {
  10. unsigned char buffer[PAGE_SIZE];
  11. unsigned int len;
  12. unsigned int readpos;
  13. int full;
  14. };
  15. static inline void
  16. trace_seq_init(struct trace_seq *s)
  17. {
  18. s->len = 0;
  19. s->readpos = 0;
  20. s->full = 0;
  21. }
  22. #define MAX_MEMHEX_BYTES 8
  23. /*
  24. * Currently only defined when tracing is enabled.
  25. */
  26. #ifdef CONFIG_TRACING
  27. extern __printf(2, 3)
  28. int trace_seq_printf(struct trace_seq *s, const char *fmt, ...);
  29. extern __printf(2, 0)
  30. int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args);
  31. extern int
  32. trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary);
  33. extern int trace_print_seq(struct seq_file *m, struct trace_seq *s);
  34. extern int trace_seq_to_user(struct trace_seq *s, char __user *ubuf,
  35. int cnt);
  36. extern int trace_seq_puts(struct trace_seq *s, const char *str);
  37. extern int trace_seq_putc(struct trace_seq *s, unsigned char c);
  38. extern int trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len);
  39. extern int trace_seq_putmem_hex(struct trace_seq *s, const void *mem,
  40. unsigned int len);
  41. extern void *trace_seq_reserve(struct trace_seq *s, unsigned int len);
  42. extern int trace_seq_path(struct trace_seq *s, const struct path *path);
  43. extern int trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp,
  44. int nmaskbits);
  45. #else /* CONFIG_TRACING */
  46. static inline int trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
  47. {
  48. return 0;
  49. }
  50. static inline int
  51. trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary)
  52. {
  53. return 0;
  54. }
  55. static inline int
  56. trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp,
  57. int nmaskbits)
  58. {
  59. return 0;
  60. }
  61. static inline int trace_print_seq(struct seq_file *m, struct trace_seq *s)
  62. {
  63. return 0;
  64. }
  65. static inline int trace_seq_to_user(struct trace_seq *s, char __user *ubuf,
  66. int cnt)
  67. {
  68. return 0;
  69. }
  70. static inline int trace_seq_puts(struct trace_seq *s, const char *str)
  71. {
  72. return 0;
  73. }
  74. static inline int trace_seq_putc(struct trace_seq *s, unsigned char c)
  75. {
  76. return 0;
  77. }
  78. static inline int
  79. trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len)
  80. {
  81. return 0;
  82. }
  83. static inline int trace_seq_putmem_hex(struct trace_seq *s, const void *mem,
  84. unsigned int len)
  85. {
  86. return 0;
  87. }
  88. static inline void *trace_seq_reserve(struct trace_seq *s, unsigned int len)
  89. {
  90. return NULL;
  91. }
  92. static inline int trace_seq_path(struct trace_seq *s, const struct path *path)
  93. {
  94. return 0;
  95. }
  96. #endif /* CONFIG_TRACING */
  97. #endif /* _LINUX_TRACE_SEQ_H */