diff options
| author | Miika Pekkarinen <miipekk@ihme.org> | 2006-03-28 11:51:12 +0000 |
|---|---|---|
| committer | Miika Pekkarinen <miipekk@ihme.org> | 2006-03-28 11:51:12 +0000 |
| commit | 2d93495df2dd0c7c61fa73e07bb8fcae3d1ea5fd (patch) | |
| tree | 38d90cb0894b238b84cfa88b3e4cc3658b8a7ced /firmware/common/file.c | |
| parent | 6784e0333f3d8ee806a7eacbf2b709f45ffea0f5 (diff) | |
| download | rockbox-2d93495df2dd0c7c61fa73e07bb8fcae3d1ea5fd.zip rockbox-2d93495df2dd0c7c61fa73e07bb8fcae3d1ea5fd.tar.gz rockbox-2d93495df2dd0c7c61fa73e07bb8fcae3d1ea5fd.tar.bz2 rockbox-2d93495df2dd0c7c61fa73e07bb8fcae3d1ea5fd.tar.xz | |
Boost open() performance on platforms with dircache. Tagcache initial
scanning now over 50% faster than before.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9306 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common/file.c')
| -rw-r--r-- | firmware/common/file.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c index 761caee..a0b4296 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c @@ -99,9 +99,35 @@ int open(const char* pathname, int flags) } file->busy = true; +#ifdef HAVE_DIRCACHE + if (dircache_is_enabled() && !file->write) + { + const struct dircache_entry *ce; + + ce = dircache_get_entry_ptr(pathname); + if (!ce) + { + errno = ENOENT; + file->busy = false; + return -7; + } + + fat_open(IF_MV2(unsupported at the moment,) + ce->startcluster, + &(file->fatfile), + NULL); + file->size = ce->size; + file->attr = ce->attribute; + file->cacheoffset = -1; + file->fileoffset = 0; + + return fd; + } +#endif + strncpy(pathnamecopy,pathname,sizeof(pathnamecopy)); pathnamecopy[sizeof(pathnamecopy)-1] = 0; - + /* locate filename */ name=strrchr(pathnamecopy+1,'/'); if ( name ) { @@ -120,7 +146,7 @@ int open(const char* pathname, int flags) file->busy = false; return -4; } - + if(name[0] == 0) { DEBUGF("Empty file name\n"); errno = EINVAL; @@ -156,7 +182,7 @@ int open(const char* pathname, int flags) return rc * 10 - 6; } #ifdef HAVE_DIRCACHE - dircache_add_file(pathname); + dircache_add_file(pathname, file->fatfile.firstcluster); #endif file->size = 0; file->attr = 0; @@ -394,6 +420,9 @@ int ftruncate(int fd, off_t size) } file->size = size; +#ifdef HAVE_DIRCACHE + dircache_update_filesize(fd, size, file->fatfile.firstcluster); +#endif return 0; } @@ -569,7 +598,7 @@ static int readwrite(int fd, void* buf, long count, bool write) { file->size = file->fileoffset; #ifdef HAVE_DIRCACHE - dircache_update_filesize(fd, file->size); + dircache_update_filesize(fd, file->size, file->fatfile.firstcluster); #endif } |