[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>
This commit is contained in:
@@ -392,6 +392,36 @@ int seq_path(struct seq_file *m, struct path *path, char *esc)
|
||||
}
|
||||
EXPORT_SYMBOL(seq_path);
|
||||
|
||||
/*
|
||||
* Same as seq_path, but relative to supplied root.
|
||||
*
|
||||
* root may be changed, see __d_path().
|
||||
*/
|
||||
int seq_path_root(struct seq_file *m, struct path *path, struct path *root,
|
||||
char *esc)
|
||||
{
|
||||
int err = -ENAMETOOLONG;
|
||||
if (m->count < m->size) {
|
||||
char *s = m->buf + m->count;
|
||||
char *p;
|
||||
|
||||
spin_lock(&dcache_lock);
|
||||
p = __d_path(path, root, s, m->size - m->count);
|
||||
spin_unlock(&dcache_lock);
|
||||
err = PTR_ERR(p);
|
||||
if (!IS_ERR(p)) {
|
||||
s = mangle_path(s, p, esc);
|
||||
if (s) {
|
||||
p = m->buf + m->count;
|
||||
m->count = s - m->buf;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
m->count = m->size;
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* returns the path of the 'dentry' from the root of its filesystem.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user