aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Blunck <jblunck@suse.de>2008-02-14 22:34:38 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-15 00:13:33 -0500
commit5dd784d04924be5d8bc066aded0ec3274b20e612 (patch)
treeb92ba8ffd3cad1175a75df0356882e50b5999f98
parent09da5916baf6d3fb9ac16c125c801ae6ea151f97 (diff)
Introduce path_get()
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>
-rw-r--r--fs/namei.c17
-rw-r--r--include/linux/path.h1
2 files changed, 16 insertions, 2 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 024993535b6f..a6575ca9f9d7 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -363,6 +363,19 @@ int deny_write_access(struct file * file)
363} 363}
364 364
365/** 365/**
366 * path_get - get a reference to a path
367 * @path: path to get the reference to
368 *
369 * Given a path increment the reference count to the dentry and the vfsmount.
370 */
371void path_get(struct path *path)
372{
373 mntget(path->mnt);
374 dget(path->dentry);
375}
376EXPORT_SYMBOL(path_get);
377
378/**
366 * path_put - put a reference to a path 379 * path_put - put a reference to a path
367 * @path: path to put the reference to 380 * @path: path to put the reference to
368 * 381 *
@@ -1160,8 +1173,8 @@ static int do_path_lookup(int dfd, const char *name,
1160 if (retval) 1173 if (retval)
1161 goto fput_fail; 1174 goto fput_fail;
1162 1175
1163 nd->path.mnt = mntget(file->f_path.mnt); 1176 nd->path = file->f_path;
1164 nd->path.dentry = dget(dentry); 1177 path_get(&file->f_path);
1165 1178
1166 fput_light(file, fput_needed); 1179 fput_light(file, fput_needed);
1167 } 1180 }
diff --git a/include/linux/path.h b/include/linux/path.h
index 4d976f959f33..915e0c382a51 100644
--- a/include/linux/path.h
+++ b/include/linux/path.h
@@ -9,6 +9,7 @@ struct path {
9 struct dentry *dentry; 9 struct dentry *dentry;
10}; 10};
11 11
12extern void path_get(struct path *);
12extern void path_put(struct path *); 13extern void path_put(struct path *);
13 14
14#endif /* _LINUX_PATH_H */ 15#endif /* _LINUX_PATH_H */