diff options
author | Thomas Mühlbacher <tmuehlbacher@posteo.net> | 2024-06-09 21:56:32 +0200 |
---|---|---|
committer | Thomas Mühlbacher <tmuehlbacher@posteo.net> | 2024-06-09 22:13:11 +0200 |
commit | b42b5b4065542d513f7114cccc6cdc9d51d0f055 (patch) | |
tree | 1663e9163406a75904cb96df5c3f8ff320659aa6 | |
parent | e1fa076a86047f6c5d305c0756adbf3b2810c070 (diff) |
fix(subvol): make cmds work with relative paths
`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 <tmuehlbacher@posteo.net>
-rw-r--r-- | src/commands/subvolume.rs | 8 |
1 files changed, 8 insertions, 0 deletions
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<String>) -> 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<String>) -> 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) |