summaryrefslogtreecommitdiff
path: root/firmware/common/dir.c
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2005-01-28 21:32:16 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2005-01-28 21:32:16 +0000
commitdc7534bdb2a784ae9d5c9089237935ff405c3525 (patch)
treee12e3eab71cbd72605d661ea026c70127d633cb3 /firmware/common/dir.c
parent3662ad2ae3a9fb5ec5a7295bb606524e642bb840 (diff)
downloadrockbox-dc7534bdb2a784ae9d5c9089237935ff405c3525.tar.gz
rockbox-dc7534bdb2a784ae9d5c9089237935ff405c3525.zip
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.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/firmware/common/dir.c b/firmware/common/dir.c
index 4b4a5fa65d..aa55aeb9e9 100644
--- a/firmware/common/dir.c
+++ b/firmware/common/dir.c
@@ -67,6 +67,26 @@ static int strip_volume(const char* name, char* namecopy)
67#endif /* #ifdef HAVE_MULTIVOLUME */ 67#endif /* #ifdef HAVE_MULTIVOLUME */
68 68
69 69
70#ifdef HAVE_HOTSWAP
71// release all dir handles on a given volume "by force", to avoid leaks
72int release_dirs(int volume)
73{
74 DIR* pdir = opendirs;
75 int dd;
76 int closed = 0;
77 for ( dd=0; dd<MAX_OPEN_DIRS; dd++, pdir++)
78 {
79 if (pdir->fatdir.file.volume == volume)
80 {
81 pdir->busy = false; /* mark as available, no further action */
82 closed++;
83 }
84 }
85 return closed; /* return how many we did */
86}
87#endif /* #ifdef HAVE_HOTSWAP */
88
89
70DIR* opendir(const char* name) 90DIR* opendir(const char* name)
71{ 91{
72 char namecopy[MAX_PATH]; 92 char namecopy[MAX_PATH];
@@ -154,6 +174,10 @@ struct dirent* readdir(DIR* dir)
154{ 174{
155 struct fat_direntry entry; 175 struct fat_direntry entry;
156 struct dirent* theent = &(dir->theent); 176 struct dirent* theent = &(dir->theent);
177
178 if (!dir->busy)
179 return NULL;
180
157#ifdef HAVE_MULTIVOLUME 181#ifdef HAVE_MULTIVOLUME
158 /* Volumes (secondary file systems) get inserted into the root directory 182 /* Volumes (secondary file systems) get inserted into the root directory
159 of the first volume, since we have no separate top level. */ 183 of the first volume, since we have no separate top level. */