Commit 8e87fa89 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

[PATCH] factor out common code around ->follow_link invocation

Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 37f5fecf
......@@ -482,6 +482,24 @@ static inline int __vfs_follow_link(struct nameidata *nd, const char *link)
return PTR_ERR(link);
}
static inline int __do_follow_link(struct dentry *dentry, struct nameidata *nd)
{
int error;
touch_atime(nd->mnt, dentry);
nd_set_link(nd, NULL);
error = dentry->d_inode->i_op->follow_link(dentry, nd);
if (!error) {
char *s = nd_get_link(nd);
if (s)
error = __vfs_follow_link(nd, s);
if (dentry->d_inode->i_op->put_link)
dentry->d_inode->i_op->put_link(dentry, nd);
}
return error;
}
/*
* This limits recursive symlink follows to 8, while
* limiting consecutive symlinks to 40.
......@@ -504,16 +522,7 @@ static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
current->link_count++;
current->total_link_count++;
nd->depth++;
touch_atime(nd->mnt, dentry);
nd_set_link(nd, NULL);
err = dentry->d_inode->i_op->follow_link(dentry, nd);
if (!err) {
char *s = nd_get_link(nd);
if (s)
err = __vfs_follow_link(nd, s);
if (dentry->d_inode->i_op->put_link)
dentry->d_inode->i_op->put_link(dentry, nd);
}
err = __do_follow_link(dentry, nd);
current->link_count--;
nd->depth--;
return err;
......@@ -1470,16 +1479,7 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
error = security_inode_follow_link(dentry, nd);
if (error)
goto exit_dput;
touch_atime(nd->mnt, dentry);
nd_set_link(nd, NULL);
error = dentry->d_inode->i_op->follow_link(dentry, nd);
if (!error) {
char *s = nd_get_link(nd);
if (s)
error = __vfs_follow_link(nd, s);
if (dentry->d_inode->i_op->put_link)
dentry->d_inode->i_op->put_link(dentry, nd);
}
error = __do_follow_link(dentry, nd);
dput(dentry);
if (error)
return error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment