MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / dfs_devfs_write

Function dfs_devfs_write

components/dfs/dfs_v2/filesystems/devfs/devfs.c:176–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176static 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
216static int dfs_devfs_ioctl(struct dfs_file *file, int cmd, void *args)
217{

Callers

nothing calls this directly

Calls 3

_get_unit_shiftFunction · 0.85
rt_device_writeFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected