VGET(9)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’œ VGET(9) β€” the Kernel Developer's Manual page you didn't know you needed

okay so bestie, real talk: this is vget from section 9 (that's the kernel-functions section, iykyk). It's short, it's sweet, and it's genuinely important if you're doing vnode shit. Let's get into it. πŸ¦‹


✨ NAME ✨

vget β€” get a vnode from the free list. that's it. that's the whole vibe. πŸŽ€


🌸 SYNOPSIS 🌸

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

int
vget(struct vnode *vp, int lockflag, struct thread *td);

literally just include those two headers and you're off to the races, bestie. 🫢


πŸ’… DESCRIPTION πŸ’…

So the actual main character move here: get a vnode from the free list and increment its reference count. That's the whole job. Two-for-one. Ate. πŸ”₯

Here's what the arguments are giving:

  • vp β€” the vnode you're pulling off the free list. this is the one, bestie.
  • lockflag β€” if this is non-zero, the vnode will also be locked. not zero = locked. that's the rule. πŸ”’

Now the lore πŸ’€ β€” when vnodes aren't in use, they get parked on a free list. The important detail: those vnodes still reference valid files, but they may be reused to refer to a new file at any time. so like... they're valid but also not yours yet. respect the ambiguity. πŸ™ˆ

And usually these free-list vnodes are also chilling in caches around the system β€” the name cache being the classic example.

So here's the scenario: you've got a vnode that's on the free list, and you want to use it again. Like β€” say the vnode turned up in the name cache because of a call to VOP_LOOKUP(9). In that case the new user (that's you πŸ’–) must call vget() to increment the reference count and remove it from the free list. Non-negotiable. Do it. periodt. πŸ‘‘


πŸ¦‹ SEE ALSO πŸ¦‹

the whole vnode friend group, honestly. go read them. 🧚


🌈 AUTHORS 🌈

This manual page was written by Doug Rabson. iconic of him, honestly. πŸ‘‘


πŸ’– cute little sign-off: this page ships from Debian, dated July 24, 1996, and it lives at VGET(9) in the Kernel Developer's Manual. yes, 1996. vintage. slay. πŸŽ€βœ¨
πŸ“¦ where this page comes from