From 38bc30b0d62eadb904c320f7c0f5f2086b170ccc Mon Sep 17 00:00:00 2001 From: Björn Stenberg Date: Wed, 29 Jan 2003 12:33:23 +0000 Subject: The dir code is now reentrant. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3184 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/fat.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'firmware/drivers/fat.c') diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 9274a9c339..ef013ac481 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -253,10 +253,6 @@ struct fat_cache_entry static char fat_cache_sectors[FAT_CACHE_SIZE][SECTOR_SIZE]; static struct fat_cache_entry fat_cache[FAT_CACHE_SIZE]; -/* sectors cache for longname use */ -static unsigned char lastsector[SECTOR_SIZE]; -static unsigned char lastsector2[SECTOR_SIZE]; - static int sec2cluster(unsigned int sec) { if ( sec < fat_bpb.firstdatasector ) @@ -1695,7 +1691,7 @@ int fat_getnext(struct fat_dir *dir, struct fat_direntry *entry) int longarray[20]; int longs=0; int sectoridx=0; - static unsigned char cached_buf[SECTOR_SIZE]; + unsigned char* cached_buf = dir->sectorcache[0]; dir->entrycount = 0; @@ -1766,13 +1762,13 @@ int fat_getnext(struct fat_dir *dir, struct fat_direntry *entry) if ( sectoridx >= SECTOR_SIZE*2 ) { if ( ( index >= SECTOR_SIZE ) && ( index < SECTOR_SIZE*2 )) - ptr = lastsector; + ptr = dir->sectorcache[1]; else - ptr = lastsector2; + ptr = dir->sectorcache[2]; } else { if ( index < SECTOR_SIZE ) - ptr = lastsector; + ptr = dir->sectorcache[1]; } index &= SECTOR_SIZE-1; @@ -1799,9 +1795,9 @@ int fat_getnext(struct fat_dir *dir, struct fat_direntry *entry) /* save this sector, for longname use */ if ( sectoridx ) - memcpy( lastsector2, cached_buf, SECTOR_SIZE ); + memcpy( dir->sectorcache[2], dir->sectorcache[0], SECTOR_SIZE ); else - memcpy( lastsector, cached_buf, SECTOR_SIZE ); + memcpy( dir->sectorcache[1], dir->sectorcache[0], SECTOR_SIZE ); sectoridx += SECTOR_SIZE; } -- cgit v1.2.3