提交 f8310c59 编写于 作者: A Al Viro

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: NAl Viro <viro@zeniv.linux.org.uk>
上级 bf884891
......@@ -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 @@ 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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册