trace_seq.h 2.4 KB

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