diff options
| author | Jörg Hohensohn <hohensoh@rockbox.org> | 2005-01-28 21:32:16 +0000 |
|---|---|---|
| committer | Jörg Hohensohn <hohensoh@rockbox.org> | 2005-01-28 21:32:16 +0000 |
| commit | dc7534bdb2a784ae9d5c9089237935ff405c3525 (patch) | |
| tree | e12e3eab71cbd72605d661ea026c70127d633cb3 /firmware/common/dir.c | |
| parent | 3662ad2ae3a9fb5ec5a7295bb606524e642bb840 (diff) | |
| download | rockbox-dc7534bdb2a784ae9d5c9089237935ff405c3525.zip rockbox-dc7534bdb2a784ae9d5c9089237935ff405c3525.tar.gz rockbox-dc7534bdb2a784ae9d5c9089237935ff405c3525.tar.bz2 rockbox-dc7534bdb2a784ae9d5c9089237935ff405c3525.tar.xz | |
preparations for hotswapping MMC
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5701 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common/dir.c')
| -rw-r--r-- | firmware/common/dir.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/firmware/common/dir.c b/firmware/common/dir.c index 4b4a5fa..aa55aeb 100644 --- a/firmware/common/dir.c +++ b/firmware/common/dir.c @@ -67,6 +67,26 @@ static int strip_volume(const char* name, char* namecopy) #endif /* #ifdef HAVE_MULTIVOLUME */ +#ifdef HAVE_HOTSWAP +// release all dir handles on a given volume "by force", to avoid leaks +int release_dirs(int volume) +{ + DIR* pdir = opendirs; + int dd; + int closed = 0; + for ( dd=0; dd<MAX_OPEN_DIRS; dd++, pdir++) + { + if (pdir->fatdir.file.volume == volume) + { + pdir->busy = false; /* mark as available, no further action */ + closed++; + } + } + return closed; /* return how many we did */ +} +#endif /* #ifdef HAVE_HOTSWAP */ + + DIR* opendir(const char* name) { char namecopy[MAX_PATH]; @@ -154,6 +174,10 @@ struct dirent* readdir(DIR* dir) { struct fat_direntry entry; struct dirent* theent = &(dir->theent); + + if (!dir->busy) + return NULL; + #ifdef HAVE_MULTIVOLUME /* Volumes (secondary file systems) get inserted into the root directory of the first volume, since we have no separate top level. */ |