A NOTE has been added to this issue. ====================================================================== https://austingroupbugs.net/view.php?id=1832 ====================================================================== Reported By: alanc Assigned To: ====================================================================== Project: Issue 8 drafts Issue ID: 1832 Category: System Interfaces Type: Enhancement Request Severity: Comment Priority: normal Status: New Name: Alan Coopersmith Organization: User Reference: Section: System Interfaces Page Number: (page or range of pages) Line Number: (Line or range of lines) Final Accepted Text: ====================================================================== Date Submitted: 2024-05-24 21:48 UTC Last Modified: 2024-05-27 20:04 UTC ====================================================================== Summary: Add preadv() and pwritev() ======================================================================
---------------------------------------------------------------------- (0006806) steffen (reporter) - 2024-05-27 20:04 https://austingroupbugs.net/view.php?id=1832#c6806 ---------------------------------------------------------------------- This remark surely belongs to Rich Felker of musl, also because he wrote the Linux kernel patch, i think (to remember), but i want to add a note .. or, let me paste parts of a musl commit message instead: POSIX requires pwrite to honor the explicit file offset where the write should take place even if the file was opened as O_APPEND. however, linux historically defined the pwrite syscall family as honoring O_APPEND. this cannot be changed on the kernel side due to stability policy, but the addition of the pwritev2 syscall with a flags argument opened the door to fixing it this patch changes the pwrite function to first attempt using the pwritev2 syscall with RWF_NOAPPEND, falling back to using the old pwrite syscall only after checking that O_APPEND is not set for the open file. if O_APPEND is set, the operation fails with EOPNOTSUPP, reflecting that the kernel does not support the correct behavior. this is an extended error case needed to avoid the wrong behavior that happened before (writing the data at the wrong location), and is aligned with the spirit of the POSIX requirement that "An attempt to perform a pwrite() on a file that is incapable of seeking shall result in an error." since the pwritev2 syscall interprets the offset of -1 as a request to write at the current file offset, it is mapped to a different negative value that will produce the expected error. pwritev, though not governed by POSIX at this time, is adjusted to match pwrite in honoring the offset. Issue History Date Modified Username Field Change ====================================================================== 2024-05-24 21:48 alanc New Issue 2024-05-24 21:48 alanc Name => Alan Coopersmith 2024-05-24 21:48 alanc Section => System Interfaces 2024-05-24 21:48 alanc Page Number => (page or range of pages) 2024-05-24 21:48 alanc Line Number => (Line or range of lines) 2024-05-24 21:56 Guy Harris Note Added: 0006800 2024-05-25 23:10 alanc Note Added: 0006803 2024-05-26 00:03 philip-guentherNote Added: 0006804 2024-05-26 02:43 Guy Harris Note Added: 0006805 2024-05-27 20:04 steffen Note Added: 0006806 ======================================================================
