diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/fat.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index ac6d240d8e..92ac2a3bf8 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c | |||
@@ -410,10 +410,10 @@ int fat_mount(int startsector) | |||
410 | } | 410 | } |
411 | 411 | ||
412 | LDEBUGF("Freecount: %d\n",fat_bpb.fsinfo.freecount); | 412 | LDEBUGF("Freecount: %d\n",fat_bpb.fsinfo.freecount); |
413 | LDEBUGF("Nextfree: %x\n",fat_bpb.fsinfo.nextfree); | 413 | LDEBUGF("Nextfree: 0x%x\n",fat_bpb.fsinfo.nextfree); |
414 | LDEBUGF("Cluster count: %x\n",fat_bpb.dataclusters); | 414 | LDEBUGF("Cluster count: 0x%x\n",fat_bpb.dataclusters); |
415 | LDEBUGF("Sectors per cluster: %d\n",fat_bpb.bpb_secperclus); | 415 | LDEBUGF("Sectors per cluster: %d\n",fat_bpb.bpb_secperclus); |
416 | LDEBUGF("FAT sectors: %x\n",fat_bpb.fatsize); | 416 | LDEBUGF("FAT sectors: 0x%x\n",fat_bpb.fatsize); |
417 | 417 | ||
418 | return 0; | 418 | return 0; |
419 | } | 419 | } |
@@ -550,10 +550,6 @@ static unsigned int find_free_cluster(unsigned int startcluster) | |||
550 | unsigned int offset = startcluster % CLUSTERS_PER_FAT_SECTOR; | 550 | unsigned int offset = startcluster % CLUSTERS_PER_FAT_SECTOR; |
551 | unsigned int i; | 551 | unsigned int i; |
552 | 552 | ||
553 | /* don't waste time scanning if the disk is already full */ | ||
554 | if (!fat_bpb.fsinfo.freecount) | ||
555 | return 0; | ||
556 | |||
557 | for (i = 0; i<fat_bpb.fatsize; i++) { | 553 | for (i = 0; i<fat_bpb.fatsize; i++) { |
558 | unsigned int j; | 554 | unsigned int j; |
559 | unsigned int nr = (i + sector) % fat_bpb.fatsize; | 555 | unsigned int nr = (i + sector) % fat_bpb.fatsize; |
@@ -600,7 +596,8 @@ static int update_fat_entry(unsigned int entry, unsigned int val) | |||
600 | fat_cache[(sector + fat_bpb.bpb_rsvdseccnt) & FAT_CACHE_MASK].dirty = true; | 596 | fat_cache[(sector + fat_bpb.bpb_rsvdseccnt) & FAT_CACHE_MASK].dirty = true; |
601 | 597 | ||
602 | if ( val ) { | 598 | if ( val ) { |
603 | if (!(SWAB32(sec[offset]) & 0x0fffffff)) | 599 | if (!(SWAB32(sec[offset]) & 0x0fffffff) && |
600 | fat_bpb.fsinfo.freecount > 0) | ||
604 | fat_bpb.fsinfo.freecount--; | 601 | fat_bpb.fsinfo.freecount--; |
605 | } | 602 | } |
606 | else { | 603 | else { |
@@ -1547,6 +1544,8 @@ int fat_readwrite( struct fat_file *file, int sectorcount, | |||
1547 | we want to append to the file */ | 1544 | we want to append to the file */ |
1548 | cluster = oldcluster; | 1545 | cluster = oldcluster; |
1549 | clusternum--; | 1546 | clusternum--; |
1547 | i = -1; /* Error code */ | ||
1548 | break; | ||
1550 | } | 1549 | } |
1551 | } | 1550 | } |
1552 | else | 1551 | else |
@@ -1598,6 +1597,7 @@ int fat_readwrite( struct fat_file *file, int sectorcount, | |||
1598 | if (eof) | 1597 | if (eof) |
1599 | i--; | 1598 | i--; |
1600 | 1599 | ||
1600 | DEBUGF("Sectors written: %d\n", i); | ||
1601 | return i; | 1601 | return i; |
1602 | } | 1602 | } |
1603 | 1603 | ||