BUF_LOCK(9)

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

πŸ’… BUF_LOCK β€” locks a buffer πŸ‘‘

okay bestie, welcome to the BUF_LOCK(9) page from the Kernel Developer's Manual ✨ β€” yes this is the kernel-dev girly side of the buf(9) family, and it's honestly giving "small function, big responsibility" energy πŸŽ€


🌸 SYNOPSIS 🌸

First you gotta bring the whole squad of headers along, no cap:

#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);

Like, all five includes. They're a package deal πŸ’œ


✨ DESCRIPTION ✨

So BUF_LOCK() locks the given buffer. That's the whole vibe. πŸ¦‹

But here's the tea: if the lock is already held, this call will block until it can acquire the lock β€” unless LK_NOWAIT is set. So if you're the impatient type, set LK_NOWAIT. If you're chill, enjoy the wait 😭

Its arguments are:

  • bp β€” literally just the buffer you wanna lock. That's it. That's the whole parameter. πŸ’…
  • locktype β€” the flags that control the type of lock. For the deets, go see lockmgr(9) β€” she has the full lore πŸ‘‘

🫢 RETURN VALUES 🫢

On success you get a 0. Iconic. Perfect. No notes. ✨

For what all the non-zero return values mean, hit up lockmgr(9) β€” that's where the drama lives 🌈


πŸŽ€ SEE ALSO πŸŽ€

the whole friend group, fr fr πŸ‘―β€β™€οΈ


πŸ’– AUTHORS πŸ’–

This manual page was written by Chad David <davidc@acns.ab.ca>. Give her her flowers πŸŒΈπŸ‘‘


and that's the page, bestie!! this lil number is from Debian, dated July 9, 2001 β€” vintage but still slaying, lowkey a nostalgic era πŸ’€πŸ’– mwah, go lock some buffers responsibly πŸ§šβ€β™€οΈβœ¨

πŸ“¦ where this page comes from