diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-07-30 03:50:30 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-07-30 03:50:30 -0400 |
commit | f8310c59201b183ebee2e3fe0c7242f5729be0af (patch) | |
tree | 534606455dd90b2ec0ee9aa53bc4e51ce102b609 /fs/namei.c | |
parent | bf8848918d751c1fb86f6514a75bf8d406f1c3c3 (diff) |
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/namei.c')
-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, | |||
2418 | if ((open_flag & O_CREAT) && !IS_POSIXACL(dir)) | 2418 | if ((open_flag & O_CREAT) && !IS_POSIXACL(dir)) |
2419 | mode &= ~current_umask(); | 2419 | mode &= ~current_umask(); |
2420 | 2420 | ||
2421 | if (open_flag & O_EXCL) { | 2421 | if ((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT)) { |
2422 | open_flag &= ~O_TRUNC; | 2422 | open_flag &= ~O_TRUNC; |
2423 | *opened |= FILE_CREATED; | 2423 | *opened |= FILE_CREATED; |
2424 | } | 2424 | } |
@@ -2742,7 +2742,7 @@ retry_lookup: | |||
2742 | } | 2742 | } |
2743 | 2743 | ||
2744 | error = -EEXIST; | 2744 | error = -EEXIST; |
2745 | if (open_flag & O_EXCL) | 2745 | if ((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT)) |
2746 | goto exit_dput; | 2746 | goto exit_dput; |
2747 | 2747 | ||
2748 | error = follow_managed(path, nd->flags); | 2748 | error = follow_managed(path, nd->flags); |