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

Function dfs_devfs_read

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

Source from the content-addressed store, hash-verified

138}
139
140static 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
176static ssize_t dfs_devfs_write(struct dfs_file *file, const void *buf, size_t count, off_t *pos)
177{

Callers

nothing calls this directly

Calls 3

_get_unit_shiftFunction · 0.85
rt_device_readFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected