posix_fadvise Subroutine
Purpose
Provides advisory information to the system regarding future behavior of the application with respect to a given file.
Syntax
#include <fcntl.h>
int posix_fadvise (int fd, off_t offset, size_t len, int advice);
Description
This
function advises the system on the expected future behavior of the
application with regards to a given file. The system can take this
advice into account when performing operations on file data specified
by this function. The advice is given over the range covered by the offset parameter
and continuing for the number of bytes specified by the len parameter.
If the value of the len parameter is 0
, then
all data following the offset parameter is covered.
The advice parameter
must be one of the following:
- POSIX_FADV_NORMAL
- POSIX_FADV_SEQUENTIAL
- POSIX_FADV_RANDOM
- POSIX_FADV_WILLNEED
- POSIX_FADV_DONTNEED
- POSIX_FADV_NOREUSE
Parameters
Item | Description |
---|---|
fd | File descriptor of the file to be advised |
offset | Represents the beginning of the address range |
len | Determines the length of the address range |
advice | Defines the advice to be given |
Return Values
Upon
successful completion, the posix_fadvise subroutine returns 0
.
Otherwise, one of the following error codes will be returned.
Error Codes
Item | Description |
---|---|
EBADF | The fd parameter is not a valid file descriptor |
EINVAL | The value of the advice parameter is invalid |
ESPIPE | The fd parameter is associated with a pipe of FIFO |