summaryrefslogtreecommitdiff
path: root/components/dfs/filesystems/devfs
diff options
context:
space:
mode:
author陈豪 | Jacob Chen <[email protected]>2015-03-29 18:35:44 +0800
committer陈豪 | Jacob Chen <[email protected]>2015-03-29 18:35:44 +0800
commit9a4dacaad743801c9be2dbae49251c4e1b8f99a9 (patch)
tree34def3bef5c5fc4a9b7594eba5a2729f8c86aab0 /components/dfs/filesystems/devfs
parentdaac5388afe5a18d51e9839719de8423b62b00c1 (diff)
parent5af7abd8c2e8b8a39c0bf096bdf9b5cb08f266fa (diff)
Merge pull request #3 from RT-Thread/master
111
Diffstat (limited to 'components/dfs/filesystems/devfs')
-rw-r--r--components/dfs/filesystems/devfs/devfs.c14
-rw-r--r--components/dfs/filesystems/devfs/devfs.h1
2 files changed, 12 insertions, 3 deletions
diff --git a/components/dfs/filesystems/devfs/devfs.c b/components/dfs/filesystems/devfs/devfs.c
index 969c5d3321..1f4569558f 100644
--- a/components/dfs/filesystems/devfs/devfs.c
+++ b/components/dfs/filesystems/devfs/devfs.c
@@ -131,6 +131,7 @@ int dfs_device_fs_close(struct dfs_fd *file)
int dfs_device_fs_open(struct dfs_fd *file)
{
+ rt_err_t result;
rt_device_t device;
if (file->flags & DFS_O_CREAT)
@@ -186,9 +187,16 @@ int dfs_device_fs_open(struct dfs_fd *file)
if (device == RT_NULL)
return -DFS_STATUS_ENODEV;
- file->data = device;
-
- return DFS_STATUS_OK;
+ /* to open device */
+ result = rt_device_open(device, RT_DEVICE_OFLAG_RDWR);
+ if (result == RT_EOK || result == -RT_ENOSYS)
+ {
+ file->data = device;
+ return DFS_STATUS_OK;
+ }
+
+ /* open device failed. */
+ return -DFS_STATUS_EIO;
}
int dfs_device_fs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
diff --git a/components/dfs/filesystems/devfs/devfs.h b/components/dfs/filesystems/devfs/devfs.h
index ef320b78c8..97b025634e 100644
--- a/components/dfs/filesystems/devfs/devfs.h
+++ b/components/dfs/filesystems/devfs/devfs.h
@@ -27,5 +27,6 @@
#include <rtthread.h>
int devfs_init(void);
+void rt_console_init(const char* device_name);
#endif