diff options
Diffstat (limited to 'include/linux/trace_seq.h')
| -rw-r--r-- | include/linux/trace_seq.h | 77 |
1 files changed, 49 insertions, 28 deletions
diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h index ea6c9dea79e3..cfaf5a1d4bad 100644 --- a/include/linux/trace_seq.h +++ b/include/linux/trace_seq.h | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #ifndef _LINUX_TRACE_SEQ_H | 1 | #ifndef _LINUX_TRACE_SEQ_H |
| 2 | #define _LINUX_TRACE_SEQ_H | 2 | #define _LINUX_TRACE_SEQ_H |
| 3 | 3 | ||
| 4 | #include <linux/fs.h> | 4 | #include <linux/seq_buf.h> |
| 5 | 5 | ||
| 6 | #include <asm/page.h> | 6 | #include <asm/page.h> |
| 7 | 7 | ||
| @@ -12,20 +12,36 @@ | |||
| 12 | 12 | ||
| 13 | struct trace_seq { | 13 | struct trace_seq { |
| 14 | unsigned char buffer[PAGE_SIZE]; | 14 | unsigned char buffer[PAGE_SIZE]; |
| 15 | unsigned int len; | 15 | struct seq_buf seq; |
| 16 | unsigned int readpos; | ||
| 17 | int full; | 16 | int full; |
| 18 | }; | 17 | }; |
| 19 | 18 | ||
| 20 | static inline void | 19 | static inline void |
| 21 | trace_seq_init(struct trace_seq *s) | 20 | trace_seq_init(struct trace_seq *s) |
| 22 | { | 21 | { |
| 23 | s->len = 0; | 22 | seq_buf_init(&s->seq, s->buffer, PAGE_SIZE); |
| 24 | s->readpos = 0; | ||
| 25 | s->full = 0; | 23 | s->full = 0; |
| 26 | } | 24 | } |
| 27 | 25 | ||
| 28 | /** | 26 | /** |
| 27 | * trace_seq_used - amount of actual data written to buffer | ||
| 28 | * @s: trace sequence descriptor | ||
| 29 | * | ||
| 30 | * Returns the amount of data written to the buffer. | ||
| 31 | * | ||
| 32 | * IMPORTANT! | ||
| 33 | * | ||
| 34 | * Use this instead of @s->seq.len if you need to pass the amount | ||
| 35 | * of data from the buffer to another buffer (userspace, or what not). | ||
| 36 | * The @s->seq.len on overflow is bigger than the buffer size and | ||
| 37 | * using it can cause access to undefined memory. | ||
| 38 | */ | ||
| 39 | static inline int trace_seq_used(struct trace_seq *s) | ||
| 40 | { | ||
| 41 | return seq_buf_used(&s->seq); | ||
| 42 | } | ||
| 43 | |||
| 44 | /** | ||
| 29 | * trace_seq_buffer_ptr - return pointer to next location in buffer | 45 | * trace_seq_buffer_ptr - return pointer to next location in buffer |
| 30 | * @s: trace sequence descriptor | 46 | * @s: trace sequence descriptor |
| 31 | * | 47 | * |
| @@ -37,7 +53,19 @@ trace_seq_init(struct trace_seq *s) | |||
| 37 | static inline unsigned char * | 53 | static inline unsigned char * |
| 38 | trace_seq_buffer_ptr(struct trace_seq *s) | 54 | trace_seq_buffer_ptr(struct trace_seq *s) |
| 39 | { | 55 | { |
| 40 | return s->buffer + s->len; | 56 | return s->buffer + seq_buf_used(&s->seq); |
| 57 | } | ||
| 58 | |||
| 59 | /** | ||
| 60 | * trace_seq_has_overflowed - return true if the trace_seq took too much | ||
| 61 | * @s: trace sequence descriptor | ||
| 62 | * | ||
| 63 | * Returns true if too much data was added to the trace_seq and it is | ||
| 64 | * now full and will not take anymore. | ||
| 65 | */ | ||
| 66 | static inline bool trace_seq_has_overflowed(struct trace_seq *s) | ||
| 67 | { | ||
| 68 | return s->full || seq_buf_has_overflowed(&s->seq); | ||
| 41 | } | 69 | } |
| 42 | 70 | ||
| 43 | /* | 71 | /* |
| @@ -45,40 +73,37 @@ trace_seq_buffer_ptr(struct trace_seq *s) | |||
| 45 | */ | 73 | */ |
| 46 | #ifdef CONFIG_TRACING | 74 | #ifdef CONFIG_TRACING |
| 47 | extern __printf(2, 3) | 75 | extern __printf(2, 3) |
| 48 | int trace_seq_printf(struct trace_seq *s, const char *fmt, ...); | 76 | void trace_seq_printf(struct trace_seq *s, const char *fmt, ...); |
| 49 | extern __printf(2, 0) | 77 | extern __printf(2, 0) |
| 50 | int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args); | 78 | void trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args); |
| 51 | extern int | 79 | extern void |
| 52 | trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary); | 80 | trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary); |
| 53 | extern int trace_print_seq(struct seq_file *m, struct trace_seq *s); | 81 | extern int trace_print_seq(struct seq_file *m, struct trace_seq *s); |
| 54 | extern int trace_seq_to_user(struct trace_seq *s, char __user *ubuf, | 82 | extern int trace_seq_to_user(struct trace_seq *s, char __user *ubuf, |
| 55 | int cnt); | 83 | int cnt); |
| 56 | extern int trace_seq_puts(struct trace_seq *s, const char *str); | 84 | extern void trace_seq_puts(struct trace_seq *s, const char *str); |
| 57 | extern int trace_seq_putc(struct trace_seq *s, unsigned char c); | 85 | extern void trace_seq_putc(struct trace_seq *s, unsigned char c); |
| 58 | extern int trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len); | 86 | extern void trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len); |
| 59 | extern int trace_seq_putmem_hex(struct trace_seq *s, const void *mem, | 87 | extern void trace_seq_putmem_hex(struct trace_seq *s, const void *mem, |
| 60 | unsigned int len); | 88 | unsigned int len); |
| 61 | extern int trace_seq_path(struct trace_seq *s, const struct path *path); | 89 | extern int trace_seq_path(struct trace_seq *s, const struct path *path); |
| 62 | 90 | ||
| 63 | extern int trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, | 91 | extern void trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, |
| 64 | int nmaskbits); | 92 | int nmaskbits); |
| 65 | 93 | ||
| 66 | #else /* CONFIG_TRACING */ | 94 | #else /* CONFIG_TRACING */ |
| 67 | static inline int trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | 95 | static inline void trace_seq_printf(struct trace_seq *s, const char *fmt, ...) |
| 68 | { | 96 | { |
| 69 | return 0; | ||
| 70 | } | 97 | } |
| 71 | static inline int | 98 | static inline void |
| 72 | trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary) | 99 | trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary) |
| 73 | { | 100 | { |
| 74 | return 0; | ||
| 75 | } | 101 | } |
| 76 | 102 | ||
| 77 | static inline int | 103 | static inline void |
| 78 | trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, | 104 | trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, |
| 79 | int nmaskbits) | 105 | int nmaskbits) |
| 80 | { | 106 | { |
| 81 | return 0; | ||
| 82 | } | 107 | } |
| 83 | 108 | ||
| 84 | static inline int trace_print_seq(struct seq_file *m, struct trace_seq *s) | 109 | static inline int trace_print_seq(struct seq_file *m, struct trace_seq *s) |
| @@ -90,23 +115,19 @@ static inline int trace_seq_to_user(struct trace_seq *s, char __user *ubuf, | |||
| 90 | { | 115 | { |
| 91 | return 0; | 116 | return 0; |
| 92 | } | 117 | } |
| 93 | static inline int trace_seq_puts(struct trace_seq *s, const char *str) | 118 | static inline void trace_seq_puts(struct trace_seq *s, const char *str) |
| 94 | { | 119 | { |
| 95 | return 0; | ||
| 96 | } | 120 | } |
| 97 | static inline int trace_seq_putc(struct trace_seq *s, unsigned char c) | 121 | static inline void trace_seq_putc(struct trace_seq *s, unsigned char c) |
| 98 | { | 122 | { |
| 99 | return 0; | ||
| 100 | } | 123 | } |
| 101 | static inline int | 124 | static inline void |
| 102 | trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len) | 125 | trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len) |
| 103 | { | 126 | { |
| 104 | return 0; | ||
| 105 | } | 127 | } |
| 106 | static inline int trace_seq_putmem_hex(struct trace_seq *s, const void *mem, | 128 | static inline void trace_seq_putmem_hex(struct trace_seq *s, const void *mem, |
| 107 | unsigned int len) | 129 | unsigned int len) |
| 108 | { | 130 | { |
| 109 | return 0; | ||
| 110 | } | 131 | } |
| 111 | static inline int trace_seq_path(struct trace_seq *s, const struct path *path) | 132 | static inline int trace_seq_path(struct trace_seq *s, const struct path *path) |
| 112 | { | 133 | { |
