mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-12-07 00:00:12 +03:00
bindgen: implement Drop for bch_sb_handle
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
688e341c4a
commit
8c851d4747
@ -91,6 +91,7 @@ fn main() {
|
||||
.allowlist_type("sb_names")
|
||||
.no_copy("btree_trans")
|
||||
.no_copy("printbuf")
|
||||
.no_copy("bch_sb_handle")
|
||||
.no_partialeq("bkey")
|
||||
.no_partialeq("bpos")
|
||||
.generate_inline_functions(true)
|
||||
|
||||
@ -91,6 +91,12 @@ impl bch_sb_handle {
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for bch_sb_handle {
|
||||
fn drop(&mut self) {
|
||||
unsafe { bch2_free_super(&mut *self); }
|
||||
}
|
||||
}
|
||||
|
||||
// #[repr(u8)]
|
||||
pub enum rhash_lock_head {}
|
||||
pub enum srcu_struct {}
|
||||
|
||||
@ -141,7 +141,7 @@ fn cmd_mount_inner(cli: &Cli) -> Result<()> {
|
||||
let opts = bch_bindgen::opts::parse_mount_opts(None, optstr.as_deref(), true)
|
||||
.unwrap_or_default();
|
||||
|
||||
let mut sbs = device_scan::scan_sbs(&cli.dev, &opts)?;
|
||||
let sbs = device_scan::scan_sbs(&cli.dev, &opts)?;
|
||||
|
||||
ensure!(!sbs.is_empty(), "No device(s) to mount specified");
|
||||
|
||||
@ -152,11 +152,6 @@ fn cmd_mount_inner(cli: &Cli) -> Result<()> {
|
||||
handle_unlock(cli, first_sb)?;
|
||||
}
|
||||
|
||||
for sb in &mut sbs {
|
||||
unsafe {
|
||||
bch_bindgen::sb_io::bch2_free_super(&mut sb.1);
|
||||
}
|
||||
}
|
||||
drop(sbs);
|
||||
|
||||
if let Some(mountpoint) = cli.mountpoint.as_deref() {
|
||||
|
||||
@ -172,13 +172,7 @@ pub fn joined_device_str(sbs: &Vec<(PathBuf, bch_sb_handle)>) -> OsString {
|
||||
}
|
||||
|
||||
pub fn scan_devices(device: &String, opts: &bch_opts) -> Result<OsString> {
|
||||
let mut sbs = scan_sbs(device, opts)?;
|
||||
|
||||
for sb in &mut sbs {
|
||||
unsafe {
|
||||
bch_bindgen::sb_io::bch2_free_super(&mut sb.1);
|
||||
}
|
||||
}
|
||||
let sbs = scan_sbs(device, opts)?;
|
||||
|
||||
Ok(joined_device_str(&sbs))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user