diff options
| author | Miika Pekkarinen <miipekk@ihme.org> | 2006-04-13 21:14:13 +0000 |
|---|---|---|
| committer | Miika Pekkarinen <miipekk@ihme.org> | 2006-04-13 21:14:13 +0000 |
| commit | d489377d460c5e7bc81a9a8a53003aa1a2882f15 (patch) | |
| tree | 38abf2330acb58c7abd00d6506cb509928466ea7 /firmware/common | |
| parent | 017914a087ca2da900bcca9cf49776ed2eaa5fc7 (diff) | |
| download | rockbox-d489377d460c5e7bc81a9a8a53003aa1a2882f15.zip rockbox-d489377d460c5e7bc81a9a8a53003aa1a2882f15.tar.gz rockbox-d489377d460c5e7bc81a9a8a53003aa1a2882f15.tar.bz2 rockbox-d489377d460c5e7bc81a9a8a53003aa1a2882f15.tar.xz | |
Fixed the file renaming/removing issue with dircache enabled.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9649 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common')
| -rw-r--r-- | firmware/common/file.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c index a83dc95..464d10f 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c @@ -58,7 +58,7 @@ int creat(const char *pathname, mode_t mode) return open(pathname, O_WRONLY|O_CREAT|O_TRUNC); } -int open(const char* pathname, int flags) +static int open_internal(const char* pathname, int flags, bool use_cache) { DIR* dir; struct dirent* entry; @@ -67,7 +67,10 @@ int open(const char* pathname, int flags) char* name; struct filedesc* file = NULL; int rc; - +#ifndef HAVE_DIRCACHE + (void)use_cache; +#endif + LDEBUGF("open(\"%s\",%d)\n",pathname,flags); if ( pathname[0] != '/' ) { @@ -100,7 +103,7 @@ int open(const char* pathname, int flags) file->busy = true; #ifdef HAVE_DIRCACHE - if (dircache_is_enabled() && !file->write) + if (dircache_is_enabled() && !file->write && use_cache) { const struct dircache_entry *ce; @@ -221,6 +224,12 @@ int open(const char* pathname, int flags) return fd; } +int open(const char* pathname, int flags) +{ + /* By default, use the dircache if available. */ + return open_internal(pathname, flags, true); +} + int close(int fd) { struct filedesc* file = &openfiles[fd]; @@ -288,7 +297,8 @@ int remove(const char* name) { int rc; struct filedesc* file; - int fd = open(name, O_WRONLY); + /* Can't use dircache now, because we need to access the fat structures. */ + int fd = open_internal(name, O_WRONLY, false); if ( fd < 0 ) return fd * 10 - 1; @@ -331,7 +341,7 @@ int rename(const char* path, const char* newpath) } close(fd); - fd = open(path, O_RDONLY); + fd = open_internal(path, O_RDONLY, false); if ( fd < 0 ) { errno = EIO; return fd * 10 - 2; |