From 611148351a9a16e8342add6e5494e3be06597734 Mon Sep 17 00:00:00 2001 From: luanshaotong Date: Thu, 27 Jul 2023 03:14:08 +0000 Subject: [PATCH] fix mount and umount --- src/client/daemon.rs | 11 ++++++++++- src/client/mod.rs | 6 +++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/client/daemon.rs b/src/client/daemon.rs index b082796..152d25b 100644 --- a/src/client/daemon.rs +++ b/src/client/daemon.rs @@ -10,7 +10,7 @@ use std::{ use async_trait::async_trait; use dashmap::DashMap; use fuser::{BackgroundSession, MountOption}; -use log::{error, info}; +use log::{error, info, warn}; use crate::{ common::{ @@ -145,6 +145,15 @@ impl SealfsFused { let volume_name = lines[i * 4 + 1].to_owned(); let read_only = lines[i * 4 + 2].parse::().unwrap(); info!("mounting volume {} to {}", volume_name, mountpoint); + + // umount old mountpoint + if let Err(e) = std::process::Command::new("umount") + .arg(&mountpoint) + .output() + { + warn!("umount {} error: {}", &mountpoint, e); + } + match self.mount(mountpoint, volume_name.clone(), read_only).await { Ok(_) => { info!("mount success"); diff --git a/src/client/mod.rs b/src/client/mod.rs index a006fe9..100c32a 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -101,7 +101,7 @@ enum Commands { #[arg(required = true, name = "mount-point")] mount_point: Option, - #[arg(name = "socket-path")] + #[arg(long = "socket-path", name = "socket-path")] socket_path: Option, }, Add { @@ -139,7 +139,7 @@ enum Commands { manager_address: Option, }, ListMountpoints { - #[arg(name = "socket-path")] + #[arg(long = "socket-path", name = "socket-path")] socket_path: Option, }, Status { @@ -148,7 +148,7 @@ enum Commands { manager_address: Option, }, Probe { - #[arg(name = "socket-path")] + #[arg(long = "socket-path", name = "socket-path")] socket_path: Option, // Probe the local client },