summaryrefslogtreecommitdiffstats
path: root/firmware/drivers/fat.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/fat.c')
-rw-r--r--firmware/drivers/fat.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c
index f117119258..a4fa7aa933 100644
--- a/firmware/drivers/fat.c
+++ b/firmware/drivers/fat.c
@@ -2084,6 +2084,8 @@ long fat_readwrite( struct fat_file *file, long sectorcount,
numsec++;
if ( numsec > (long)fat_bpb->bpb_secperclus || !cluster ) {
long oldcluster = cluster;
+ long oldsector = sector;
+ long oldnumsec = numsec;
if (write)
cluster = next_write_cluster(file, cluster, &sector);
else {
@@ -2099,7 +2101,9 @@ long fat_readwrite( struct fat_file *file, long sectorcount,
if ( write ) {
/* remember last cluster, in case
we want to append to the file */
+ sector = oldsector;
cluster = oldcluster;
+ numsec = oldnumsec;
clusternum--;
i = -1; /* Error code */
break;