mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
Merge pull request #294 from tmuehlbacher/subvol-fix
fix(subvol): canonicalize requires path to exist
This commit is contained in:
commit
e743caf71c
@ -1,4 +1,4 @@
|
|||||||
use std::path::PathBuf;
|
use std::{env, path::PathBuf};
|
||||||
|
|
||||||
use bch_bindgen::c::BCH_SUBVOL_SNAPSHOT_RO;
|
use bch_bindgen::c::BCH_SUBVOL_SNAPSHOT_RO;
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
@ -42,9 +42,13 @@ 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
|
let target = if target.is_absolute() {
|
||||||
.canonicalize()
|
target
|
||||||
.expect("unable to canonicalize a target path");
|
} else {
|
||||||
|
env::current_dir()
|
||||||
|
.map(|p| p.join(target))
|
||||||
|
.expect("unable to get current directory")
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(dirname) = target.parent() {
|
if let Some(dirname) = target.parent() {
|
||||||
let fs = unsafe { BcachefsHandle::open(dirname) };
|
let fs = unsafe { BcachefsHandle::open(dirname) };
|
||||||
@ -56,7 +60,7 @@ pub fn subvolume(argv: Vec<String>) -> i32 {
|
|||||||
Subcommands::Delete { target } => {
|
Subcommands::Delete { target } => {
|
||||||
let target = target
|
let target = target
|
||||||
.canonicalize()
|
.canonicalize()
|
||||||
.expect("unable to canonicalize a target path");
|
.expect("subvolume path does not exist or can not be canonicalized");
|
||||||
|
|
||||||
if let Some(dirname) = target.parent() {
|
if let Some(dirname) = target.parent() {
|
||||||
let fs = unsafe { BcachefsHandle::open(dirname) };
|
let fs = unsafe { BcachefsHandle::open(dirname) };
|
||||||
|
Loading…
Reference in New Issue
Block a user