From 41249b7059be332fb41099456fca26300297bdc2 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Wed, 16 Jul 2003 22:28:24 +0000 Subject: Fixed a bug that included the reserved clusters 0 and 1 in the search for available clusters. That could in some cases lead to a bogus disk-full error. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3836 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/fat.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 92ac2a3bf8..099417baca 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -546,10 +546,17 @@ static void *cache_fat_sector(int fatsector) static unsigned int find_free_cluster(unsigned int startcluster) { - unsigned int sector = startcluster / CLUSTERS_PER_FAT_SECTOR; - unsigned int offset = startcluster % CLUSTERS_PER_FAT_SECTOR; + unsigned int sector; + 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; + for (i = 0; i