// Reading the directory entries one by one means
// we won't need an as large buffer on the stack.
for i in 0..NUM_SECTORS {
- let address = i * SECTOR_SIZE;
- let mut chunk = [0u8; 4];
+ self.read_sector_header(i);
+ }
+ }
- self.storage.read(address, &mut chunk);
+ fn read_sector_header(&mut self, sector_index: usize) {
+ let address = sector_index * SECTOR_SIZE;
+ let mut chunk = [0u8; 4];
- let sector_header_ptr: *mut SectorHeader =
- &mut self.sector_header[i];
+ self.storage.read(address, &mut chunk);
- unsafe {
- core::ptr::copy(chunk.as_ptr(),
- sector_header_ptr as *mut u8,
- chunk.len());
- }
+ let sector_header_ptr: *mut SectorHeader =
+ &mut self.sector_header[sector_index];
+
+ unsafe {
+ core::ptr::copy(chunk.as_ptr(),
+ sector_header_ptr as *mut u8,
+ chunk.len());
}
}