mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-12-09 00:00:17 +03:00
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>
This commit is contained in:
parent
e1fa076a86
commit
b42b5b4065
@ -42,6 +42,10 @@ pub fn subvolume(argv: Vec<String>) -> i32 {
|
|||||||
match cli.subcommands {
|
match cli.subcommands {
|
||||||
Subcommands::Create { targets } => {
|
Subcommands::Create { targets } => {
|
||||||
for target in targets {
|
for target in targets {
|
||||||
|
let target = target
|
||||||
|
.canonicalize()
|
||||||
|
.expect("unable to canonicalize a target path");
|
||||||
|
|
||||||
if let Some(dirname) = target.parent() {
|
if let Some(dirname) = target.parent() {
|
||||||
let fs = unsafe { BcachefsHandle::open(dirname) };
|
let fs = unsafe { BcachefsHandle::open(dirname) };
|
||||||
fs.create_subvolume(target)
|
fs.create_subvolume(target)
|
||||||
@ -50,6 +54,10 @@ pub fn subvolume(argv: Vec<String>) -> i32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Subcommands::Delete { target } => {
|
Subcommands::Delete { target } => {
|
||||||
|
let target = target
|
||||||
|
.canonicalize()
|
||||||
|
.expect("unable to canonicalize a target path");
|
||||||
|
|
||||||
if let Some(dirname) = target.parent() {
|
if let Some(dirname) = target.parent() {
|
||||||
let fs = unsafe { BcachefsHandle::open(dirname) };
|
let fs = unsafe { BcachefsHandle::open(dirname) };
|
||||||
fs.delete_subvolume(target)
|
fs.delete_subvolume(target)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user