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

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Oct 14 15:42:05 CEST 2024


On September 4, 2024 4:11 pm, Hannes Laimer wrote:
> ... for mounting and unmounting
> 
> Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
> ---
>  src/tools/disks/mod.rs | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/src/tools/disks/mod.rs b/src/tools/disks/mod.rs
> index c729c26a..9d8ff05c 100644
> --- a/src/tools/disks/mod.rs
> +++ b/src/tools/disks/mod.rs
> @@ -1315,3 +1315,33 @@ 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> {

path

> +    let mut command = std::process::Command::new("mount");
> +    command.arg(&format!("UUID={uuid}"));
> +    command.arg(mount_point);
> +
> +    proxmox_sys::command::run_command(command, None)?;
> +    Ok(())
> +}
> +
> +/// Create bind mount.
> +pub fn bind_mount(path: &Path, target: &Path) -> Result<(), Error> {

path(s)

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

str? seems inconsistent, or is there a reason for this?

> +    let mut command = std::process::Command::new("umount");
> +    command.arg(path);
> +
> +    proxmox_sys::command::run_command(command, None)?;
> +    Ok(())
> +}
> -- 
> 2.39.2
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
> 
> 
> 




More information about the pbs-devel mailing list