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