aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2014-10-29 13:48:37 -0400
committerSteven Rostedt <rostedt@goodmis.org>2014-11-19 22:01:10 -0500
commitdd23180aacf4b27d48f40b27249f1e58c8df03be (patch)
tree18b658af8993237ed6194dc5328de7d182df6a59 /kernel/trace
parent3a161d99c43ce74c76aecff309be4c3ba455e823 (diff)
tracing: Convert seq_buf_path() to be like seq_path()
Rewrite seq_buf_path() like it is done in seq_path() and allow it to accept any escape character instead of just "\n". Making seq_buf_path() like seq_path() will help prevent problems when converting seq_file to use the seq_buf logic. Link: http://lkml.kernel.org/r/20141104160222.048795666@goodmis.org Link: http://lkml.kernel.org/r/20141114011412.338523371@goodmis.org Tested-by: Jiri Kosina <jkosina@suse.cz> Acked-by: Jiri Kosina <jkosina@suse.cz> Reviewed-by: Petr Mladek <pmladek@suse.cz> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/seq_buf.c28
-rw-r--r--kernel/trace/trace_seq.c5
2 files changed, 18 insertions, 15 deletions
diff --git a/kernel/trace/seq_buf.c b/kernel/trace/seq_buf.c
index e9a7861595d2..7dac34d1235b 100644
--- a/kernel/trace/seq_buf.c
+++ b/kernel/trace/seq_buf.c
@@ -272,28 +272,32 @@ int seq_buf_putmem_hex(struct seq_buf *s, const void *mem,
272 * seq_buf_path - copy a path into the sequence buffer 272 * seq_buf_path - copy a path into the sequence buffer
273 * @s: seq_buf descriptor 273 * @s: seq_buf descriptor
274 * @path: path to write into the sequence buffer. 274 * @path: path to write into the sequence buffer.
275 * @esc: set of characters to escape in the output
275 * 276 *
276 * Write a path name into the sequence buffer. 277 * Write a path name into the sequence buffer.
277 * 278 *
278 * Returns zero on success, -1 on overflow 279 * Returns the number of written bytes on success, -1 on overflow
279 */ 280 */
280int seq_buf_path(struct seq_buf *s, const struct path *path) 281int seq_buf_path(struct seq_buf *s, const struct path *path, const char *esc)
281{ 282{
282 unsigned int len = seq_buf_buffer_left(s); 283 char *buf = s->buffer + s->len;
283 unsigned char *p; 284 size_t size = seq_buf_buffer_left(s);
285 int res = -1;
284 286
285 WARN_ON(s->size == 0); 287 WARN_ON(s->size == 0);
286 288
287 p = d_path(path, s->buffer + s->len, len); 289 if (size) {
288 if (!IS_ERR(p)) { 290 char *p = d_path(path, buf, size);
289 p = mangle_path(s->buffer + s->len, p, "\n"); 291 if (!IS_ERR(p)) {
290 if (p) { 292 char *end = mangle_path(buf, p, esc);
291 s->len = p - s->buffer; 293 if (end)
292 return 0; 294 res = end - buf;
293 } 295 }
294 } 296 }
295 seq_buf_set_overflow(s); 297 if (res > 0)
296 return -1; 298 s->len += res;
299
300 return res;
297} 301}
298 302
299/** 303/**
diff --git a/kernel/trace/trace_seq.c b/kernel/trace/trace_seq.c
index 8c0c54fe674b..74cacc930c24 100644
--- a/kernel/trace/trace_seq.c
+++ b/kernel/trace/trace_seq.c
@@ -326,7 +326,6 @@ EXPORT_SYMBOL_GPL(trace_seq_putmem_hex);
326int trace_seq_path(struct trace_seq *s, const struct path *path) 326int trace_seq_path(struct trace_seq *s, const struct path *path)
327{ 327{
328 unsigned int save_len = s->seq.len; 328 unsigned int save_len = s->seq.len;
329 int ret;
330 329
331 if (s->full) 330 if (s->full)
332 return 0; 331 return 0;
@@ -338,7 +337,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
338 return 0; 337 return 0;
339 } 338 }
340 339
341 ret = seq_buf_path(&s->seq, path); 340 seq_buf_path(&s->seq, path, "\n");
342 341
343 if (unlikely(seq_buf_has_overflowed(&s->seq))) { 342 if (unlikely(seq_buf_has_overflowed(&s->seq))) {
344 s->seq.len = save_len; 343 s->seq.len = save_len;
@@ -346,7 +345,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
346 return 0; 345 return 0;
347 } 346 }
348 347
349 return ret; 348 return 1;
350} 349}
351EXPORT_SYMBOL_GPL(trace_seq_path); 350EXPORT_SYMBOL_GPL(trace_seq_path);
352 351