VOP_ADVISE(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’… VOP_ADVISE β€” apply advice about use of file data

okay so bestie, welcome to VOP_ADVISE(9) from the Kernel Developer's Manual β€” yes the kernel one, this is real main-character vnode energy and we're gonna get through it together 🫢


✨ SYNOPSIS ✨

#include <sys/param.h>
#include <sys/vnode.h>

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

literally just one function, iconic, no notes πŸ”₯


🌸 DESCRIPTION 🌸

okay so this call applies advice for a range of a file's data β€” like you're dropping a little hint to the filesystem, no cap. fun fact: it's the thing that implements the posix_fadvise(2) system call. slay πŸŽ€

here's its arguments, one by one:

  • vp β€” the vnode of the file. the whole main character of this function ngl πŸ’œ
  • start β€” the start of the range of file data.
  • end β€” the end of the range of file data. and listen, a value of OFF_MAX means the advice applies all the way to the end of the file. iykyk 🌈
  • 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's not already resident. like, "bestie i'm gonna need this, get it ready" ⭐
    • POSIX_FADV_DONTNEED β€” decrease the in-memory priority of clean file data, or just discard clean file data. yeah it said clean, read it again 🧚

also! if the start and end offsets are both zero, then the operation should be applied to the entire file πŸ’–

🚨 okay this part matters: this call is advisory only. it may do the requested operation on a subset of the requested range β€” including not doing it at all β€” and still return success. so don't come for it, it warned you 😭 it's giving "i'll try my best" energy.

πŸ”’ LOCKS πŸ”’

the file should be unlocked on entry. unlock it before you call, bestie, fr fr πŸ’…


βœ… RETURN VALUES βœ…

0 is returned if the call is successful πŸŽ‰ otherwise an appropriate error code comes back at you. that's the whole vibe check.


πŸ’€ ERRORS πŸ’€

  • [EINVAL] β€” an invalid value was given for advice. yeah. you gave it nonsense. it's not mad, it's just disappointed πŸ™ˆ

πŸ‘‘ SEE ALSO πŸ‘‘

  • vnode(9) β€” go read it, it's the whole family πŸ¦‹

and that's the page, bestie!! go forth and advise responsibly ✨

β€” written under the Debian banner, dated September 26, 2015, from the Kernel Developer's Manual β€” periodt πŸ’œ

πŸ“¦ where this page comes from