diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-11-04 14:59:46 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-11-04 14:59:46 +0000 |
commit | c9fb0982505291c6efab4abfc805fc907c575933 (patch) | |
tree | ef4186827fe30bdfe685bdfce3f058c56cf351af /firmware/drivers | |
parent | 6a8900b528922b4b26ce2f582233036da14c2614 (diff) | |
download | rockbox-c9fb0982505291c6efab4abfc805fc907c575933.tar.gz rockbox-c9fb0982505291c6efab4abfc805fc907c575933.zip |
Bugfix: lseek() did not invalidate sector cache when seeking to start of file.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2803 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/fat.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index f6d6c73e74..26149d4e4a 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c | |||
@@ -1202,25 +1202,29 @@ int fat_readwrite( struct fat_file *file, int sectorcount, | |||
1202 | 1202 | ||
1203 | int fat_seek(struct fat_file *file, int seeksector ) | 1203 | int fat_seek(struct fat_file *file, int seeksector ) |
1204 | { | 1204 | { |
1205 | int clusternum, sectornum, sector=0; | 1205 | int clusternum=0, sectornum=0, sector=0; |
1206 | int cluster = file->firstcluster; | 1206 | int cluster = file->firstcluster; |
1207 | int i; | 1207 | int i; |
1208 | 1208 | ||
1209 | seeksector--; | 1209 | if (seeksector) { |
1210 | clusternum = seeksector / fat_bpb.bpb_secperclus; | 1210 | /* we need to find the sector BEFORE the requested, since |
1211 | sectornum = seeksector % fat_bpb.bpb_secperclus; | 1211 | the file struct stores the last accessed sector */ |
1212 | 1212 | seeksector--; | |
1213 | for (i=0; i<clusternum; i++) { | 1213 | clusternum = seeksector / fat_bpb.bpb_secperclus; |
1214 | cluster = get_next_cluster(cluster); | 1214 | sectornum = seeksector % fat_bpb.bpb_secperclus; |
1215 | if (!cluster) { | 1215 | |
1216 | sector = -1; | 1216 | for (i=0; i<clusternum; i++) { |
1217 | break; | 1217 | cluster = get_next_cluster(cluster); |
1218 | if (!cluster) { | ||
1219 | sector = -1; | ||
1220 | break; | ||
1221 | } | ||
1218 | } | 1222 | } |
1223 | |||
1224 | if ( sector > -1 ) | ||
1225 | sector = cluster2sec(cluster) + sectornum; | ||
1219 | } | 1226 | } |
1220 | 1227 | ||
1221 | if ( sector > -1 ) | ||
1222 | sector = cluster2sec(cluster) + sectornum; | ||
1223 | |||
1224 | LDEBUGF("fat_seek(%x) == %x, %x, %x\n", | 1228 | LDEBUGF("fat_seek(%x) == %x, %x, %x\n", |
1225 | seeksector, cluster, sector, sectornum); | 1229 | seeksector, cluster, sector, sectornum); |
1226 | 1230 | ||