Commit 55db2fd9 authored by Al Viro's avatar Al Viro

atomic_open(): massage the create_error logics a bit

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 9d0728e1
...@@ -2855,34 +2855,31 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry, ...@@ -2855,34 +2855,31 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
* Another problem is returing the "right" error value (e.g. for an * Another problem is returing the "right" error value (e.g. for an
* O_EXCL open we want to return EEXIST not EROFS). * O_EXCL open we want to return EEXIST not EROFS).
*/ */
if (((open_flag & (O_CREAT | O_TRUNC)) || if (open_flag & O_CREAT) {
(open_flag & O_ACCMODE) != O_RDONLY) && unlikely(!got_write)) { if (unlikely(!got_write)) {
if (!(open_flag & O_CREAT)) {
/*
* No O_CREATE -> atomicity not a requirement -> fall
* back to lookup + open
*/
goto no_open;
} else if (open_flag & (O_EXCL | O_TRUNC)) {
/* Fall back and fail with the right error */
create_error = -EROFS; create_error = -EROFS;
if (open_flag & (O_EXCL | O_TRUNC)) {
/* Fall back and fail with the right error */
goto no_open; goto no_open;
} else { }
/* No side effects, safe to clear O_CREAT */ /* No side effects, safe to clear O_CREAT */
create_error = -EROFS;
open_flag &= ~O_CREAT; open_flag &= ~O_CREAT;
} } else {
} create_error = may_o_create(&nd->path, dentry, mode);
if (create_error) {
if (open_flag & O_CREAT) {
error = may_o_create(&nd->path, dentry, mode);
if (error) {
create_error = error;
if (open_flag & O_EXCL) if (open_flag & O_EXCL)
goto no_open; goto no_open;
open_flag &= ~O_CREAT; open_flag &= ~O_CREAT;
} }
} }
} else if ((open_flag & (O_TRUNC|O_WRONLY|O_RDWR)) &&
unlikely(!got_write)) {
/*
* No O_CREATE -> atomicity not a requirement -> fall
* back to lookup + open
*/
goto no_open;
}
if (nd->flags & LOOKUP_DIRECTORY) if (nd->flags & LOOKUP_DIRECTORY)
open_flag |= O_DIRECTORY; open_flag |= O_DIRECTORY;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment