summaryrefslogtreecommitdiff
path: root/rust-src/bch_bindgen/src/fs.rs
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-03-04 07:35:29 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-03-04 19:14:50 -0500
commit9fc4b5d675cd6dc0b2503abe95b1c761d8d05abe (patch)
treeb547922481166d5279170a5bce58e58c03dcbbfc /rust-src/bch_bindgen/src/fs.rs
parent1ee7dc7a55273d34358a0ee525a9e823c999ffe6 (diff)
rust: Fix ptr casting in Fs::open()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'rust-src/bch_bindgen/src/fs.rs')
-rw-r--r--rust-src/bch_bindgen/src/fs.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/rust-src/bch_bindgen/src/fs.rs b/rust-src/bch_bindgen/src/fs.rs
index 1176846d..b26c51b6 100644
--- a/rust-src/bch_bindgen/src/fs.rs
+++ b/rust-src/bch_bindgen/src/fs.rs
@@ -9,15 +9,12 @@ pub struct Fs {
}
impl Fs {
- pub fn open(devices: &Vec<PathBuf>, opts: c::bch_opts) -> Result<Fs, bch_errcode> {
- let devices: Vec<_> = devices.iter()
- .map(|i| CString::new(i.as_os_str().as_bytes()).unwrap()).collect();
- let dev_c_strs: Vec<_> = devices.iter()
- .map(|i| { let p: *const i8 = i.as_ptr(); p })
+ pub fn open(devs: &Vec<PathBuf>, opts: c::bch_opts) -> Result<Fs, bch_errcode> {
+ let devs: Vec<_> = devs.iter()
+ .map(|i| CString::new(i.as_os_str().as_bytes()).unwrap().into_raw())
.collect();
- let dev_c_strarray: *const *mut i8 = dev_c_strs[..].as_ptr() as *const *mut i8;
- let ret = unsafe { c::bch2_fs_open(dev_c_strarray, dev_c_strs.len() as u32, opts) };
+ let ret = unsafe { c::bch2_fs_open(devs[..].as_ptr(), devs.len() as u32, opts) };
errptr_to_result(ret).map(|fs| Fs { raw: fs})
}