diff options
Diffstat (limited to 'fs/seq_file.c')
-rw-r--r-- | fs/seq_file.c | 74 |
1 files changed, 39 insertions, 35 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c index 6c959275f2d0..eae7d9dbf3ff 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c | |||
@@ -429,20 +429,21 @@ EXPORT_SYMBOL(mangle_path); | |||
429 | */ | 429 | */ |
430 | int seq_path(struct seq_file *m, struct path *path, char *esc) | 430 | int seq_path(struct seq_file *m, struct path *path, char *esc) |
431 | { | 431 | { |
432 | if (m->count < m->size) { | 432 | char *buf; |
433 | char *s = m->buf + m->count; | 433 | size_t size = seq_get_buf(m, &buf); |
434 | char *p = d_path(path, s, m->size - m->count); | 434 | int res = -1; |
435 | |||
436 | if (size) { | ||
437 | char *p = d_path(path, buf, size); | ||
435 | if (!IS_ERR(p)) { | 438 | if (!IS_ERR(p)) { |
436 | s = mangle_path(s, p, esc); | 439 | char *end = mangle_path(buf, p, esc); |
437 | if (s) { | 440 | if (end) |
438 | p = m->buf + m->count; | 441 | res = end - buf; |
439 | m->count = s - m->buf; | ||
440 | return s - p; | ||
441 | } | ||
442 | } | 442 | } |
443 | } | 443 | } |
444 | m->count = m->size; | 444 | seq_commit(m, res); |
445 | return -1; | 445 | |
446 | return res; | ||
446 | } | 447 | } |
447 | EXPORT_SYMBOL(seq_path); | 448 | EXPORT_SYMBOL(seq_path); |
448 | 449 | ||
@@ -454,26 +455,28 @@ EXPORT_SYMBOL(seq_path); | |||
454 | int seq_path_root(struct seq_file *m, struct path *path, struct path *root, | 455 | int seq_path_root(struct seq_file *m, struct path *path, struct path *root, |
455 | char *esc) | 456 | char *esc) |
456 | { | 457 | { |
457 | int err = -ENAMETOOLONG; | 458 | char *buf; |
458 | if (m->count < m->size) { | 459 | size_t size = seq_get_buf(m, &buf); |
459 | char *s = m->buf + m->count; | 460 | int res = -ENAMETOOLONG; |
461 | |||
462 | if (size) { | ||
460 | char *p; | 463 | char *p; |
461 | 464 | ||
462 | spin_lock(&dcache_lock); | 465 | spin_lock(&dcache_lock); |
463 | p = __d_path(path, root, s, m->size - m->count); | 466 | p = __d_path(path, root, buf, size); |
464 | spin_unlock(&dcache_lock); | 467 | spin_unlock(&dcache_lock); |
465 | err = PTR_ERR(p); | 468 | res = PTR_ERR(p); |
466 | if (!IS_ERR(p)) { | 469 | if (!IS_ERR(p)) { |
467 | s = mangle_path(s, p, esc); | 470 | char *end = mangle_path(buf, p, esc); |
468 | if (s) { | 471 | if (end) |
469 | p = m->buf + m->count; | 472 | res = end - buf; |
470 | m->count = s - m->buf; | 473 | else |
471 | return 0; | 474 | res = -ENAMETOOLONG; |
472 | } | ||
473 | } | 475 | } |
474 | } | 476 | } |
475 | m->count = m->size; | 477 | seq_commit(m, res); |
476 | return err; | 478 | |
479 | return res < 0 ? res : 0; | ||
477 | } | 480 | } |
478 | 481 | ||
479 | /* | 482 | /* |
@@ -481,20 +484,21 @@ int seq_path_root(struct seq_file *m, struct path *path, struct path *root, | |||
481 | */ | 484 | */ |
482 | int seq_dentry(struct seq_file *m, struct dentry *dentry, char *esc) | 485 | int seq_dentry(struct seq_file *m, struct dentry *dentry, char *esc) |
483 | { | 486 | { |
484 | if (m->count < m->size) { | 487 | char *buf; |
485 | char *s = m->buf + m->count; | 488 | size_t size = seq_get_buf(m, &buf); |
486 | char *p = dentry_path(dentry, s, m->size - m->count); | 489 | int res = -1; |
490 | |||
491 | if (size) { | ||
492 | char *p = dentry_path(dentry, buf, size); | ||
487 | if (!IS_ERR(p)) { | 493 | if (!IS_ERR(p)) { |
488 | s = mangle_path(s, p, esc); | 494 | char *end = mangle_path(buf, p, esc); |
489 | if (s) { | 495 | if (end) |
490 | p = m->buf + m->count; | 496 | res = end - buf; |
491 | m->count = s - m->buf; | ||
492 | return s - p; | ||
493 | } | ||
494 | } | 497 | } |
495 | } | 498 | } |
496 | m->count = m->size; | 499 | seq_commit(m, res); |
497 | return -1; | 500 | |
501 | return res; | ||
498 | } | 502 | } |
499 | 503 | ||
500 | int seq_bitmap(struct seq_file *m, const unsigned long *bits, | 504 | int seq_bitmap(struct seq_file *m, const unsigned long *bits, |