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

Function fstat

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

* this function is a POSIX compliant version, which will get file status. * * @param fildes the file description * @param buf the data buffer to save stat description. * * @return 0 on successful, -1 on failed. */

Source from the content-addressed store, hash-verified

552 * @return 0 on successful, -1 on failed.
553 */
554int fstat(int fildes, struct stat *buf)
555{
556 int ret = -1;
557 struct dfs_file *file;
558
559 if (buf == NULL)
560 {
561 rt_set_errno(-EBADF);
562 return -1;
563 }
564
565 /* get the fd */
566 file = fd_get(fildes);
567 if (file == NULL)
568 {
569 rt_set_errno(-EBADF);
570
571 return -1;
572 }
573
574 if (dfs_is_mounted(file->dentry->mnt) == 0)
575 {
576 ret = file->dentry->mnt->fs_ops->stat(file->dentry, buf);
577 }
578
579 return ret;
580}
581RTM_EXPORT(fstat);
582#endif
583

Callers

nothing calls this directly

Calls 3

rt_set_errnoFunction · 0.85
dfs_is_mountedFunction · 0.85
fd_getFunction · 0.70

Tested by

no test coverage detected