diff --git a/proxmox-sys/src/fs/file.rs b/proxmox-sys/src/fs/file.rs index ffddc201..75eaaf24 100644 --- a/proxmox-sys/src/fs/file.rs +++ b/proxmox-sys/src/fs/file.rs @@ -2,6 +2,7 @@ use std::fs::File; 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}; @@ -14,8 +15,10 @@ use serde_json::Value; 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; @@ -346,6 +349,7 @@ pub fn image_size(path: &Path) -> Result { } } +#[cfg(feature = "timer")] /// Create a file lock using fntl. This function allows you to specify /// a timeout if you want to avoid infinite blocking. /// @@ -399,6 +403,7 @@ pub fn lock_file( 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>( diff --git a/proxmox-sys/src/fs/read_dir.rs b/proxmox-sys/src/fs/read_dir.rs index 8c0c5a0d..773baa06 100644 --- a/proxmox-sys/src/fs/read_dir.rs +++ b/proxmox-sys/src/fs/read_dir.rs @@ -12,6 +12,7 @@ use regex::Regex; use proxmox_borrow::Tied; +#[cfg(feature = "timer")] use crate::error::SysError; pub type DirLockGuard = Dir; @@ -264,6 +265,7 @@ where } } +#[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( @@ -274,6 +276,7 @@ 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( @@ -284,6 +287,7 @@ 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,