diff --git a/bch_bindgen/src/sb_io.rs b/bch_bindgen/src/sb_io.rs index 7537560b..46e17673 100644 --- a/bch_bindgen/src/sb_io.rs +++ b/bch_bindgen/src/sb_io.rs @@ -4,6 +4,8 @@ use crate::errcode::bch_errcode; use crate::path_to_cstr; use anyhow::anyhow; +pub use crate::bcachefs::bch2_free_super; + pub fn read_super_opts( path: &std::path::Path, mut opts: bch_opts, diff --git a/src/commands/mount.rs b/src/commands/mount.rs index e01f5388..20b692bc 100644 --- a/src/commands/mount.rs +++ b/src/commands/mount.rs @@ -321,7 +321,7 @@ fn cmd_mount_inner(cli: &Cli) -> Result<()> { // Grab the udev information once let udev_info = udev_bcachefs_info()?; - let (devices, sbs) = if let Some(("UUID" | "OLD_BLKID_UUID", uuid)) = cli.dev.split_once('=') { + let (devices, mut sbs) = if let Some(("UUID" | "OLD_BLKID_UUID", uuid)) = cli.dev.split_once('=') { devs_str_sbs_from_uuid(&udev_info, uuid)? } else if cli.dev.contains(':') { // If the device string contains ":" we will assume the user knows the @@ -343,11 +343,16 @@ fn cmd_mount_inner(cli: &Cli) -> Result<()> { ensure!(!sbs.is_empty(), "No device(s) to mount specified"); - let first_sb = sbs[0]; + let first_sb = &sbs[0]; if unsafe { bcachefs::bch2_sb_is_encrypted(first_sb.sb) } { handle_unlock(cli, &first_sb)?; } + for sb in &mut sbs { + unsafe { bch_bindgen::sb_io::bch2_free_super(sb); } + } + drop(sbs); + if let Some(mountpoint) = cli.mountpoint.as_deref() { info!( "mounting with params: device: {}, target: {}, options: {}",