From b42b5b4065542d513f7114cccc6cdc9d51d0f055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BChlbacher?= Date: Sun, 9 Jun 2024 21:56:32 +0200 Subject: [PATCH] fix(subvol): make cmds work with relative paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `Path::parent()` returns `Some("")` for relative paths with a single component. The simplest fix is to just canonicalize the paths first. Signed-off-by: Thomas Mühlbacher --- src/commands/subvolume.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/commands/subvolume.rs b/src/commands/subvolume.rs index a5ebcf53..64743115 100644 --- a/src/commands/subvolume.rs +++ b/src/commands/subvolume.rs @@ -42,6 +42,10 @@ pub fn subvolume(argv: Vec) -> i32 { match cli.subcommands { Subcommands::Create { targets } => { for target in targets { + let target = target + .canonicalize() + .expect("unable to canonicalize a target path"); + if let Some(dirname) = target.parent() { let fs = unsafe { BcachefsHandle::open(dirname) }; fs.create_subvolume(target) @@ -50,6 +54,10 @@ pub fn subvolume(argv: Vec) -> i32 { } } Subcommands::Delete { target } => { + let target = target + .canonicalize() + .expect("unable to canonicalize a target path"); + if let Some(dirname) = target.parent() { let fs = unsafe { BcachefsHandle::open(dirname) }; fs.delete_subvolume(target)