* this function is a POSIX compliant version, which will close the open * file descriptor. * * @param fd the file descriptor. * * @return 0 on successful, -1 on failed. */
| 282 | * @return 0 on successful, -1 on failed. |
| 283 | */ |
| 284 | int close(int fd) |
| 285 | { |
| 286 | int result; |
| 287 | struct dfs_file *file; |
| 288 | |
| 289 | file = fd_get(fd); |
| 290 | if (file == NULL) |
| 291 | { |
| 292 | rt_set_errno(-EBADF); |
| 293 | |
| 294 | return -1; |
| 295 | } |
| 296 | |
| 297 | result = dfs_file_close(file); |
| 298 | if (result < 0) |
| 299 | { |
| 300 | rt_set_errno(result); |
| 301 | |
| 302 | return -1; |
| 303 | } |
| 304 | |
| 305 | fd_release(fd); |
| 306 | |
| 307 | return 0; |
| 308 | } |
| 309 | RTM_EXPORT(close); |
| 310 | |
| 311 | /** |
no test coverage detected