]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
fix snapshotting when dst is single component path
authorKent Overstreet <kent.overstreet@linux.dev>
Tue, 6 Feb 2024 06:32:37 +0000 (01:32 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Tue, 6 Feb 2024 06:34:50 +0000 (01:34 -0500)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
src/commands/cmd_subvolume.rs

index 85183fa4889525b13c069195a42df26f46881779..a3176f406c121935e29c47a512709cc0cda07a98 100644 (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");
             }