diff options
author | Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro> | 2009-03-23 09:12:22 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-31 11:45:02 -0400 |
commit | bdd6df6af98ce7e70702edfb5fd5dbbd8d1b0453 (patch) | |
tree | d590d52a6837e0201abf8fd4461fa177d3658a5a /kernel | |
parent | 2a4efa42450762cbfa5c5712aa4cc9f06924c9fd (diff) |
tracing: provide trace_seq_reserve()
trace_seq_reserve() allows a caller to reserve space in a trace_seq and
write directly into it. This makes it easier to export binary data to
userspace via the tracing interface, by simply filling in a struct.
Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace_output.c | 13 | ||||
-rw-r--r-- | kernel/trace/trace_output.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index 19261fdd2455..6595074cbac5 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c | |||
@@ -167,6 +167,19 @@ int trace_seq_putmem_hex(struct trace_seq *s, void *mem, size_t len) | |||
167 | return trace_seq_putmem(s, hex, j); | 167 | return trace_seq_putmem(s, hex, j); |
168 | } | 168 | } |
169 | 169 | ||
170 | void *trace_seq_reserve(struct trace_seq *s, size_t len) | ||
171 | { | ||
172 | void *ret; | ||
173 | |||
174 | if (len > ((PAGE_SIZE - 1) - s->len)) | ||
175 | return NULL; | ||
176 | |||
177 | ret = s->buffer + s->len; | ||
178 | s->len += len; | ||
179 | |||
180 | return ret; | ||
181 | } | ||
182 | |||
170 | int trace_seq_path(struct trace_seq *s, struct path *path) | 183 | int trace_seq_path(struct trace_seq *s, struct path *path) |
171 | { | 184 | { |
172 | unsigned char *p; | 185 | unsigned char *p; |
diff --git a/kernel/trace/trace_output.h b/kernel/trace/trace_output.h index 35c422fb51a9..0ae20b83eec8 100644 --- a/kernel/trace/trace_output.h +++ b/kernel/trace/trace_output.h | |||
@@ -33,6 +33,7 @@ int trace_seq_puts(struct trace_seq *s, const char *str); | |||
33 | int trace_seq_putc(struct trace_seq *s, unsigned char c); | 33 | int trace_seq_putc(struct trace_seq *s, unsigned char c); |
34 | int trace_seq_putmem(struct trace_seq *s, void *mem, size_t len); | 34 | int trace_seq_putmem(struct trace_seq *s, void *mem, size_t len); |
35 | int trace_seq_putmem_hex(struct trace_seq *s, void *mem, size_t len); | 35 | int trace_seq_putmem_hex(struct trace_seq *s, void *mem, size_t len); |
36 | void *trace_seq_reserve(struct trace_seq *s, size_t len); | ||
36 | int trace_seq_path(struct trace_seq *s, struct path *path); | 37 | int trace_seq_path(struct trace_seq *s, struct path *path); |
37 | int seq_print_userip_objs(const struct userstack_entry *entry, | 38 | int seq_print_userip_objs(const struct userstack_entry *entry, |
38 | struct trace_seq *s, unsigned long sym_flags); | 39 | struct trace_seq *s, unsigned long sym_flags); |