Loading fs/namei.c +26 −33 Original line number Original line Diff line number Diff line Loading @@ -1866,7 +1866,7 @@ static int step_into(struct nameidata *nd, int flags, return pick_link(nd, &path, inode, seq); return pick_link(nd, &path, inode, seq); } } static int walk_component(struct nameidata *nd, int flags) static const char *walk_component(struct nameidata *nd, int flags) { { struct dentry *dentry; struct dentry *dentry; struct inode *inode; struct inode *inode; Loading @@ -1881,19 +1881,24 @@ static int walk_component(struct nameidata *nd, int flags) if (!(flags & WALK_MORE) && nd->depth) if (!(flags & WALK_MORE) && nd->depth) put_link(nd); put_link(nd); err = handle_dots(nd, nd->last_type); err = handle_dots(nd, nd->last_type); return err; return ERR_PTR(err); } } dentry = lookup_fast(nd, &inode, &seq); dentry = lookup_fast(nd, &inode, &seq); if (IS_ERR(dentry)) if (IS_ERR(dentry)) return PTR_ERR(dentry); return ERR_CAST(dentry); if (unlikely(!dentry)) { if (unlikely(!dentry)) { dentry = lookup_slow(&nd->last, nd->path.dentry, nd->flags); dentry = lookup_slow(&nd->last, nd->path.dentry, nd->flags); if (IS_ERR(dentry)) if (IS_ERR(dentry)) return PTR_ERR(dentry); return ERR_CAST(dentry); } } if (!(flags & WALK_MORE) && nd->depth) if (!(flags & WALK_MORE) && nd->depth) put_link(nd); put_link(nd); return step_into(nd, flags, dentry, inode, seq); err = step_into(nd, flags, dentry, inode, seq); if (!err) return NULL; if (err > 0) return get_link(nd); return ERR_PTR(err); } } /* /* Loading Loading @@ -2145,6 +2150,7 @@ static int link_path_walk(const char *name, struct nameidata *nd) /* At this point we know we have a real path component. */ /* At this point we know we have a real path component. */ for(;;) { for(;;) { const char *link; u64 hash_len; u64 hash_len; int type; int type; Loading Loading @@ -2202,25 +2208,19 @@ static int link_path_walk(const char *name, struct nameidata *nd) if (!name) if (!name) return 0; return 0; /* last component of nested symlink */ /* last component of nested symlink */ err = walk_component(nd, WALK_FOLLOW); link = walk_component(nd, WALK_FOLLOW); } else { } else { /* not the last component */ /* not the last component */ err = walk_component(nd, WALK_FOLLOW | WALK_MORE); link = walk_component(nd, WALK_FOLLOW | WALK_MORE); } } if (err < 0) if (unlikely(link)) { return err; if (IS_ERR(link)) return PTR_ERR(link); if (err) { /* a symlink to follow */ const char *s = get_link(nd); if (IS_ERR(s)) return PTR_ERR(s); if (likely(s)) { nd->stack[nd->depth - 1].name = name; nd->stack[nd->depth - 1].name = name; name = s; name = link; continue; continue; } } } if (unlikely(!d_can_lookup(nd->path.dentry))) { if (unlikely(!d_can_lookup(nd->path.dentry))) { if (nd->flags & LOOKUP_RCU) { if (nd->flags & LOOKUP_RCU) { if (unlazy_walk(nd)) if (unlazy_walk(nd)) Loading Loading @@ -2335,24 +2335,17 @@ static const char *path_init(struct nameidata *nd, unsigned flags) static inline const char *lookup_last(struct nameidata *nd) static inline const char *lookup_last(struct nameidata *nd) { { int err; const char *link; if (nd->last_type == LAST_NORM && nd->last.name[nd->last.len]) if (nd->last_type == LAST_NORM && nd->last.name[nd->last.len]) nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; nd->flags &= ~LOOKUP_PARENT; nd->flags &= ~LOOKUP_PARENT; err = walk_component(nd, 0); link = walk_component(nd, 0); if (unlikely(err)) { if (link) { const char *s; if (err < 0) return PTR_ERR(err); s = get_link(nd); if (s) { nd->flags |= LOOKUP_PARENT; nd->flags |= LOOKUP_PARENT; nd->stack[0].name = NULL; nd->stack[0].name = NULL; return s; } } } return NULL; return link; } } static int handle_lookup_down(struct nameidata *nd) static int handle_lookup_down(struct nameidata *nd) Loading Loading
fs/namei.c +26 −33 Original line number Original line Diff line number Diff line Loading @@ -1866,7 +1866,7 @@ static int step_into(struct nameidata *nd, int flags, return pick_link(nd, &path, inode, seq); return pick_link(nd, &path, inode, seq); } } static int walk_component(struct nameidata *nd, int flags) static const char *walk_component(struct nameidata *nd, int flags) { { struct dentry *dentry; struct dentry *dentry; struct inode *inode; struct inode *inode; Loading @@ -1881,19 +1881,24 @@ static int walk_component(struct nameidata *nd, int flags) if (!(flags & WALK_MORE) && nd->depth) if (!(flags & WALK_MORE) && nd->depth) put_link(nd); put_link(nd); err = handle_dots(nd, nd->last_type); err = handle_dots(nd, nd->last_type); return err; return ERR_PTR(err); } } dentry = lookup_fast(nd, &inode, &seq); dentry = lookup_fast(nd, &inode, &seq); if (IS_ERR(dentry)) if (IS_ERR(dentry)) return PTR_ERR(dentry); return ERR_CAST(dentry); if (unlikely(!dentry)) { if (unlikely(!dentry)) { dentry = lookup_slow(&nd->last, nd->path.dentry, nd->flags); dentry = lookup_slow(&nd->last, nd->path.dentry, nd->flags); if (IS_ERR(dentry)) if (IS_ERR(dentry)) return PTR_ERR(dentry); return ERR_CAST(dentry); } } if (!(flags & WALK_MORE) && nd->depth) if (!(flags & WALK_MORE) && nd->depth) put_link(nd); put_link(nd); return step_into(nd, flags, dentry, inode, seq); err = step_into(nd, flags, dentry, inode, seq); if (!err) return NULL; if (err > 0) return get_link(nd); return ERR_PTR(err); } } /* /* Loading Loading @@ -2145,6 +2150,7 @@ static int link_path_walk(const char *name, struct nameidata *nd) /* At this point we know we have a real path component. */ /* At this point we know we have a real path component. */ for(;;) { for(;;) { const char *link; u64 hash_len; u64 hash_len; int type; int type; Loading Loading @@ -2202,25 +2208,19 @@ static int link_path_walk(const char *name, struct nameidata *nd) if (!name) if (!name) return 0; return 0; /* last component of nested symlink */ /* last component of nested symlink */ err = walk_component(nd, WALK_FOLLOW); link = walk_component(nd, WALK_FOLLOW); } else { } else { /* not the last component */ /* not the last component */ err = walk_component(nd, WALK_FOLLOW | WALK_MORE); link = walk_component(nd, WALK_FOLLOW | WALK_MORE); } } if (err < 0) if (unlikely(link)) { return err; if (IS_ERR(link)) return PTR_ERR(link); if (err) { /* a symlink to follow */ const char *s = get_link(nd); if (IS_ERR(s)) return PTR_ERR(s); if (likely(s)) { nd->stack[nd->depth - 1].name = name; nd->stack[nd->depth - 1].name = name; name = s; name = link; continue; continue; } } } if (unlikely(!d_can_lookup(nd->path.dentry))) { if (unlikely(!d_can_lookup(nd->path.dentry))) { if (nd->flags & LOOKUP_RCU) { if (nd->flags & LOOKUP_RCU) { if (unlazy_walk(nd)) if (unlazy_walk(nd)) Loading Loading @@ -2335,24 +2335,17 @@ static const char *path_init(struct nameidata *nd, unsigned flags) static inline const char *lookup_last(struct nameidata *nd) static inline const char *lookup_last(struct nameidata *nd) { { int err; const char *link; if (nd->last_type == LAST_NORM && nd->last.name[nd->last.len]) if (nd->last_type == LAST_NORM && nd->last.name[nd->last.len]) nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; nd->flags &= ~LOOKUP_PARENT; nd->flags &= ~LOOKUP_PARENT; err = walk_component(nd, 0); link = walk_component(nd, 0); if (unlikely(err)) { if (link) { const char *s; if (err < 0) return PTR_ERR(err); s = get_link(nd); if (s) { nd->flags |= LOOKUP_PARENT; nd->flags |= LOOKUP_PARENT; nd->stack[0].name = NULL; nd->stack[0].name = NULL; return s; } } } return NULL; return link; } } static int handle_lookup_down(struct nameidata *nd) static int handle_lookup_down(struct nameidata *nd) Loading