summaryrefslogtreecommitdiff
path: root/fs/namei.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2012-06-18 10:47:04 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-14 16:35:40 +0400
commitb5fb63c18315c5510c1d0636179c057e0c761c77 (patch)
tree19e42c9aa285eb64c277ece4083d4834351b3d5b /fs/namei.c
parent408ef013cc9e2f94a14f7ccbbe52ddfb18437a99 (diff)
fs: add nd_jump_link
Add a helper that abstracts out the jump to an already parsed struct path from ->follow_link operation from procfs. Not only does this clean up the code by moving the two sides of this game into a single helper, but it also prepares for making struct nameidata private to namei.c Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/fs/namei.c b/fs/namei.c
index a9b94c62c303..0e1b9c3eb36d 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -586,6 +586,21 @@ static inline void path_to_nameidata(const struct path *path,
nd->path.dentry = path->dentry;
}
+/*
+ * Helper to directly jump to a known parsed path from ->follow_link,
+ * caller must have taken a reference to path beforehand.
+ */
+void nd_jump_link(struct nameidata *nd, struct path *path)
+{
+ path_put(&nd->path);
+
+ nd->path = *path;
+ nd->inode = nd->path.dentry->d_inode;
+ nd->flags |= LOOKUP_JUMPED;
+
+ BUG_ON(nd->inode->i_op->follow_link);
+}
+
static inline void put_link(struct nameidata *nd, struct path *link, void *cookie)
{
struct inode *inode = link->dentry->d_inode;
@@ -630,17 +645,9 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
s = nd_get_link(nd);
if (s) {
error = __vfs_follow_link(nd, s);
- } else if (nd->last_type == LAST_BIND) {
- nd->flags |= LOOKUP_JUMPED;
- nd->inode = nd->path.dentry->d_inode;
- if (nd->inode->i_op->follow_link) {
- /* stepped on a _really_ weird one */
- path_put(&nd->path);
- error = -ELOOP;
- }
+ if (unlikely(error))
+ put_link(nd, link, *p);
}
- if (unlikely(error))
- put_link(nd, link, *p);
return error;