BUF_ISLOCKED(9)

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

✨ 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 by curthread. that's you! you got it, you own it, slay 🫢
  • LK_EXCLOTHER β€” an exclusive lock is held by someone other than curthread. 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