diff options
Diffstat (limited to 'kernel/trace/seq_buf.c')
-rw-r--r-- | kernel/trace/seq_buf.c | 28 |
1 files changed, 16 insertions, 12 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 | */ |
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 | /** |