posix_fadvise(), posix_fadvise64()

Provide advisory information about the expected use of a file

Synopsis:

#include <fcntl.h>

int posix_fadvise( int fd,
                   off_t offset,
                   size_t len,
                   int advice );

int posix_fadvise64( int fd,
                     off64_t offset,
                     size_t len,
                     int advice );

Arguments:

fd
An open file descriptor.
offset
The offset of the data about which you want to provide advice.
len
The length of the data.
advice
The advice you want to give; one of:

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The posix_fadvise() and posix_fadvise64() functions advise the filesystem how the application expects to use the data in the file associated with the open file descriptor, fd, starting at offset and continuing for len bytes. The posix_fadvise64() is a large-file support version of posix_fadvise().

The specified range need not currently exist in the file. If len is zero, all data following offset is specified. The filesystem may use this information to optimize handling of the specified data. The posix_fadvise() function has no effect on the semantics of other operations on the specified data, although it may affect the performance of other operations.

Returns:

0
Success.
EBADF
The fd argument isn't a valid file descriptor.
EINVAL
The value of advice is invalid, or len is less than zero.
ESPIPE
The fd argument is associated with a pipe or FIFO.

Classification:

posix_fadvise() is POSIX 1003.1 ADV; posix_fadvise64() is Large-file support

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

posix_madvise()