]> git.proxmox.com Git - proxmox-backup.git/blob - src/tools/fs.rs
bump proxmox-rrd to 0.2 and proxmox-time to 2.0
[proxmox-backup.git] / src / tools / fs.rs
1 use std::ffi::CStr;
2 use std::path::PathBuf;
3
4 use anyhow::{format_err, Error};
5 use tokio::task::spawn_blocking;
6
7 /// `proxmox_sys::fs::fs_into` wrapped in a `spawn_blocking` call.
8 pub async fn fs_info(path: PathBuf) -> Result<proxmox_sys::fs::FileSystemInformation, Error> {
9 Ok(spawn_blocking(move || proxmox_sys::fs::fs_info(&path))
10 .await
11 .map_err(|err| format_err!("error waiting for fs_info call: {err}"))??)
12 }
13
14 /// `proxmox_sys::fs::fs_into` wrapped in a `spawn_blocking` call.
15 ///
16 /// We cannot use `&'static CStr` in the above as we get from a C-string literal
17 /// because `NixPath` is only implemented directly on `CStr`, not on `&CStr`.
18 pub async fn fs_info_static(
19 path: &'static CStr,
20 ) -> Result<proxmox_sys::fs::FileSystemInformation, Error> {
21 Ok(spawn_blocking(move || proxmox_sys::fs::fs_info(path))
22 .await
23 .map_err(|err| format_err!("error waiting for fs_info call: {err}"))??)
24 }