diff options
| author | [email protected] <[email protected]> | 2012-08-08 15:46:48 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2012-08-08 15:46:48 +0000 |
| commit | 063fb36089eaed9e7ea7bbd97083edad40002379 (patch) | |
| tree | ec16f9c48b978e500e91bcfff368de5103b2aa6c /components | |
| parent | 3dbbc479fc035af88c89d9e836a875b7248898b2 (diff) | |
add f_opendir to open root directory 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@2251 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components')
| -rw-r--r-- | components/dfs/filesystems/elmfat/dfs_elm.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c index c2ccac1a89..ee3d29962f 100644 --- a/components/dfs/filesystems/elmfat/dfs_elm.c +++ b/components/dfs/filesystems/elmfat/dfs_elm.c @@ -103,7 +103,26 @@ 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) + { + char drive[8]; + DIR * dir; + + rt_snprintf(drive, sizeof(drive), "%d:/", fat->drv); + dir = (DIR *)rt_malloc(sizeof(DIR)); + if (dir == RT_NULL) + return -DFS_STATUS_ENOMEM; + + /* open the root directory to test whether the fatfs is valid */ + result = f_opendir(dir, drive); + if (result != FR_OK) + { + rt_free(dir); + return elm_result_to_dfs(result); + } + rt_free(dir); + fs->data = fat; + } else { rt_free(fat); |
