VOP_LOCK(9)
π NAME π
VOP_LOCK, VOP_UNLOCK, VOP_ISLOCKED, vn_lock β serialize access to a vnode. periodt.
okay so real talk bestie, this is the VOP_LOCK(9) page from the Kernel Developer's Manual, and it's here to help you understand locking a vnode without losing your entire mind π«Ά.
β¨ SYNOPSIS β¨
the include lineup is giving kernel-core, no cap:
#include <sys/param.h>
#include <sys/lock.h>
#include <sys/vnode.h>
int
VOP_LOCK(struct vnode *vp, int flags);
int
VOP_UNLOCK(struct vnode *vp);
int
VOP_ISLOCKED(struct vnode *vp);
int
vn_lock(struct vnode *vp, int flags);
π¦ DESCRIPTION π¦
These calls are used to serialize access to the file system, such as to prevent two writes to the same file from happening at the same time. it's giving "please do not let the writes fight" energy π
The arguments are:
vpβ the vnode being locked or unlocked.flagsβ one of the lock request types:LK_SHAREDβ Shared lock.LK_EXCLUSIVEβ Exclusive lock.LK_UPGRADEβ Shared-to-exclusive upgrade.LK_DOWNGRADEβ Exclusive-to-shared downgrade.LK_RELEASEβ Release any type of lock.LK_DRAINβ Wait for all lock activity to end.
The lock type may be or'ed with these lock flags:
LK_NOWAITβ Do not sleep to wait for lock.LK_SLEEPFAILβ Sleep, then return failure.LK_CANRECURSEβ Allow recursive exclusive lock.LK_NOWITNESSβ Instructwitness(4)to ignore this instance.
The lock type may be or'ed with these control flags:
LK_INTERLOCKβ Specify when the caller already has a simple lock (VOP_LOCK()will unlock the simple lock after getting the lock).LK_RETRYβ Retry until locked.
Kernel code should use vn_lock() to lock a vnode rather than calling VOP_LOCK() directly. vn_lock() also does not want a thread specified as argument but it assumes curthread to be used. fr fr, that's the rule.
πΈ RETURN VALUES πΈ
Zero is returned on success, otherwise an error is returned. so: success = 0, anything else = error, bestie.
π SEE ALSO π
vnode(9) β go read it, iykyk.
π AUTHORS π
This manual page was written by Doug Rabson. shoutout Doug, iconic behavior.
source/version + date check: Debian Β· August 23, 2022 Β· VOP_LOCK(9) β bye bestie, go lock those vnodes responsibly πβ¨
π¦ 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