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