* @brief drop fd from the fd table. * * @param fdt is the fd table, if empty, use global (_fdtab). * * @param fd is the fd in the designate fd table. * * @return -1 on failed the drop file descriptor. */
| 632 | * @return -1 on failed the drop file descriptor. |
| 633 | */ |
| 634 | int dfs_fdtable_drop_fd(struct dfs_fdtable *fdt, int fd) |
| 635 | { |
| 636 | int err = 0; |
| 637 | |
| 638 | if (fdt == NULL) |
| 639 | { |
| 640 | fdt = &_fdtab; |
| 641 | } |
| 642 | |
| 643 | if (dfs_file_lock() != RT_EOK) |
| 644 | { |
| 645 | return -RT_ENOSYS; |
| 646 | } |
| 647 | |
| 648 | err = dfs_file_close(fdt->fds[fd]); |
| 649 | if (!err) |
| 650 | { |
| 651 | fdt_fd_release(fdt, fd); |
| 652 | } |
| 653 | |
| 654 | dfs_file_unlock(); |
| 655 | |
| 656 | return err; |
| 657 | } |
| 658 | |
| 659 | /** |
| 660 | * @brief Duplicate a file descriptor in the current process's file descriptor table |
nothing calls this directly
no test coverage detected