Manual browser: uiomove(9)

UIOMOVE(9) Kernel Developer's Manual UIOMOVE(9)


uiomovemove data described by a struct uio


#include <sys/systm.h>

uiomove(void *buf, size_t n, struct uio *uio);


The uiomove() function copies up to 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; 
	int	uio_iovcnt; 
	off_t	uio_offset; 
	size_t	uio_resid; 
	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.

Pointer to array of I/O vectors to be processed. The struct iovec is defined to be:

struct iovec { 
	void	*iov_base; 
	size_t	 iov_len; 

The members in the struct iovec should only be initialized. These are:

The address for a range of memory to or from which data is transferred.
The number of bytes of data to be transferred to or from the range of memory starting at iov_base.
The number of I/O vectors in the uio_iov array.
An offset into the corresponding object.
The amount of space described by the structure; notionally, the amount of data remaining to be transferred.
A flag indicating whether data should be read into the space (UIO_READ) or written from the space (UIO_WRITE).
A pointer to the address space which is being transferred to or from.

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.


Upon successful completion, uiomove() returns 0. If a bad address is encountered, EFAULT is returned.
April 26, 2010 NetBSD 7.0