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

Function fcntl

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

* this function is a POSIX compliant version, which shall perform a variety of * control functions on devices. * * @param fildes the file description * @param cmd the specified command, Common values include: * - `F_DUPFD`: Duplicate a file descriptor. * - `F_GETFD`: Get the file descriptor flags. * - `F_SETFD`: Set the file descriptor flags. * - `F_GETFL`: Get the file sta

Source from the content-addressed store, hash-verified

629 * set to indicate the error.
630 */
631int fcntl(int fildes, int cmd, ...)
632{
633 int ret = -1;
634 struct dfs_file *file;
635
636 file = fd_get(fildes);
637 if (file)
638 {
639 void *arg;
640 va_list ap;
641
642 va_start(ap, cmd);
643 arg = va_arg(ap, void *);
644 va_end(ap);
645
646 ret = dfs_file_ioctl(file, cmd, arg);
647 if (ret < 0)
648 {
649 ret = dfs_file_fcntl(fildes, cmd, (unsigned long)arg);
650 }
651 }
652 else
653 {
654 ret = -EBADF;
655 }
656
657 if (ret < 0)
658 {
659 rt_set_errno(ret);
660 ret = -1;
661 }
662
663 return ret;
664}
665RTM_EXPORT(fcntl);
666
667/**

Callers 1

ioctlFunction · 0.70

Calls 4

dfs_file_fcntlFunction · 0.85
rt_set_errnoFunction · 0.85
fd_getFunction · 0.70
dfs_file_ioctlFunction · 0.70

Tested by

no test coverage detected