From 168126a41e1d2d43104988d113603fcc13d020e0 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Tue, 6 Feb 2024 01:32:37 -0500 Subject: [PATCH] fix snapshotting when dst is single component path Signed-off-by: Kent Overstreet --- src/commands/cmd_subvolume.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/commands/cmd_subvolume.rs b/src/commands/cmd_subvolume.rs index 85183fa..a3176f4 100644 --- a/src/commands/cmd_subvolume.rs +++ b/src/commands/cmd_subvolume.rs @@ -53,7 +53,9 @@ pub fn cmd_subvolumes(argv: Vec) -> 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"); } -- 2.39.2