]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
cmd_mount: Use noxcl for opening block devices
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 13 Jan 2024 06:47:33 +0000 (01:47 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 15 Jan 2024 17:53:52 +0000 (12:53 -0500)
We're only reading the superblocks, no need for O_EXCL - and this fixes
mounts failing because we're still holding the devices open.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
rust-src/src/cmd_mount.rs

index 6db109c481dbd33e5940f7970e8a002952cff5e9..eccfe6d0301d2ccb6d4e3d5d63cb3d2373fe2505 100644 (file)
@@ -1,5 +1,5 @@
 use atty::Stream;
-use bch_bindgen::{bcachefs, bcachefs::bch_sb_handle};
+use bch_bindgen::{bcachefs, bcachefs::bch_sb_handle, opt_set};
 use log::{info, debug, error, LevelFilter};
 use clap::{Parser};
 use uuid::Uuid;
@@ -104,7 +104,10 @@ fn read_super_silent(path: &std::path::PathBuf) -> anyhow::Result<bch_sb_handle>
     // Stop libbcachefs from spamming the output
     let _gag = gag::BufferRedirect::stdout().unwrap();
 
-    bch_bindgen::rs::read_super(&path)
+    let mut opts = bcachefs::bch_opts::default();
+    opt_set!(opts, noexcl, 1);
+
+    bch_bindgen::rs::read_super_opts(&path, opts)
 }
 
 fn get_devices_by_uuid(uuid: Uuid) -> anyhow::Result<Vec<(PathBuf, bch_sb_handle)>> {
@@ -188,7 +191,7 @@ fn cmd_mount_inner(opt: Cli) -> anyhow::Result<()> {
 
         for dev in opt.dev.split(':') {
             let dev = PathBuf::from(dev);
-            sbs.push(bch_bindgen::rs::read_super(&dev)?);
+            sbs.push(read_super_silent(&dev)?);
         }
 
         (opt.dev, sbs)