merging pick_link() with get_link(), part 5
move get_link() call into step_into(). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
43
fs/namei.c
43
fs/namei.c
@ -1841,14 +1841,14 @@ enum {WALK_FOLLOW = 1, WALK_MORE = 2, WALK_NOFOLLOW = 4};
|
|||||||
* so we keep a cache of "no, this doesn't need follow_link"
|
* so we keep a cache of "no, this doesn't need follow_link"
|
||||||
* for the common case.
|
* for the common case.
|
||||||
*/
|
*/
|
||||||
static int step_into(struct nameidata *nd, int flags,
|
static const char *step_into(struct nameidata *nd, int flags,
|
||||||
struct dentry *dentry, struct inode *inode, unsigned seq)
|
struct dentry *dentry, struct inode *inode, unsigned seq)
|
||||||
{
|
{
|
||||||
struct path path;
|
struct path path;
|
||||||
int err = handle_mounts(nd, dentry, &path, &inode, &seq);
|
int err = handle_mounts(nd, dentry, &path, &inode, &seq);
|
||||||
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return ERR_PTR(err);
|
||||||
if (likely(!d_is_symlink(path.dentry)) ||
|
if (likely(!d_is_symlink(path.dentry)) ||
|
||||||
!((flags & WALK_FOLLOW) || (nd->flags & LOOKUP_FOLLOW)) ||
|
!((flags & WALK_FOLLOW) || (nd->flags & LOOKUP_FOLLOW)) ||
|
||||||
(flags & WALK_NOFOLLOW)) {
|
(flags & WALK_NOFOLLOW)) {
|
||||||
@ -1856,14 +1856,17 @@ static int step_into(struct nameidata *nd, int flags,
|
|||||||
path_to_nameidata(&path, nd);
|
path_to_nameidata(&path, nd);
|
||||||
nd->inode = inode;
|
nd->inode = inode;
|
||||||
nd->seq = seq;
|
nd->seq = seq;
|
||||||
return 0;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* 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) {
|
||||||
if (read_seqcount_retry(&path.dentry->d_seq, seq))
|
if (read_seqcount_retry(&path.dentry->d_seq, seq))
|
||||||
return -ECHILD;
|
return ERR_PTR(-ECHILD);
|
||||||
}
|
}
|
||||||
return pick_link(nd, &path, inode, seq);
|
err = pick_link(nd, &path, inode, seq);
|
||||||
|
if (err > 0)
|
||||||
|
return get_link(nd);
|
||||||
|
return ERR_PTR(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *walk_component(struct nameidata *nd, int flags)
|
static const char *walk_component(struct nameidata *nd, int flags)
|
||||||
@ -1893,12 +1896,7 @@ static const char *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 = step_into(nd, flags, dentry, inode, seq);
|
return step_into(nd, flags, dentry, inode, seq);
|
||||||
if (!err)
|
|
||||||
return NULL;
|
|
||||||
if (err > 0)
|
|
||||||
return get_link(nd);
|
|
||||||
return ERR_PTR(err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2352,8 +2350,8 @@ static int handle_lookup_down(struct nameidata *nd)
|
|||||||
{
|
{
|
||||||
if (!(nd->flags & LOOKUP_RCU))
|
if (!(nd->flags & LOOKUP_RCU))
|
||||||
dget(nd->path.dentry);
|
dget(nd->path.dentry);
|
||||||
return step_into(nd, WALK_NOFOLLOW,
|
return PTR_ERR(step_into(nd, WALK_NOFOLLOW,
|
||||||
nd->path.dentry, nd->inode, nd->seq);
|
nd->path.dentry, nd->inode, nd->seq));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
|
/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
|
||||||
@ -3193,6 +3191,7 @@ static const char *do_last(struct nameidata *nd,
|
|||||||
unsigned seq;
|
unsigned seq;
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
struct dentry *dentry;
|
struct dentry *dentry;
|
||||||
|
const char *res;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
nd->flags &= ~LOOKUP_PARENT;
|
nd->flags &= ~LOOKUP_PARENT;
|
||||||
@ -3294,18 +3293,12 @@ static const char *do_last(struct nameidata *nd,
|
|||||||
finish_lookup:
|
finish_lookup:
|
||||||
if (nd->depth)
|
if (nd->depth)
|
||||||
put_link(nd);
|
put_link(nd);
|
||||||
error = step_into(nd, 0, dentry, inode, seq);
|
res = step_into(nd, 0, dentry, inode, seq);
|
||||||
if (unlikely(error)) {
|
if (unlikely(res)) {
|
||||||
const char *s;
|
nd->flags |= LOOKUP_PARENT;
|
||||||
if (error < 0)
|
nd->flags &= ~(LOOKUP_OPEN|LOOKUP_CREATE|LOOKUP_EXCL);
|
||||||
return ERR_PTR(error);
|
nd->stack[0].name = NULL;
|
||||||
s = get_link(nd);
|
return res;
|
||||||
if (s) {
|
|
||||||
nd->flags |= LOOKUP_PARENT;
|
|
||||||
nd->flags &= ~(LOOKUP_OPEN|LOOKUP_CREATE|LOOKUP_EXCL);
|
|
||||||
nd->stack[0].name = NULL;
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT))) {
|
if (unlikely((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT))) {
|
||||||
|
Reference in New Issue
Block a user