mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-19 09:03:30 +08:00
对 /dev 目录做特殊处理
This commit is contained in:
parent
1a7cd8b43f
commit
f2dd21ccee
@ -40,6 +40,9 @@ int dfs_device_fs_ioctl(struct dfs_fd *file, int cmd, void *args)
|
||||
dev_id = (rt_device_t)file->vnode->data;
|
||||
RT_ASSERT(dev_id != RT_NULL);
|
||||
|
||||
if ((file->vnode->path[0] == '/') && (file->vnode->path[1] == '\0'))
|
||||
return -RT_ENOSYS;
|
||||
|
||||
/* close device handler */
|
||||
result = rt_device_control(dev_id, cmd, args);
|
||||
if (result == RT_EOK)
|
||||
@ -59,6 +62,9 @@ int dfs_device_fs_read(struct dfs_fd *file, void *buf, size_t count)
|
||||
dev_id = (rt_device_t)file->vnode->data;
|
||||
RT_ASSERT(dev_id != RT_NULL);
|
||||
|
||||
if ((file->vnode->path[0] == '/') && (file->vnode->path[1] == '\0'))
|
||||
return -RT_ENOSYS;
|
||||
|
||||
/* read device data */
|
||||
result = rt_device_read(dev_id, file->pos, buf, count);
|
||||
file->pos += result;
|
||||
@ -77,6 +83,9 @@ int dfs_device_fs_write(struct dfs_fd *file, const void *buf, size_t count)
|
||||
dev_id = (rt_device_t)file->vnode->data;
|
||||
RT_ASSERT(dev_id != RT_NULL);
|
||||
|
||||
if ((file->vnode->path[0] == '/') && (file->vnode->path[1] == '\0'))
|
||||
return -RT_ENOSYS;
|
||||
|
||||
/* read device data */
|
||||
result = rt_device_write(dev_id, file->pos, buf, count);
|
||||
file->pos += result;
|
||||
@ -97,7 +106,7 @@ int dfs_device_fs_close(struct dfs_fd *file)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (file->vnode->type == FT_DIRECTORY)
|
||||
if (file->vnode->type == FT_DIRECTORY && (file->vnode->path[0] == '/') && (file->vnode->path[1] == '\0'))
|
||||
{
|
||||
struct device_dirent *root_dirent;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user