Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <j@bitron.ch>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by

Jürg Billeter and committed by
Al Viro
e1fc742e c981f254

+7 -1
+2
include/linux/fs.h
··· 3224 3224 ki->ki_flags |= IOCB_DSYNC; 3225 3225 if (flags & RWF_SYNC) 3226 3226 ki->ki_flags |= (IOCB_DSYNC | IOCB_SYNC); 3227 + if (flags & RWF_APPEND) 3228 + ki->ki_flags |= IOCB_APPEND; 3227 3229 return 0; 3228 3230 } 3229 3231
+5 -1
include/uapi/linux/fs.h
··· 377 377 /* per-IO, return -EAGAIN if operation would block */ 378 378 #define RWF_NOWAIT ((__force __kernel_rwf_t)0x00000008) 379 379 380 + /* per-IO O_APPEND */ 381 + #define RWF_APPEND ((__force __kernel_rwf_t)0x00000010) 382 + 380 383 /* 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) 382 386 383 387 #endif /* _UAPI_LINUX_FS_H */