|
@@ -1725,6 +1725,8 @@ static int pick_link(struct nameidata *nd, struct path *link,
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+enum {WALK_GET = 1, WALK_MORE = 2};
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* Do we need to follow links? We _really_ want to be able
|
|
* Do we need to follow links? We _really_ want to be able
|
|
* to do this check without having to look at inode->i_op,
|
|
* to do this check without having to look at inode->i_op,
|
|
@@ -1732,12 +1734,14 @@ static int pick_link(struct nameidata *nd, struct path *link,
|
|
* for the common case.
|
|
* for the common case.
|
|
*/
|
|
*/
|
|
static inline int should_follow_link(struct nameidata *nd, struct path *link,
|
|
static inline int should_follow_link(struct nameidata *nd, struct path *link,
|
|
- int follow,
|
|
|
|
|
|
+ int flags,
|
|
struct inode *inode, unsigned seq)
|
|
struct inode *inode, unsigned seq)
|
|
{
|
|
{
|
|
|
|
+ if (!(flags & WALK_MORE) && nd->depth)
|
|
|
|
+ put_link(nd);
|
|
if (likely(!d_is_symlink(link->dentry)))
|
|
if (likely(!d_is_symlink(link->dentry)))
|
|
return 0;
|
|
return 0;
|
|
- if (!follow && !(nd->flags & LOOKUP_FOLLOW))
|
|
|
|
|
|
+ if (!(flags & WALK_GET) && !(nd->flags & LOOKUP_FOLLOW))
|
|
return 0;
|
|
return 0;
|
|
/* make sure that d_is_symlink above matches inode */
|
|
/* make sure that d_is_symlink above matches inode */
|
|
if (nd->flags & LOOKUP_RCU) {
|
|
if (nd->flags & LOOKUP_RCU) {
|
|
@@ -1747,8 +1751,6 @@ static inline int should_follow_link(struct nameidata *nd, struct path *link,
|
|
return pick_link(nd, link, inode, seq);
|
|
return pick_link(nd, link, inode, seq);
|
|
}
|
|
}
|
|
|
|
|
|
-enum {WALK_GET = 1, WALK_MORE = 2};
|
|
|
|
-
|
|
|
|
static int walk_component(struct nameidata *nd, int flags)
|
|
static int walk_component(struct nameidata *nd, int flags)
|
|
{
|
|
{
|
|
struct path path;
|
|
struct path path;
|
|
@@ -1789,9 +1791,7 @@ static int walk_component(struct nameidata *nd, int flags)
|
|
inode = d_backing_inode(path.dentry);
|
|
inode = d_backing_inode(path.dentry);
|
|
}
|
|
}
|
|
|
|
|
|
- if (!(flags & WALK_MORE) && nd->depth)
|
|
|
|
- put_link(nd);
|
|
|
|
- err = should_follow_link(nd, &path, flags & WALK_GET, inode, seq);
|
|
|
|
|
|
+ err = should_follow_link(nd, &path, flags, inode, seq);
|
|
if (unlikely(err))
|
|
if (unlikely(err))
|
|
return err;
|
|
return err;
|
|
path_to_nameidata(&path, nd);
|
|
path_to_nameidata(&path, nd);
|
|
@@ -2616,8 +2616,6 @@ mountpoint_last(struct nameidata *nd)
|
|
dput(path.dentry);
|
|
dput(path.dentry);
|
|
return -ENOENT;
|
|
return -ENOENT;
|
|
}
|
|
}
|
|
- if (nd->depth)
|
|
|
|
- put_link(nd);
|
|
|
|
path.mnt = nd->path.mnt;
|
|
path.mnt = nd->path.mnt;
|
|
error = should_follow_link(nd, &path, 0,
|
|
error = should_follow_link(nd, &path, 0,
|
|
d_backing_inode(path.dentry), 0);
|
|
d_backing_inode(path.dentry), 0);
|
|
@@ -3313,8 +3311,6 @@ static int do_last(struct nameidata *nd,
|
|
seq = 0; /* out of RCU mode, so the value doesn't matter */
|
|
seq = 0; /* out of RCU mode, so the value doesn't matter */
|
|
inode = d_backing_inode(path.dentry);
|
|
inode = d_backing_inode(path.dentry);
|
|
finish_lookup:
|
|
finish_lookup:
|
|
- if (nd->depth)
|
|
|
|
- put_link(nd);
|
|
|
|
error = should_follow_link(nd, &path, 0, inode, seq);
|
|
error = should_follow_link(nd, &path, 0, inode, seq);
|
|
if (unlikely(error))
|
|
if (unlikely(error))
|
|
return error;
|
|
return error;
|