@@ -1720,6 +1720,11 @@ static int dosfs_volume_commit(dosfs_volume_t *volume)
1720
1720
if (status == F_NO_ERROR )
1721
1721
{
1722
1722
status = dosfs_dir_cache_read (volume , blkno , & entry );
1723
+
1724
+ if (status == F_NO_ERROR )
1725
+ {
1726
+ dir = (dosfs_dir_t * )((void * )(entry -> data ));
1727
+ }
1723
1728
}
1724
1729
}
1725
1730
@@ -1843,6 +1848,11 @@ static int dosfs_volume_commit(dosfs_volume_t *volume)
1843
1848
if (status == F_NO_ERROR )
1844
1849
{
1845
1850
status = dosfs_dir_cache_read (volume , blkno , & entry );
1851
+
1852
+ if (status == F_NO_ERROR )
1853
+ {
1854
+ dir = (dosfs_dir_t * )((void * )(entry -> data ));
1855
+ }
1846
1856
}
1847
1857
}
1848
1858
@@ -2411,26 +2421,23 @@ static int dosfs_volume_format(dosfs_volume_t *volume)
2411
2421
* this CHS range, then use the maximum value. This can only happen with FAT32,
2412
2422
* in which case the partition type signals to use LBA anyway.
2413
2423
*/
2414
- if (sys_id == 0x0c )
2415
- {
2416
- start_c = 1023 ;
2417
- start_h = 254 ;
2418
- start_s = 63 ;
2424
+
2425
+ start_c = boot_blkno / (hpc * spt );
2426
+ start_h = (boot_blkno - (start_c * hpc * spt )) / spt ;
2427
+ start_s = boot_blkno - (start_c * hpc * spt ) - (start_h * spt ) + 1 ;
2419
2428
2420
- end_c = 1023 ;
2421
- end_h = 254 ;
2422
- end_s = 63 ;
2423
- }
2424
- else
2429
+ if (blkcnt <= 16450560 )
2425
2430
{
2426
- start_c = boot_blkno / (hpc * spt );
2427
- start_h = (boot_blkno - (start_c * hpc * spt )) / spt ;
2428
- start_s = boot_blkno - (start_c * hpc * spt ) - (start_h * spt ) + 1 ;
2429
-
2430
2431
end_c = (blkcnt - 1 ) / (hpc * spt );
2431
2432
end_h = ((blkcnt - 1 ) - (end_c * hpc * spt )) / spt ;
2432
2433
end_s = (blkcnt - 1 ) - (end_c * hpc * spt ) - (end_h * spt ) + 1 ;
2433
2434
}
2435
+ else
2436
+ {
2437
+ end_c = 1023 ;
2438
+ end_h = 254 ;
2439
+ end_s = 63 ;
2440
+ }
2434
2441
2435
2442
/* Write the MBR */
2436
2443
@@ -7460,6 +7467,11 @@ static int dosfs_path_create_entry(dosfs_volume_t *volume, uint32_t clsno_d, uin
7460
7467
if (status == F_NO_ERROR )
7461
7468
{
7462
7469
status = dosfs_dir_cache_read (volume , blkno , & entry );
7470
+
7471
+ if (status == F_NO_ERROR )
7472
+ {
7473
+ dir = (dosfs_dir_t * )((void * )(entry -> data ));
7474
+ }
7463
7475
}
7464
7476
}
7465
7477
@@ -7603,6 +7615,11 @@ static int dosfs_path_destroy_entry(dosfs_volume_t *volume, uint32_t clsno, uint
7603
7615
if (status == F_NO_ERROR )
7604
7616
{
7605
7617
status = dosfs_dir_cache_read (volume , blkno , & entry );
7618
+
7619
+ if (status == F_NO_ERROR )
7620
+ {
7621
+ dir = (dosfs_dir_t * )((void * )(entry -> data ));
7622
+ }
7606
7623
}
7607
7624
}
7608
7625
0 commit comments