3 use crate::bcachefs::*;
4 use crate::errcode::bch_errcode;
6 pub fn read_super_opts(
7 path: &std::path::Path,
9 ) -> anyhow::Result<bch_sb_handle> {
10 use std::os::unix::ffi::OsStrExt;
11 let path = std::ffi::CString::new(path.as_os_str().as_bytes()).unwrap();
13 let mut sb = std::mem::MaybeUninit::zeroed();
16 unsafe { crate::bcachefs::bch2_read_super(path.as_ptr(), &mut opts, sb.as_mut_ptr()) };
19 let err: bch_errcode = unsafe { ::std::mem::transmute(ret) };
22 Ok(unsafe { sb.assume_init() })
26 pub fn read_super(path: &std::path::Path) -> anyhow::Result<bch_sb_handle> {
27 let opts = bcachefs::bch_opts::default();
28 read_super_opts(path, opts)