xref: /freebsd/share/man/man9/copy.9 (revision 5406291a1d340b0e66fa52dda3230c0b65f47e63)
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.\"
355406291aSMike Pritchard.Dd Jan 7, 1996
365406291aSMike Pritchard.Dt COPY 9
375406291aSMike Pritchard.Os FreeBSD
385406291aSMike Pritchard.Sh NAME
395406291aSMike Pritchard.Nm copy ,
405406291aSMike Pritchard.Nm copyin ,
415406291aSMike Pritchard.Nm copyout ,
425406291aSMike Pritchard.Nm copystr ,
435406291aSMike Pritchard.Nm copyinstr
445406291aSMike Pritchard.Nd kernel copy functions
455406291aSMike Pritchard.Sh SYNOPSIS
465406291aSMike Pritchard.Fd #include <sys/types.h>
475406291aSMike Pritchard.Fd #include <sys/systm.h>
485406291aSMike Pritchard.Ft int
495406291aSMike Pritchard.Fn copyin "void *uaddr" "void *kaddr" "size_t len"
505406291aSMike Pritchard.Ft int
515406291aSMike Pritchard.Fn copyout "void *kaddr" "void *uaddr" "size_t len"
525406291aSMike Pritchard.Ft int
535406291aSMike Pritchard.Fn copystr "void *kfaddr" "void *kdaddr" "size_t len" "size_t *done"
545406291aSMike Pritchard.Ft int
555406291aSMike Pritchard.Fn copyinstr "void *uaddr" "void *kaddr" "size_t len" "size_t *done"
565406291aSMike Pritchard.\" .Ft int
575406291aSMike Pritchard.\" .Fn copyoutstr "void *kaddr" "void *uaddr" "size_t len" "size_t *done"
585406291aSMike Pritchard.Sh DESCRIPTION
595406291aSMike PritchardThe
605406291aSMike Pritchard.Nm
615406291aSMike Pritchardfunctions are designed to copy contiguous data from one address
625406291aSMike Pritchardto another.  All but
635406291aSMike Pritchard.Fn copystr
645406291aSMike Pritchardcopy data from user-space to kernel-space or vice-versa.
655406291aSMike Pritchard.Pp
665406291aSMike PritchardThe
675406291aSMike Pritchard.Nm
685406291aSMike Pritchardroutines provide the following functionality:
695406291aSMike Pritchard.Bl -tag -width "copyoutstr()"
705406291aSMike Pritchard.It Fn copyin
715406291aSMike PritchardCopies
725406291aSMike Pritchard.Pa len
735406291aSMike Pritchardbytes of data from the user-space address
745406291aSMike Pritchard.Pa uaddr
755406291aSMike Pritchardto the kernel-space address
765406291aSMike Pritchard.Pa kaddr .
775406291aSMike Pritchard.It Fn copyout
785406291aSMike PritchardCopies
795406291aSMike Pritchard.Pa len
805406291aSMike Pritchardbytes of data from the kernel-space address
815406291aSMike Pritchard.Pa kaddr
825406291aSMike Pritchardto the user-space address
835406291aSMike Pritchard.Pa uaddr .
845406291aSMike Pritchard.It Fn copystr
855406291aSMike PritchardCopies a NULL-terminated string, at most
865406291aSMike Pritchard.Pa len
875406291aSMike Pritchardbytes long, from kernel-space address
885406291aSMike Pritchard.Pa kfaddr
895406291aSMike Pritchardto kernel-space address
905406291aSMike Pritchard.Pa kdaddr .
915406291aSMike PritchardThe number of bytes actually copied, including the terminating
925406291aSMike PritchardNULL, is returned in
935406291aSMike Pritchard.Pa *done .
945406291aSMike Pritchard.It Fn copyinstr
955406291aSMike PritchardCopies a NULL-terminated string, at most
965406291aSMike Pritchard.Pa len
975406291aSMike Pritchardbytes long, from user-space address
985406291aSMike Pritchard.Pa uaddr
995406291aSMike Pritchardto kernel-space address
1005406291aSMike Pritchard.Pa kaddr .
1015406291aSMike PritchardThe number of bytes actually copied, including the terminating
1025406291aSMike PritchardNULL, is returned in
1035406291aSMike Pritchard.Pa *done .
1045406291aSMike Pritchard.\" .It Fn copyoutstr
1055406291aSMike Pritchard.\" Copies a NULL-terminated string, at most
1065406291aSMike Pritchard.\" bytes long, from kernel-space address
1075406291aSMike Pritchard.\" .Pa kaddr
1085406291aSMike Pritchard.\" to user-space address
1095406291aSMike Pritchard.\" .Pa uaddr .
1105406291aSMike Pritchard.\" The number of bytes actually copied, including the terminating
1115406291aSMike Pritchard.\" NULL, is returned in
1125406291aSMike Pritchard.\" .Pa *done .
1135406291aSMike Pritchard.El
1145406291aSMike Pritchard.Sh RETURN VALUES
1155406291aSMike PritchardThe
1165406291aSMike Pritchard.Nm
1175406291aSMike Pritchardfunctions return 0 on success or EFAULT if a bad address is encountered.
1185406291aSMike PritchardIn addition, the
1195406291aSMike Pritchard.Fn copystr ,
1205406291aSMike Pritchardand
1215406291aSMike Pritchard.Fn copyinstr
1225406291aSMike Pritchard.\" .Fn copyinstr ,
1235406291aSMike Pritchard.\" and
1245406291aSMike Pritchard.\" .Fn copyoutstr
1255406291aSMike Pritchardfunctions return ENAMETOOLONG if the string is longer than
1265406291aSMike Pritchard.Pa len
1275406291aSMike Pritchardbytes.
1285406291aSMike Pritchard.Sh SEE ALSO
1295406291aSMike Pritchard.Xr fetch 9 ,
1305406291aSMike Pritchard.Xr store 9 .
131