Mailing List Archive

[patch 08/10] 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>
---
fs/namei.c | 17 +++++++++++++++--
include/linux/path.h | 1 +
2 files changed, 16 insertions(+), 2 deletions(-)

Index: b/fs/namei.c
===================================================================
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -348,6 +348,20 @@ int deny_write_access(struct file * file
}

/**
+ * 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.
+ */
+struct path *path_get(struct path *path)
+{
+ mntget(path->mnt);
+ dget(path->dentry);
+ return path;
+}
+EXPORT_SYMBOL(path_get);
+
+/**
* path_put - put a reference to a path
* @path: path to put the reference to
*
@@ -1145,8 +1159,7 @@ static int fastcall do_path_lookup(int d
if (retval)
goto fput_fail;

- nd->path.mnt = mntget(file->f_path.mnt);
- nd->path.dentry = dget(dentry);
+ nd->path = *path_get(&file->f_path);

fput_light(file, fput_needed);
}
Index: b/include/linux/path.h
===================================================================
--- a/include/linux/path.h
+++ b/include/linux/path.h
@@ -9,6 +9,7 @@ struct path {
struct dentry *dentry;
};

+extern struct path *path_get(struct path *);
extern void path_put(struct path *);

#endif /* _LINUX_PATH_H */

--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [patch 08/10] Introduce path_get() [ In reply to ]
On Thu, Sep 27, 2007 at 04:12:08PM +0200, jblunck@suse.de wrote:
> 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.

Looks good in general,

> /**
> + * 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.
> + */
> +struct path *path_get(struct path *path)
> +{
> + mntget(path->mnt);
> + dget(path->dentry);
> + return path;
> +}

but the calling convention is rather odd, because the only thing callers
might do with this is to dereference and then assign it. Maybe this
should just return void to make it more clear what's going on?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[patch 08/10] Introduce path_get() [ In reply to ]
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>
---
fs/namei.c | 17 +++++++++++++++--
include/linux/namei.h | 6 ------
include/linux/path.h | 1 +
3 files changed, 16 insertions(+), 8 deletions(-)

Index: b/fs/namei.c
===================================================================
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -363,6 +363,19 @@ int deny_write_access(struct file * file
}

/**
+ * 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
*
@@ -1161,8 +1174,8 @@ static int fastcall do_path_lookup(int d
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: b/include/linux/namei.h
===================================================================
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -94,10 +94,4 @@ static inline char *nd_get_link(struct n
return nd->saved_names[nd->depth];
}

-static inline void pathget(struct path *path)
-{
- mntget(path->mnt);
- dget(path->dentry);
-}
-
#endif /* _LINUX_NAMEI_H */
Index: b/include/linux/path.h
===================================================================
--- a/include/linux/path.h
+++ b/include/linux/path.h
@@ -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 */

--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/