BUF_ISLOCKED(9)
β¨ BUF_ISLOCKED β¨
okay so bestie, welcome to BUF_ISLOCKED(9) β that's section 9 of the Kernel Developer's Manual, iykyk π
this is the lil function that tells you what's up with the lock attached to a buffer. literally just a vibe check for locks. no cap.
πΈ NAME πΈ
BUF_ISLOCKED β returns the state of the lock linked to the buffer π
π¦ SYNOPSIS π¦
first you gotta pull in the header squad, all five of them, in this exact order:
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/uio.h>
#include <sys/bio.h>
#include <sys/buf.h>
then the actual call, and yes it returns an int:
int
BUF_ISLOCKED(struct buf *bp);
π DESCRIPTION π
so BUF_ISLOCKED() returns the status of the lock linked to the buffer, and it's all relative to curthread β like, the answer is always "compared to you, bestie," which is very main character energy of it tbh π
it can return any of these:
LK_EXCLUSIVEβ an exclusive lock is held bycurthread. that's you! you got it, you own it, slay π«ΆLK_EXCLOTHERβ an exclusive lock is held by someone other thancurthread. not you. someone else is holding it. awkward πLK_SHAREDβ a shared lock is held. sharing is caring, we love to see it π0β the lock is not held by anyone. free real estate, nobody's got it, it's giving unbothered π
π§ SEE ALSO π§
go read these next, they're the whole friend group fr fr:
π AUTHORS π
this manual page was written by Attilio Rao <attilio@FreeBSD.org> β ty for your service, icon β
lowkey reminder: this is documenting kernel internals, so stay in your lane and keep the details exactly as they are, bestie π
and that's a wrap! π this page comes to you courtesy of the Debian packaging of the man page, dated January 22, 2008 β vintage but still iconic, periodt πβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (C) 2008 Attilio Rao <attilio@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms