summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/fat.c28
-rw-r--r--firmware/drivers/fat.h3
2 files changed, 31 insertions, 0 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c
index fe5cef878d..3eab47e8b3 100644
--- a/firmware/drivers/fat.c
+++ b/firmware/drivers/fat.c
@@ -860,6 +860,34 @@ int fat_read(struct bpb *bpb,
860 return sectorcount; 860 return sectorcount;
861} 861}
862 862
863int fat_seek(struct bpb *bpb,
864 struct fat_fileent *ent,
865 int seeksector )
866{
867 int cluster = ent->firstcluster;
868 int sector;
869 int numsec = 0;
870 int i;
871
872 for (i=0; i<seeksector; i++) {
873 numsec++;
874 if ( numsec >= bpb->bpb_secperclus ) {
875 cluster = get_next_cluster(bpb,cluster);
876 if (!cluster)
877 /* end of file */
878 return -1;
879
880 sector = cluster2sec(bpb,cluster);
881 if (sector<0)
882 return -2;
883 numsec=0;
884 }
885 }
886 ent->nextcluster = cluster;
887 ent->nextsector = sector;
888 ent->sectornum = numsec;
889 return 0;
890}
863 891
864int fat_opendir(struct bpb *bpb, 892int fat_opendir(struct bpb *bpb,
865 struct fat_dirent *ent, 893 struct fat_dirent *ent,
diff --git a/firmware/drivers/fat.h b/firmware/drivers/fat.h
index a7c73c53fe..e259255d51 100644
--- a/firmware/drivers/fat.h
+++ b/firmware/drivers/fat.h
@@ -115,6 +115,9 @@ extern int fat_read(struct bpb *bpb,
115 struct fat_fileent *ent, 115 struct fat_fileent *ent,
116 int sectorcount, 116 int sectorcount,
117 void* buf ); 117 void* buf );
118extern int fat_seek(struct bpb *bpb,
119 struct fat_fileent *ent,
120 int sector );
118 121
119extern int fat_opendir(struct bpb *bpb, 122extern int fat_opendir(struct bpb *bpb,
120 struct fat_dirent *ent, 123 struct fat_dirent *ent,