@@ -80,8 +80,9 @@ impl FatVolume {
8080 return Ok ( ( ) ) ;
8181 }
8282 let mut blocks = [ Block :: new ( ) ] ;
83+ trace ! ( "Reading info sector" ) ;
8384 block_device
84- . read ( & mut blocks, fat32_info. info_location , "read_info_sector" )
85+ . read ( & mut blocks, fat32_info. info_location )
8586 . map_err ( Error :: DeviceError ) ?;
8687 let block = & mut blocks[ 0 ] ;
8788 if let Some ( count) = self . free_clusters_count {
@@ -90,6 +91,7 @@ impl FatVolume {
9091 if let Some ( next_free_cluster) = self . next_free_cluster {
9192 block[ 492 ..496 ] . copy_from_slice ( & next_free_cluster. 0 . to_le_bytes ( ) ) ;
9293 }
94+ trace ! ( "Writing info sector" ) ;
9395 block_device
9496 . write ( & blocks, fat32_info. info_location )
9597 . map_err ( Error :: DeviceError ) ?;
@@ -123,8 +125,9 @@ impl FatVolume {
123125 let fat_offset = cluster. 0 * 2 ;
124126 this_fat_block_num = self . lba_start + self . fat_start . offset_bytes ( fat_offset) ;
125127 let this_fat_ent_offset = ( fat_offset % Block :: LEN_U32 ) as usize ;
128+ trace ! ( "Reading FAT" ) ;
126129 block_device
127- . read ( & mut blocks, this_fat_block_num, "read_fat" )
130+ . read ( & mut blocks, this_fat_block_num)
128131 . map_err ( Error :: DeviceError ) ?;
129132 // See <https://en.wikipedia.org/wiki/Design_of_the_FAT_file_system>
130133 let entry = match new_value {
@@ -144,8 +147,9 @@ impl FatVolume {
144147 let fat_offset = cluster. 0 * 4 ;
145148 this_fat_block_num = self . lba_start + self . fat_start . offset_bytes ( fat_offset) ;
146149 let this_fat_ent_offset = ( fat_offset % Block :: LEN_U32 ) as usize ;
150+ trace ! ( "Reading FAT" ) ;
147151 block_device
148- . read ( & mut blocks, this_fat_block_num, "read_fat" )
152+ . read ( & mut blocks, this_fat_block_num)
149153 . map_err ( Error :: DeviceError ) ?;
150154 let entry = match new_value {
151155 ClusterId :: INVALID => 0x0FFF_FFF6 ,
@@ -163,6 +167,7 @@ impl FatVolume {
163167 ) ;
164168 }
165169 }
170+ trace ! ( "Writing FAT" ) ;
166171 block_device
167172 . write ( & blocks, this_fat_block_num)
168173 . map_err ( Error :: DeviceError ) ?;
@@ -187,8 +192,8 @@ impl FatVolume {
187192 let fat_offset = cluster. 0 * 2 ;
188193 let this_fat_block_num = self . lba_start + self . fat_start . offset_bytes ( fat_offset) ;
189194 let this_fat_ent_offset = ( fat_offset % Block :: LEN_U32 ) as usize ;
190- let block =
191- fat_block_cache. read ( block_device, this_fat_block_num, "next_cluster" ) ?;
195+ trace ! ( "Reading FAT" ) ;
196+ let block = fat_block_cache. read ( block_device, this_fat_block_num) ?;
192197 let fat_entry =
193198 LittleEndian :: read_u16 ( & block[ this_fat_ent_offset..=this_fat_ent_offset + 1 ] ) ;
194199 match fat_entry {
@@ -210,8 +215,8 @@ impl FatVolume {
210215 let fat_offset = cluster. 0 * 4 ;
211216 let this_fat_block_num = self . lba_start + self . fat_start . offset_bytes ( fat_offset) ;
212217 let this_fat_ent_offset = ( fat_offset % Block :: LEN_U32 ) as usize ;
213- let block =
214- fat_block_cache. read ( block_device, this_fat_block_num, "next_cluster" ) ?;
218+ trace ! ( "Reading FAT" ) ;
219+ let block = fat_block_cache. read ( block_device, this_fat_block_num) ?;
215220 let fat_entry =
216221 LittleEndian :: read_u32 ( & block[ this_fat_ent_offset..=this_fat_ent_offset + 3 ] )
217222 & 0x0FFF_FFFF ;
@@ -310,8 +315,9 @@ impl FatVolume {
310315 let mut blocks = [ Block :: new ( ) ] ;
311316 while let Some ( cluster) = current_cluster {
312317 for block in first_dir_block_num. range ( dir_size) {
318+ trace ! ( "Reading directory" ) ;
313319 block_device
314- . read ( & mut blocks, block, "read_dir" )
320+ . read ( & mut blocks, block)
315321 . map_err ( Error :: DeviceError ) ?;
316322 for ( i, dir_entry_bytes) in
317323 blocks[ 0 ] . chunks_exact_mut ( OnDiskDirEntry :: LEN ) . enumerate ( )
@@ -330,6 +336,7 @@ impl FatVolume {
330336 ) ;
331337 dir_entry_bytes
332338 . copy_from_slice ( & entry. serialize ( FatType :: Fat16 ) [ ..] ) ;
339+ trace ! ( "Updating directory" ) ;
333340 block_device
334341 . write ( & blocks, block)
335342 . map_err ( Error :: DeviceError ) ?;
@@ -375,8 +382,9 @@ impl FatVolume {
375382 // Loop through the blocks in the cluster
376383 for block in first_dir_block_num. range ( dir_size) {
377384 // Read a block of directory entries
385+ trace ! ( "Reading directory" ) ;
378386 block_device
379- . read ( & mut blocks, block, "read_dir" )
387+ . read ( & mut blocks, block)
380388 . map_err ( Error :: DeviceError ) ?;
381389 // Are any entries in the block we just loaded blank? If so
382390 // we can use them.
@@ -397,6 +405,7 @@ impl FatVolume {
397405 ) ;
398406 dir_entry_bytes
399407 . copy_from_slice ( & entry. serialize ( FatType :: Fat32 ) [ ..] ) ;
408+ trace ! ( "Updating directory" ) ;
400409 block_device
401410 . write ( & blocks, block)
402411 . map_err ( Error :: DeviceError ) ?;
@@ -481,7 +490,8 @@ impl FatVolume {
481490 let mut block_cache = BlockCache :: empty ( ) ;
482491 while let Some ( cluster) = current_cluster {
483492 for block_idx in first_dir_block_num. range ( dir_size) {
484- let block = block_cache. read ( block_device, block_idx, "read_dir" ) ?;
493+ trace ! ( "Reading FAT" ) ;
494+ let block = block_cache. read ( block_device, block_idx) ?;
485495 for ( i, dir_entry_bytes) in block. chunks_exact ( OnDiskDirEntry :: LEN ) . enumerate ( ) {
486496 let dir_entry = OnDiskDirEntry :: new ( dir_entry_bytes) ;
487497 if dir_entry. is_end ( ) {
@@ -532,8 +542,9 @@ impl FatVolume {
532542 while let Some ( cluster) = current_cluster {
533543 let block_idx = self . cluster_to_block ( cluster) ;
534544 for block in block_idx. range ( BlockCount ( u32:: from ( self . blocks_per_cluster ) ) ) {
545+ trace ! ( "Reading FAT" ) ;
535546 block_device
536- . read ( & mut blocks, block, "read_dir" )
547+ . read ( & mut blocks, block)
537548 . map_err ( Error :: DeviceError ) ?;
538549 for ( i, dir_entry_bytes) in
539550 blocks[ 0 ] . chunks_exact_mut ( OnDiskDirEntry :: LEN ) . enumerate ( )
@@ -658,8 +669,9 @@ impl FatVolume {
658669 D : BlockDevice ,
659670 {
660671 let mut blocks = [ Block :: new ( ) ] ;
672+ trace ! ( "Reading directory" ) ;
661673 block_device
662- . read ( & mut blocks, block, "read_dir" )
674+ . read ( & mut blocks, block)
663675 . map_err ( Error :: DeviceError ) ?;
664676 for ( i, dir_entry_bytes) in blocks[ 0 ] . chunks_exact_mut ( OnDiskDirEntry :: LEN ) . enumerate ( ) {
665677 let dir_entry = OnDiskDirEntry :: new ( dir_entry_bytes) ;
@@ -792,8 +804,9 @@ impl FatVolume {
792804 D : BlockDevice ,
793805 {
794806 let mut blocks = [ Block :: new ( ) ] ;
807+ trace ! ( "Reading directory" ) ;
795808 block_device
796- . read ( & mut blocks, block, "read_dir" )
809+ . read ( & mut blocks, block)
797810 . map_err ( Error :: DeviceError ) ?;
798811 for ( i, dir_entry_bytes) in blocks[ 0 ] . chunks_exact_mut ( OnDiskDirEntry :: LEN ) . enumerate ( ) {
799812 let dir_entry = OnDiskDirEntry :: new ( dir_entry_bytes) ;
@@ -805,6 +818,7 @@ impl FatVolume {
805818 let start = i * OnDiskDirEntry :: LEN ;
806819 // set first byte to the 'unused' marker
807820 blocks[ 0 ] . contents [ start] = 0xE5 ;
821+ trace ! ( "Updating directory" ) ;
808822 return block_device
809823 . write ( & blocks, block)
810824 . map_err ( Error :: DeviceError ) ;
@@ -842,7 +856,7 @@ impl FatVolume {
842856 . map_err ( |_| Error :: ConversionError ) ?;
843857 trace ! ( "Reading block {:?}" , this_fat_block_num) ;
844858 block_device
845- . read ( & mut blocks, this_fat_block_num, "next_cluster" )
859+ . read ( & mut blocks, this_fat_block_num)
846860 . map_err ( Error :: DeviceError ) ?;
847861
848862 while this_fat_ent_offset <= Block :: LEN - 2 {
@@ -873,7 +887,7 @@ impl FatVolume {
873887 . map_err ( |_| Error :: ConversionError ) ?;
874888 trace ! ( "Reading block {:?}" , this_fat_block_num) ;
875889 block_device
876- . read ( & mut blocks, this_fat_block_num, "next_cluster" )
890+ . read ( & mut blocks, this_fat_block_num)
877891 . map_err ( Error :: DeviceError ) ?;
878892
879893 while this_fat_ent_offset <= Block :: LEN - 4 {
@@ -969,6 +983,7 @@ impl FatVolume {
969983 let first_block = self . cluster_to_block ( new_cluster) ;
970984 let num_blocks = BlockCount ( u32:: from ( self . blocks_per_cluster ) ) ;
971985 for block in first_block. range ( num_blocks) {
986+ trace ! ( "Zeroing cluster" ) ;
972987 block_device
973988 . write ( & blocks, block)
974989 . map_err ( Error :: DeviceError ) ?;
@@ -1041,14 +1056,16 @@ impl FatVolume {
10411056 FatSpecificInfo :: Fat32 ( _) => FatType :: Fat32 ,
10421057 } ;
10431058 let mut blocks = [ Block :: new ( ) ] ;
1059+ trace ! ( "Reading directory for update" ) ;
10441060 block_device
1045- . read ( & mut blocks, entry. entry_block , "read" )
1061+ . read ( & mut blocks, entry. entry_block )
10461062 . map_err ( Error :: DeviceError ) ?;
10471063 let block = & mut blocks[ 0 ] ;
10481064
10491065 let start = usize:: try_from ( entry. entry_offset ) . map_err ( |_| Error :: ConversionError ) ?;
10501066 block[ start..start + 32 ] . copy_from_slice ( & entry. serialize ( fat_type) [ ..] ) ;
10511067
1068+ trace ! ( "Updating directory" ) ;
10521069 block_device
10531070 . write ( & blocks, entry. entry_block )
10541071 . map_err ( Error :: DeviceError ) ?;
@@ -1068,8 +1085,9 @@ where
10681085 D :: Error : core:: fmt:: Debug ,
10691086{
10701087 let mut blocks = [ Block :: new ( ) ] ;
1088+ trace ! ( "Reading BPB" ) ;
10711089 block_device
1072- . read ( & mut blocks, lba_start, "read_bpb" )
1090+ . read ( & mut blocks, lba_start)
10731091 . map_err ( Error :: DeviceError ) ?;
10741092 let block = & blocks[ 0 ] ;
10751093 let bpb = Bpb :: create_from_bytes ( block) . map_err ( Error :: FormatError ) ?;
@@ -1112,12 +1130,9 @@ where
11121130 // Safe to unwrap since this is a Fat32 Type
11131131 let info_location = bpb. fs_info_block ( ) . unwrap ( ) ;
11141132 let mut info_blocks = [ Block :: new ( ) ] ;
1133+ trace ! ( "Reading info block" ) ;
11151134 block_device
1116- . read (
1117- & mut info_blocks,
1118- lba_start + info_location,
1119- "read_info_sector" ,
1120- )
1135+ . read ( & mut info_blocks, lba_start + info_location)
11211136 . map_err ( Error :: DeviceError ) ?;
11221137 let info_block = & info_blocks[ 0 ] ;
11231138 let info_sector =
0 commit comments