diff options
-rw-r--r-- | firmware/common/file.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c index 623e898257..81b5a194c0 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c | |||
@@ -457,18 +457,15 @@ static int readwrite(int fd, void* buf, int count, bool write) | |||
457 | nread = headbytes; | 457 | nread = headbytes; |
458 | count -= headbytes; | 458 | count -= headbytes; |
459 | } | 459 | } |
460 | 460 | ||
461 | /* if buffer has been modified, write it back to disk */ | 461 | /* If the buffer has been modified, either it has been flushed already |
462 | if (nread && file->dirty) { | 462 | * (if (offs+headbytes == SECTOR_SIZE)...) or does not need to be (no |
463 | rc = flush_cache(fd); | 463 | * more data to follow in this call). Do NOT flush here. */ |
464 | if (rc < 0) | ||
465 | return rc * 10 - 3; | ||
466 | } | ||
467 | 464 | ||
468 | /* read/write whole sectors right into/from the supplied buffer */ | 465 | /* read/write whole sectors right into/from the supplied buffer */ |
469 | sectors = count / SECTOR_SIZE; | 466 | sectors = count / SECTOR_SIZE; |
470 | if ( sectors ) { | 467 | if ( sectors ) { |
471 | int rc = fat_readwrite(&(file->fatfile), sectors, | 468 | int rc = fat_readwrite(&(file->fatfile), sectors, |
472 | (unsigned char*)buf+nread, write ); | 469 | (unsigned char*)buf+nread, write ); |
473 | if ( rc < 0 ) { | 470 | if ( rc < 0 ) { |
474 | DEBUGF("Failed read/writing %d sectors\n",sectors); | 471 | DEBUGF("Failed read/writing %d sectors\n",sectors); |