1.\" $NetBSD: uiomove.9,v 1.13 2007/05/19 14:30:55 wiz Exp $ 2.\" 3.\" Copyright (c) 1996 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed by the NetBSD 17.\" Foundation, Inc. and its contributors. 18.\" 4. Neither the name of The NetBSD Foundation nor the names of its 19.\" contributors may be used to endorse or promote products derived 20.\" from this software without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 23.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 26.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32.\" POSSIBILITY OF SUCH DAMAGE. 33.\" 34.Dd March 7, 2007 35.Dt UIOMOVE 9 36.Os 37.Sh NAME 38.Nm uiomove 39.Nd move data described by a struct uio 40.Sh SYNOPSIS 41.In sys/systm.h 42.Ft int 43.Fn uiomove "void *buf" "size_t n" "struct uio *uio" 44.Sh DESCRIPTION 45The 46.Nm 47function copies up to 48.Fa n 49bytes between the kernel-space address pointed 50to by 51.Fa buf 52and the addresses described by 53.Fa uio , 54which may be in user-space or kernel-space. 55.Pp 56The 57.Fa uio 58argument is a pointer to a 59.Fa struct uio 60as defined by 61.Aq Pa sys/uio.h : 62.Bd -literal 63struct uio { 64 struct iovec *uio_iov; /* pointer to array of iovecs */ 65 int uio_iovcnt; /* number of iovecs in array */ 66 off_t uio_offset; /* offset into file this uio corresponds to */ 67 size_t uio_resid; /* residual i/o count */ 68 enum uio_rw uio_rw; 69 struct vmspace *uio_vmspace; 70}; 71.Ed 72.Pp 73A 74.Fa struct uio 75typically describes data in motion. 76Several of the fields described below reflect that expectation. 77.Pp 78.Bl -tag -width uio_xxxxxx 79.It uio_iov 80Pointer to array of 81.Fa struct iovecs : 82.Bd -literal 83struct iovec { 84 void *iov_base; /* Base address. */ 85 size_t iov_len; /* Length. */ 86}; 87.Ed 88.It uio_iovcnt 89The number of iovecs in the array. 90.It uio_offset 91An offset into the corresponding object. 92.It uio_resid 93The amount of space described by the structure; notionally, the amount 94of data remaining to be transferred. 95.It uio_rw 96A flag indicating whether data should be read into the space 97(UIO_READ) or written from the space (UIO_WRITE). 98.It uio_vmspace 99A pointer to the address space which is being transferred to or from. 100.El 101.Pp 102The value of 103.Fa uio-\*[Gt]uio_rw 104controls whether 105.Nm 106copies data from 107.Fa buf 108to 109.Fa uio 110or vice versa. 111.Pp 112The lesser of 113.Fa n 114or 115.Fa uio-\*[Gt]uio_resid 116bytes are copied. 117.Pp 118.Nm 119changes fields of the structure pointed to by 120.Fa uio , 121such that 122.Fa uio-\*[Gt]uio_resid 123is decremented by the amount of data moved, 124.Fa uio-\*[Gt]uio_offset 125is incremented by the same amount, and the array of iovecs is adjusted 126to point that much farther into the region described. 127This allows multiple calls to 128.Nm 129to easily be used to fill or drain the region of data. 130.Sh RETURN VALUES 131.Nm 132returns 0 on success or EFAULT if a bad address is encountered. 133.Sh SEE ALSO 134.Xr copy 9 , 135.Xr fetch 9 , 136.Xr store 9 137