25 lines
781 B
C
25 lines
781 B
C
#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;
|
|
}
|