File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ pub struct DiskAccess {
88}
99
1010impl Read for DiskAccess {
11- fn read_exact ( & mut self , len : usize ) -> & [ u8 ] {
11+ unsafe fn read_exact ( & mut self , len : usize ) -> & [ u8 ] {
1212 let current_sector_offset = usize:: try_from ( self . current_offset % 512 ) . unwrap ( ) ;
1313
1414 static mut TMP_BUF : AlignedArrayBuffer < 1024 > = AlignedArrayBuffer {
@@ -70,7 +70,7 @@ impl Seek for DiskAccess {
7070}
7171
7272pub trait Read {
73- fn read_exact ( & mut self , len : usize ) -> & [ u8 ] ;
73+ unsafe fn read_exact ( & mut self , len : usize ) -> & [ u8 ] ;
7474 fn read_exact_into ( & mut self , len : usize , buf : & mut dyn AlignedBuffer ) ;
7575}
7676
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ struct Bpb {
3434impl Bpb {
3535 fn parse < D : Read + Seek > ( disk : & mut D ) -> Self {
3636 disk. seek ( SeekFrom :: Start ( 0 ) ) ;
37- let raw = disk. read_exact ( 512 ) ;
37+ let raw = unsafe { disk. read_exact ( 512 ) } ;
3838
3939 let bytes_per_sector = u16:: from_le_bytes ( raw[ 11 ..13 ] . try_into ( ) . unwrap ( ) ) ;
4040 let sectors_per_cluster = raw[ 13 ] ;
@@ -483,21 +483,21 @@ where
483483 FatType :: Fat32 => {
484484 let base = n as u64 * 4 ;
485485 disk. seek ( SeekFrom :: Start ( fat_start + base) ) ;
486- let buf = disk. read_exact ( 4 ) ;
486+ let buf = unsafe { disk. read_exact ( 4 ) } ;
487487 let buf: [ u8 ; 4 ] = buf. try_into ( ) . unwrap ( ) ;
488488 u32:: from_le_bytes ( buf) & 0x0FFFFFFF
489489 }
490490 FatType :: Fat16 => {
491491 let base = n as u64 * 2 ;
492492 disk. seek ( SeekFrom :: Start ( fat_start + base) ) ;
493- let buf = disk. read_exact ( 2 ) ;
493+ let buf = unsafe { disk. read_exact ( 2 ) } ;
494494 let buf: [ u8 ; 2 ] = buf. try_into ( ) . unwrap ( ) ;
495495 u16:: from_le_bytes ( buf) as u32
496496 }
497497 FatType :: Fat12 => {
498498 let base = n as u64 + ( n as u64 / 2 ) ;
499499 disk. seek ( SeekFrom :: Start ( fat_start + base) ) ;
500- let buf = disk. read_exact ( 2 ) ;
500+ let buf = unsafe { disk. read_exact ( 2 ) } ;
501501 let buf: [ u8 ; 2 ] = buf. try_into ( ) . unwrap ( ) ;
502502 let entry16 = u16:: from_le_bytes ( buf) ;
503503 if n & 1 == 0 {
You can’t perform that action at this time.
0 commit comments