diff options
author | Malte Schröder <malte.schroeder@tnxip.de> | 2024-10-25 20:52:26 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-10-25 15:07:49 -0400 |
commit | cb8dc1b2baf8e79ad3cf035dce964297bf16ddde (patch) | |
tree | 1bfa2d7d7073877a4294f0de2392434f5c32540d | |
parent | 254175598102532d8df1e127b4cb915fd7f8b31f (diff) |
Allow multiple targets for subvolume delete.
Signed-off-by: Malte Schröder <malte.schroeder@tnxip.de>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | src/commands/subvolume.rs | 20 |
1 files 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<PathBuf>, }, #[command(allow_missing_positional = true, visible_aliases = ["snap"])] @@ -58,15 +58,17 @@ pub fn subvolume(argv: Vec<String>) -> 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 { |