diff --git a/proxmox-tools/src/fs.rs b/proxmox-tools/src/fs.rs index f5d38914..00498f98 100644 --- a/proxmox-tools/src/fs.rs +++ b/proxmox-tools/src/fs.rs @@ -215,18 +215,15 @@ impl CreateOptions { } } -/// Creates directory at the provided path with specified ownership +/// Creates directory at the provided path with specified ownership. /// /// Simply returns if the directory already exists. -pub fn create_dir_chown>( - path: P, - perm: Option, - owner: Option, - group: Option, -) -> Result<(), nix::Error> { +pub fn create_dir>(path: P, options: CreateOptions) -> Result<(), nix::Error> { // clippy bug?: from_bits_truncate is actually a const fn... #[allow(clippy::or_fun_call)] - let mode: stat::Mode = perm.unwrap_or(stat::Mode::from_bits_truncate(0o770)); + let mode: stat::Mode = options + .perm + .unwrap_or(stat::Mode::from_bits_truncate(0o770)); let path = path.as_ref(); @@ -238,7 +235,7 @@ pub fn create_dir_chown>( err => return err, } - unistd::chown(path, owner, group)?; + unistd::chown(path, options.owner, options.group)?; Ok(()) }