diff options
| author | guozhanxin <[email protected]> | 2022-01-26 16:02:24 +0800 |
|---|---|---|
| committer | guozhanxin <[email protected]> | 2022-01-26 16:03:31 +0800 |
| commit | 9b44535740b7e1deda584e8c7397b40113fa43f0 (patch) | |
| tree | 7f318dcfbf7a8f01da544e909653a5601e4d13a6 /components/dfs/filesystems/devfs/devfs.c | |
| parent | e665bacf89c5901244cd43e195a7ae039b3c0463 (diff) | |
add RT_DEBUG_SCHEDULER_AVAILABLE check
Diffstat (limited to 'components/dfs/filesystems/devfs/devfs.c')
| -rw-r--r-- | components/dfs/filesystems/devfs/devfs.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/components/dfs/filesystems/devfs/devfs.c b/components/dfs/filesystems/devfs/devfs.c index d60f7ddc9b..8e58fb9f53 100644 --- a/components/dfs/filesystems/devfs/devfs.c +++ b/components/dfs/filesystems/devfs/devfs.c @@ -144,11 +144,15 @@ int dfs_device_fs_open(struct dfs_fd *file) { count ++; } + rt_exit_critical(); root_dirent = (struct device_dirent *)rt_malloc(sizeof(struct device_dirent) + count * sizeof(rt_device_t)); if (root_dirent != RT_NULL) { + /* lock scheduler */ + rt_enter_critical(); + root_dirent->devices = (rt_device_t *)(root_dirent + 1); root_dirent->read_index = 0; root_dirent->device_count = count; @@ -156,12 +160,18 @@ int dfs_device_fs_open(struct dfs_fd *file) /* get all device node */ for (node = information->object_list.next; node != &(information->object_list); node = node->next) { + /* avoid memory write through */ + if (count == root_dirent->device_count) + { + rt_kprintf("warning: There are newly added devices that are not displayed!"); + break; + } object = rt_list_entry(node, struct rt_object, list); root_dirent->devices[count] = (rt_device_t)object; count ++; } + rt_exit_critical(); } - rt_exit_critical(); /* set data */ file->data = root_dirent; |
