sys_flock(9)
π 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 chillingLOCK_EXβ an exclusive lock π₯ one holder only, everyone else can go touch grassLOCK_UNβ remove an existing lock. bye bestie, unlock, free the file π«ΆLOCK_MANDβ a 'mandatory' flock. (DEPRECATED) π
ok so real talk aboutLOCK_MAND:LOCK_MANDsupport 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:
locks_owner_has_blockers(9)lease_open_conflict(9)locks_delete_block(9)posix_lock_file(9)posix_lock_inode_wait(9)inode_lease_ignore_mask(9)__break_lease(9)lease_get_mtime(9)__fcntl_getlease(9)generic_setlease(9)vfs_setlease(9)fcntl_setlease(9)fcntl_setdeleg(9)flock_lock_inode_wait(9)locks_lock_inode_wait(9)vfs_test_lock(9)locks_translate_pid(9)vfs_lock_file(9)vfs_cancel_lock(9)vfs_inode_has_locks(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms