VOP_RENAME(9)

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

πŸ’– VOP_RENAME(9) β€” rename a file πŸ’–

okay so welcome to the Kernel Developer's Manual corner of the group chat, bestie β€” this is the VOP_RENAME(9) page and we're learning how a file gets renamed. πŸ’…βœ¨


🌸 NAME 🌸

VOP_RENAME β€” rename a file πŸŽ€


✨ SYNOPSIS ✨

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

int
VOP_RENAME(struct vnode *fdvp, struct vnode *fvp,
    struct componentname *fcnp, struct vnode *tdvp, struct vnode *tvp,
    struct componentname *tcnp);

πŸ¦‹ DESCRIPTION πŸ¦‹

so this literally renames a file, and it can possibly change its parent directory too. no cap. if the destination object exists, it will be removed first β€” the old one gets yeeted before the new name lands. πŸ’€βœ¨

the cast of characters (aka its arguments) is:

  • fdvp β€” the vnode of the old parent directory. the "before" parent, if you will 🫢
  • fvp β€” the vnode of the file to be renamed. main character energy fr fr πŸ‘‘
  • fcnp β€” pathname information about the file's current name. it knows what the file is called right now 🌸
  • tdvp β€” the vnode of the new parent directory. the "after" parent, slay πŸ’…
  • tvp β€” the vnode of the target file (if it exists). lowkey conditional bestie πŸ™ˆ
  • tcnp β€” pathname information about the file's new name. the glow-up name info ✨

πŸ”’ LOCKS πŸ”’

the source directory and file are unlocked, but they're expected to have their ref count bumped on entry. the VOP routine is expected to vrele(9) both prior to returning. 🧚

the destination directory and file are locked as well as having their ref count bumped. the VOP routine is expected to vput(9) both prior to returning. πŸ’–

lock lore is serious business, bestie β€” don't skip the vrele(9) / vput(9) steps 😭

πŸ’€ ERRORS πŸ’€

  • [EPERM] β€” the file is immutable. hands off, bestie πŸ™ˆ
  • [EXDEV] β€” it is not possible to rename a file between different file systems. cross-filesystem rename said nope πŸ’…
  • [EINVAL] β€” an attempt was made to rename . or .., or to perform an operation which would break the directory tree structure. not the directory tree, please 😭
  • [ENOTDIR] β€” an attempt was made to rename a directory to a file or vice versa. mismatched vibes fr fr πŸ’€
  • [ENOTEMPTY] β€” an attempt was made to remove a directory which is not empty. it's giving "full house" 🏠✨

πŸ‘€ SEE ALSO πŸ‘€

vnode(9) β€” go peek, bestie 🫢


πŸŽ€ AUTHORS πŸŽ€

this manual page was written by Doug Rabson. iconic. πŸ‘‘


okay that's the whole page: footer energy says Debian, dated July 24, 1996, and it's the VOP_RENAME(9) manual page. bye bestie πŸ’‹πŸ«ΆπŸŒΈ

πŸ“¦ where this page comes from