diff options
| author | Björn Stenberg <bjorn@haxx.se> | 2002-11-05 14:46:27 +0000 |
|---|---|---|
| committer | Björn Stenberg <bjorn@haxx.se> | 2002-11-05 14:46:27 +0000 |
| commit | 0e51fefda68c0651bdc3847d30e9644fff840569 (patch) | |
| tree | 7ce8117ad3691567a09c9f22cc8f355fa082099d | |
| parent | ab0dce026489391e8a4426e0cb6e6779814cdb2c (diff) | |
| download | rockbox-0e51fefda68c0651bdc3847d30e9644fff840569.zip rockbox-0e51fefda68c0651bdc3847d30e9644fff840569.tar.gz rockbox-0e51fefda68c0651bdc3847d30e9644fff840569.tar.bz2 rockbox-0e51fefda68c0651bdc3847d30e9644fff840569.tar.xz | |
Bug fixes: fat_seek(0) would sometimes start at sector 1. find_free_cluster() didn't find all free clusters.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2806 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | firmware/drivers/fat.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 26149d4..fc6b33b 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -331,6 +331,7 @@ int fat_mount(int startsector) LDEBUGF("Freecount: %x\n",fat_bpb.fsinfo.freecount); LDEBUGF("Nextfree: %x\n",fat_bpb.fsinfo.nextfree); LDEBUGF("Cluster count: %x\n",fat_bpb.dataclusters); + LDEBUGF("Sectors per cluster: %d\n",fat_bpb.bpb_secperclus); LDEBUGF("FAT sectors: %x\n",fat_bpb.fatsize); return 0; @@ -442,11 +443,12 @@ static int find_free_cluster(int startcluster) unsigned int* fat = cache_fat_sector(nr); if ( !fat ) break; - for (j = offset; j < CLUSTERS_PER_FAT_SECTOR; j++) { - if (!(SWAB32(fat[j]) & 0x0fffffff)) { - int c = nr * CLUSTERS_PER_FAT_SECTOR + j; + for (j = 0; j < CLUSTERS_PER_FAT_SECTOR; j++) { + int k = (j + offset) % CLUSTERS_PER_FAT_SECTOR; + if (!(SWAB32(fat[k]) & 0x0fffffff)) { + int c = nr * CLUSTERS_PER_FAT_SECTOR + k; if ( c > fat_bpb.dataclusters+1 ) /* nr 0 is unused */ - break; + continue; LDEBUGF("find_free_cluster(%x) == %x\n",startcluster,c); fat_bpb.fsinfo.nextfree = c; return c; @@ -1224,6 +1226,8 @@ int fat_seek(struct fat_file *file, int seeksector ) if ( sector > -1 ) sector = cluster2sec(cluster) + sectornum; } + else + sectornum = -1; LDEBUGF("fat_seek(%x) == %x, %x, %x\n", seeksector, cluster, sector, sectornum); |