summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
author[email protected] <[email protected]>2012-08-08 15:09:30 +0000
committer[email protected] <[email protected]>2012-08-08 15:09:30 +0000
commit853b1259b0d6d90fbc4f87fde5517453d7525075 (patch)
tree887f5cf351ce7c6ea69c76f6dc9c445b76470394 /components
parent6c4302822722a231dcda337b31d1b9e5100cfea7 (diff)
add chk_mounted in dfs_elm_mount to make sure that there is a valid fat partition on physical media.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2248 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components')
-rw-r--r--components/dfs/filesystems/elmfat/dfs_elm.c20
-rw-r--r--components/dfs/filesystems/elmfat/ff.c7
2 files changed, 26 insertions, 1 deletions
diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c
index c2ccac1a89..c9812181ae 100644
--- a/components/dfs/filesystems/elmfat/dfs_elm.c
+++ b/components/dfs/filesystems/elmfat/dfs_elm.c
@@ -103,7 +103,27 @@ int dfs_elm_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *d
/* mount fatfs, always 0 logic driver */
result = f_mount(index, fat);
if (result == FR_OK)
+ {
+ extern FRESULT chk_mounted(const TCHAR **path, FATFS **rfs, BYTE chk_wp);
+ extern void leavefs(FATFS* fs, int res);
+ char driver[16];
+ const char * path;
+ DIR dj;
+ path = (const char *)driver;
+ rt_snprintf(driver, sizeof(driver), "%d:/", fat->drv);
+#if !_FS_READONLY
+ result = chk_mounted(&path, &dj.fs, 1);
+#else
+ result = chk_mounted(&path, &dj.fs, 0);
+#endif
+ if (result != FR_OK)
+ {
+ rt_free(fat);
+ return -1;
+ }
+ leavefs(dj.fs, result);
fs->data = fat;
+ }
else
{
rt_free(fat);
diff --git a/components/dfs/filesystems/elmfat/ff.c b/components/dfs/filesystems/elmfat/ff.c
index e967bc76d7..ea09720d3b 100644
--- a/components/dfs/filesystems/elmfat/ff.c
+++ b/components/dfs/filesystems/elmfat/ff.c
@@ -2004,7 +2004,7 @@ BYTE check_fs ( /* 0:The FAT BR, 1:Valid BR but not an FAT, 2:Not a BR, 3:Disk e
/* Check if the file system object is valid or not */
/*-----------------------------------------------------------------------*/
-static
+
FRESULT chk_mounted ( /* FR_OK(0): successful, !=0: any error occurred */
const TCHAR **path, /* Pointer to pointer to the path name (drive number) */
FATFS **rfs, /* Pointer to pointer to the found file system object */
@@ -4019,3 +4019,8 @@ int elm_get_vol(FATFS *fat)
return -1;
}
#endif
+
+void leavefs(FATFS* fs, int res)
+{
+ LEAVE_FF(fs, res);
+}