vfs_test_lock(9)
π vfs_test_lock β Kernel API Manual β¨
okay so bestie, today we're learning about vfs_test_lock(9). it's giving "peek at the lock without touching it" energy and honestly? iconic. π
πΈ NAME πΈ
vfs_test_lock β test file byte range lock πβ¨
π¦ SYNOPSIS π¦
int vfs_test_lock (struct file *filp , struct file_lock *fl );
π ARGUMENTS π
filpβ the file you wanna test the lock on, periodt π«Άflβ the byte-range in the file you're testing; it also gets used to hold the result, so it's like doing double duty (main character energy fr fr) π
π DESCRIPTION π
okay so on entry, fl does not contain a lock β like, it's empty, it's just vibing and holding a description. it identifies a range (fl_start, fl_end) in the file (c.flc_file), plus an owner (c.flc_owner) for whom existing locks should be ignored π. also c.flc_type and c.flc_flags are ignored β literally not important, don't even worry about them bestie π.
both fl_lmops and fl_ops in fl must be NULL. no cap. β
it returns -ERRNO on failure π. and it shows there's a conflicting lock by setting fl->fl_type to something other than F_UNLCK β that's the little tell, iykyk π
π¨ big sister warning π¨: ifvfs_test_lockdoes find a lock and return it, the caller must uselocks_free_lockorlocks_release_privateon the returned lock. like, you have to, it's not optional, don't leave it hanging π«₯π
π₯ SEE ALSO π₯
kernel file ./fs/locks.c plus this whole squad right here π (besties, all of them):
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)sys_flock(9)locks_translate_pid(9)vfs_lock_file(9)vfs_cancel_lock(9)vfs_inode_has_locks(9)
β¨π
and that's the whole page, bestie! it's from the ./fs source, dated October 2026, page name vfs_test_lock(9) β slay, go test some locks responsibly ππ¦π
π¦ 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