VOP_LINK(9)

okay so this is a page from the Kernel Developer's Manual (section 9, the kernel-functions girly) and it's literally all about VOP_LINK. slay. let's get into it πŸ’…


🌸 SYNOPSIS 🌸

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

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

πŸ¦‹ DESCRIPTION πŸ¦‹

The way that this one works is: it links a new name in the specified directory to an existing file. that's the whole vibe. one file, two names, no cap 🫢

Its arguments are:

  • dvp β€” the vnode of the directory. the place where the new name is gonna live ✨
  • vp β€” the vnode of the file to be linked. the file getting a glow-up with a second name πŸ’–
  • cnp β€” pathname information about the file.

okay important note bestie, do NOT release the pathname info on exit, because the caller is the one who handles that. and the directory and file vnodes? also not released on exit. don't do it. not your job. leave them alone πŸ™ˆ


πŸ”’ LOCKS πŸ”’

VOP_LINK() expects the directory and file vnodes to be locked on entry, and it will leave the vnodes locked on return. so you lock 'em, it keeps 'em locked, everyone stays locked. consistency is iconic πŸ‘‘


πŸŽ€ RETURN VALUES πŸŽ€

Zero is returned if the file was linked successfully. anything else means an error came through, and that's not the energy we wanted 😭


πŸ’€ ERRORS πŸ’€

  • [EMLINK] β€” the file has too many links. it's overstimulated, it needs a break.
  • [EPERM] β€” the file is immutable. it said no changes, and it meant it.
  • [EXDEV] β€” a hard link is not possible between different file systems. different worlds, bestie, it's just not gonna work πŸ’”

πŸ‘€ SEE ALSO πŸ‘€

vn_lock(9), vnode(9)

iykyk β€” go read those next, they're the supporting cast 🧚


πŸ’œ AUTHORS πŸ’œ

This manual page was originally written by Doug Rabson. legend behaviour, fr fr.


and that's the whole page bestie. no notes, just links. periodt πŸ’…

okay and before you go β€” this one came from Debian and it's dated July 24, 1996, which is literally so vintage of it, an absolute classic from the archives πŸŽ€βœ¨

πŸ“¦ where this page comes from