NetBSD/share/man/man9/uiomove.9

155 lines
4.0 KiB
Groff
Raw Normal View History

2010-04-26 11:51:36 +04:00
.\" $NetBSD: uiomove.9,v 1.17 2010/04/26 07:51:36 jruoho 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.
.\"
2010-04-26 11:36:33 +04:00
.Dd April 26, 2010
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
2010-04-26 11:36:33 +04:00
.Fn uiomove
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
2010-04-26 11:36:33 +04:00
.Va struct uio
1999-02-13 11:03:34 +03:00
as defined by
.In sys/uio.h :
2010-04-26 11:36:33 +04:00
.Bd -literal -offset indent
1999-02-13 11:03:34 +03:00
struct uio {
2010-04-26 11:36:33 +04:00
struct iovec *uio_iov;
int uio_iovcnt;
off_t uio_offset;
size_t uio_resid;
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
2010-04-26 11:36:33 +04:00
.Va 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
2010-04-26 11:36:33 +04:00
.Bl -tag -width "uio_vmspace "
.It Va uio_iov
2001-09-04 06:51:15 +04:00
Pointer to array of
2010-04-26 11:36:33 +04:00
.Tn I/O
vectors to be processed.
The
.Va struct iovec
is defined to be:
2010-04-26 11:51:36 +04:00
.Bd -literal -offset indent
1999-02-13 11:03:34 +03:00
struct iovec {
2010-04-26 11:51:36 +04:00
void *iov_base;
size_t iov_len;
1999-02-13 11:03:34 +03:00
};
.Ed
2010-04-26 11:51:36 +04:00
.Pp
The members in the
.Va struct iovec
should only be initialized.
These are:
.Bl -tag -width "*iov_base " -offset indent
.It Va iov_base
The address for a range of memory to or from which data is transferred.
.It Va iov_len
The number of bytes of data to be transferred to
or from the range of memory starting at
.Va iov_base .
.El
2010-04-26 11:36:33 +04:00
.It Va uio_iovcnt
The number of
.Tn I/O
vectors in the
.Va uio_iov
array.
.It Va uio_offset
1999-02-13 11:03:34 +03:00
An offset into the corresponding object.
2010-04-26 11:36:33 +04:00
.It Va uio_resid
1999-02-13 11:03:34 +03:00
The amount of space described by the structure; notionally, the amount
of data remaining to be transferred.
2010-04-26 11:36:33 +04:00
.It Va 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).
2010-04-26 11:36:33 +04:00
.It Va 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
2010-04-26 11:36:33 +04:00
.Va uio-\*[Gt]uio_rw
2001-09-04 06:51:15 +04:00
controls whether
2010-04-26 11:36:33 +04:00
.Fn uiomove
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
2010-04-26 11:36:33 +04:00
.Va uio-\*[Gt]uio_resid
2001-09-04 06:51:15 +04:00
bytes are copied.
2001-09-04 06:52:44 +04:00
.Pp
2010-04-26 11:36:33 +04:00
.Fn uiomove
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
2010-04-26 11:36:33 +04:00
.Va uio-\*[Gt]uio_resid
2001-09-04 06:51:15 +04:00
is decremented by the amount of data moved,
2010-04-26 11:36:33 +04:00
.Va 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
2010-04-26 11:36:33 +04:00
.Fn uiomove
1999-02-13 11:03:34 +03:00
to easily be used to fill or drain the region of data.
.Sh RETURN VALUES
2010-04-26 11:36:33 +04:00
Upon successful completion,
.Fn uiomove
returns 0.
If a bad address is encountered,
.Er EFAULT
is returned.
1999-02-13 11:03:34 +03:00
.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