NetBSD/share/man/man9/uiomove.9

130 lines
3.6 KiB
Groff
Raw Normal View History

.\" $NetBSD: uiomove.9,v 1.14 2008/04/30 13:10:58 martin Exp $
1999-02-13 11:03:34 +03:00
.\"
.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
2007-05-19 18:30:55 +04:00
.Dd March 7, 2007
1999-02-13 11:03:34 +03:00
.Dt UIOMOVE 9
.Os
1999-02-13 11:03:34 +03:00
.Sh NAME
.Nm uiomove
.Nd move data described by a struct uio
.Sh SYNOPSIS
.In sys/systm.h
1999-02-13 11:03:34 +03:00
.Ft int
.Fn uiomove "void *buf" "size_t n" "struct uio *uio"
1999-02-13 11:03:34 +03:00
.Sh DESCRIPTION
2001-09-04 06:51:15 +04:00
The
1999-02-13 11:03:34 +03:00
.Nm
2001-09-04 06:51:15 +04:00
function copies up to
1999-02-13 11:03:34 +03:00
.Fa n
bytes between the kernel-space address pointed
2001-09-04 06:51:15 +04:00
to by
1999-02-13 11:03:34 +03:00
.Fa buf
and the addresses described by
.Fa uio ,
2001-09-04 06:51:15 +04:00
which may be in user-space or kernel-space.
2001-09-04 06:52:44 +04:00
.Pp
2001-09-04 06:51:15 +04:00
The
1999-02-13 11:03:34 +03:00
.Fa uio
2001-09-04 06:51:15 +04:00
argument is a pointer to a
1999-02-13 11:03:34 +03:00
.Fa struct uio
as defined by
.Aq Pa sys/uio.h :
.Bd -literal
struct uio {
struct iovec *uio_iov; /* pointer to array of iovecs */
int uio_iovcnt; /* number of iovecs in array */
off_t uio_offset; /* offset into file this uio corresponds to */
size_t uio_resid; /* residual i/o count */
2001-09-04 06:51:15 +04:00
enum uio_rw uio_rw;
struct vmspace *uio_vmspace;
1999-02-13 11:03:34 +03:00
};
.Ed
2001-09-04 06:52:44 +04:00
.Pp
2001-09-04 06:51:15 +04:00
A
1999-02-13 11:03:34 +03:00
.Fa struct uio
typically describes data in motion.
Several of the fields described below reflect that expectation.
2001-09-04 06:52:44 +04:00
.Pp
1999-02-13 11:03:34 +03:00
.Bl -tag -width uio_xxxxxx
.It uio_iov
2001-09-04 06:51:15 +04:00
Pointer to array of
1999-02-13 11:03:34 +03:00
.Fa struct iovecs :
.Bd -literal
struct iovec {
void *iov_base; /* Base address. */
size_t iov_len; /* Length. */
};
.Ed
.It uio_iovcnt
The number of iovecs in the array.
.It uio_offset
An offset into the corresponding object.
.It uio_resid
The amount of space described by the structure; notionally, the amount
of data remaining to be transferred.
.It uio_rw
2004-07-20 18:34:27 +04:00
A flag indicating whether data should be read into the space
2001-09-04 06:51:15 +04:00
(UIO_READ) or written from the space (UIO_WRITE).
.It uio_vmspace
A pointer to the address space which is being transferred to or from.
1999-02-13 11:03:34 +03:00
.El
2001-09-04 06:52:44 +04:00
.Pp
1999-02-13 11:03:34 +03:00
The value of
.Fa uio-\*[Gt]uio_rw
2001-09-04 06:51:15 +04:00
controls whether
1999-02-13 11:03:34 +03:00
.Nm
2001-09-04 06:51:15 +04:00
copies data from
1999-02-13 11:03:34 +03:00
.Fa buf
to
.Fa uio
2001-09-04 06:51:15 +04:00
or vice versa.
2001-09-04 06:52:44 +04:00
.Pp
2001-09-04 06:51:15 +04:00
The lesser of
1999-02-13 11:03:34 +03:00
.Fa n
2001-09-04 06:51:15 +04:00
or
.Fa uio-\*[Gt]uio_resid
2001-09-04 06:51:15 +04:00
bytes are copied.
2001-09-04 06:52:44 +04:00
.Pp
2001-09-04 06:51:15 +04:00
.Nm
1999-02-13 11:03:34 +03:00
changes fields of the structure pointed to by
2001-09-04 06:51:15 +04:00
.Fa uio ,
such that
.Fa uio-\*[Gt]uio_resid
2001-09-04 06:51:15 +04:00
is decremented by the amount of data moved,
.Fa uio-\*[Gt]uio_offset
1999-02-13 11:03:34 +03:00
is incremented by the same amount, and the array of iovecs is adjusted
to point that much farther into the region described.
2001-09-04 06:51:15 +04:00
This allows multiple calls to
1999-02-13 11:03:34 +03:00
.Nm
to easily be used to fill or drain the region of data.
.Sh RETURN VALUES
2001-09-04 06:51:15 +04:00
.Nm
1999-02-13 11:03:34 +03:00
returns 0 on success or EFAULT if a bad address is encountered.
.Sh SEE ALSO
2001-12-26 03:16:30 +03:00
.Xr copy 9 ,
1999-02-13 11:03:34 +03:00
.Xr fetch 9 ,
2001-12-26 03:16:30 +03:00
.Xr store 9