diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2008-03-27 08:06:21 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2008-04-23 00:04:38 -0400 |
commit | 9d1bc60138977d9c79471b344a64f2df13b2ccef (patch) | |
tree | 84ed2e1920a1a88ae84515bd9d90240faed5805c /fs/seq_file.c | |
parent | 6092d048183b76bfa3f84b32f8158dd8d10bd811 (diff) |
[patch 2/7] vfs: mountinfo: add seq_file_root()
Add a new function:
seq_file_root()
This is similar to seq_path(), but calculates the path relative to the
given root, instead of current->fs->root. If the path was unreachable
from root, then modify the root parameter to reflect this.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/seq_file.c')
-rw-r--r-- | fs/seq_file.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c index ae59f5a6c5c1..3f54dbd6c49b 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c | |||
@@ -393,6 +393,36 @@ int seq_path(struct seq_file *m, struct path *path, char *esc) | |||
393 | EXPORT_SYMBOL(seq_path); | 393 | EXPORT_SYMBOL(seq_path); |
394 | 394 | ||
395 | /* | 395 | /* |
396 | * Same as seq_path, but relative to supplied root. | ||
397 | * | ||
398 | * root may be changed, see __d_path(). | ||
399 | */ | ||
400 | int seq_path_root(struct seq_file *m, struct path *path, struct path *root, | ||
401 | char *esc) | ||
402 | { | ||
403 | int err = -ENAMETOOLONG; | ||
404 | if (m->count < m->size) { | ||
405 | char *s = m->buf + m->count; | ||
406 | char *p; | ||
407 | |||
408 | spin_lock(&dcache_lock); | ||
409 | p = __d_path(path, root, s, m->size - m->count); | ||
410 | spin_unlock(&dcache_lock); | ||
411 | err = PTR_ERR(p); | ||
412 | if (!IS_ERR(p)) { | ||
413 | s = mangle_path(s, p, esc); | ||
414 | if (s) { | ||
415 | p = m->buf + m->count; | ||
416 | m->count = s - m->buf; | ||
417 | return 0; | ||
418 | } | ||
419 | } | ||
420 | } | ||
421 | m->count = m->size; | ||
422 | return err; | ||
423 | } | ||
424 | |||
425 | /* | ||
396 | * returns the path of the 'dentry' from the root of its filesystem. | 426 | * returns the path of the 'dentry' from the root of its filesystem. |
397 | */ | 427 | */ |
398 | int seq_dentry(struct seq_file *m, struct dentry *dentry, char *esc) | 428 | int seq_dentry(struct seq_file *m, struct dentry *dentry, char *esc) |