[pbs-devel] [PATCH proxmox-backup 08/26] tools: disks: add mount and unmount helper

Hannes Laimer h.laimer at proxmox.com
Tue Jul 5 15:08:16 CEST 2022


Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
---
 src/tools/disks/mod.rs | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/tools/disks/mod.rs b/src/tools/disks/mod.rs
index 35ec9996..e217ac87 100644
--- a/src/tools/disks/mod.rs
+++ b/src/tools/disks/mod.rs
@@ -1136,6 +1136,24 @@ pub fn complete_disk_name(_arg: &str, _param: &HashMap<String, String>) -> Vec<S
         .collect()
 }
 
+pub fn mount_by_uuid(uuid: &str, mountpoint: &str) -> Result<(), Error> {
+    let mut command = std::process::Command::new("mount");
+    command.args(&[format!("UUID={}", uuid)]);
+    command.arg(mountpoint);
+
+    proxmox_sys::command::run_command(command, None)?;
+    Ok(())
+}
+
+pub fn unmount_by_mountpoint(path: &str) -> Result<(), Error> {
+    let mut command = std::process::Command::new("umount");
+    command.arg("-l");
+    command.arg(path);
+
+    proxmox_sys::command::run_command(command, None)?;
+    Ok(())
+}
+
 /// Read the FS UUID (parse blkid output)
 ///
 /// Note: Calling blkid is more reliable than using the udev ID_FS_UUID property.
-- 
2.30.2






More information about the pbs-devel mailing list