static struct oe_dirent* _hostfs_readdir(oe_fd_t* desc)
{
    struct oe_dirent* ret = NULL;
    dir_t* dir = _cast_dir(desc);
    int retval = -1;

    if (!dir)
        OE_RAISE_ERRNO(OE_EINVAL);

    /* Call the host to get the next directory entry. */
    if (oe_syscall_readdir_ocall(&retval, dir->host_dir, &dir->entry) != OE_OK)
    {
        OE_RAISE_ERRNO(OE_EINVAL);
    }

    /* Handle any error. */
    if (retval == -1)
        OE_RAISE_ERRNO(oe_errno);

    /* If end of file, then return NULL. */
    if (retval == 1)
        goto done;

    /* Check for an unexpected return value (indicates a coding error). */
    if (retval != 0)
        OE_RAISE_ERRNO(OE_EINVAL);

    ret = &dir->entry;

done:

    return ret;
}
static struct oe_dirent* _hostfs_readdir(oe_fd_t* desc)
{
    struct oe_dirent* ret = NULL;
    dir_t* dir = _cast_dir(desc);
    int retval = -1;

    if (!dir)
        OE_RAISE_ERRNO(OE_EINVAL);

     
    if (oe_syscall_readdir_ocall(&retval, dir->host_dir, &dir->entry) != OE_OK)
    {
        OE_RAISE_ERRNO(OE_EINVAL);
    }

     
    if (retval == -1)
        OE_RAISE_ERRNO(oe_errno);

     
    if (retval == 1)
        goto done;

     
    if (retval != 0)
        OE_RAISE_ERRNO(OE_EINVAL);

    ret = &dir->entry;

done:

    return ret;
}