1.\" $NetBSD: uiomove.9,v 1.8 2002/08/25 22:29:11 thorpej 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 February 12, 1999 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.Fd #include \*[Lt]sys/systm.h\*[Gt] 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_seg uio_segflg; 69 enum uio_rw uio_rw; 70 struct proc *uio_procp;/* process if UIO_USERSPACE */ 71}; 72.Ed 73.Pp 74A 75.Fa struct uio 76typically describes data in motion. 77Several of the fields described below reflect that expectation. 78.Pp 79.Bl -tag -width uio_xxxxxx 80.It uio_iov 81Pointer to array of 82.Fa struct iovecs : 83.Bd -literal 84struct iovec { 85 void *iov_base; /* Base address. */ 86 size_t iov_len; /* Length. */ 87}; 88.Ed 89.It uio_iovcnt 90The number of iovecs in the array. 91.It uio_offset 92An offset into the corresponding object. 93.It uio_resid 94The amount of space described by the structure; notionally, the amount 95of data remaining to be transferred. 96.It uio_segflg 97A flag indicating whether the space described is in user-space 98(UIO_USERSPACE) or kernel-space (UIO_SYSSPACE). 99.It uio_rw 100A flag indicating whether date should be read into the space 101(UIO_READ) or written from the space (UIO_WRITE). 102.It uio_procp 103A pointer to the process whose data area is described by the 104structure, or NULL if the area is in kernel-space. 105.El 106.Pp 107The value of 108.Fa uio-\*[Gt]uio_rw 109controls whether 110.Nm 111copies data from 112.Fa buf 113to 114.Fa uio 115or vice versa. 116.Pp 117The lesser of 118.Fa n 119or 120.Fa uio-\*[Gt]resid 121bytes are copied. 122.Pp 123.Nm 124changes fields of the structure pointed to by 125.Fa uio , 126such that 127.Fa uio-\*[Gt]uio_resid 128is decremented by the amount of data moved, 129.Fa uio-\*[Gt]uio_offset 130is incremented by the same amount, and the array of iovecs is adjusted 131to point that much farther into the region described. 132This allows multiple calls to 133.Nm 134to easily be used to fill or drain the region of data. 135.Sh RETURN VALUES 136.Nm 137returns 0 on success or EFAULT if a bad address is encountered. 138.Sh SEE ALSO 139.Xr copy 9 , 140.Xr fetch 9 , 141.Xr store 9 142