xref: /freebsd/share/man/man9/copy.9 (revision bc216e3cd2e323bf176b10b84c28c32e79d307da)
15406291aSMike Pritchard.\"	$NetBSD: copy.9,v 1.2 1996/01/09 03:23:04 thorpej Exp $
25406291aSMike Pritchard.\"
35406291aSMike Pritchard.\" Copyright (c) 1996 Jason R. Thorpe.
45406291aSMike Pritchard.\" All rights reserved.
55406291aSMike Pritchard.\"
65406291aSMike Pritchard.\" This code is derived from software contributed by Kenneth Stailey.
75406291aSMike Pritchard.\"
85406291aSMike Pritchard.\" Redistribution and use in source and binary forms, with or without
95406291aSMike Pritchard.\" modification, are permitted provided that the following conditions
105406291aSMike Pritchard.\" are met:
115406291aSMike Pritchard.\" 1. Redistributions of source code must retain the above copyright
125406291aSMike Pritchard.\"    notice, this list of conditions and the following disclaimer.
135406291aSMike Pritchard.\" 2. Redistributions in binary form must reproduce the above copyright
145406291aSMike Pritchard.\"    notice, this list of conditions and the following disclaimer in the
155406291aSMike Pritchard.\"    documentation and/or other materials provided with the distribution.
165406291aSMike Pritchard.\" 3. All advertising materials mentioning features or use of this software
175406291aSMike Pritchard.\"    must display the following acknowledgement:
185406291aSMike Pritchard.\"	This product includes software developed for the NetBSD Project
195406291aSMike Pritchard.\"	by Jason R. Thorpe.
205406291aSMike Pritchard.\" 4. The name of the author may not be used to endorse or promote products
215406291aSMike Pritchard.\"    derived from this software without specific prior written permission.
225406291aSMike Pritchard.\"
235406291aSMike Pritchard.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
245406291aSMike Pritchard.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
255406291aSMike Pritchard.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
265406291aSMike Pritchard.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
275406291aSMike Pritchard.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
285406291aSMike Pritchard.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
295406291aSMike Pritchard.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
305406291aSMike Pritchard.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
315406291aSMike Pritchard.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
325406291aSMike Pritchard.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
335406291aSMike Pritchard.\" SUCH DAMAGE.
345406291aSMike Pritchard.\"
357f3dea24SPeter Wemm.\" $FreeBSD$
365bf6ab83SNik Clayton.\"
37d7b336c0SRuslan Ermilov.Dd January 7, 1996
385406291aSMike Pritchard.Dt COPY 9
393d45e180SRuslan Ermilov.Os
405406291aSMike Pritchard.Sh NAME
415406291aSMike Pritchard.Nm copy ,
425406291aSMike Pritchard.Nm copyin ,
435406291aSMike Pritchard.Nm copyout ,
445406291aSMike Pritchard.Nm copystr ,
455406291aSMike Pritchard.Nm copyinstr
465406291aSMike Pritchard.Nd kernel copy functions
475406291aSMike Pritchard.Sh SYNOPSIS
4832eef9aeSRuslan Ermilov.In sys/types.h
4932eef9aeSRuslan Ermilov.In sys/systm.h
505406291aSMike Pritchard.Ft int
512e14815bSBruce Evans.Fn copyin "const void *uaddr" "void *kaddr" "size_t len"
525406291aSMike Pritchard.Ft int
532e14815bSBruce Evans.Fn copyout "const void *kaddr" "void *uaddr" "size_t len"
545406291aSMike Pritchard.Ft int
552e14815bSBruce Evans.Fn copystr "const void *kfaddr" "void *kdaddr" "size_t len" "size_t *done"
565406291aSMike Pritchard.Ft int
572e14815bSBruce Evans.Fn copyinstr "const void *uaddr" "void *kaddr" "size_t len" "size_t *done"
585406291aSMike Pritchard.\" .Ft int
592e14815bSBruce Evans.\" .Fn copyoutstr "const void *kaddr" "void *uaddr" "size_t len" "size_t *done"
605406291aSMike Pritchard.Sh DESCRIPTION
615406291aSMike PritchardThe
625406291aSMike Pritchard.Nm
635406291aSMike Pritchardfunctions are designed to copy contiguous data from one address
643a858f37SHiten Pandyato another.
653a858f37SHiten PandyaAll but
665406291aSMike Pritchard.Fn copystr
675406291aSMike Pritchardcopy data from user-space to kernel-space or vice-versa.
685406291aSMike Pritchard.Pp
695406291aSMike PritchardThe
705406291aSMike Pritchard.Nm
715406291aSMike Pritchardroutines provide the following functionality:
725406291aSMike Pritchard.Bl -tag -width "copyoutstr()"
735406291aSMike Pritchard.It Fn copyin
745406291aSMike PritchardCopies
75bc216e3cSHiten Pandya.Fa len
765406291aSMike Pritchardbytes of data from the user-space address
77bc216e3cSHiten Pandya.Fa uaddr
785406291aSMike Pritchardto the kernel-space address
79bc216e3cSHiten Pandya.Fa kaddr .
805406291aSMike Pritchard.It Fn copyout
815406291aSMike PritchardCopies
82bc216e3cSHiten Pandya.Fa len
835406291aSMike Pritchardbytes of data from the kernel-space address
84bc216e3cSHiten Pandya.Fa kaddr
855406291aSMike Pritchardto the user-space address
86bc216e3cSHiten Pandya.Fa uaddr .
875406291aSMike Pritchard.It Fn copystr
88de635b06SWolfram SchneiderCopies a NUL-terminated string, at most
89bc216e3cSHiten Pandya.Fa len
905406291aSMike Pritchardbytes long, from kernel-space address
91bc216e3cSHiten Pandya.Fa kfaddr
925406291aSMike Pritchardto kernel-space address
93bc216e3cSHiten Pandya.Fa kdaddr .
945406291aSMike PritchardThe number of bytes actually copied, including the terminating
95de635b06SWolfram SchneiderNUL, is returned in
96bc216e3cSHiten Pandya.Fa *done
97bc216e3cSHiten Pandya.Po
98bc216e3cSHiten Pandyaif
99bc216e3cSHiten Pandya.Fa done
100449dfbbcSPawel Jakub Dawidekis
101bc216e3cSHiten Pandya.No non- Ns Dv NULL
102bc216e3cSHiten Pandya.Pc .
1035406291aSMike Pritchard.It Fn copyinstr
104de635b06SWolfram SchneiderCopies a NUL-terminated string, at most
105bc216e3cSHiten Pandya.Fa len
1065406291aSMike Pritchardbytes long, from user-space address
107bc216e3cSHiten Pandya.Fa uaddr
1085406291aSMike Pritchardto kernel-space address
109bc216e3cSHiten Pandya.Fa kaddr .
1105406291aSMike PritchardThe number of bytes actually copied, including the terminating
111de635b06SWolfram SchneiderNUL, is returned in
112bc216e3cSHiten Pandya.Fa *done
113bc216e3cSHiten Pandya.Po
114bc216e3cSHiten Pandyaif
115bc216e3cSHiten Pandya.Fa done
116449dfbbcSPawel Jakub Dawidekis
117bc216e3cSHiten Pandya.No non- Ns Dv NULL Ns
118bc216e3cSHiten Pandya.Pc .
1195406291aSMike Pritchard.\" .It Fn copyoutstr
12095297e22SJames Raynard.\" Copies a NUL-terminated string, at most
1215406291aSMike Pritchard.\" bytes long, from kernel-space address
1225406291aSMike Pritchard.\" .Pa kaddr
1235406291aSMike Pritchard.\" to user-space address
1245406291aSMike Pritchard.\" .Pa uaddr .
1255406291aSMike Pritchard.\" The number of bytes actually copied, including the terminating
12695297e22SJames Raynard.\" NUL, is returned in
1275406291aSMike Pritchard.\" .Pa *done .
1285406291aSMike Pritchard.El
1295406291aSMike Pritchard.Sh RETURN VALUES
1305406291aSMike PritchardThe
1315406291aSMike Pritchard.Nm
132b92a189eSRuslan Ermilovfunctions return 0 on success or
133b92a189eSRuslan Ermilov.Er EFAULT
134b92a189eSRuslan Ermilovif a bad address is encountered.
1355406291aSMike PritchardIn addition, the
1365406291aSMike Pritchard.Fn copystr ,
1375406291aSMike Pritchardand
1385406291aSMike Pritchard.Fn copyinstr
1395406291aSMike Pritchard.\" .Fn copyinstr ,
1405406291aSMike Pritchard.\" and
1415406291aSMike Pritchard.\" .Fn copyoutstr
142b92a189eSRuslan Ermilovfunctions return
143b92a189eSRuslan Ermilov.Er ENAMETOOLONG
144b92a189eSRuslan Ermilovif the string is longer than
145bc216e3cSHiten Pandya.Fa len
1465406291aSMike Pritchardbytes.
1475406291aSMike Pritchard.Sh SEE ALSO
1485406291aSMike Pritchard.Xr fetch 9 ,
1496fe89339SBen Smithurst.Xr store 9
150