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

Function dfs_file_fcntl

components/dfs/dfs_v2/src/dfs_file.c:1553–1616  ·  view source on GitHub ↗

* @brief Perform file control operations * * This function performs various control operations on an open file descriptor. * It supports the following operations: * - F_DUPFD: Duplicate file descriptor * - F_GETFD: Get file descriptor flags * - F_SETFD: Set file descriptor flags * - F_GETFL: Get file status flags * - F_SETFL: Set file status flags * - F_GETLK/F_SETLK/F_SETLKW: File lockin

Source from the content-addressed store, hash-verified

1551 * @note File locking operations (F_GETLK/F_SETLK/F_SETLKW) are currently unimplemented
1552 */
1553int dfs_file_fcntl(int fd, int cmd, unsigned long arg)
1554{
1555 int ret = 0;
1556 struct dfs_file *file;
1557
1558 file = fd_get(fd);
1559 if (file)
1560 {
1561 switch (cmd)
1562 {
1563 case F_DUPFD:
1564 ret = dfs_dup(fd, arg);
1565 break;
1566 case F_GETFD:
1567 ret = file->mode;
1568 break;
1569 case F_SETFD:
1570 file->mode = arg;
1571 break;
1572 case F_GETFL:
1573 ret = file->flags;
1574 break;
1575 case F_SETFL:
1576 {
1577 int flags = (int)(rt_base_t)arg;
1578 int mask =
1579#ifdef O_ASYNC
1580 O_ASYNC |
1581#endif
1582#ifdef O_DIRECT
1583 O_DIRECT |
1584#endif
1585#ifdef O_NOATIME
1586 O_NOATIME |
1587#endif
1588 O_APPEND | O_NONBLOCK;
1589
1590 flags &= mask;
1591 file->flags &= ~mask;
1592 file->flags |= flags;
1593 break;
1594 }
1595 case F_GETLK:
1596 break;
1597 case F_SETLK:
1598 case F_SETLKW:
1599 break;
1600#ifdef RT_USING_MUSLLIBC
1601 case F_DUPFD_CLOEXEC:
1602 ret = -EINVAL;
1603 break;
1604#endif
1605 default:
1606 ret = -EPERM;
1607 break;
1608 }
1609 }
1610 else

Callers 1

fcntlFunction · 0.85

Calls 2

dfs_dupFunction · 0.85
fd_getFunction · 0.70

Tested by

no test coverage detected