/* this function is a POSIX compliant version, which will close a directory stream. */
int closedir(DIR *d)
/* this function is a POSIX compliant version, which will close a directory stream. */
int closedir(DIR *d)
{
    int result;
    struct dfs_fd *fd;
    fd = fd_get(d->fd);
    if (fd == NULL)
    {
        rt_set_errno(-EBADF);
        return -1;
    }
    result = dfs_file_close(fd);
    fd_put(fd);
    fd_put(fd);
    rt_free(d);
    if (result < 0)
    {
        rt_set_errno(result);
        return -1;
    }
    else
        return 0;
}