diff options
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/seq_file.c | 75 |
1 files changed, 39 insertions, 36 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c index 66efd0aa8fb3..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,27 +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 | err = -ENAMETOOLONG; | ||
| 474 | } | 475 | } |
| 475 | } | 476 | } |
| 476 | m->count = m->size; | 477 | seq_commit(m, res); |
| 477 | return err; | 478 | |
| 479 | return res < 0 ? res : 0; | ||
| 478 | } | 480 | } |
| 479 | 481 | ||
| 480 | /* | 482 | /* |
| @@ -482,20 +484,21 @@ int seq_path_root(struct seq_file *m, struct path *path, struct path *root, | |||
| 482 | */ | 484 | */ |
| 483 | 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) |
| 484 | { | 486 | { |
| 485 | if (m->count < m->size) { | 487 | char *buf; |
| 486 | char *s = m->buf + m->count; | 488 | size_t size = seq_get_buf(m, &buf); |
| 487 | 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); | ||
| 488 | if (!IS_ERR(p)) { | 493 | if (!IS_ERR(p)) { |
| 489 | s = mangle_path(s, p, esc); | 494 | char *end = mangle_path(buf, p, esc); |
| 490 | if (s) { | 495 | if (end) |
| 491 | p = m->buf + m->count; | 496 | res = end - buf; |
| 492 | m->count = s - m->buf; | ||
| 493 | return s - p; | ||
| 494 | } | ||
| 495 | } | 497 | } |
| 496 | } | 498 | } |
| 497 | m->count = m->size; | 499 | seq_commit(m, res); |
| 498 | return -1; | 500 | |
| 501 | return res; | ||
| 499 | } | 502 | } |
| 500 | 503 | ||
| 501 | int seq_bitmap(struct seq_file *m, const unsigned long *bits, | 504 | int seq_bitmap(struct seq_file *m, const unsigned long *bits, |
