Skip to content

Commit e1fc742

Browse files
juergbiAl Viro
authored andcommitted
fs: add RWF_APPEND
This is the per-I/O equivalent of O_APPEND to support atomic append operations on any open file. If a file is opened with O_APPEND, pwrite() ignores the offset and always appends data to the end of the file. RWF_APPEND enables atomic append and pwrite() with offset on a single file descriptor. Signed-off-by: Jürg Billeter <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent c981f25 commit e1fc742

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

include/linux/fs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3224,6 +3224,8 @@ static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags)
32243224
ki->ki_flags |= IOCB_DSYNC;
32253225
if (flags & RWF_SYNC)
32263226
ki->ki_flags |= (IOCB_DSYNC | IOCB_SYNC);
3227+
if (flags & RWF_APPEND)
3228+
ki->ki_flags |= IOCB_APPEND;
32273229
return 0;
32283230
}
32293231

include/uapi/linux/fs.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,11 @@ typedef int __bitwise __kernel_rwf_t;
377377
/* per-IO, return -EAGAIN if operation would block */
378378
#define RWF_NOWAIT ((__force __kernel_rwf_t)0x00000008)
379379

380+
/* per-IO O_APPEND */
381+
#define RWF_APPEND ((__force __kernel_rwf_t)0x00000010)
382+
380383
/* mask of flags supported by the kernel */
381-
#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT)
384+
#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
385+
RWF_APPEND)
382386

383387
#endif /* _UAPI_LINUX_FS_H */

0 commit comments

Comments
 (0)