use std::io::{self, BufRead, BufReader, Write};
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd};
use std::path::{Path, PathBuf};
+#[cfg(feature = "timer")]
use std::time::Duration;
use anyhow::{bail, format_err, Error};
use proxmox_lang::try_block;
-use crate::error::{SysError, SysResult};
-use crate::linux::timer;
+use crate::error::SysError;
+
+#[cfg(feature = "timer")]
+use crate::{error::SysResult, linux::timer};
use crate::fs::CreateOptions;
}
}
+#[cfg(feature = "timer")]
/// Create a file lock using fntl. This function allows you to specify
/// a timeout if you want to avoid infinite blocking.
///
Ok(())
}
+#[cfg(feature = "timer")]
/// Open or create a lock file (append mode). Then try to
/// acquire a lock using `lock_file()`.
pub fn open_file_locked<P: AsRef<Path>>(
use proxmox_borrow::Tied;
+#[cfg(feature = "timer")]
use crate::error::SysError;
pub type DirLockGuard = Dir;
}
}
+#[cfg(feature = "timer")]
/// Attempt to acquire a shared flock on the given path, 'what' and
/// 'would_block_message' are used for error formatting.
pub fn lock_dir_noblock_shared(
do_lock_dir_noblock(path, what, would_block_msg, false)
}
+#[cfg(feature = "timer")]
/// Attempt to acquire an exclusive flock on the given path, 'what' and
/// 'would_block_message' are used for error formatting.
pub fn lock_dir_noblock(
do_lock_dir_noblock(path, what, would_block_msg, true)
}
+#[cfg(feature = "timer")]
fn do_lock_dir_noblock(
path: &std::path::Path,
what: &str,