| 138 | } |
| 139 | |
| 140 | static ssize_t dfs_devfs_read(struct dfs_file *file, void *buf, size_t count, off_t *pos) |
| 141 | { |
| 142 | ssize_t ret = -RT_EIO; |
| 143 | rt_device_t device; |
| 144 | |
| 145 | RT_ASSERT(file != RT_NULL); |
| 146 | |
| 147 | if (file->vnode && file->vnode->data) |
| 148 | { |
| 149 | /* get device handler */ |
| 150 | device = (rt_device_t)file->vnode->data; |
| 151 | |
| 152 | #ifdef RT_USING_POSIX_DEVIO |
| 153 | if (device->fops && device->fops->read) |
| 154 | { |
| 155 | ret = device->fops->read(file, buf, count, pos); |
| 156 | } |
| 157 | else |
| 158 | #else |
| 159 | if (device->ops) |
| 160 | #endif /* RT_USING_POSIX_DEVIO */ |
| 161 | { |
| 162 | rt_ubase_t shift = _get_unit_shift(device); |
| 163 | |
| 164 | ret = rt_device_read(device, *pos, buf, count >> shift); |
| 165 | if (ret > 0) |
| 166 | { |
| 167 | ret <<= shift; |
| 168 | *pos += ret; |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | return ret; |
| 174 | } |
| 175 | |
| 176 | static ssize_t dfs_devfs_write(struct dfs_file *file, const void *buf, size_t count, off_t *pos) |
| 177 | { |
nothing calls this directly
no test coverage detected