posix_lock_file(9)
π posix_lock_file(9) π
okay bestie, welcome to the Kernel API Manual entry for posix_lock_file β yes that's the manual name, yes it's giving very serious kernel energy, and yes i'm gonna make it make sense for you π«Ά
β¨ NAME β¨
posix_lock_file β apply a POSIX-style lock to a file π
πΈ SYNOPSIS πΈ
int posix_lock_file (struct file *filp , struct file_lock *fl , struct file_lock *conflock );
π ARGUMENTS π
filpβ the file you're applying the lock to, like your main character file πflβ the actual lock you want to apply, no cap β¨conflockβ a spot to stash a copy of the conflicting lock, if one is found π
π¦ DESCRIPTION π¦
so the vibe here is: you're adding a POSIX style lock to a file. that's literally it, that's the whole thing π
the way this works, we merge adjacent & overlapping locks whenever possible β highkey efficient, we love to see it. and POSIX locks are sorted by owner task, then by starting address. iykyk π
π¨ important lil note bestie: if you call this with anFL_EXISTSargument, the caller may determine whether or not a lock was successfully freed by testing the return value for-ENOENT. so like,-ENOENT? that's your answer right there. write that down π₯
π SEE ALSO π
go be nosy, here's the whole friend group β Kernel file ./fs/locks.c and:
locks_owner_has_blockers(9)lease_open_conflict(9)locks_delete_block(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)sys_flock(9)vfs_test_lock(9)locks_translate_pid(9)vfs_lock_file(9)vfs_cancel_lock(9)vfs_inode_has_locks(9)
and that's a wrap, bestie π§π this lil page came from ./fs and it's dated October 2026, still stamped posix_lock_file(9) β iconic, no notes πβ
π¦ 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