#file-lock #lock #locking #file

no-std fslock-arti-fork

A library to use files as locks, forked for use in Arti

1 unstable release

0.2.0 Jan 22, 2024

#1129 in Filesystem

Download history 1690/week @ 2024-08-07 1215/week @ 2024-08-14 1620/week @ 2024-08-21 1514/week @ 2024-08-28 2003/week @ 2024-09-04 1556/week @ 2024-09-11 1403/week @ 2024-09-18 3439/week @ 2024-09-25 2583/week @ 2024-10-02 1442/week @ 2024-10-09 2221/week @ 2024-10-16 2062/week @ 2024-10-23 2922/week @ 2024-10-30 1103/week @ 2024-11-06 1797/week @ 2024-11-13 1403/week @ 2024-11-20

7,746 downloads per month
Used in 31 crates (via fslock-guard)

MIT license

54KB
1.5K SLoC

fslock-arti-fork

NOTE: This is a fork of the fslock crate for use by Arti. We are forking temporarily because we need https://github.com/brunoczim/fslock/pull/15 in order to implement file deletion safely.

API to use files as a lock. Supports non-std crates by disabling feature std.

Types

Currently, only one type is provided: LockFile. It does not destroy the file after closed and behaviour on locking different file handles owned by the same process is different between Unix and Windows, unless you activate the multilock feature, which enables the open_excl method that locks files per file descriptor/handle on all platforms.

Example

use fslock::LockFile;
fn main() -> Result<(), fslock::Error> {

    let mut file = LockFile::open("mylock")?;
    file.lock()?;
    do_stuff();
    file.unlock()?;

    Ok(())
}

Docs on Master

https://brunoczim.github.io/fslock/fslock

[]


lib.rs:

WARNING: v0.1.x is incompatible with v0.2.x onwards.

NOTE: This is a fork of the fslock crate for use by Arti. We are forking temporarily because we need https://github.com/brunoczim/fslock/pull/15 in order to implement file deletion safely.

API to use files as a lock. Supports non-std crates by disabling feature std.

Types

Currently, only one type is provided: LockFile. It does not destroy the file after closed. Locks are per-handle and not by per-process in any platform. On Unix, however, under fork file descriptors might be duplicated sharing the same lock, but fork is usually unsafe in Rust.

Example

use fslock::LockFile;
fn main() -> Result<(), fslock::Error> {

    let mut file = LockFile::open("testfiles/mylock.lock")?;
    file.lock()?;
    do_stuff();
    file.unlock()?;

    Ok(())
}

Dependencies

~220KB