* @brief Release a file descriptor from the file descriptor table * * @param[in,out] fdt Pointer to the file descriptor table * @param[in] fd The file descriptor to be released */
| 348 | * @param[in] fd The file descriptor to be released |
| 349 | */ |
| 350 | void fdt_fd_release(struct dfs_fdtable *fdt, int fd) |
| 351 | { |
| 352 | if (fd < fdt->maxfd) |
| 353 | { |
| 354 | struct dfs_file *file; |
| 355 | |
| 356 | file = fdt_get_file(fdt, fd); |
| 357 | |
| 358 | if (file && file->ref_count == 1) |
| 359 | { |
| 360 | dfs_file_destroy(file); |
| 361 | } |
| 362 | else |
| 363 | { |
| 364 | rt_atomic_sub(&(file->ref_count), 1); |
| 365 | } |
| 366 | |
| 367 | fdt->fds[fd] = RT_NULL; |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | /** |
| 372 | * @ingroup group_fs_file_descriptor |
no test coverage detected