From 9cb1b41d0ea29297359413f092370a7f5c30efd2 Mon Sep 17 00:00:00 2001 From: Lars Milz Date: Sun, 15 Nov 2026 20:50:56 +0100 Subject: [PATCH] flock: implement flock Support the file, directory and file descriptor forms with -s/-x/-u, -n, -w, -E and -c. Exit codes follow util-linux. Not yet implemented: -o, -F, --verbose, --fcntl. --- Cargo.lock | 11 ++ Cargo.toml | 2 + README.md | 2 +- src/uu/flock/Cargo.toml | 17 ++ src/uu/flock/flock.md | 9 + src/uu/flock/src/errors.rs | 53 ++++++ src/uu/flock/src/flock.rs | 327 ++++++++++++++++++++++++++++++++++++ src/uu/flock/src/main.rs | 1 + tests/by-util/test_flock.rs | 287 +++++++++++++++++++++++++++++++ tests/tests.rs | 4 + 10 files changed, 712 insertions(+), 1 deletion(-) create mode 100644 src/uu/flock/Cargo.toml create mode 100644 src/uu/flock/flock.md create mode 100644 src/uu/flock/src/errors.rs create mode 100644 src/uu/flock/src/flock.rs create mode 100644 src/uu/flock/src/main.rs create mode 100644 tests/by-util/test_flock.rs diff --git a/Cargo.lock b/Cargo.lock index 861caaa3..ab1835b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1473,6 +1473,7 @@ dependencies = [ "uu_chcpu", "uu_ctrlaltdel", "uu_dmesg", + "uu_flock", "uu_fsfreeze", "uu_hexdump", "uu_last", @@ -1549,6 +1550,16 @@ dependencies = [ "uucore 0.2.2", ] +[[package]] +name = "uu_flock" +version = "0.0.1" +dependencies = [ + "clap", + "libc", + "thiserror", + "uucore 0.2.2", +] + [[package]] name = "uu_fsfreeze" version = "0.0.1" diff --git a/Cargo.toml b/Cargo.toml index 425987fc..be512c07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,7 @@ feat_common_core = [ "chcpu", "ctrlaltdel", "dmesg", + "flock", "fsfreeze", "hexdump", "last", @@ -102,6 +103,7 @@ cal = { optional = true, version = "0.0.1", package = "uu_cal", path = "src/uu/c chcpu = { optional = true, version = "0.0.1", package = "uu_chcpu", path = "src/uu/chcpu" } ctrlaltdel = { optional = true, version = "0.0.1", package = "uu_ctrlaltdel", path = "src/uu/ctrlaltdel" } dmesg = { optional = true, version = "0.0.1", package = "uu_dmesg", path = "src/uu/dmesg" } +flock = { optional = true, version = "0.0.1", package = "uu_flock", path = "src/uu/flock" } fsfreeze = { optional = true, version = "0.0.1", package = "uu_fsfreeze", path = "src/uu/fsfreeze" } hexdump = { optional = true, version = "0.0.1", package = "uu_hexdump", path = "src/uu/hexdump" } last = { optional = true, version = "0.0.1", package = "uu_last", path = "src/uu/last" } diff --git a/README.md b/README.md index 6955d878..fc190776 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ First, reimplement the most important tools from util-linux: ## Utility Tools - [ ] `lsblk`: Lists block devices. - [ ] `fallocate`: Preallocates file space. -- [ ] `flock`: Manages file locks. +- [ ] `flock`: Manages file locks. (started) - [ ] `getopt`: Parses command options. - [ ] `hardlink`: Creates hard links. - [x] `mcookie`: Generates random numbers. diff --git a/src/uu/flock/Cargo.toml b/src/uu/flock/Cargo.toml new file mode 100644 index 00000000..1ea23bb1 --- /dev/null +++ b/src/uu/flock/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "uu_flock" +version = "0.0.1" +edition = "2021" + +[dependencies] +uucore = { workspace = true } +thiserror = { workspace = true } +libc = { workspace = true } +clap = { workspace = true } + +[lib] +path = "src/flock.rs" + +[[bin]] +name = "flock" +path = "src/main.rs" diff --git a/src/uu/flock/flock.md b/src/uu/flock/flock.md new file mode 100644 index 00000000..4219d5e3 --- /dev/null +++ b/src/uu/flock/flock.md @@ -0,0 +1,9 @@ +# flock + +``` +flock [options] | [...] +flock [options] | -c +flock [options] +``` + +Manage file locks from shell scripts. diff --git a/src/uu/flock/src/errors.rs b/src/uu/flock/src/errors.rs new file mode 100644 index 00000000..dac24e3a --- /dev/null +++ b/src/uu/flock/src/errors.rs @@ -0,0 +1,53 @@ +// This file is part of the uutils util-linux package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. + +use std::{ffi::OsString, io}; +use uucore::{ + display::Quotable, + error::{strip_errno, UError}, +}; + +// Exit codes +pub const EX_USAGE: i32 = 64; +pub const EX_DATAERR: i32 = 65; +pub const EX_NOINPUT: i32 = 66; +pub const EX_UNAVAILABLE: i32 = 69; +pub const EX_OSERR: i32 = 71; + +#[derive(Debug, thiserror::Error)] +pub enum FlockError { + #[error("cannot open lock file {}: {}", .path.to_string_lossy(), strip_errno(.source))] + OpenLockFile { path: OsString, source: io::Error }, + + #[error("bad file descriptor: {}", .file_or_fd.quote())] + BadFileDescriptor { file_or_fd: OsString }, + + #[error("cannot set up timer: Invalid argument")] + TimerSetup, + + #[error("{}: {}", .file_or_fd.to_string_lossy(), strip_errno(.source))] + CannotAcquireLock { + file_or_fd: OsString, + source: io::Error, + }, + + #[error("failed to execute {}: {}", .program.to_string_lossy(), strip_errno(.source))] + FailedToExecute { + program: OsString, + source: io::Error, + }, +} + +impl UError for FlockError { + fn code(&self) -> i32 { + match self { + Self::BadFileDescriptor { .. } => EX_USAGE, + Self::CannotAcquireLock { .. } => EX_DATAERR, + Self::OpenLockFile { .. } => EX_NOINPUT, + Self::FailedToExecute { .. } => EX_UNAVAILABLE, + Self::TimerSetup => EX_OSERR, + } + } +} diff --git a/src/uu/flock/src/flock.rs b/src/uu/flock/src/flock.rs new file mode 100644 index 00000000..e7a320eb --- /dev/null +++ b/src/uu/flock/src/flock.rs @@ -0,0 +1,327 @@ +// This file is part of the uutils util-linux package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. + +use clap::{builder::ValueParser, crate_version, value_parser, Arg, ArgAction, Command}; +use uucore::{error::UResult, format_usage, help_about, help_usage}; + +const ABOUT: &str = help_about!("flock.md"); +const USAGE: &str = help_usage!("flock.md"); + +mod options { + pub const SHARED: &str = "shared"; + pub const TIMEOUT: &str = "timeout"; + pub const EXCLUSIVE: &str = "exclusive"; + pub const UNLOCK: &str = "unlock"; + pub const NONBLOCK: &str = "nonblock"; + pub const CONFLICT_EXIT_CODE: &str = "conflict-exit-code"; + pub const COMMAND: &str = "command"; + + // Positional arguments + pub const FILE_OR_FD: &str = "file_or_fd"; + pub const PROG_ARGS: &str = "prog_args"; +} + +#[cfg(unix)] +mod errors; + +#[cfg(unix)] +mod unix { + use super::options; + use crate::errors::{FlockError, EX_OSERR}; + use clap::ArgMatches; + use std::{ + ffi::{OsStr, OsString}, + fs::{File, OpenOptions}, + os::fd::{AsRawFd, RawFd}, + os::unix::process::ExitStatusExt, + process::Command as ProcessCommand, + time::{Duration, Instant}, + }; + use uucore::error::{ExitCode, UResult}; + + pub enum LockMode { + Shared, + Exclusive, + Unlock, + } + + impl LockMode { + pub fn operation(&self) -> i32 { + match self { + Self::Shared => libc::LOCK_SH, + Self::Exclusive => libc::LOCK_EX, + Self::Unlock => libc::LOCK_UN, + } + } + } + + pub fn lock_mode(matches: &ArgMatches) -> LockMode { + if matches.get_flag(options::SHARED) { + LockMode::Shared + } else if matches.get_flag(options::UNLOCK) { + LockMode::Unlock + } else { + LockMode::Exclusive + } + } + + pub fn deadline(timeout: Option) -> UResult> { + timeout + .map(|secs| { + Duration::try_from_secs_f64(secs) + .ok() + .and_then(|d| Instant::now().checked_add(d)) + .ok_or_else(|| FlockError::TimerSetup.into()) + }) + .transpose() + } + + fn open_lock_file(path: &OsStr) -> UResult { + OpenOptions::new() + .read(true) + .write(true) + .create(true) + .truncate(false) + .open(path) + .or_else(|err| OpenOptions::new().read(true).open(path).map_err(|_| err)) + .map_err(|source| { + FlockError::OpenLockFile { + path: path.into(), + source, + } + .into() + }) + } + + pub fn lock_target(file_or_fd: &OsStr, has_command: bool) -> UResult<(RawFd, Option)> { + if has_command { + let file = open_lock_file(file_or_fd)?; + let fd = file.as_raw_fd(); + Ok((fd, Some(file))) + } else { + let fd = file_or_fd + .to_str() + .and_then(|s| s.parse::().ok()) + .ok_or_else(|| FlockError::BadFileDescriptor { + file_or_fd: file_or_fd.into(), + })?; + Ok((fd, None)) + } + } + + pub fn acquire_lock( + fd: RawFd, + operation: i32, + nonblock: bool, + deadline: Option, + conflict_exit_code: u8, + file_or_fd: &OsStr, + ) -> UResult<()> { + loop { + let op = if nonblock || deadline.is_some() { + operation | libc::LOCK_NB + } else { + operation + }; + + // SAFETY: `fd` is either an open file descriptor from `open_lock_file` or a + // user-supplied descriptor number (invalid descriptors fail cleanly with EBADF), + // and `op` is a valid combination of `libc::LOCK_*` flags. + if unsafe { libc::flock(fd, op) } == 0 { + return Ok(()); + } + + let err = std::io::Error::last_os_error(); + match err.kind() { + std::io::ErrorKind::WouldBlock => { + if nonblock { + return Err(ExitCode::new(i32::from(conflict_exit_code))); + } + if let Some(dl) = deadline { + let now = Instant::now(); + if now >= dl { + return Err(ExitCode::new(i32::from(conflict_exit_code))); + } + std::thread::sleep((dl - now).min(Duration::from_millis(5))); + continue; + } + } + // EINTR: a signal interrupted the blocking call before the lock was acquired. This + // is not an error, so retry. + std::io::ErrorKind::Interrupted => continue, + _ => {} + } + return Err(FlockError::CannotAcquireLock { + file_or_fd: file_or_fd.into(), + source: err, + } + .into()); + } + } + + pub fn build_command(matches: &ArgMatches) -> Option { + if let Some(prog_args) = matches.get_many::(options::PROG_ARGS) { + let args: Vec<&OsString> = prog_args.collect(); + let mut command = ProcessCommand::new(args[0]); + command.args(&args[1..]); + Some(command) + } else if let Some(shell_cmd) = matches.get_one::(options::COMMAND) { + let shell = std::env::var_os("SHELL") + .filter(|s| !s.is_empty()) + .unwrap_or_else(|| OsString::from("/bin/sh")); + let mut command = ProcessCommand::new(shell); + command.arg("-c").arg(shell_cmd); + Some(command) + } else { + None + } + } + + pub fn run_command(mut cmd: ProcessCommand) -> UResult<()> { + match cmd.status() { + Ok(status) => { + let code = status + .code() + .or_else(|| status.signal().map(|sig| 128 + sig)) + .unwrap_or(EX_OSERR); + uucore::error::set_exit_code(code); + Ok(()) + } + Err(source) => Err(FlockError::FailedToExecute { + program: cmd.get_program().into(), + source, + } + .into()), + } + } +} + +#[cfg(unix)] +#[uucore::main] +pub fn uumain(args: impl uucore::Args) -> UResult<()> { + use std::ffi::OsString; + use unix::*; + + let matches = uu_app().try_get_matches_from(args)?; + let timeout: Option = matches.get_one::(options::TIMEOUT).copied(); + let nonblock = matches.get_flag(options::NONBLOCK); + let conflict_exit_code = *matches.get_one::(options::CONFLICT_EXIT_CODE).unwrap(); + let has_command = + matches.contains_id(options::PROG_ARGS) || matches.contains_id(options::COMMAND); + let operation = lock_mode(&matches).operation(); + let file_or_fd = matches.get_one::(options::FILE_OR_FD).unwrap(); + let (fd, _keep_open) = lock_target(file_or_fd, has_command)?; + let deadline = deadline(timeout)?; + + acquire_lock( + fd, + operation, + nonblock, + deadline, + conflict_exit_code, + file_or_fd, + )?; + + if let Some(cmd) = build_command(&matches) { + run_command(cmd)?; + } + + Ok(()) +} + +#[cfg(not(unix))] +#[uucore::main] +pub fn uumain(args: impl uucore::Args) -> UResult<()> { + let _matches = uu_app().try_get_matches_from(args)?; + Err(uucore::error::USimpleError::new( + 1, + "`flock` is unavailable on this platform", + )) +} + +pub fn uu_app() -> Command { + Command::new(uucore::util_name()) + .version(crate_version!()) + .about(ABOUT) + .override_usage(format_usage(USAGE)) + .infer_long_args(true) + .arg( + Arg::new(options::SHARED) + .short('s') + .long("shared") + .help("get a shared lock") + .overrides_with_all([options::SHARED, options::EXCLUSIVE, options::UNLOCK]) + .action(ArgAction::SetTrue), + ) + .arg( + Arg::new(options::EXCLUSIVE) + .short('x') + .short_alias('e') + .long("exclusive") + .help("get an exclusive lock (default)") + .overrides_with_all([options::SHARED, options::EXCLUSIVE, options::UNLOCK]) + .action(ArgAction::SetTrue), + ) + .arg( + Arg::new(options::UNLOCK) + .short('u') + .long("unlock") + .help("remove a lock") + .overrides_with_all([options::SHARED, options::EXCLUSIVE, options::UNLOCK]) + .action(ArgAction::SetTrue), + ) + .arg( + Arg::new(options::NONBLOCK) + .short('n') + .long("nonblocking") + .visible_alias("nb") + .alias("nonblock") + .help("fail rather than wait") + .action(ArgAction::SetTrue), + ) + .arg( + Arg::new(options::TIMEOUT) + .short('w') + .long("timeout") + .alias("wait") + .value_name("secs") + .allow_negative_numbers(true) + .help("wait for a limited amount of time") + .value_parser(value_parser!(f64)), + ) + .arg( + Arg::new(options::CONFLICT_EXIT_CODE) + .short('E') + .long("conflict-exit-code") + .value_name("number") + .help("exit code after conflict or timeout") + .default_value("1") + .value_parser(value_parser!(u8)), + ) + .arg( + Arg::new(options::COMMAND) + .short('c') + .long("command") + .value_name("command") + .help("run a single command through the shell") + .conflicts_with(options::PROG_ARGS) + .value_parser(ValueParser::os_string()), + ) + .arg( + Arg::new(options::FILE_OR_FD) + .index(1) + .required(true) + .help("file, directory, or file descriptor number") + .value_parser(ValueParser::os_string()), + ) + .arg( + Arg::new(options::PROG_ARGS) + .index(2) + .num_args(1..) + .trailing_var_arg(true) + .help("command to execute and its arguments") + .value_parser(ValueParser::os_string()), + ) +} diff --git a/src/uu/flock/src/main.rs b/src/uu/flock/src/main.rs new file mode 100644 index 00000000..0ae9fcc1 --- /dev/null +++ b/src/uu/flock/src/main.rs @@ -0,0 +1 @@ +uucore::bin!(uu_flock); diff --git a/tests/by-util/test_flock.rs b/tests/by-util/test_flock.rs new file mode 100644 index 00000000..4bc58879 --- /dev/null +++ b/tests/by-util/test_flock.rs @@ -0,0 +1,287 @@ +// This file is part of the uutils util-linux package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. + +use uutests::new_ucmd; + +#[test] +fn test_invalid_arg() { + new_ucmd!().arg("--definitely-invalid").fails().code_is(1); +} + +#[test] +fn test_missing_args() { + new_ucmd!() + .fails() + .code_is(1) + .stderr_contains("required arguments were not provided"); +} + +#[test] +fn test_command_flag_and_positional_conflict() { + new_ucmd!() + .args(&["file", "-c", "echo hi", "extra_arg"]) + .fails() + .stderr_contains("cannot be used with"); +} + +#[test] +fn test_conflict_exit_code_out_of_range() { + new_ucmd!() + .args(&["-E", "300", "lockfile", "true"]) + .fails() + .code_is(1) + .stderr_contains("300 is not in 0..=255"); +} + +#[cfg(unix)] +mod unix { + use std::fs::File; + use std::os::fd::AsRawFd; + use uutests::new_ucmd; + use uutests::util::{get_tests_binary, TestScenario}; + use uutests::util_name; + + fn scenario_with_lockfile() -> (TestScenario, String) { + let ts = TestScenario::new(util_name!()); + let lockfile = ts.fixtures.plus_as_string("lockfile"); + (ts, lockfile) + } + + fn hold_lock(path: &str, op: i32) -> File { + let file = File::create(path).unwrap(); + + // SAFETY: `file` owns the descriptor and stays alive until the end of this function, so it + // is open during the call. `op` is `LOCK_EX` or `LOCK_SH`, combined with `LOCK_NB`, which + // is a valid operation for `flock(2)`. + assert_eq!( + unsafe { libc::flock(file.as_raw_fd(), op | libc::LOCK_NB) }, + 0 + ); + + file + } + + #[test] + fn test_lock_mode_override() { + let (ts, lockfile) = scenario_with_lockfile(); + ts.ucmd().args(&["-s", "-x", &lockfile, "true"]).succeeds(); + ts.ucmd().args(&["-u", "-s", &lockfile, "true"]).succeeds(); + ts.ucmd().args(&["-s", "-s", &lockfile, "true"]).succeeds(); + } + + #[test] + fn test_executes_command_and_creates_lockfile() { + let ts = TestScenario::new(util_name!()); + let lockfile = ts.fixtures.plus("new_lockfile"); + + ts.ucmd() + .args(&[lockfile.to_str().unwrap(), "echo", "hello", "world"]) + .succeeds() + .stdout_is("hello world\n"); + + assert!(lockfile.exists()); + } + + #[test] + fn test_dash_c_command() { + let (ts, lockfile) = scenario_with_lockfile(); + + ts.ucmd() + .args(&[&lockfile, "-c", "echo from_shell"]) + .succeeds() + .stdout_is("from_shell\n"); + } + + #[test] + fn test_propagates_child_exit_code() { + let (ts, lockfile) = scenario_with_lockfile(); + + ts.ucmd() + .args(&[&lockfile, "-c", "exit 42"]) + .fails() + .code_is(42); + } + + #[test] + fn test_exclusive_lock_conflict_and_custom_exit_code() { + let (ts, lockfile) = scenario_with_lockfile(); + let _lock = hold_lock(&lockfile, libc::LOCK_EX); + + ts.ucmd() + .args(&["-n", &lockfile, "true"]) + .fails() + .code_is(1) + .no_output(); + + ts.ucmd() + .args(&["-n", "-E", "123", &lockfile, "true"]) + .fails() + .code_is(123) + .no_output(); + } + + #[test] + fn test_shared_locks_do_not_conflict() { + let (ts, lockfile) = scenario_with_lockfile(); + let _lock = hold_lock(&lockfile, libc::LOCK_SH); + + ts.ucmd().args(&["-s", "-n", &lockfile, "true"]).succeeds(); + + ts.ucmd() + .args(&["-x", "-n", &lockfile, "true"]) + .fails() + .code_is(1); + } + + #[test] + fn test_lock_directory() { + let ts = TestScenario::new(util_name!()); + ts.ucmd() + .args(&["-n", &ts.fixtures.as_string(), "true"]) + .succeeds(); + } + + #[test] + fn test_invalid_fd() { + new_ucmd!() + .arg("77") + .fails() + .code_is(65) + .stderr_contains("77: Bad file descriptor"); + } + + #[test] + fn test_unparseable_fd() { + new_ucmd!() + .arg("not_a_fd") + .fails() + .code_is(64) + .stderr_contains("bad file descriptor"); + } + + #[test] + fn test_unopenable_file() { + new_ucmd!() + .args(&["/nonexistent_dir_for_flock/lockfile", "true"]) + .fails() + .code_is(66) + .stderr_contains("cannot open lock file"); + } + + #[test] + fn test_missing_command_binary() { + let (ts, lockfile) = scenario_with_lockfile(); + ts.ucmd() + .args(&[&lockfile, "/this_binary_does_not_exist_12345"]) + .fails() + .code_is(69) + .stderr_is( + "flock: failed to execute /this_binary_does_not_exist_12345: No such file or directory\n", + ); + } + + #[test] + fn test_fd_form_and_unlock() { + let (ts, lockfile) = scenario_with_lockfile(); + let bin = get_tests_binary(); + + let script = format!( + "exec 9>'{lockfile}'; \ + '{bin}' flock -n 9 && \ + ! '{bin}' flock -n '{lockfile}' true && \ + '{bin}' flock -u 9 && \ + '{bin}' flock -n '{lockfile}' true" + ); + + ts.cmd("sh").args(&["-c", &script]).succeeds(); + } + + #[test] + fn test_child_killed_by_signal() { + let (ts, lockfile) = scenario_with_lockfile(); + + ts.ucmd() + .args(&[&lockfile, "sh", "-c", "kill -9 $$"]) + .fails() + .code_is(137); + } + + #[test] + fn test_timeout_expires() { + let (ts, lockfile) = scenario_with_lockfile(); + let _lock = hold_lock(&lockfile, libc::LOCK_EX); + + ts.ucmd() + .args(&["-w", "0.05", "-E", "77", &lockfile, "true"]) + .fails() + .code_is(77); + } + + #[test] + fn test_timeout_succeeds_when_lock_released() { + use std::time::Duration; + + let (ts, lockfile) = scenario_with_lockfile(); + let file = hold_lock(&lockfile, libc::LOCK_EX); + + let handle = std::thread::spawn(move || { + std::thread::sleep(Duration::from_millis(100)); + drop(file); + }); + + ts.ucmd().args(&["-w", "5", &lockfile, "true"]).succeeds(); + handle.join().unwrap(); + } + + #[test] + fn test_invalid_timeouts() { + let (ts, lockfile) = scenario_with_lockfile(); + + for invalid in ["-1", "nan", "1e20", "inf"] { + ts.ucmd() + .args(&["-w", invalid, &lockfile, "true"]) + .fails() + .code_is(71) + .stderr_contains("cannot set up timer: Invalid argument"); + } + } + + #[test] + fn test_nonblocking_long_and_alias() { + let (ts, lockfile) = scenario_with_lockfile(); + let _lock = hold_lock(&lockfile, libc::LOCK_EX); + + for flag in ["--nonblocking", "--nonblock", "--nb"] { + ts.ucmd() + .args(&[flag, &lockfile, "true"]) + .fails() + .code_is(1) + .no_output(); + } + } + + #[test] + fn test_read_only_lock_file() { + let (ts, lockfile) = scenario_with_lockfile(); + ts.fixtures.touch("lockfile"); + ts.fixtures.set_mode("lockfile", 0o444); // read-only file + + ts.ucmd().args(&[&lockfile, "true"]).succeeds().no_output(); + } +} + +#[cfg(not(unix))] +mod non_unix { + use uutests::new_ucmd; + + #[test] + fn test_unsupported_platform() { + new_ucmd!() + .args(&["lockfile", "true"]) + .fails() + .code_is(1) + .stderr_contains("`flock` is unavailable on this platform"); + } +} diff --git a/tests/tests.rs b/tests/tests.rs index 469a0281..aa2b7d9f 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -79,6 +79,10 @@ mod test_last; #[path = "by-util/test_dmesg.rs"] mod test_dmesg; +#[cfg(feature = "flock")] +#[path = "by-util/test_flock.rs"] +mod test_flock; + #[cfg(feature = "fsfreeze")] #[path = "by-util/test_fsfreeze.rs"] mod test_fsfreeze;