static oe_fd_t* _hostfs_opendir(oe_device_t* device, const char* name)
{
    oe_fd_t* ret = NULL;
    device_t* fs = _cast_device(device);
    dir_t* dir = NULL;
    char host_name[OE_PATH_MAX];
    uint64_t retval = 0;

    if (!fs || !name)
        OE_RAISE_ERRNO(OE_EINVAL);

    if (_make_host_path(fs, name, host_name) != 0)
        OE_RAISE_ERRNO_MSG(oe_errno, "name=%s", name);

    if (!(dir = oe_calloc(1, sizeof(dir_t))))
        OE_RAISE_ERRNO(OE_ENOMEM);

    if (oe_syscall_opendir_ocall(&retval, host_name) != OE_OK)
        OE_RAISE_ERRNO(OE_EINVAL);

    if (!retval)
        OE_RAISE_ERRNO(oe_errno);

    dir->base.type = OE_FD_TYPE_FILE;
    dir->magic = DIR_MAGIC;
    dir->base.ops.file = _get_file_ops();
    dir->host_dir = retval;

    ret = &dir->base;
    dir = NULL;

done:

    if (dir)
        oe_free(dir);

    return ret;
}
static oe_fd_t* _hostfs_opendir(oe_device_t* device, const char* name)
{
    oe_fd_t* ret = NULL;
    device_t* fs = _cast_device(device);
    dir_t* dir = NULL;
    char host_name[OE_PATH_MAX];
    uint64_t retval = 0;

    if (!fs || !name)
        OE_RAISE_ERRNO(OE_EINVAL);

    if (_make_host_path(fs, name, host_name) != 0)
        OE_RAISE_ERRNO_MSG(oe_errno, "name=%s", name);

    if (!(dir = oe_calloc(1, sizeof(dir_t))))
        OE_RAISE_ERRNO(OE_ENOMEM);

    if (oe_syscall_opendir_ocall(&retval, host_name) != OE_OK)
        OE_RAISE_ERRNO(OE_EINVAL);

    if (!retval)
        OE_RAISE_ERRNO(oe_errno);

    dir->base.type = OE_FD_TYPE_FILE;
    dir->magic = DIR_MAGIC;
    dir->base.ops.file = _get_file_ops();
    dir->host_dir = retval;

    ret = &dir->base;
    dir = NULL;

done:

    if (dir)
        oe_free(dir);

    return ret;
}