xref: /netbsd-src/share/man/man9/uiomove.9 (revision b5677b36047b601b9addaaa494a58ceae82c2a6c)
1.\"	$NetBSD: uiomove.9,v 1.14 2008/04/30 13:10:58 martin 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.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25.\" POSSIBILITY OF SUCH DAMAGE.
26.\"
27.Dd March 7, 2007
28.Dt UIOMOVE 9
29.Os
30.Sh NAME
31.Nm uiomove
32.Nd move data described by a struct uio
33.Sh SYNOPSIS
34.In sys/systm.h
35.Ft int
36.Fn uiomove "void *buf" "size_t n" "struct uio *uio"
37.Sh DESCRIPTION
38The
39.Nm
40function copies up to
41.Fa n
42bytes between the kernel-space address pointed
43to by
44.Fa buf
45and the addresses described by
46.Fa uio ,
47which may be in user-space or kernel-space.
48.Pp
49The
50.Fa uio
51argument is a pointer to a
52.Fa struct uio
53as defined by
54.Aq Pa sys/uio.h :
55.Bd -literal
56struct uio {
57	struct	iovec *uio_iov;	/* pointer to array of iovecs */
58	int	uio_iovcnt;	/* number of iovecs in array */
59	off_t	uio_offset;	/* offset into file this uio corresponds to */
60	size_t	uio_resid;	/* residual i/o count */
61	enum	uio_rw uio_rw;
62	struct	vmspace *uio_vmspace;
63};
64.Ed
65.Pp
66A
67.Fa struct uio
68typically describes data in motion.
69Several of the fields described below reflect that expectation.
70.Pp
71.Bl -tag -width uio_xxxxxx
72.It uio_iov
73Pointer to array of
74.Fa struct iovecs :
75.Bd -literal
76struct iovec {
77	void	*iov_base;	/* Base address. */
78	size_t	 iov_len;	/* Length. */
79};
80.Ed
81.It uio_iovcnt
82The number of iovecs in the array.
83.It uio_offset
84An offset into the corresponding object.
85.It uio_resid
86The amount of space described by the structure; notionally, the amount
87of data remaining to be transferred.
88.It uio_rw
89A flag indicating whether data should be read into the space
90(UIO_READ) or written from the space (UIO_WRITE).
91.It uio_vmspace
92A pointer to the address space which is being transferred to or from.
93.El
94.Pp
95The value of
96.Fa uio-\*[Gt]uio_rw
97controls whether
98.Nm
99copies data from
100.Fa buf
101to
102.Fa uio
103or vice versa.
104.Pp
105The lesser of
106.Fa n
107or
108.Fa uio-\*[Gt]uio_resid
109bytes are copied.
110.Pp
111.Nm
112changes fields of the structure pointed to by
113.Fa uio ,
114such that
115.Fa uio-\*[Gt]uio_resid
116is decremented by the amount of data moved,
117.Fa uio-\*[Gt]uio_offset
118is incremented by the same amount, and the array of iovecs is adjusted
119to point that much farther into the region described.
120This allows multiple calls to
121.Nm
122to easily be used to fill or drain the region of data.
123.Sh RETURN VALUES
124.Nm
125returns 0 on success or EFAULT if a bad address is encountered.
126.Sh SEE ALSO
127.Xr copy 9 ,
128.Xr fetch 9 ,
129.Xr store 9
130