summaryrefslogtreecommitdiff
path: root/firmware/common
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/common')
-rw-r--r--firmware/common/dir_uncached.c2
-rw-r--r--firmware/common/disk.c27
-rw-r--r--firmware/common/file.c2
3 files changed, 23 insertions, 8 deletions
diff --git a/firmware/common/dir_uncached.c b/firmware/common/dir_uncached.c
index e4c4397fe2..00123c1b07 100644
--- a/firmware/common/dir_uncached.c
+++ b/firmware/common/dir_uncached.c
@@ -36,7 +36,6 @@
36 36
37static DIR_UNCACHED opendirs[MAX_OPEN_DIRS]; 37static DIR_UNCACHED opendirs[MAX_OPEN_DIRS];
38 38
39#ifdef HAVE_HOTSWAP
40// release all dir handles on a given volume "by force", to avoid leaks 39// release all dir handles on a given volume "by force", to avoid leaks
41int release_dirs(int volume) 40int release_dirs(int volume)
42{ 41{
@@ -57,7 +56,6 @@ int release_dirs(int volume)
57 } 56 }
58 return closed; /* return how many we did */ 57 return closed; /* return how many we did */
59} 58}
60#endif /* #ifdef HAVE_HOTSWAP */
61 59
62DIR_UNCACHED* opendir_uncached(const char* name) 60DIR_UNCACHED* opendir_uncached(const char* name)
63{ 61{
diff --git a/firmware/common/disk.c b/firmware/common/disk.c
index 6be9b47379..400d21f359 100644
--- a/firmware/common/disk.c
+++ b/firmware/common/disk.c
@@ -23,10 +23,8 @@
23#include "storage.h" 23#include "storage.h"
24#include "debug.h" 24#include "debug.h"
25#include "fat.h" 25#include "fat.h"
26#ifdef HAVE_HOTSWAP
27#include "dir.h" /* for release_dirs() */ 26#include "dir.h" /* for release_dirs() */
28#include "file.h" /* for release_files() */ 27#include "file.h" /* for release_files() */
29#endif
30#include "disk.h" 28#include "disk.h"
31#include <string.h> 29#include <string.h>
32 30
@@ -235,12 +233,13 @@ int disk_mount(int drive)
235 return mounted; 233 return mounted;
236} 234}
237 235
238#ifdef HAVE_HOTSWAP
239int disk_unmount(int drive) 236int disk_unmount(int drive)
240{ 237{
241 int unmounted = 0; 238 int unmounted = 0;
242 int i; 239 int i;
240#ifdef HAVE_HOTSWAP
243 mutex_lock(&disk_mutex); 241 mutex_lock(&disk_mutex);
242#endif
244 for (i=0; i<NUM_VOLUMES; i++) 243 for (i=0; i<NUM_VOLUMES; i++)
245 { 244 {
246 if (vol_drive[i] == drive) 245 if (vol_drive[i] == drive)
@@ -252,8 +251,28 @@ int disk_unmount(int drive)
252 fat_unmount(i, false); 251 fat_unmount(i, false);
253 } 252 }
254 } 253 }
254#ifdef HAVE_HOTSWAP
255 mutex_unlock(&disk_mutex); 255 mutex_unlock(&disk_mutex);
256#endif
257
258 return unmounted;
259}
260
261int disk_unmount_all(void)
262{
263#ifndef HAVE_MULTIDRIVE
264 return disk_unmount(0);
265#else /* HAVE_MULTIDRIVE */
266 int unmounted = 0;
267 int i;
268 for (i = 0; i < NUM_DRIVES; i++)
269 {
270#ifdef HAVE_HOTSWAP
271 if (storage_present(i))
272#endif
273 unmounted += disk_unmount(i);
274 }
256 275
257 return unmounted; 276 return unmounted;
277#endif /* HAVE_MULTIDRIVE */
258} 278}
259#endif /* #ifdef HAVE_HOTSWAP */
diff --git a/firmware/common/file.c b/firmware/common/file.c
index da85846a34..3477c10061 100644
--- a/firmware/common/file.c
+++ b/firmware/common/file.c
@@ -793,7 +793,6 @@ off_t filesize(int fd)
793} 793}
794 794
795 795
796#ifdef HAVE_HOTSWAP
797/* release all file handles on a given volume "by force", to avoid leaks */ 796/* release all file handles on a given volume "by force", to avoid leaks */
798int release_files(int volume) 797int release_files(int volume)
799{ 798{
@@ -814,4 +813,3 @@ int release_files(int volume)
814 } 813 }
815 return closed; /* return how many we did */ 814 return closed; /* return how many we did */
816} 815}
817#endif /* #ifdef HAVE_HOTSWAP */