History

vfs: add RWF_NOAPPEND flag for pwritev2

The pwrite function, originally defined by POSIX (thus the "p"), is defined to ignore O_APPEND and write at the offset passed as its argument. However, historically Linux honored O_APPEND if set and ignored the offset. This cannot be changed due to stability policy, but is documented in the man page as a bug. Now that there's a pwritev2 syscall providing a superset of the pwrite functionality that has a flags argument, the conforming behavior can be offered to userspace via a new flag. Since pwritev2 checks flag validity (in kiocb_set_rw_flags) and reports unknown ones with EOPNOTSUPP, callers will not get wrong behavior on old kernels that don't support the new flag; the error is reported and the caller can decide how to handle it.

Rich Felker committed 6 years ago

Commit 73fa7541 parent 9e3f1c52 files · +12 −1Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/fs.h+4−1
@@ -301,9 +301,12 @@ typedef int __bitwise __kernel_rwf_t; · 300 unmodified lines
301301 /* per-IO O_APPEND */
302302 #define RWF_APPEND ((__force __kernel_rwf_t)0x00000010)
303303
304+/* per-IO negation of O_APPEND */
305+#define RWF_NOAPPEND ((__force __kernel_rwf_t)0x00000020)
306+
304307 /* mask of flags supported by the kernel */
305308 #define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
306− RWF_APPEND)
309+ RWF_APPEND | RWF_NOAPPEND)
307310
308311 /* Pagemap ioctl */
309312 #define PAGEMAP_SCAN _IOWR('f', 16, struct pm_scan_arg)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t