[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 7/7] Mini-OS: add read and write support to 9pfsfront



Juergen Gross, le ven. 10 févr. 2023 11:46:28 +0100, a ecrit:
> +    while ( len )
> +    {
> +        count = len;
> +        if ( count > dev->msize_max - 24 )
> +            count = dev->msize_max - 24;

24 should be detailed, to include e.g. sizeof(p9_header) and the sum of
sizes of the fields (I'm surprised that it's the same 24 for read and
write, notably).

> +        send_9p(dev, req, "ULU", fid, offset, count);
> +        rcv_9p(dev, req, "D", &count, data);
> +
> +        if ( !count )
> +            break;
> +        if ( req->result )
> +        {
> +            ret = -1;
> +            errno = EIO;

I'd say log req->result?

> +            break;
> +        }
> +        ret += count;
> +        offset += count;
> +        data += count;
> +        len -= count;
> +    }
> +
> +    put_free_req(dev, req);
> +
> +    return ret;
> +}
> +
> +static int p9_write(struct dev_9pfs *dev, uint32_t fid, uint64_t offset,
> +                    const uint8_t *data, uint32_t len)
> +{
> +    struct req *req = get_free_req(dev);
> +    int ret = 0;
> +    uint32_t count;
> +
> +    if ( !req )
> +    {
> +        errno = EAGAIN;
> +        return -1;
> +    }
> +    req->cmd = P9_CMD_WRITE;
> +
> +    while ( len )
> +    {
> +        count = len;
> +        if ( count > dev->msize_max - 24 )
> +            count = dev->msize_max - 24;

Same here.

> +        send_9p(dev, req, "ULD", fid, offset, count, data);
> +        rcv_9p(dev, req, "U", &count);
> +        if ( req->result )
> +        {
> +            ret = -1;
> +            errno = EIO;

Same here.

> +            break;
> +        }
> +        ret += count;
> +        offset += count;
> +        data += count;
> +        len -= count;
> +    }
> +
> +    put_free_req(dev, req);
> +
> +    return ret;
> +}



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.