diff --git a/src/driver.rs b/src/driver.rs index acd19704d..3ca79fbaf 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -91,7 +91,7 @@ pub trait Storage { /// Read data from the storage device. /// Guaranteed to be called only with bufs of length a multiple of READ_SIZE. - fn read(&self, off: usize, buf: &mut [u8]) -> Result; + fn read(&mut self, off: usize, buf: &mut [u8]) -> Result; /// Write data to the storage device. /// Guaranteed to be called only with bufs of length a multiple of WRITE_SIZE. fn write(&mut self, off: usize, data: &[u8]) -> Result; diff --git a/src/fs.rs b/src/fs.rs index f40631292..9ea9ad8c9 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -505,7 +505,7 @@ impl Filesystem<'_, Storage> { size: ll::lfs_size_t, ) -> cty::c_int { // println!("in lfs_config_read for {} bytes", size); - let storage = unsafe { &*((*c).context as *const Storage) }; + let storage = unsafe { &mut *((*c).context as *mut Storage) }; debug_assert!(!c.is_null()); let block_size = unsafe { c.read().block_size }; let off = (block * block_size + off) as usize; diff --git a/src/macros.rs b/src/macros.rs index 6d4fd6a5b..326ab20fa 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -51,7 +51,7 @@ macro_rules! ram_storage { ( const BLOCK_COUNT: usize = $block_count; type LOOKAHEADWORDS_SIZE = $lookaheadwords_size; - fn read(&self, offset: usize, buf: &mut [u8]) -> $Result { + fn read(&mut self, offset: usize, buf: &mut [u8]) -> $Result { let read_size: usize = Self::READ_SIZE; debug_assert!(offset % read_size == 0); debug_assert!(buf.len() % read_size == 0); @@ -180,7 +180,7 @@ macro_rules! const_ram_storage { ( const BLOCK_COUNT: usize = $block_count; type LOOKAHEADWORDS_SIZE = $lookaheadwords_size; - fn read(&self, offset: usize, buf: &mut [u8]) -> $Result { + fn read(&mut self, offset: usize, buf: &mut [u8]) -> $Result { let read_size: usize = Self::READ_SIZE; debug_assert!(offset % read_size == 0); debug_assert!(buf.len() % read_size == 0);