int
uiomove(
void *buf
, size_t n
, struct uio *uio
)
n
bytes between the kernel-space address pointed
to by
buf
and the addresses described by
uio
,
which may be in user-space or kernel-space.
The
uio
argument is a pointer to a
struct
uio
as defined by
<sys/uio.h
>:
struct uio {
struct iovec *uio_iov; /* pointer to array of iovecs */
int uio_iovcnt; /* number of iovecs in array */
off_t uio_offset; /* offset into file this uio corresponds to */
size_t uio_resid; /* residual i/o count */
enum uio_rw uio_rw;
struct vmspace *uio_vmspace;
};
A
struct
uio
typically describes data in motion.
Several of the fields described below reflect that expectation.
struct
iovecs
:
struct iovec {
void *iov_base; /* Base address. */
size_t iov_len; /* Length. */
};
The value of
uio->uio_rw
controls whether
uiomove
copies data from
buf
to
uio
or vice versa.
The lesser of
n
or
uio->uio_resid
bytes are copied.
uiomove
changes fields of the structure pointed to by
uio
,
such that
uio->uio_resid
is decremented by the amount of data moved,
uio->uio_offset
is incremented by the same amount, and the array of iovecs is adjusted
to point that much farther into the region described.
This allows multiple calls to
uiomove
to easily be used to fill or drain the region of data.