summaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2016-11-14 01:39:36 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2016-12-05 19:11:57 -0500
commit1c4ff1a87e46a06fc00a83da2fbbc3ac0298f221 (patch)
tree66a914e6069ea2cf99906e85879e6c178d3eef74 /fs/namei.c
parent7f49b471097011d03316d4ae1bc38f9c177126c3 (diff)
namei: invert WALK_PUT logics
... turning the condition for put_link() in walk_component() into "WALK_MORE not passed and depth is non-zero". Again, makes for simpler arguments. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 379168db782b..57d60922396e 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1747,7 +1747,7 @@ static inline int should_follow_link(struct nameidata *nd, struct path *link,
1747 return pick_link(nd, link, inode, seq); 1747 return pick_link(nd, link, inode, seq);
1748} 1748}
1749 1749
1750enum {WALK_GET = 1, WALK_PUT = 2}; 1750enum {WALK_GET = 1, WALK_MORE = 2};
1751 1751
1752static int walk_component(struct nameidata *nd, int flags) 1752static int walk_component(struct nameidata *nd, int flags)
1753{ 1753{
@@ -1762,7 +1762,7 @@ static int walk_component(struct nameidata *nd, int flags)
1762 */ 1762 */
1763 if (unlikely(nd->last_type != LAST_NORM)) { 1763 if (unlikely(nd->last_type != LAST_NORM)) {
1764 err = handle_dots(nd, nd->last_type); 1764 err = handle_dots(nd, nd->last_type);
1765 if (flags & WALK_PUT) 1765 if (!(flags & WALK_MORE) && nd->depth)
1766 put_link(nd); 1766 put_link(nd);
1767 return err; 1767 return err;
1768 } 1768 }
@@ -1789,7 +1789,7 @@ static int walk_component(struct nameidata *nd, int flags)
1789 inode = d_backing_inode(path.dentry); 1789 inode = d_backing_inode(path.dentry);
1790 } 1790 }
1791 1791
1792 if (flags & WALK_PUT) 1792 if (!(flags & WALK_MORE) && nd->depth)
1793 put_link(nd); 1793 put_link(nd);
1794 err = should_follow_link(nd, &path, flags & WALK_GET, inode, seq); 1794 err = should_follow_link(nd, &path, flags & WALK_GET, inode, seq);
1795 if (unlikely(err)) 1795 if (unlikely(err))
@@ -2104,9 +2104,10 @@ OK:
2104 if (!name) 2104 if (!name)
2105 return 0; 2105 return 0;
2106 /* last component of nested symlink */ 2106 /* last component of nested symlink */
2107 err = walk_component(nd, WALK_GET | WALK_PUT);
2108 } else {
2109 err = walk_component(nd, WALK_GET); 2107 err = walk_component(nd, WALK_GET);
2108 } else {
2109 /* not the last component */
2110 err = walk_component(nd, WALK_GET | WALK_MORE);
2110 } 2111 }
2111 if (err < 0) 2112 if (err < 0)
2112 return err; 2113 return err;
@@ -2248,7 +2249,7 @@ static inline int lookup_last(struct nameidata *nd)
2248 nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; 2249 nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
2249 2250
2250 nd->flags &= ~LOOKUP_PARENT; 2251 nd->flags &= ~LOOKUP_PARENT;
2251 return walk_component(nd, nd->depth ? WALK_PUT : 0); 2252 return walk_component(nd, 0);
2252} 2253}
2253 2254
2254/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */ 2255/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */