sys_flock(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– sys_flock(9) πŸ’–

okay so bestie, quick vibe check: this is one of those kernel API manual pages β€” it's sys_flock, which is literally the kernel-side implementation of the flock() system call. yes, that flock. the file-locking one. we love a syscall with main character energy πŸ‘


✨ SYNOPSIS ✨

long sys_flock (unsigned int fd , unsigned int cmd );

that's the whole signature, that's the assignment. two unsigned ints in, one long out. slay πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • fd β€” the file descriptor you wanna lock. the thing being locked. your target, your muse, your file πŸ’–
  • cmd β€” the type of lock to apply. which flavour of locking we're doing today. keep reading, there's a whole menu πŸ“

πŸ¦‹ DESCRIPTION πŸ¦‹

so what it does: it applies a FL_FLOCK style lock to an open file descriptor. that's the whole bit. that's the job ✨

and the cmd you pass can be one of these little icons:

  • LOCK_SH β€” a shared lock 🌸 multiple friends can hold it at the same time, everyone's chilling
  • LOCK_EX β€” an exclusive lock πŸ”₯ one holder only, everyone else can go touch grass
  • LOCK_UN β€” remove an existing lock. bye bestie, unlock, free the file 🫢
  • LOCK_MAND β€” a 'mandatory' flock. (DEPRECATED) πŸ’€
ok so real talk about LOCK_MAND: LOCK_MAND support has been removed from the kernel. it's gone-gone. not "use at your own risk" gone, removed. the kernel said no cap and meant it 😭 so don't come crying to me when it doesn't work, i warned you, i literally italicised it

🌈 SEE ALSO 🌈

bestie i need you to brace yourself, this list is long. like, suspiciously long. it's giving "the locking subsystem is a whole friend group." anyway, here's everyone the page links arms with πŸ’œ

the kernel file to go stare at is ./fs/locks.c, and then:

twenty whole siblings. twenty. and every single one of them is invited to the group chat πŸ‘‘


okay that's the page!! mwah πŸ’‹ it came from ./fs, and it's dated October 2026 β€” so yeah, it's got a whole calendar moment going on. go forth and lock responsibly, bestie πŸ§šπŸ’–

πŸ“¦ where this page comes from