summaryrefslogtreecommitdiff
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2020-03-05 11:41:29 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2020-04-02 01:09:28 -0400
commitc5971b8c6354a95c9ee7eb722928af5000bac247 (patch)
treeca99af95ce86268f890fb2a1b553d07dffa7a67c /fs/namei.c
parent0f705953012a753068b20016f55dc12d1f7e17e5 (diff)
take post-lookup part of do_last() out of loop
now we can have open_last_lookups() directly from the loop in path_openat() - the rest of do_last() never returns a symlink to follow, so we can bloody well leave the loop first. Rename the rest of that thing from do_last() to do_open() and make it return an int. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/fs/namei.c b/fs/namei.c
index e737d884592d..329ade345e62 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3220,31 +3220,26 @@ finish_lookup:
/*
* Handle the last step of open()
*/
-static const char *do_last(struct nameidata *nd,
+static int do_open(struct nameidata *nd,
struct file *file, const struct open_flags *op)
{
int open_flag = op->open_flag;
bool do_truncate;
int acc_mode;
- const char *link;
int error;
- link = open_last_lookups(nd, file, op);
- if (unlikely(link))
- return link;
-
if (!(file->f_mode & FMODE_CREATED))
audit_inode(nd->name, nd->path.dentry, 0);
if (open_flag & O_CREAT) {
if (d_is_dir(nd->path.dentry))
- return ERR_PTR(-EISDIR);
+ return -EISDIR;
error = may_create_in_sticky(nd->dir_mode, nd->dir_uid,
d_backing_inode(nd->path.dentry));
if (unlikely(error))
- return ERR_PTR(error);
+ return error;
}
if ((nd->flags & LOOKUP_DIRECTORY) && !d_can_lookup(nd->path.dentry))
- return ERR_PTR(-ENOTDIR);
+ return -ENOTDIR;
do_truncate = false;
acc_mode = op->acc_mode;
@@ -3255,7 +3250,7 @@ static const char *do_last(struct nameidata *nd,
} else if (d_is_reg(nd->path.dentry) && open_flag & O_TRUNC) {
error = mnt_want_write(nd->path.mnt);
if (error)
- return ERR_PTR(error);
+ return error;
do_truncate = true;
}
error = may_open(&nd->path, acc_mode, open_flag);
@@ -3271,7 +3266,7 @@ static const char *do_last(struct nameidata *nd,
}
if (do_truncate)
mnt_drop_write(nd->path.mnt);
- return ERR_PTR(error);
+ return error;
}
struct dentry *vfs_tmpfile(struct dentry *dentry, umode_t mode, int open_flag)
@@ -3374,8 +3369,10 @@ static struct file *path_openat(struct nameidata *nd,
} else {
const char *s = path_init(nd, flags);
while (!(error = link_path_walk(s, nd)) &&
- (s = do_last(nd, file, op)) != NULL)
+ (s = open_last_lookups(nd, file, op)) != NULL)
;
+ if (!error)
+ error = do_open(nd, file, op);
terminate_walk(nd);
}
if (likely(!error)) {