Go to file
Rich Felker 5370070fde fix pwrite/pwritev handling of O_APPEND files
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, and linux commit
73fa7547c70b32cc69685f79be31135797734eb6 adds the RWF_NOAPPEND flag
that lets us request a write honoring the file offset argument.

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.
2024-03-14 10:04:28 -04:00
arch loongarch64: add new syscall numbers 2024-02-29 17:33:45 -05:00
compat/time32 remove LFS64 symbol aliases; replace with dynamic linker remapping 2022-10-19 14:01:31 -04:00
crt remove unnecessary and problematic _Noreturn from crt/ldso startup 2019-06-25 19:05:40 -04:00
dist add another example option to dist/config.mak 2012-04-24 16:49:11 -04:00
include uio.h: add RWF_NOAPPEND flag for pwritev2 2024-03-13 10:39:37 -04:00
ldso ldso: fix TLSDESC addend processing on archs with backwards descriptors 2023-11-06 21:50:37 -05:00
src fix pwrite/pwritev handling of O_APPEND files 2024-03-14 10:04:28 -04:00
tools install.sh: avoid creating symlinks with restricted permissions 2024-02-03 19:57:30 -05:00
.gitignore remove obsolete gitignore rules 2016-07-06 00:21:25 -04:00
.mailmap update contributor name 2019-12-07 12:21:35 -05:00
configure configure: enable riscv32 port 2024-02-29 16:59:06 -05:00
COPYRIGHT add optimized aarch64 memcpy and memset 2020-06-26 17:49:51 -04:00
dynamic.list fix regression in access to optopt object 2018-11-19 13:20:41 -05:00
INSTALL update INSTALL file archs list with riscv32, loongarch64 additions 2024-02-29 19:23:03 -05:00
Makefile make mallocng the default malloc implementation 2020-06-30 15:38:27 -04:00
README update version reference in the README file 2014-06-25 14:16:53 -04:00
VERSION release 1.2.5 2024-02-29 21:07:33 -05:00
WHATSNEW release 1.2.5 2024-02-29 21:07:33 -05:00

    musl libc

musl, pronounced like the word "mussel", is an MIT-licensed
implementation of the standard C library targetting the Linux syscall
API, suitable for use in a wide range of deployment environments. musl
offers efficient static and dynamic linking support, lightweight code
and low runtime overhead, strong fail-safe guarantees under correct
usage, and correctness in the sense of standards conformance and
safety. musl is built on the principle that these goals are best
achieved through simple code that is easy to understand and maintain.

The 1.1 release series for musl features coverage for all interfaces
defined in ISO C99 and POSIX 2008 base, along with a number of
non-standardized interfaces for compatibility with Linux, BSD, and
glibc functionality.

For basic installation instructions, see the included INSTALL file.
Information on full musl-targeted compiler toolchains, system
bootstrapping, and Linux distributions built on musl can be found on
the project website:

    http://www.musl-libc.org/