#lock-files #lock-guard #fs #fs-file

fslock-guard

Wrapper around a lockfile with unlock-on-drop semantics

15 unstable releases (4 breaking)

Uses new Rust 2024

0.5.1 Dec 2, 2025
0.5.0 Oct 30, 2025
0.4.0 Oct 6, 2025
0.2.4 Jul 8, 2025
0.1.1 Mar 4, 2024

#537 in Filesystem

Download history 958/week @ 2025-09-29 493/week @ 2025-10-06 293/week @ 2025-10-13 283/week @ 2025-10-20 478/week @ 2025-10-27 761/week @ 2025-11-03 523/week @ 2025-11-10 602/week @ 2025-11-17 473/week @ 2025-11-24 556/week @ 2025-12-01 338/week @ 2025-12-08 781/week @ 2025-12-15 674/week @ 2025-12-22 643/week @ 2025-12-29 848/week @ 2026-01-05 534/week @ 2026-01-12

2,721 downloads per month
Used in 37 crates (2 directly)

MIT/Apache

17KB
156 lines

fslock-guard — A guard object to ensure we have an exclusive lock to a file

This crate is a thin wrapper around fslock, which uses flock(2) or LockFileEx to acquire an advisory lock on the filesystem.

We add two features that fslock does not (currently) have:

  • We have a LockFileGuard type, which can be used to ensure that a lock is actually held until the guard is dropped.
  • We perform a post-lock check to make sure that our lockfile has not been removed and re-created on disk by someone else. This check makes it safe to remove lockfiles.

Dependencies

~0.2–0.9MB
~16K SLoC