Your small yet useful swiss army knife for the fcntl
system call,
specifically for acquiring and testing file locks, but not limited to those.
This tool only works on UNIX or POSIX-like systems. Please find more information in the following resources:
This is for example useful for testing during development. Imagine you want
to check how your program behaves, when a lock is already held. Using
fcntl-tool
, you can acquire these locks!
This crate works on all platforms that Rust code can be compiled to. It, however, only makes sense on UNIX or POSIX-like systems.
operation | supported |
---|---|
F_GETLK |
✅ |
F_SETLK |
✅ |
F_OFD_GETLK |
✅ |
F_OFD_SETLK |
✅ |
... | Not yet |
Type fcntl-tool --help
to get guidance.
$ fcntl-tool --help
# Terminal 1
$ fcntl-tool write-lock --file ./foo.txt
Please press enter to release the Write lock ...
# Terminal 2
$ fcntl-tool test-lock --file ./foo.txt
state: ExclusiveWrite
You can also take a look onto the integration test in the repository.
The MSRV of the binary is 1.85.0
stable.