summaryrefslogtreecommitdiff
path: root/fs/seq_file.c
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2008-03-27 15:06:21 +0300
committerAl Viro <viro@zeniv.linux.org.uk>2008-04-23 08:04:38 +0400
commit9d1bc60138977d9c79471b344a64f2df13b2ccef (patch)
tree84ed2e1920a1a88ae84515bd9d90240faed5805c /fs/seq_file.c
parent6092d048183b76bfa3f84b32f8158dd8d10bd811 (diff)
downloadlinux-9d1bc60138977d9c79471b344a64f2df13b2ccef.tar.xz
[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.c30
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)
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.
*/
int seq_dentry(struct seq_file *m, struct dentry *dentry, char *esc)