uiomove question
John Baldwin
jhb at freebsd.org
Mon May 8 20:37:22 UTC 2017
On Saturday, March 11, 2017 02:03:06 PM Anindya Mukherjee wrote:
> An example of the usage I am talking about:
>
> xxx_write(...)
> {
> ...
> amount = MIN(uio->uio_resid, // 0. This is the no of bytes in the uio left to write
> (BUFFER_SIZE - 1 - uio->uio_offset > 0) ?
> BUFFER_SIZE - 1 - uio->uio_offset : 0); // 1. amount to write is computed
> //assuming write will happen at uio_offset in sc_buffer
> if (amount == 0)
> return (error);
> error = uiomove(sc->sc_buffer, amount, uio); // 2. sc_buffer is not offset
> ...
> }
>
> xxx_read(...)
> {
> ...
> amount = MIN(uio->uio_resid,
> (sc->sc_length - uio->uio_offset > 0) ?
> sc->sc_length - uio->uio_offset : 0); // 3. Same as comment 1 above
> error = uiomove(sc->sc_buffer + uio->uio_offset, amount, uio); // 4. Here buffer is offset
> ...
> }
>
> Anindya
Yes, I think your point is correct.
--
John Baldwin
More information about the freebsd-drivers
mailing list