diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-07-30 09:50:30 +0200 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-07-30 09:50:30 +0200 |
commit | f8310c59201b183ebee2e3fe0c7242f5729be0af (patch) | |
tree | 534606455dd90b2ec0ee9aa53bc4e51ce102b609 /fs | |
parent | lockd: handle lockowner allocation failure in nlmclnt_proc() (diff) | |
download | linux-f8310c59201b183ebee2e3fe0c7242f5729be0af.tar.xz linux-f8310c59201b183ebee2e3fe0c7242f5729be0af.zip |
fix O_EXCL handling for devices
O_EXCL without O_CREAT has different semantics; it's "fail if already opened",
not "fail if already exists". commit 71574865 broke that...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/namei.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/namei.c b/fs/namei.c index 618d3531cf9f..e133bf3bbb03 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2418,7 +2418,7 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry, if ((open_flag & O_CREAT) && !IS_POSIXACL(dir)) mode &= ~current_umask(); - if (open_flag & O_EXCL) { + if ((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT)) { open_flag &= ~O_TRUNC; *opened |= FILE_CREATED; } @@ -2742,7 +2742,7 @@ retry_lookup: } error = -EEXIST; - if (open_flag & O_EXCL) + if ((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT)) goto exit_dput; error = follow_managed(path, nd->flags); |