summaryrefslogtreecommitdiffstats
path: root/firmware/drivers/fat.c
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-05-08 12:02:42 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-05-08 12:02:42 +0000
commit7dd442b7c36f43e3593905d86283f707b0b2dfe1 (patch)
tree05674032c27108fd337833eead773b36562a9eaa /firmware/drivers/fat.c
parent143471447c3f7307c5fc24a861bdb73df34d4a7c (diff)
downloadrockbox-7dd442b7c36f43e3593905d86283f707b0b2dfe1.tar.gz
rockbox-7dd442b7c36f43e3593905d86283f707b0b2dfe1.zip
Fixed EOF handling
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@512 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/fat.c')
-rw-r--r--firmware/drivers/fat.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c
index 7951b6b280..3a3f63d9f1 100644
--- a/firmware/drivers/fat.c
+++ b/firmware/drivers/fat.c
@@ -795,6 +795,9 @@ int fat_read( struct fat_file *file, int sectorcount, void* buf )
int numsec = file->sectornum;
int err, i;
+ if ( sector == -1 )
+ return 0;
+
for ( i=0; i<sectorcount; i++ ) {
err = ata_read_sectors(sector + fat_bpb.startsector, 1,
(char*)buf+(i*SECTOR_SIZE));
@@ -807,8 +810,11 @@ int fat_read( struct fat_file *file, int sectorcount, void* buf )
numsec++;
if ( numsec >= fat_bpb.bpb_secperclus ) {
cluster = get_next_cluster(cluster);
- if (!cluster)
- break; /* end of file */
+ if (!cluster) {
+ /* end of file */
+ sector = -1;
+ break;
+ }
sector = cluster2sec(cluster);
if (sector<0)