Introduce path_get()
authorJan Blunck <jblunck@suse.de>
Fri, 15 Feb 2008 03:34:38 +0000 (19:34 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Fri, 15 Feb 2008 05:13:33 +0000 (21:13 -0800)
This introduces the symmetric function to path_put() for getting a reference
to the dentry and vfsmount of a struct path in the right order.

Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/namei.c
include/linux/path.h

index 024993535b6f195af876727238ed9390d65af62a..a6575ca9f9d77eb49e2d14fbe27068cd1a6e70f0 100644 (file)
@@ -362,6 +362,19 @@ int deny_write_access(struct file * file)
        return 0;
 }
 
+/**
+ * path_get - get a reference to a path
+ * @path: path to get the reference to
+ *
+ * Given a path increment the reference count to the dentry and the vfsmount.
+ */
+void path_get(struct path *path)
+{
+       mntget(path->mnt);
+       dget(path->dentry);
+}
+EXPORT_SYMBOL(path_get);
+
 /**
  * path_put - put a reference to a path
  * @path: path to put the reference to
@@ -1160,8 +1173,8 @@ static int do_path_lookup(int dfd, const char *name,
                if (retval)
                        goto fput_fail;
 
-               nd->path.mnt = mntget(file->f_path.mnt);
-               nd->path.dentry = dget(dentry);
+               nd->path = file->f_path;
+               path_get(&file->f_path);
 
                fput_light(file, fput_needed);
        }
index 4d976f959f338b54eb810a14e89f4ff1c1a9d6fe..915e0c382a51fad7a3169748664b5e2153fa645e 100644 (file)
@@ -9,6 +9,7 @@ struct path {
        struct dentry *dentry;
 };
 
+extern void path_get(struct path *);
 extern void path_put(struct path *);
 
 #endif  /* _LINUX_PATH_H */