summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-05-08 15:16:02 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-05-08 15:16:02 +0000
commit1c3217909b444b86f87f976925f05ac05555cc6d (patch)
treea88403f37f9ea9cab683c74ff0dd05e50cd45ac9 /firmware/drivers
parent6a63f911fef19eae9aaa96b20dbe57aab63399d9 (diff)
Added lseek()
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@518 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/fat.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c
index 3a3f63d9f1..a55a8a2864 100644
--- a/firmware/drivers/fat.c
+++ b/firmware/drivers/fat.c
@@ -838,22 +838,30 @@ int fat_seek(struct fat_file *file, int seeksector )
int numsec = 0;
int i;
- for (i=0; i<seeksector; i++) {
- numsec++;
- if ( numsec >= fat_bpb.bpb_secperclus ) {
- cluster = get_next_cluster(cluster);
- if (!cluster)
- /* end of file */
- return -1;
-
- sector = cluster2sec(cluster);
- if (sector<0)
- return -2;
- numsec=0;
+ if ( seeksector ) {
+ for (i=0; i<seeksector; i++) {
+ numsec++;
+ if ( numsec >= fat_bpb.bpb_secperclus ) {
+ cluster = get_next_cluster(cluster);
+ if (!cluster)
+ /* end of file */
+ return -1;
+
+ sector = cluster2sec(cluster);
+ if (sector<0)
+ return -2;
+ numsec=0;
+ }
+ else
+ sector++;
}
- else
- sector++;
}
+ else {
+ sector = cluster2sec(cluster);
+ if (sector<0)
+ return -2;
+ }
+
file->nextcluster = cluster;
file->nextsector = sector;
file->sectornum = numsec;