xref: /freebsd/share/man/man9/copy.9 (revision 3a858f3798eb709b5f316cdae50865332284211d)
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
755406291aSMike Pritchard.Pa len
765406291aSMike Pritchardbytes of data from the user-space address
775406291aSMike Pritchard.Pa uaddr
785406291aSMike Pritchardto the kernel-space address
795406291aSMike Pritchard.Pa kaddr .
805406291aSMike Pritchard.It Fn copyout
815406291aSMike PritchardCopies
825406291aSMike Pritchard.Pa len
835406291aSMike Pritchardbytes of data from the kernel-space address
845406291aSMike Pritchard.Pa kaddr
855406291aSMike Pritchardto the user-space address
865406291aSMike Pritchard.Pa uaddr .
875406291aSMike Pritchard.It Fn copystr
88de635b06SWolfram SchneiderCopies a NUL-terminated string, at most
895406291aSMike Pritchard.Pa len
905406291aSMike Pritchardbytes long, from kernel-space address
915406291aSMike Pritchard.Pa kfaddr
925406291aSMike Pritchardto kernel-space address
935406291aSMike Pritchard.Pa kdaddr .
945406291aSMike PritchardThe number of bytes actually copied, including the terminating
95de635b06SWolfram SchneiderNUL, is returned in
965406291aSMike Pritchard.Pa *done .
975406291aSMike Pritchard.It Fn copyinstr
98de635b06SWolfram SchneiderCopies a NUL-terminated string, at most
995406291aSMike Pritchard.Pa len
1005406291aSMike Pritchardbytes long, from user-space address
1015406291aSMike Pritchard.Pa uaddr
1025406291aSMike Pritchardto kernel-space address
1035406291aSMike Pritchard.Pa kaddr .
1045406291aSMike PritchardThe number of bytes actually copied, including the terminating
105de635b06SWolfram SchneiderNUL, is returned in
1065406291aSMike Pritchard.Pa *done .
1075406291aSMike Pritchard.\" .It Fn copyoutstr
10895297e22SJames Raynard.\" Copies a NUL-terminated string, at most
1095406291aSMike Pritchard.\" bytes long, from kernel-space address
1105406291aSMike Pritchard.\" .Pa kaddr
1115406291aSMike Pritchard.\" to user-space address
1125406291aSMike Pritchard.\" .Pa uaddr .
1135406291aSMike Pritchard.\" The number of bytes actually copied, including the terminating
11495297e22SJames Raynard.\" NUL, is returned in
1155406291aSMike Pritchard.\" .Pa *done .
1165406291aSMike Pritchard.El
1175406291aSMike Pritchard.Sh RETURN VALUES
1185406291aSMike PritchardThe
1195406291aSMike Pritchard.Nm
120b92a189eSRuslan Ermilovfunctions return 0 on success or
121b92a189eSRuslan Ermilov.Er EFAULT
122b92a189eSRuslan Ermilovif a bad address is encountered.
1235406291aSMike PritchardIn addition, the
1245406291aSMike Pritchard.Fn copystr ,
1255406291aSMike Pritchardand
1265406291aSMike Pritchard.Fn copyinstr
1275406291aSMike Pritchard.\" .Fn copyinstr ,
1285406291aSMike Pritchard.\" and
1295406291aSMike Pritchard.\" .Fn copyoutstr
130b92a189eSRuslan Ermilovfunctions return
131b92a189eSRuslan Ermilov.Er ENAMETOOLONG
132b92a189eSRuslan Ermilovif the string is longer than
1335406291aSMike Pritchard.Pa len
1345406291aSMike Pritchardbytes.
1355406291aSMike Pritchard.Sh SEE ALSO
1365406291aSMike Pritchard.Xr fetch 9 ,
1376fe89339SBen Smithurst.Xr store 9
138