diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2003-07-16 22:28:24 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2003-07-16 22:28:24 +0000 |
commit | 41249b7059be332fb41099456fca26300297bdc2 (patch) | |
tree | 60f3212221aa3629dc610503c3a5b5a74f4e4e43 | |
parent | 50192e87dc27d7b81bcba1f643bcea6f0c0428f2 (diff) | |
download | rockbox-41249b7059be332fb41099456fca26300297bdc2.tar.gz rockbox-41249b7059be332fb41099456fca26300297bdc2.zip |
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
-rw-r--r-- | firmware/drivers/fat.c | 11 |
1 files 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) | |||
546 | 546 | ||
547 | static unsigned int find_free_cluster(unsigned int startcluster) | 547 | static unsigned int find_free_cluster(unsigned int startcluster) |
548 | { | 548 | { |
549 | unsigned int sector = startcluster / CLUSTERS_PER_FAT_SECTOR; | 549 | unsigned int sector; |
550 | unsigned int offset = startcluster % CLUSTERS_PER_FAT_SECTOR; | 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; | ||
558 | offset = startcluster % CLUSTERS_PER_FAT_SECTOR; | ||
559 | |||
553 | for (i = 0; i<fat_bpb.fatsize; i++) { | 560 | for (i = 0; i<fat_bpb.fatsize; i++) { |
554 | unsigned int j; | 561 | unsigned int j; |
555 | unsigned int nr = (i + sector) % fat_bpb.fatsize; | 562 | unsigned int nr = (i + sector) % fat_bpb.fatsize; |