[pbs-devel] [PATCH proxmox-backup 08/26] tools: disks: add mount and unmount helper
Wolfgang Bumiller
w.bumiller at proxmox.com
Wed Jul 6 13:42:50 CEST 2022
On Tue, Jul 05, 2022 at 01:08:16PM +0000, Hannes Laimer wrote:
> 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");
I'm really not a fan of using `-l` at all. This would pull the device
out from any current user of it. Anything not exclusively using
`openat()` on an already open directory handle to it will start to
simply keep using the paths without the disk mounted.
I'd rather have it fail when still in use.
> + 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