| 174 | } |
| 175 | |
| 176 | static ssize_t dfs_devfs_write(struct dfs_file *file, const void *buf, size_t count, off_t *pos) |
| 177 | { |
| 178 | ssize_t ret = -RT_EIO; |
| 179 | rt_device_t device; |
| 180 | |
| 181 | RT_ASSERT(file != RT_NULL); |
| 182 | |
| 183 | if(file->vnode->data) |
| 184 | { |
| 185 | /* get device handler */ |
| 186 | device = (rt_device_t)file->vnode->data; |
| 187 | |
| 188 | if ((file->dentry->pathname[0] == '/') && (file->dentry->pathname[1] == '\0')) |
| 189 | return -RT_ENOSYS; |
| 190 | |
| 191 | #ifdef RT_USING_POSIX_DEVIO |
| 192 | if (device->fops && device->fops->write) |
| 193 | { |
| 194 | ret = device->fops->write(file, buf, count, pos); |
| 195 | } |
| 196 | else |
| 197 | #else |
| 198 | if (device->ops) |
| 199 | #endif /* RT_USING_POSIX_DEVIO */ |
| 200 | { |
| 201 | rt_ubase_t shift = _get_unit_shift(device); |
| 202 | |
| 203 | /* read device data */ |
| 204 | ret = rt_device_write(device, *pos, buf, count >> shift); |
| 205 | if (ret > 0) |
| 206 | { |
| 207 | ret <<= shift; |
| 208 | *pos += ret; |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | return ret; |
| 214 | } |
| 215 | |
| 216 | static int dfs_devfs_ioctl(struct dfs_file *file, int cmd, void *args) |
| 217 | { |
nothing calls this directly
no test coverage detected