static oe_fd_t* _new_file(uint32_t fileno)
{
    oe_fd_t* ret = NULL;
    file_t* file = NULL;

    if (fileno > OE_STDERR_FILENO)
        goto done;

    /* Create the file struct. */
    {
        if (!(file = oe_calloc(1, sizeof(file_t))))
            goto done;

        file->base.type = OE_FD_TYPE_FILE;
        file->base.ops.file = _ops;
        file->magic = MAGIC;
    }

    /* Ask the host to duplicate the file descriptor. */
    {
        oe_host_fd_t retval;

        if (oe_syscall_dup_ocall(&retval, fileno) != OE_OK)
            goto done;

        if (retval < 0)
            goto done;

        file->host_fd = retval;
    }

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

done:

    if (file)
        oe_free(file);

    return ret;
}
static oe_fd_t* _new_file(uint32_t fileno)
{
    oe_fd_t* ret = NULL;
    file_t* file = NULL;

    if (fileno > OE_STDERR_FILENO)
        goto done;

     
    {
        if (!(file = oe_calloc(1, sizeof(file_t))))
            goto done;

        file->base.type = OE_FD_TYPE_FILE;
        file->base.ops.file = _ops;
        file->magic = MAGIC;
    }

     
    {
        oe_host_fd_t retval;

        if (oe_syscall_dup_ocall(&retval, fileno) != OE_OK)
            goto done;

        if (retval < 0)
            goto done;

        file->host_fd = retval;
    }

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

done:

    if (file)
        oe_free(file);

    return ret;
}