diff options
-rw-r--r-- | include/linux/seq_buf.h | 2 | ||||
-rw-r--r-- | kernel/trace/seq_buf.c | 28 | ||||
-rw-r--r-- | kernel/trace/trace_seq.c | 5 |
3 files changed, 19 insertions, 16 deletions
diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h index 4f7a96a9d71a..38770688a627 100644 --- a/include/linux/seq_buf.h +++ b/include/linux/seq_buf.h | |||
@@ -73,7 +73,7 @@ extern int seq_buf_putc(struct seq_buf *s, unsigned char c); | |||
73 | extern int seq_buf_putmem(struct seq_buf *s, const void *mem, unsigned int len); | 73 | extern int seq_buf_putmem(struct seq_buf *s, const void *mem, unsigned int len); |
74 | extern int seq_buf_putmem_hex(struct seq_buf *s, const void *mem, | 74 | extern int seq_buf_putmem_hex(struct seq_buf *s, const void *mem, |
75 | unsigned int len); | 75 | unsigned int len); |
76 | extern int seq_buf_path(struct seq_buf *s, const struct path *path); | 76 | extern int seq_buf_path(struct seq_buf *s, const struct path *path, const char *esc); |
77 | 77 | ||
78 | extern int seq_buf_bitmask(struct seq_buf *s, const unsigned long *maskp, | 78 | extern int seq_buf_bitmask(struct seq_buf *s, const unsigned long *maskp, |
79 | int nmaskbits); | 79 | int nmaskbits); |
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 | */ |
280 | int seq_buf_path(struct seq_buf *s, const struct path *path) | 281 | int 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); | |||
326 | int trace_seq_path(struct trace_seq *s, const struct path *path) | 326 | int 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 | } |
351 | EXPORT_SYMBOL_GPL(trace_seq_path); | 350 | EXPORT_SYMBOL_GPL(trace_seq_path); |
352 | 351 | ||