trace_seq.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. /**
  23. * trace_seq_buffer_ptr - return pointer to next location in buffer
  24. * @s: trace sequence descriptor
  25. *
  26. * Returns the pointer to the buffer where the next write to
  27. * the buffer will happen. This is useful to save the location
  28. * that is about to be written to and then return the result
  29. * of that write.
  30. */
  31. static inline unsigned char *
  32. trace_seq_buffer_ptr(struct trace_seq *s)
  33. {
  34. return s->buffer + s->len;
  35. }
  36. /*
  37. * Currently only defined when tracing is enabled.
  38. */
  39. #ifdef CONFIG_TRACING
  40. extern __printf(2, 3)
  41. int trace_seq_printf(struct trace_seq *s, const char *fmt, ...);
  42. extern __printf(2, 0)
  43. int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args);
  44. extern int
  45. trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary);
  46. extern int trace_print_seq(struct seq_file *m, struct trace_seq *s);
  47. extern int trace_seq_to_user(struct trace_seq *s, char __user *ubuf,
  48. int cnt);
  49. extern int trace_seq_puts(struct trace_seq *s, const char *str);
  50. extern int trace_seq_putc(struct trace_seq *s, unsigned char c);
  51. extern int trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len);
  52. extern int trace_seq_putmem_hex(struct trace_seq *s, const void *mem,
  53. unsigned int len);
  54. extern int trace_seq_path(struct trace_seq *s, const struct path *path);
  55. extern int trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp,
  56. int nmaskbits);
  57. #else /* CONFIG_TRACING */
  58. static inline int trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
  59. {
  60. return 0;
  61. }
  62. static inline int
  63. trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary)
  64. {
  65. return 0;
  66. }
  67. static inline int
  68. trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp,
  69. int nmaskbits)
  70. {
  71. return 0;
  72. }
  73. static inline int trace_print_seq(struct seq_file *m, struct trace_seq *s)
  74. {
  75. return 0;
  76. }
  77. static inline int trace_seq_to_user(struct trace_seq *s, char __user *ubuf,
  78. int cnt)
  79. {
  80. return 0;
  81. }
  82. static inline int trace_seq_puts(struct trace_seq *s, const char *str)
  83. {
  84. return 0;
  85. }
  86. static inline int trace_seq_putc(struct trace_seq *s, unsigned char c)
  87. {
  88. return 0;
  89. }
  90. static inline int
  91. trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len)
  92. {
  93. return 0;
  94. }
  95. static inline int trace_seq_putmem_hex(struct trace_seq *s, const void *mem,
  96. unsigned int len)
  97. {
  98. return 0;
  99. }
  100. static inline int trace_seq_path(struct trace_seq *s, const struct path *path)
  101. {
  102. return 0;
  103. }
  104. #endif /* CONFIG_TRACING */
  105. #endif /* _LINUX_TRACE_SEQ_H */