diff options
author | Frank Gevaerts <frank@gevaerts.be> | 2010-11-28 15:22:51 +0000 |
---|---|---|
committer | Frank Gevaerts <frank@gevaerts.be> | 2010-11-28 15:22:51 +0000 |
commit | 1db3dfdd759476ae4930958ec775fd2009674091 (patch) | |
tree | d3f4ca8200a049ecdad0452ca4bb322e452b2ae6 /firmware/common/disk.c | |
parent | 4063389bffe63052da2e78413b0cc1f530733db3 (diff) | |
download | rockbox-1db3dfdd759476ae4930958ec775fd2009674091.tar.gz rockbox-1db3dfdd759476ae4930958ec775fd2009674091.zip |
Accept FS#11774 by Michael Hohmuth (with some own modifications to #ifdef conditions)
Unmount all filesystems before connecting USB. This ensures that all filehandles are closed, which avoids possible filesystem corruption
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28693 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common/disk.c')
-rw-r--r-- | firmware/common/disk.c | 27 |
1 files changed, 23 insertions, 4 deletions
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 | ||
239 | int disk_unmount(int drive) | 236 | int 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 | |||
261 | int 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 */ | ||