summaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-04-22 12:10:45 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-05-10 22:18:31 -0400
commita5cfe2d5e14d4c2dec06b22d18050c443c7537f9 (patch)
tree675ff9450e7eafa62da07c63bc4262964909246c /fs/namei.c
parentfd2805be238947eb819284189205e8de6f6c41c4 (diff)
do_last: regularize the logics around following symlinks
With LOOKUP_FOLLOW we unlazy and return 1; without it we either fail with ELOOP or, for O_PATH opens, succeed. No need to mix those cases... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 3e452338f1b7..54cbfe799249 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3046,9 +3046,7 @@ retry_lookup:
3046 goto out; 3046 goto out;
3047 } 3047 }
3048finish_lookup: 3048finish_lookup:
3049 /* we _can_ be in RCU mode here */ 3049 if (should_follow_link(path->dentry, nd->flags & LOOKUP_FOLLOW)) {
3050 if (should_follow_link(path->dentry,
3051 !(open_flag & O_PATH) || (nd->flags & LOOKUP_FOLLOW))) {
3052 if (nd->flags & LOOKUP_RCU) { 3050 if (nd->flags & LOOKUP_RCU) {
3053 if (unlikely(nd->path.mnt != path->mnt || 3051 if (unlikely(nd->path.mnt != path->mnt ||
3054 unlazy_walk(nd, path->dentry))) { 3052 unlazy_walk(nd, path->dentry))) {
@@ -3057,14 +3055,15 @@ finish_lookup:
3057 } 3055 }
3058 } 3056 }
3059 BUG_ON(inode != path->dentry->d_inode); 3057 BUG_ON(inode != path->dentry->d_inode);
3060 if (!(nd->flags & LOOKUP_FOLLOW)) {
3061 path_put_conditional(path, nd);
3062 path_put(&nd->path);
3063 return -ELOOP;
3064 }
3065 return 1; 3058 return 1;
3066 } 3059 }
3067 3060
3061 if (unlikely(d_is_symlink(path->dentry)) && !(open_flag & O_PATH)) {
3062 path_to_nameidata(path, nd);
3063 error = -ELOOP;
3064 goto out;
3065 }
3066
3068 if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path->mnt) { 3067 if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path->mnt) {
3069 path_to_nameidata(path, nd); 3068 path_to_nameidata(path, nd);
3070 } else { 3069 } else {