@@ -1100,7 +1100,7 @@ static int dosfs_volume_read(dosfs_volume_t *volume, uint32_t address, uint8_t *
1100
1100
1101
1101
do
1102
1102
{
1103
- status = (* volume -> interface -> read_sequential )(volume -> context , address , 1 , data );
1103
+ status = (* volume -> interface -> read )(volume -> context , address , 1 , data );
1104
1104
1105
1105
if ((status == F_ERR_ONDRIVE ) && (retries >= 1 ))
1106
1106
{
@@ -1143,7 +1143,7 @@ static int dosfs_volume_write(dosfs_volume_t *volume, uint32_t address, const ui
1143
1143
1144
1144
do
1145
1145
{
1146
- status = (* volume -> interface -> write )(volume -> context , address , data );
1146
+ status = (* volume -> interface -> write )(volume -> context , address , 1 , data , NULL );
1147
1147
1148
1148
if ((status == F_ERR_ONDRIVE ) && (retries >= 1 ))
1149
1149
{
@@ -1183,7 +1183,7 @@ static int dosfs_volume_write(dosfs_volume_t *volume, uint32_t address, const ui
1183
1183
static int dosfs_volume_zero (dosfs_volume_t * volume , uint32_t address , uint32_t length , volatile uint8_t * p_status )
1184
1184
{
1185
1185
int status = F_NO_ERROR ;
1186
- uint8_t * data ;
1186
+ uint8_t * data , zero_status ;
1187
1187
1188
1188
status = dosfs_dir_cache_flush (volume );
1189
1189
@@ -1194,9 +1194,11 @@ static int dosfs_volume_zero(dosfs_volume_t *volume, uint32_t address, uint32_t
1194
1194
1195
1195
memset (data , 0 , DOSFS_BLK_SIZE );
1196
1196
1197
+ zero_status = F_NO_ERROR ;
1198
+
1197
1199
do
1198
1200
{
1199
- status = (* volume -> interface -> write_sequential )(volume -> context , address , 1 , data , p_status );
1201
+ status = (* volume -> interface -> write )(volume -> context , address , 1 , data , ( p_status ? p_status : & zero_status ) );
1200
1202
1201
1203
if (status == F_NO_ERROR )
1202
1204
{
@@ -1207,6 +1209,19 @@ static int dosfs_volume_zero(dosfs_volume_t *volume, uint32_t address, uint32_t
1207
1209
length -- ;
1208
1210
}
1209
1211
while ((status == F_NO_ERROR ) && length );
1212
+
1213
+ if (p_status == NULL )
1214
+ {
1215
+ if (status == F_NO_ERROR )
1216
+ {
1217
+ status = (* volume -> interface -> sync )(volume -> context );
1218
+
1219
+ if (status == F_NO_ERROR )
1220
+ {
1221
+ status = zero_status ;
1222
+ }
1223
+ }
1224
+ }
1210
1225
}
1211
1226
1212
1227
#if (DOSFS_CONFIG_MEDIA_FAILURE_SUPPORTED == 1 )
@@ -1218,11 +1233,6 @@ static int dosfs_volume_zero(dosfs_volume_t *volume, uint32_t address, uint32_t
1218
1233
1219
1234
if (p_status == NULL )
1220
1235
{
1221
- if (status == F_NO_ERROR )
1222
- {
1223
- status = (* volume -> interface -> sync )(volume -> context , NULL );
1224
- }
1225
-
1226
1236
if (status != F_NO_ERROR )
1227
1237
{
1228
1238
if (status != F_ERR_CARDREMOVED )
@@ -2738,7 +2748,7 @@ static int dosfs_dir_cache_write(dosfs_volume_t *volume)
2738
2748
{
2739
2749
dosfs_file_t * file = volume -> data_file ;
2740
2750
2741
- status = (* volume -> interface -> write_sequential )(volume -> context , volume -> dir_cache .blkno , 1 , volume -> dir_cache .data , & file -> status );
2751
+ status = (* volume -> interface -> write )(volume -> context , volume -> dir_cache .blkno , 1 , volume -> dir_cache .data , & file -> status );
2742
2752
2743
2753
#if (DOSFS_CONFIG_MEDIA_FAILURE_SUPPORTED == 1 )
2744
2754
if (status == F_ERR_INVALIDSECTOR )
@@ -3682,7 +3692,7 @@ static int dosfs_data_cache_write(dosfs_volume_t *volume, dosfs_file_t *file)
3682
3692
{
3683
3693
int status = F_NO_ERROR ;
3684
3694
3685
- status = (* volume -> interface -> write_sequential )(volume -> context , file -> data_cache .blkno , 1 , file -> data_cache .data , & file -> status );
3695
+ status = (* volume -> interface -> write )(volume -> context , file -> data_cache .blkno , 1 , file -> data_cache .data , & file -> status );
3686
3696
3687
3697
#if (DOSFS_CONFIG_MEDIA_FAILURE_SUPPORTED == 1 )
3688
3698
if (status == F_ERR_INVALIDSECTOR )
@@ -3738,7 +3748,7 @@ static int dosfs_data_cache_fill(dosfs_volume_t *volume, dosfs_file_t *file, uin
3738
3748
}
3739
3749
else
3740
3750
{
3741
- status = (* volume -> interface -> read_sequential )(volume -> context , blkno , 1 , file -> data_cache .data );
3751
+ status = (* volume -> interface -> read )(volume -> context , blkno , 1 , file -> data_cache .data );
3742
3752
3743
3753
#if (DOSFS_CONFIG_MEDIA_FAILURE_SUPPORTED == 1 )
3744
3754
if (status == F_ERR_INVALIDSECTOR )
@@ -3844,7 +3854,7 @@ static int dosfs_data_cache_write(dosfs_volume_t *volume, dosfs_file_t *file)
3844
3854
{
3845
3855
int status = F_NO_ERROR ;
3846
3856
3847
- status = (* volume -> interface -> write_sequential )(volume -> context , volume -> data_cache .blkno , 1 , volume -> data_cache .data , & file -> status );
3857
+ status = (* volume -> interface -> write )(volume -> context , volume -> data_cache .blkno , 1 , volume -> data_cache .data , & file -> status );
3848
3858
3849
3859
#if (DOSFS_CONFIG_MEDIA_FAILURE_SUPPORTED == 1 )
3850
3860
if (status == F_ERR_INVALIDSECTOR )
@@ -3899,7 +3909,7 @@ static int dosfs_data_cache_fill(dosfs_volume_t *volume, dosfs_file_t *file, uin
3899
3909
}
3900
3910
else
3901
3911
{
3902
- status = (* volume -> interface -> read_sequential )(volume -> context , blkno , 1 , volume -> data_cache .data );
3912
+ status = (* volume -> interface -> read )(volume -> context , blkno , 1 , volume -> data_cache .data );
3903
3913
3904
3914
#if (DOSFS_CONFIG_MEDIA_FAILURE_SUPPORTED == 1 )
3905
3915
if (status == F_ERR_INVALIDSECTOR )
@@ -4043,7 +4053,7 @@ static int dosfs_data_cache_fill(dosfs_volume_t *volume, dosfs_file_t *file, uin
4043
4053
}
4044
4054
else
4045
4055
{
4046
- status = (* volume -> interface -> read_sequential )(volume -> context , blkno , 1 , volume -> dir_cache .data );
4056
+ status = (* volume -> interface -> read )(volume -> context , blkno , 1 , volume -> dir_cache .data );
4047
4057
4048
4058
#if (DOSFS_CONFIG_MEDIA_FAILURE_SUPPORTED == 1 )
4049
4059
if (status == F_ERR_INVALIDSECTOR )
@@ -7865,7 +7875,7 @@ static int dosfs_file_flush(dosfs_volume_t *volume, dosfs_file_t *file, int clos
7865
7875
7866
7876
if (status == F_NO_ERROR )
7867
7877
{
7868
- status = (* volume -> interface -> sync )(volume -> context , & file -> status );
7878
+ status = (* volume -> interface -> sync )(volume -> context );
7869
7879
}
7870
7880
7871
7881
if (file -> status == F_NO_ERROR )
@@ -8515,7 +8525,7 @@ static int dosfs_file_extend(dosfs_volume_t *volume, dosfs_file_t *file, uint32_
8515
8525
static int dosfs_file_reserve (dosfs_volume_t * volume , dosfs_file_t * file , uint32_t size )
8516
8526
{
8517
8527
int status = F_NO_ERROR ;
8518
- uint32_t clsno_a , clscnt ;
8528
+ uint32_t clsno_a , clscnt , blkno , blkno_e ;
8519
8529
8520
8530
clscnt = DOSFS_SIZE_TO_CLSCNT (size );
8521
8531
clscnt = ((((clscnt << volume -> cls_blk_shift ) + (volume -> blk_unit_size - 1 )) / volume -> blk_unit_size ) * volume -> blk_unit_size ) >> volume -> cls_blk_shift ;
@@ -8543,6 +8553,19 @@ static int dosfs_file_reserve(dosfs_volume_t *volume, dosfs_file_t *file, uint32
8543
8553
*/
8544
8554
8545
8555
status = dosfs_file_sync (volume , file , FALSE, FALSE, file -> first_clsno , file -> length );
8556
+
8557
+ if (status == F_NO_ERROR )
8558
+ {
8559
+ for (blkno = file -> blkno , blkno_e = blkno + (clscnt << volume -> cls_blk_shift ); blkno < blkno_e ; blkno += volume -> blk_unit_size )
8560
+ {
8561
+ status = (* volume -> interface -> erase )(volume -> context , blkno , volume -> blk_unit_size );
8562
+
8563
+ if (status != F_NO_ERROR )
8564
+ {
8565
+ break ;
8566
+ }
8567
+ }
8568
+ }
8546
8569
}
8547
8570
}
8548
8571
@@ -9040,7 +9063,7 @@ static int dosfs_file_read(dosfs_volume_t *volume, dosfs_file_t *file, uint8_t *
9040
9063
9041
9064
if (status == F_NO_ERROR )
9042
9065
{
9043
- status = (* volume -> interface -> read_sequential )(volume -> context , blkno , blkcnt , data );
9066
+ status = (* volume -> interface -> read )(volume -> context , blkno , blkcnt , data );
9044
9067
9045
9068
#if (DOSFS_CONFIG_MEDIA_FAILURE_SUPPORTED == 1 )
9046
9069
if (status == F_ERR_INVALIDSECTOR )
@@ -9336,7 +9359,7 @@ static int dosfs_file_write(dosfs_volume_t *volume, dosfs_file_t *file, const ui
9336
9359
9337
9360
if (status == F_NO_ERROR )
9338
9361
{
9339
- status = (* volume -> interface -> write_sequential )(volume -> context , blkno , blkcnt , data , & file -> status );
9362
+ status = (* volume -> interface -> write )(volume -> context , blkno , blkcnt , data , & file -> status );
9340
9363
9341
9364
#if (DOSFS_CONFIG_MEDIA_FAILURE_SUPPORTED == 1 )
9342
9365
if (status == F_ERR_INVALIDSECTOR )
@@ -9372,7 +9395,12 @@ static int dosfs_file_write(dosfs_volume_t *volume, dosfs_file_t *file, const ui
9372
9395
{
9373
9396
if (file -> mode & DOSFS_FILE_MODE_COMMIT )
9374
9397
{
9375
- status = (* volume -> interface -> sync )(volume -> context , & file -> status );
9398
+ status = (* volume -> interface -> sync )(volume -> context );
9399
+ }
9400
+
9401
+ if (file -> status != F_NO_ERROR )
9402
+ {
9403
+ status = file -> status ;
9376
9404
}
9377
9405
9378
9406
if (status == F_NO_ERROR )
@@ -9528,36 +9556,6 @@ int f_hardformat(int fattype)
9528
9556
}
9529
9557
9530
9558
9531
- int f_reclaim (long size )
9532
- {
9533
- int status = F_NO_ERROR ;
9534
- dosfs_volume_t * volume ;
9535
-
9536
- volume = DOSFS_DEFAULT_VOLUME ();
9537
-
9538
- status = dosfs_volume_lock (volume );
9539
-
9540
- if (status == F_NO_ERROR )
9541
- {
9542
- if (volume -> flags & DOSFS_VOLUME_FLAG_WRITE_PROTECTED )
9543
- {
9544
- status = F_ERR_WRITEPROTECT ;
9545
- }
9546
- else
9547
- {
9548
- if (status == F_NO_ERROR )
9549
- {
9550
- status = (* volume -> interface -> reclaim )(volume -> context , (size + (DOSFS_BLK_SIZE - 1 )) / DOSFS_BLK_SIZE );
9551
- }
9552
- }
9553
-
9554
- status = dosfs_volume_unlock (volume , status );
9555
- }
9556
-
9557
- return status ;
9558
- }
9559
-
9560
-
9561
9559
int f_getfreespace (F_SPACE * pspace )
9562
9560
{
9563
9561
int status = F_NO_ERROR ;
@@ -11579,7 +11577,7 @@ int f_rewind(F_FILE *file)
11579
11577
11580
11578
if (status == F_NO_ERROR )
11581
11579
{
11582
- status = (* volume -> interface -> sync )(volume -> context , & file -> status );
11580
+ status = (* volume -> interface -> sync )(volume -> context );
11583
11581
11584
11582
if (status == F_NO_ERROR )
11585
11583
{
0 commit comments