From cb8dc1b2baf8e79ad3cf035dce964297bf16ddde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20Schr=C3=B6der?= Date: Fri, 25 Oct 2024 20:52:26 +0200 Subject: [PATCH] Allow multiple targets for subvolume delete. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Malte Schröder Signed-off-by: Kent Overstreet --- src/commands/subvolume.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/commands/subvolume.rs b/src/commands/subvolume.rs index bb0141c4..7df20819 100644 --- a/src/commands/subvolume.rs +++ b/src/commands/subvolume.rs @@ -24,7 +24,7 @@ enum Subcommands { #[command(visible_aliases = ["del"])] Delete { /// Path - target: PathBuf, + targets: Vec, }, #[command(allow_missing_positional = true, visible_aliases = ["snap"])] @@ -58,15 +58,17 @@ pub fn subvolume(argv: Vec) -> Result<()> { } } } - Subcommands::Delete { target } => { - let target = target - .canonicalize() - .context("subvolume path does not exist or can not be canonicalized")?; + Subcommands::Delete { targets } => { + for target in targets { + let target = target + .canonicalize() + .context("subvolume path does not exist or can not be canonicalized")?; - if let Some(dirname) = target.parent() { - let fs = unsafe { BcachefsHandle::open(dirname) }; - fs.delete_subvolume(target) - .context("Failed to delete the subvolume")?; + if let Some(dirname) = target.parent() { + let fs = unsafe { BcachefsHandle::open(dirname) }; + fs.delete_subvolume(target) + .context("Failed to delete the subvolume")?; + } } } Subcommands::Snapshot {