VOP_RENAME(9)
π 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 thevrele(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
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 1996 Doug Rabson
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms