LibC: Negate kernel errors before returning them in posix_fallocate()

Since posix_fallocate() doesn't set errno, it has to make sure to
manually "unwrap" any error from the kernel.
This commit is contained in:
Andreas Kling 2022-11-27 19:39:48 +01:00
parent f274f04e35
commit 361897192c
Notes: sideshowbarker 2024-07-17 10:10:18 +09:00

View file

@ -117,7 +117,7 @@ int posix_fadvise(int fd, off_t offset, off_t len, int advice)
int posix_fallocate(int fd, off_t offset, off_t len)
{
// posix_fallocate does not set errno.
return static_cast<int>(syscall(SC_posix_fallocate, fd, &offset, &len));
return -static_cast<int>(syscall(SC_posix_fallocate, fd, &offset, &len));
}
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/utimensat.html