VOP_CREATE(9)

πŸ’… VOP_CREATE β€” the Kernel Developer's Manual, bestie edition (section 9) πŸŽ€

okay so. welcome to the group chat where we make files. this is VOP_CREATE(9), and honestly? it's giving main character energy in the VFS world. let's go ✨


🌸 NAME 🌸

VOP_CREATE, VOP_MKNOD, VOP_MKDIR, VOP_SYMLINK β€” bestie, these are the entry points that create a file, socket, fifo, device, directory or symlink. the whole "new thing appears in your filesystem" vibe, no cap. πŸ¦‹


✨ SYNOPSIS ✨

#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, char *target);

πŸ‘‘ DESCRIPTION πŸ‘‘

so these entry points create a brand new file, socket, fifo, device, directory or symlink inside a given directory. literally birthing an inode. iconic. 🌈

the arguments, one by one, because we don't skip:

  • dvp β€” the locked vnode of the directory. locked. do not forget. πŸ”’
  • vpp β€” the address of a variable where the resulting locked vnode should be stored. that's where your new baby goes. 🍼
  • cnp β€” the pathname component being created.
  • vap β€” the attributes that the new object should be created with. its whole personality, basically. πŸ’…
  • target β€” the pathname of the target of the symlink. (symlink-only behaviour, iykyk πŸ”—)

and fr fr: these entry points get called after VOP_LOOKUP(9) when an object is being created. like, lookup goes first, then the creation happens. order matters, bestie. 🫢


πŸ”’ LOCKS πŸ”’

the directory, dvp, will be locked on entry and must remain locked on return. not optional. do not unlock it, do not pass go, do not collect $200. πŸ’€

and if the call is successful? the new object will be returned locked. so it arrives locked, and it stays locked, and it's yours to deal with. πŸ’–


πŸŽ€ RETURN VALUES πŸŽ€

if it slayed: the vnode for the new object is placed in *vpp and zero is returned. βœ…

otherwise: an appropriate error is returned. 😭


πŸ’€ ERRORS πŸ’€

  • [ENOSPC] β€” The file system is full. no room. the disk said no. 🚫
  • [EDQUOT] β€” The user's file system space or inode quota would be exceeded. bestie you hit your limit. 🧚

πŸ¦‹ SEE ALSO πŸ¦‹

go read those, they're relevant, I promise. πŸ“š


⭐ HISTORY ⭐

The function VOP_CREATE appeared in 4.3BSD. vintage. a classic. we stan a legacy API. πŸ•°οΈ


πŸ’œ AUTHORS πŸ’œ

This manual page was written by Doug Rabson. thank you Doug, king behavior. πŸ‘‘


and that's the whole page bestie!! it's from the Debian manual, dated July 24, 1996 β€” yes, 1996, ancient, retro, lowkey iconic β€” and it's the VOP_CREATE(9) kernel developer's page. mwah. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from