]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
cmd_mount: Fix test-only mount path
authorChristopher James Halse Rogers <raof@ubuntu.com>
Fri, 1 Sep 2023 06:51:32 +0000 (16:51 +1000)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 3 Sep 2023 22:27:10 +0000 (18:27 -0400)
The comman line help claims that `bcachefs mount <DEV>` without a
mount point will do a dry-run mount - all the steps required to
mount the fs, but without actually doing the final real mount.

Make the code actually do this, rather than complain that you
haven't supplied a mountpoint if you don't provide a mountpoint

Signed-off-by: Christopher James Halse Rogers <raof@ubuntu.com>
rust-src/src/cmd_mount.rs

index b79985d82c4040bcfeeb623dfdc6d269a8872203..bb23c1a16bb8426f7f643d87d5c05f2ce5c0e8cb 100644 (file)
@@ -145,7 +145,7 @@ struct Cli {
     /// Where the filesystem should be mounted. If not set, then the filesystem
     /// won't actually be mounted. But all steps preceeding mounting the
     /// filesystem (e.g. asking for passphrase) will still be performed.
-    mountpoint:     std::path::PathBuf,
+    mountpoint:     Option<std::path::PathBuf>,
 
     /// Mount options
     #[arg(short, default_value = "")]
@@ -207,14 +207,23 @@ fn cmd_mount_inner(opt: Cli) -> anyhow::Result<()> {
         key::prepare_key(&sbs[0], key)?;
     }
 
-    info!(
-        "mounting with params: device: {}, target: {}, options: {}",
-        devs,
-        &opt.mountpoint.to_string_lossy(),
-        &opt.options
-    );
+    if let Some(mountpoint) = opt.mountpoint {
+        info!(
+            "mounting with params: device: {}, target: {}, options: {}",
+            devs,
+            mountpoint.to_string_lossy(),
+            &opt.options
+        );
+
+        mount(devs, mountpoint, &opt.options)?;
+    } else {
+        info!(
+            "would mount with params: device: {}, options: {}",
+            devs,
+            &opt.options
+        );
+    }
 
-    mount(devs, &opt.mountpoint, &opt.options)?;
     Ok(())
 }