Skip to content

Commit ba57ea6

Browse files
author
Al Viro
committed
allow O_TMPFILE to work with O_WRONLY
Signed-off-by: Al Viro <[email protected]>
1 parent c0d15cc commit ba57ea6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

fs/open.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,8 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
844844
if ((flags & O_TMPFILE_MASK) != O_TMPFILE)
845845
return -EINVAL;
846846
acc_mode = MAY_OPEN | ACC_MODE(flags);
847+
if (!(acc_mode & MAY_WRITE))
848+
return -EINVAL;
847849
} else if (flags & O_PATH) {
848850
/*
849851
* If we have O_PATH in the open flag. Then we

include/uapi/asm-generic/fcntl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@
8989
#endif
9090

9191
/* a horrid kludge trying to make sure that this will fail on old kernels */
92-
#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY | O_RDWR)
93-
#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT | O_ACCMODE)
92+
#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
93+
#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT)
9494

9595
#ifndef O_NDELAY
9696
#define O_NDELAY O_NONBLOCK

0 commit comments

Comments
 (0)