fix snapshotting when dst is single component path

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2024-02-06 01:32:37 -05:00
parent f3f005c76e
commit 168126a41e

View File

@ -53,7 +53,9 @@ pub fn cmd_subvolumes(argv: Vec<String>) -> i32 {
},
Subcommands::Snapshot { read_only, source, dest } => {
if let Some(dirname) = dest.parent() {
let fs = unsafe { BcachefsHandle::open(dirname) };
let dot = PathBuf::from(".");
let dir = if dirname.as_os_str().is_empty() { &dot } else { dirname };
let fs = unsafe { BcachefsHandle::open(dir) };
fs.snapshot_subvolume(if read_only { BCH_SUBVOL_SNAPSHOT_RO } else { 0x0 }, source, dest).expect("Failed to snapshot the subvolume");
}