[patch 3/4] Introduce pathget

Andreas Gruenbacher
2007-08-10T14:44:20Z

[-- Attachment #1: pathget.diff --]
[-- Type: text/plain, Size: 1390 bytes --]

This is the symmetric operation to pathput.

Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>

---
fs/namei.c | 9 +++------
include/linux/namei.h | 8 --------
2 files changed, 3 insertions(+), 14 deletions(-)

--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1003,14 +1003,12 @@ static int fastcall link_path_walk(const
int result;

/* make sure the stuff we saved doesn't go away */
- dget(save.lookup.path.dentry);
- mntget(save.lookup.path.mnt);
+ pathget(&save.lookup.path);

result = __link_path_walk(name, nd);
if (result == -ESTALE) {
*nd = save;
- dget(nd->lookup.path.dentry);
- mntget(nd->lookup.path.mnt);
+ pathget(&nd->lookup.path);
nd->lookup.flags |= LOOKUP_REVAL;
result = __link_path_walk(name, nd);
}
@@ -1140,8 +1138,7 @@ static int fastcall do_path_lookup(int d
if (retval)
goto fput_fail;

- mntget(nd->lookup.path.mnt);
- dget(nd->lookup.path.dentry);
+ pathget(&nd->lookup.path);

fput_light(file, fput_needed);
}
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -102,6 +102,14 @@ static inline char *nd_get_link(struct n
return nd->saved_names[nd->depth];
}

+static inline struct path *pathget(struct path *path)
+{
+ mntget(path->mnt);
+ dget(path->dentry);
+
+ return path;
+}
+
static inline void pathput(struct path *path)
{
dput(path->dentry);