cmd_mount: Use noxcl for opening block devices

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>
This commit is contained in:
Kent Overstreet 2024-01-13 01:47:33 -05:00
parent 5ed0dcc001
commit 039fd4064a

View 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)