[pbs-devel] [PATCH proxmox-backup v7 01/20] tools: add disks utility functions

Christian Ebner c.ebner at proxmox.com
Fri Apr 19 11:54:16 CEST 2024


nit inline

On 4/19/24 10:58, Hannes Laimer wrote:
> ... for mounting and unmounting
> 
> Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
> ---
>   src/tools/disks/mod.rs | 19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
> 
> diff --git a/src/tools/disks/mod.rs b/src/tools/disks/mod.rs
> index 94f89e0a..68854918 100644
> --- a/src/tools/disks/mod.rs
> +++ b/src/tools/disks/mod.rs
> @@ -1323,3 +1323,22 @@ pub fn get_fs_uuid(disk: &Disk) -> Result<String, Error> {
>   
>       bail!("get_fs_uuid failed - missing UUID");
>   }
> +
> +/// Mount a disk by its UUID and the mount point.
> +pub fn mount_by_uuid(uuid: &str, mount_point: &Path) -> Result<(), Error> {
> +    let mut command = std::process::Command::new("mount");
> +    command.args([&format!("UUID={uuid}")]);
this should be: `command.arg(&format!("UUID={uuid}"));`, or pass already 
both arguments when using args.

> +    command.arg(mount_point);
> +
> +    proxmox_sys::command::run_command(command, None)?;
> +    Ok(())
> +}
> +
> +/// Unmount a disk by its mount point.
> +pub fn unmount_by_mountpoint(path: &str) -> Result<(), Error> {
> +    let mut command = std::process::Command::new("umount");
> +    command.arg(path);
> +
> +    proxmox_sys::command::run_command(command, None)?;
> +    Ok(())
> +}





More information about the pbs-devel mailing list