BUF_LOCK(9)
π BUF_LOCK(9) π
okay so bestie, this is a Kernel Developer's Manual page β yes we're in the kernel now, we're not in userspace anymore, we're literally in the grown-up section of the manual, and honestly? iconic. β¨
πΈ NAME πΈ
BUF_LOCK β locks a buffer π«Ά
β¨ SYNOPSIS β¨
so first you gotta bring in the whole squad of headers, no skipping:
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/uio.h>
#include <sys/bio.h>
#include <sys/buf.h>
int
BUF_LOCK(struct buf *bp, int locktype);
π DESCRIPTION π
okay so the way that BUF_LOCK() works is: it locks the buffer you hand it. that's the whole vibe. π
and here's the part you actually need to know, bestie β if the lock is already held by somebody else, this call will block until it can actually acquire the lock. like it's just gonna stand there in the group chat waiting for its turn, no matter how long it takes. unless you set LK_NOWAIT, in which case it does not do that. periodt.
now, its arguments, because we love a breakdown:
bpβ the buffer you wanna lock. that's your main character right there. πlocktypeβ flags that control what kind of lock you're getting. for the details on those, go readlockmgr(9), that's the source of truth, iykyk. π§
π RETURN VALUES π
you get a 0 back when it succeeds β slay, we love a clean win. β¨
for what all the non-zero return values mean, you gotta go check lockmgr(9), because that's where the lore lives. π
π¦ SEE ALSO π¦
the whole little friend group, go read them too:
π AUTHORS π
this manual page was written by Chad David <davidc@acns.ab.ca>. thank you Chad, we appreciate you fr fr. π
and that's the page bestie, no cap β written on this Debian system, dated July 9, 2001, from the Kernel Developer's Manual, section 9. she's vintage, she's got history, and she ate. π βπ
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (C) 2001 Chad David <davidc@acns.ab.ca>. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms