VOP_CREATE(9)

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

πŸ’… VOP_CREATE(9) β€” the kernel dev manual, bestie edition πŸŽ€

okay so the manual name is VOP_CREATE(9) and honestly? this whole page is about the four lil entry points that bring new things into existence. creation core. main character energy fr fr ✨


🌸 NAME 🌸

VOP_CREATE, VOP_MKNOD, VOP_MKDIR, VOP_SYMLINK β€” the squad that creates a file, socket, fifo, device, directory or symlink πŸ’–


✨ SYNOPSIS ✨

like, here's the exact vibe, no edits, copy-pasted straight from the source because we do NOT mess with code:

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

int
VOP_CREATE(struct vnode *dvp, struct vnode **vpp,
    struct componentname *cnp, struct vattr *vap);

int
VOP_MKNOD(struct vnode *dvp, struct vnode **vpp,
    struct componentname *cnp, struct vattr *vap);

int
VOP_MKDIR(struct vnode *dvp, struct vnode **vpp,
    struct componentname *cnp, struct vattr *vap);

int
VOP_SYMLINK(struct vnode *dvp, struct vnode **vpp,
    struct componentname *cnp, struct vattr *vap, const char *target);

note how VOP_SYMLINK gets an extra lil const char *target at the end β€” she's built different πŸ‘‘ (because symlinks need a place to point at, duh πŸ’β€β™€οΈ)


πŸ¦‹ DESCRIPTION πŸ¦‹

so these entry points create a brand-new file, socket, fifo, device, directory or symlink inside a given directory. that's it. that's the whole job. creating things. iconic behavior 🌈

the arguments, one by one, because we're being thorough and also because you deserve to know:

  • dvp β€” the locked vnode of the directory. she's locked and she's staying that way, iykyk πŸ”’
  • vpp β€” the address of a variable where the resulting locked vnode should be stored. think of it as the lil spot where the new baby vnode gets dropped off 🫢
  • cnp β€” the pathname component created
  • vap β€” the attributes that the new object should be created with
  • target β€” the pathname of the target of the symlink 🎯

and like, timing matters here: these entry points get called after VOP_LOOKUP(9) when an object is being created. lookup first, then create. the order is the order, bestie πŸ’…


πŸ”’ LOCKS πŸ”’

okay this part is important, pay attention 😀

the directory, dvp, will be locked on entry and must remain locked on return. no unlocking behind our backs, that's not the vibe.

and if the call is successful? the new object will be returned locked. so it comes into the world already locked. locked at birth. honestly relatable πŸ’€


⭐ RETURN VALUES ⭐

if it works: the vnode for the new object is placed in *vpp and zero is returned. zero = success = slay πŸŽ‰

otherwise? an appropriate error is returned. that's it, that's the deal πŸ™ˆ


πŸ’€ ERRORS πŸ’€

  • [ENOSPC] β€” the file system is full. no room. she's at capacity. 😭
  • [EDQUOT] β€” the user's file system space or inode quota would be exceeded. you've hit your limit bestie, the quota said no more 🚫

🌸 SEE ALSO 🌸

(the besties. the companions. read them too fr fr 🫢)


πŸŽ€ HISTORY πŸŽ€

the function VOP_CREATE appeared in 4.3BSD. old money. vintage. still serving πŸ’œ


πŸ‘‘ AUTHORS πŸ‘‘

this manual page was written by Doug Rabson. thank you for your service king 🫑✨


πŸ’– and that's the whole page, no cap β€” every flag, every argument, every error, every name. go create something iconic. periodt. πŸ’…

this gem was brought to you by the Debian crew, dated November 2, 2018 β€” yeah she's a little vintage but she still ate πŸ“πŸ§š

πŸ“¦ where this page comes from