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

Function read

components/dfs/dfs_v2/src/dfs_posix.c:325–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323_READ_WRITE_RETURN_TYPE _EXFUN(read, (int fd, void *buf, size_t len))
324#else
325ssize_t read(int fd, void *buf, size_t len)
326#endif
327{
328 ssize_t result;
329 struct dfs_file *file;
330
331 if (buf == NULL)
332 {
333 rt_set_errno(-EBADF);
334 return -1;
335 }
336
337 file = fd_get(fd);
338 if (file == NULL)
339 {
340 rt_set_errno(-EBADF);
341
342 return -1;
343 }
344
345 result = dfs_file_read(file, buf, len);
346 if (result < 0)
347 {
348 rt_set_errno(result);
349
350 return -1;
351 }
352
353 return result;
354}
355RTM_EXPORT(read);
356
357/**

Callers

nothing calls this directly

Calls 3

rt_set_errnoFunction · 0.85
fd_getFunction · 0.70
dfs_file_readFunction · 0.70

Tested by

no test coverage detected