[...] static int hddcachereadsectors = 0; [...] int fat_read( struct fat_file *file, int sectorcount, void* buf ) { int cluster = file->nextcluster; int sector = file->nextsector; int numsec = file->sectornum; int err, i; if ( sector == -1 ) return 0; for ( i=0; i= fat_bpb.bpb_secperclus ) { cluster = get_next_cluster(cluster); if (!cluster) { /* end of file */ sector = -1; break; } sector = cluster2sec(cluster); if (sector<0) return -1; numsec=0; } else sector++; } file->nextcluster = cluster; file->nextsector = sector; file->sectornum = numsec; // read more sectors to fill hdd cache (every 2nd read) hddcachereadsectors = !hddcachereadsectors; if (hddcachereadsectors) { for ( i=0; i= fat_bpb.bpb_secperclus ) { cluster = get_next_cluster(cluster); if (!cluster) { /* end of file */ sector = -1; break; } sector = cluster2sec(cluster); if (sector<0) return -1; numsec=0; } else sector++; } } return sectorcount; }