posix_lock_file(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 an FL_EXISTS argument, 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:


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