summaryrefslogtreecommitdiff
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
parentb5b73045640f80dff419284e042ea30a06e8bbe3 (diff)
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
-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)
unsigned int offset;
unsigned int i;
- /* Cluster 0 and 1 are reserved */
- if(startcluster < 2)
- startcluster = 2;
-
sector = startcluster / CLUSTERS_PER_FAT_SECTOR;
offset = startcluster % CLUSTERS_PER_FAT_SECTOR;
@@ -567,7 +563,9 @@ static unsigned int find_free_cluster(unsigned int startcluster)
int k = (j + offset) % CLUSTERS_PER_FAT_SECTOR;
if (!(SWAB32(fat[k]) & 0x0fffffff)) {
unsigned int c = nr * CLUSTERS_PER_FAT_SECTOR + k;
- if ( c > fat_bpb.dataclusters+1 ) /* nr 0 is unused */
+ /* Ignore the reserved clusters 0 & 1, and also
+ cluster numbers out of bounds */
+ if ( c < 2 || c > fat_bpb.dataclusters+1 )
continue;
LDEBUGF("find_free_cluster(%x) == %x\n",startcluster,c);
fat_bpb.fsinfo.nextfree = c;