summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2003-01-29 12:33:23 +0000
committerBjörn Stenberg <bjorn@haxx.se>2003-01-29 12:33:23 +0000
commit38bc30b0d62eadb904c320f7c0f5f2086b170ccc (patch)
tree19ecc261e1e5cf4b164931f857cf4b60c789a338
parentff4da18d1a42342917a62f6e0a904b2884c98ae1 (diff)
The dir code is now reentrant.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3184 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/fat.c16
-rw-r--r--firmware/drivers/fat.h1
2 files changed, 7 insertions, 10 deletions
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;
}
diff --git a/firmware/drivers/fat.h b/firmware/drivers/fat.h
index 6a3e5cf967..ec71fceb05 100644
--- a/firmware/drivers/fat.h
+++ b/firmware/drivers/fat.h
@@ -64,6 +64,7 @@ struct fat_dir
unsigned int entrycount;
int sector;
struct fat_file file;
+ unsigned char sectorcache[3][SECTOR_SIZE];
};