VOP_ADVISE(9)

VOP_ADVISE9

Apply advice about use of file data

Usage

#include <sys/param.h>

#include <sys/vnode.h>

int

VOP_ADVISE(struct vnode *vp, off_t start, off_t end, int advice);

Overview

This call applies advice for a range of a file's data. It is used to implement the posix_fadvise(2) system call.

Its arguments are:

vp

The vnode of the file.

start

The start of the range of file data.

end

The end of the range of file data. A value of OFF_MAX indicates that the advice is to be applied up to the end of the file.

advice

The type of operation to apply to the file data. Possible values are:

POSIX_FADV_WILLNEED

Initiate an asynchronous read of the file data if it is not already resident.

POSIX_FADV_DONTNEED

Decrease the in-memory priority of clean file data or discard clean file data.

If the start and end offsets are both zero, then the operation should be applied to the entire file. Note that this call is advisory only and may perform the requested operation on a subset of the requested range (including not performing it at all) and still return success.

Locks

The file should be unlocked on entry.

Return values

Zero is returned if the call is successful, otherwise an appropriate error code is returned.

Errors

[EINVAL]

An invalid value was given for advice.

Releases

30 releases since FreeBSD 10.0-RELEASE; the text changed 17 times.

  1. 10.0
  2. 10.1
  3. 10.2
  4. 10.3
  5. 10.4
  6. 11.0
  7. 11.1
  8. 11.2
  9. 11.3
  10. 11.4
  11. 12.0
  12. 12.1
  13. 12.2
  14. 12.3
  15. 12.4
  16. 13.0–13.2
  17. 13.3–14.2
  18. 14.3–16.0

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.