VOP_LINK(9)

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

okay so bestie, welcome to the VOP_LINK era β€” this is a kernel developer's manual page from the 9 section, and it's literally all about giving a file a whole new name, no cap πŸŽ€

✨ SYNOPSIS ✨

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

int
VOP_LINK(struct vnode *dvp, struct vnode *vp,
    struct componentname *cnp);

πŸ’… DESCRIPTION πŸ’…

so what this does is it links a brand-new name inside the directory you specify to a file that already exists. it's giving "same file, new identity" energy fr fr πŸ‘‘

its arguments are:

  • dvp β€” the vnode of the directory (the folder it's all happening in)
  • vp β€” the vnode of the file that's getting linked
  • cnp β€” pathname info about the file
bestie listen β€” the pathname info should not be released on exit, because the caller is the one doing that. and the directory and file vnodes should not be released on exit either. don't do it. not your job πŸ™ˆ

πŸ”’ LOCKS πŸ”’

VOP_LINK() expects the directory and file vnodes to be locked on entry, and it will leave them locked on return. so you hand them over locked, you get them back locked β€” that's the deal, periodt πŸ”

🫢 RETURN VALUES 🫢

zero gets returned if the file was linked successfully (slay ✨), otherwise an error comes back at you 😭

πŸ’€ ERRORS πŸ’€

  • [EMLINK] β€” the file has too many links (it's maxed out ngl)
  • [EPERM] β€” the file is immutable (can't touch this 🚫)
  • [EXDEV] β€” a hard link is not possible between different file systems (they're in different vibes entirely, no bridge)

πŸ‘€ SEE ALSO πŸ‘€

vn_lock(9), vnode(9)

🧚 AUTHORS 🧚

this manual page was originally written by Doug Rabson β€” iconic behavior honestly πŸ†


okurrr that's the whole page bestie, you ate that πŸ’… and for the record this was the VOP_LINK kernel developer's manual page, debian flavored, dated July 24, 1996 β€” vintage but still serving looks 🌈

πŸ“¦ where this page comes from