Merge pull request #293 from tmuehlbacher/fix-subvolume-commands-with-relative-paths

fix(subvol): make cmds work with relative paths
This commit is contained in:
koverstreet 2024-06-09 17:43:41 -04:00 committed by GitHub
commit c2354f0326
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)