atomic_open(): lift the call of may_open() into do_last()
there we'll be able to merge it with its counterparts in other cases, and there's no reason to do it before the parent has been unlocked Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
6fb968cdf9
commit
7be219b4dc
26
fs/namei.c
26
fs/namei.c
|
@ -2949,23 +2949,12 @@ static struct dentry *atomic_open(struct nameidata *nd, struct dentry *dentry,
|
||||||
d_lookup_done(dentry);
|
d_lookup_done(dentry);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
if (file->f_mode & FMODE_OPENED) {
|
if (file->f_mode & FMODE_OPENED) {
|
||||||
int acc_mode = op->acc_mode;
|
|
||||||
if (unlikely(dentry != file->f_path.dentry)) {
|
if (unlikely(dentry != file->f_path.dentry)) {
|
||||||
dput(dentry);
|
dput(dentry);
|
||||||
dentry = dget(file->f_path.dentry);
|
dentry = dget(file->f_path.dentry);
|
||||||
}
|
}
|
||||||
/*
|
if (file->f_mode & FMODE_CREATED)
|
||||||
* We didn't have the inode before the open, so check open
|
|
||||||
* permission here.
|
|
||||||
*/
|
|
||||||
if (file->f_mode & FMODE_CREATED) {
|
|
||||||
WARN_ON(!(open_flag & O_CREAT));
|
|
||||||
fsnotify_create(dir, dentry);
|
fsnotify_create(dir, dentry);
|
||||||
acc_mode = 0;
|
|
||||||
}
|
|
||||||
error = may_open(&file->f_path, acc_mode, open_flag);
|
|
||||||
if (WARN_ON(error > 0))
|
|
||||||
error = -EINVAL;
|
|
||||||
} else if (WARN_ON(file->f_path.dentry == DENTRY_NOT_SET)) {
|
} else if (WARN_ON(file->f_path.dentry == DENTRY_NOT_SET)) {
|
||||||
error = -EIO;
|
error = -EIO;
|
||||||
} else {
|
} else {
|
||||||
|
@ -3208,12 +3197,19 @@ static const char *do_last(struct nameidata *nd,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file->f_mode & FMODE_OPENED) {
|
if (file->f_mode & FMODE_OPENED) {
|
||||||
if ((file->f_mode & FMODE_CREATED) ||
|
if (file->f_mode & FMODE_CREATED) {
|
||||||
!S_ISREG(file_inode(file)->i_mode))
|
open_flag &= ~O_TRUNC;
|
||||||
|
will_truncate = false;
|
||||||
|
acc_mode = 0;
|
||||||
|
} else if (!S_ISREG(file_inode(file)->i_mode))
|
||||||
will_truncate = false;
|
will_truncate = false;
|
||||||
|
|
||||||
audit_inode(nd->name, file->f_path.dentry, 0);
|
audit_inode(nd->name, file->f_path.dentry, 0);
|
||||||
dput(dentry);
|
dput(nd->path.dentry);
|
||||||
|
nd->path.dentry = dentry;
|
||||||
|
error = may_open(&nd->path, acc_mode, open_flag);
|
||||||
|
if (error)
|
||||||
|
goto out;
|
||||||
goto opened;
|
goto opened;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue