feat(fcntl): fcntl/open flag handling

This commit is contained in:
2026-09-05 16:46:34 -04:00
parent 6eaacd4448
commit c9e9676d38
7 changed files with 857 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <fcntl.h>
#include "../internal/syscall.h"
/*
* posix_fadvise over SYS_fadvise64 (221). POSIX return convention, unlike
* the rest of the family: an error NUMBER directly — 0 on success, else
* the positive errno value (EBADF, ESPIPE, EINVAL, ...) — and errno is
* left untouched. The raw syscall result is therefore mapped without the
* syscall_ret() translation (which would write errno): a negative return
* is negated, 0 stays 0. On x86_64 the syscall takes the offset as one
* 64-bit value (fd, offset, len, advice) — no lo/hi split.
*/
int
posix_fadvise(int fd, off_t offset, off_t len, int advice)
{
long r = __syscall4(SYS_fadvise64, fd, offset, len, advice);
return r < 0 ? (int)-r : 0;
}