Skip to content

Commit

Permalink
fix O_EXCL handling for devices
Browse files Browse the repository at this point in the history
O_EXCL without O_CREAT has different semantics; it's "fail if already opened",
not "fail if already exists".  commit 7157486 broke that...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Jul 30, 2012
1 parent bf88489 commit f8310c5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -2742,7 +2742,7 @@ static int do_last(struct nameidata *nd, struct path *path,
}

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);
Expand Down

0 comments on commit f8310c5

Please sign in to comment.