diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2017-12-01 17:57:02 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2018-01-05 11:54:36 -0500 |
commit | 9b20d7fc5250f50660c4dd4bea52e54e373b678d (patch) | |
tree | 2796acb4cee1a470f6448d19f89a4a01969d37a1 | |
parent | 066cc813e94a344ae4482af310d324739955c3b5 (diff) |
mqueue: clean prepare_open() up
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | ipc/mqueue.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c index e8a872e9c808..ce498ff906bb 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -721,26 +721,19 @@ static int prepare_open(struct dentry *dentry, int oflag, int ro, MAY_READ | MAY_WRITE }; int acc; - if (oflag & O_CREAT) { - if (d_really_is_positive(dentry)) { /* entry already exists */ - audit_inode(name, dentry, 0); - if (oflag & O_EXCL) - return -EEXIST; - } else { - if (ro) - return ro; - - audit_inode_parent_hidden(name, dentry->d_parent); - return vfs_mkobj(dentry, mode & ~current_umask(), - mqueue_create_attr, attr); - } - } else { - if (d_really_is_negative(dentry)) { + if (d_really_is_negative(dentry)) { + if (!(oflag & O_CREAT)) return -ENOENT; - } else { - audit_inode(name, dentry, 0); - } + if (ro) + return ro; + audit_inode_parent_hidden(name, dentry->d_parent); + return vfs_mkobj(dentry, mode & ~current_umask(), + mqueue_create_attr, attr); } + /* it already existed */ + audit_inode(name, dentry, 0); + if ((oflag & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) + return -EEXIST; if ((oflag & O_ACCMODE) == (O_RDWR | O_WRONLY)) return -EINVAL; acc = oflag2acc[oflag & O_ACCMODE]; |