summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprife <[email protected]>2013-12-20 20:16:58 -0800
committerprife <[email protected]>2013-12-20 20:16:58 -0800
commiteac3b8d96ccdd3b8d4edc0d09d0402d2c136c5cf (patch)
treee1ae4c5c29339e9735ff865ca594e0c35ef800ea
parentca270a46678b8de14fc23b2851ef84d265f29268 (diff)
parent1289dff20387909fb23c89ea1cdf70b1481423b8 (diff)
Merge pull request #217 from grissiom/fix-dfs
DFS: let mount fail on device open error
-rw-r--r--components/dfs/src/dfs_fs.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/components/dfs/src/dfs_fs.c b/components/dfs/src/dfs_fs.c
index 7e1dbd3584..a3a8210225 100644
--- a/components/dfs/src/dfs_fs.c
+++ b/components/dfs/src/dfs_fs.c
@@ -285,7 +285,16 @@ int dfs_mount(const char *device_name,
/* open device, but do not check the status of device */
if (dev_id != RT_NULL)
- rt_device_open(fs->dev_id, RT_DEVICE_OFLAG_RDWR);
+ {
+ if (rt_device_open(fs->dev_id,
+ RT_DEVICE_OFLAG_RDWR) != RT_EOK)
+ {
+ /* The underlaying device has error, clear the entry. */
+ dfs_lock();
+ rt_memset(fs, 0, sizeof(struct dfs_filesystem));
+ goto err1;
+ }
+ }
/* call mount of this filesystem */
if ((*ops)->mount(fs, rwflag, data) < 0)