summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2003-07-19 00:34:22 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2003-07-19 00:34:22 +0000
commit68125796b8a6d42990a0d2da8dd5119594fc27fe (patch)
tree1322baab1ab1380ba262484ae15c9c18c3dc92af /firmware
parentb5b73045640f80dff419284e042ea30a06e8bbe3 (diff)
downloadrockbox-68125796b8a6d42990a0d2da8dd5119594fc27fe.tar.gz
rockbox-68125796b8a6d42990a0d2da8dd5119594fc27fe.zip
Another go at the disk-full FAT driver fix. Now it skips the reserved sectors at all times.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3847 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/fat.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c
index 099417baca..079bf1ea10 100644
--- a/firmware/drivers/fat.c
+++ b/firmware/drivers/fat.c
@@ -550,10 +550,6 @@ static unsigned int find_free_cluster(unsigned int startcluster)
550 unsigned int offset; 550 unsigned int offset;
551 unsigned int i; 551 unsigned int i;
552 552
553 /* Cluster 0 and 1 are reserved */
554 if(startcluster < 2)
555 startcluster = 2;
556
557 sector = startcluster / CLUSTERS_PER_FAT_SECTOR; 553 sector = startcluster / CLUSTERS_PER_FAT_SECTOR;
558 offset = startcluster % CLUSTERS_PER_FAT_SECTOR; 554 offset = startcluster % CLUSTERS_PER_FAT_SECTOR;
559 555
@@ -567,7 +563,9 @@ static unsigned int find_free_cluster(unsigned int startcluster)
567 int k = (j + offset) % CLUSTERS_PER_FAT_SECTOR; 563 int k = (j + offset) % CLUSTERS_PER_FAT_SECTOR;
568 if (!(SWAB32(fat[k]) & 0x0fffffff)) { 564 if (!(SWAB32(fat[k]) & 0x0fffffff)) {
569 unsigned int c = nr * CLUSTERS_PER_FAT_SECTOR + k; 565 unsigned int c = nr * CLUSTERS_PER_FAT_SECTOR + k;
570 if ( c > fat_bpb.dataclusters+1 ) /* nr 0 is unused */ 566 /* Ignore the reserved clusters 0 & 1, and also
567 cluster numbers out of bounds */
568 if ( c < 2 || c > fat_bpb.dataclusters+1 )
571 continue; 569 continue;
572 LDEBUGF("find_free_cluster(%x) == %x\n",startcluster,c); 570 LDEBUGF("find_free_cluster(%x) == %x\n",startcluster,c);
573 fat_bpb.fsinfo.nextfree = c; 571 fat_bpb.fsinfo.nextfree = c;