/* this function is a POSIX compliant version, which will set position of next directory structure in the directory stream. */
void seekdir(DIR *d, long offset)
/* this function is a POSIX compliant version, which will set position of next directory structure in the directory stream. */
void seekdir(DIR *d, long offset)
{
    struct dfs_file *file;
    if (d == NULL)
    {
        rt_set_errno(-EBADF);
        return;
    }
    file = fd_get(d->fd);
    if (file == NULL)
    {
        rt_set_errno(-EBADF);
        return;
    }
    if (d && d->fd > 0)
    {
        if (file->fpos > offset)
        {
            if (dfs_file_lseek(fd_get(d->fd), 0, SEEK_SET) >= 0)
                d->num = d->cur = 0;
        }
        while(file->fpos < offset)
        {
            if (!readdir(d))
            {
                break;
            }
        }
    }
}