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 {
8
8
}
9
9
10
10
impl Read for DiskAccess {
11
- fn read_exact ( & mut self , len : usize ) -> & [ u8 ] {
11
+ unsafe fn read_exact ( & mut self , len : usize ) -> & [ u8 ] {
12
12
let current_sector_offset = usize:: try_from ( self . current_offset % 512 ) . unwrap ( ) ;
13
13
14
14
static mut TMP_BUF : AlignedArrayBuffer < 1024 > = AlignedArrayBuffer {
@@ -70,7 +70,7 @@ impl Seek for DiskAccess {
70
70
}
71
71
72
72
pub trait Read {
73
- fn read_exact ( & mut self , len : usize ) -> & [ u8 ] ;
73
+ unsafe fn read_exact ( & mut self , len : usize ) -> & [ u8 ] ;
74
74
fn read_exact_into ( & mut self , len : usize , buf : & mut dyn AlignedBuffer ) ;
75
75
}
76
76
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ struct Bpb {
34
34
impl Bpb {
35
35
fn parse < D : Read + Seek > ( disk : & mut D ) -> Self {
36
36
disk. seek ( SeekFrom :: Start ( 0 ) ) ;
37
- let raw = disk. read_exact ( 512 ) ;
37
+ let raw = unsafe { disk. read_exact ( 512 ) } ;
38
38
39
39
let bytes_per_sector = u16:: from_le_bytes ( raw[ 11 ..13 ] . try_into ( ) . unwrap ( ) ) ;
40
40
let sectors_per_cluster = raw[ 13 ] ;
@@ -483,21 +483,21 @@ where
483
483
FatType :: Fat32 => {
484
484
let base = n as u64 * 4 ;
485
485
disk. seek ( SeekFrom :: Start ( fat_start + base) ) ;
486
- let buf = disk. read_exact ( 4 ) ;
486
+ let buf = unsafe { disk. read_exact ( 4 ) } ;
487
487
let buf: [ u8 ; 4 ] = buf. try_into ( ) . unwrap ( ) ;
488
488
u32:: from_le_bytes ( buf) & 0x0FFFFFFF
489
489
}
490
490
FatType :: Fat16 => {
491
491
let base = n as u64 * 2 ;
492
492
disk. seek ( SeekFrom :: Start ( fat_start + base) ) ;
493
- let buf = disk. read_exact ( 2 ) ;
493
+ let buf = unsafe { disk. read_exact ( 2 ) } ;
494
494
let buf: [ u8 ; 2 ] = buf. try_into ( ) . unwrap ( ) ;
495
495
u16:: from_le_bytes ( buf) as u32
496
496
}
497
497
FatType :: Fat12 => {
498
498
let base = n as u64 + ( n as u64 / 2 ) ;
499
499
disk. seek ( SeekFrom :: Start ( fat_start + base) ) ;
500
- let buf = disk. read_exact ( 2 ) ;
500
+ let buf = unsafe { disk. read_exact ( 2 ) } ;
501
501
let buf: [ u8 ; 2 ] = buf. try_into ( ) . unwrap ( ) ;
502
502
let entry16 = u16:: from_le_bytes ( buf) ;
503
503
if n & 1 == 0 {
You can’t perform that action at this time.
0 commit comments