posix_fadvise(2) System Calls Manual posix_fadvise(2) posix_fadvise - LIBRARY Standard C library (libc, -lc) #include int posix_fadvise(int fd, off_t offset, off_t len, int advice); glibc (. feature_test_macros(7)): posix_fadvise(): _POSIX_C_SOURCE >= 200112L posix_fadvise() , . advice ( ) , offset, len ( , len 0) , fd. advice ; . advice: POSIX_FADV_NORMAL , . , . POSIX_FADV_SEQUENTIAL ( ). POSIX_FADV_RANDOM . POSIX_FADV_NOREUSE . Before Linux 2.6.18, POSIX_FADV_NOREUSE had the same semantics as POSIX_FADV_WILLNEED. This was probably a bug; since Linux 2.6.18, this flag is a no-op. POSIX_FADV_WILLNEED . POSIX_FADV_WILLNEED . ( , , , ). POSIX_FADV_DONTNEED . POSIX_FADV_DONTNEED , . , , . , . . , . , , offset len . (dirty) , . . , fsync(2) fdatasync(2). 0. . EBADF fd . EINVAL advice. ESPIPE The specified file descriptor refers to a pipe or FIFO. (ESPIPE is the error specified by POSIX, but before Linux 2.6.16, Linux returned EINVAL in this case.) Linux POSIX_FADV_NORMAL ; POSIX_FADV_SEQUENTIAL , POSIX_FADV_RANDOM . , ( ). C C posix_fadvise(). fadvise64() ( -- fadvise64_64()); , len size_t, -- loff_t. , , 64- ( syscall(2)). posix_fadvise() fd offset. , posix_fadvise(). , Linux 2.6.14, ARM : long arm_fadvise64_64(int fd, int advice, loff_t offset, loff_t len); , , , , glibc posix_fadvise(), . POSIX.1-2008. POSIX.1-2001. Kernel support first appeared in Linux 2.5.60; the underlying system call is called fadvise64(). Library support has been provided since glibc 2.2, via the wrapper function posix_fadvise(). Linux 3.18 , , CONFIG_ADVISE_SYSCALLS. The type of the len argument was changed from size_t to off_t in POSIX.1-2001 TC1. /proc/sys/vm/drop_caches, proc(5). , : , mmap(2) mincore(2) . Before Linux 2.6.6, if len was specified as 0, then this was interpreted literally as "zero bytes", rather than as meaning "all bytes through to the end of the file". . fincore(1), mincore(2), readahead(2), sync_file_range(2), posix_fallocate(3), posix_madvise(3) Alexey, Azamat Hackimov , kogamatranslator49 , Kogan, Max Is , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . posix_fadvise(2)