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 645406291aSMike Pritchardto another. All but 655406291aSMike Pritchard.Fn copystr 665406291aSMike Pritchardcopy data from user-space to kernel-space or vice-versa. 675406291aSMike Pritchard.Pp 685406291aSMike PritchardThe 695406291aSMike Pritchard.Nm 705406291aSMike Pritchardroutines provide the following functionality: 715406291aSMike Pritchard.Bl -tag -width "copyoutstr()" 725406291aSMike Pritchard.It Fn copyin 735406291aSMike PritchardCopies 745406291aSMike Pritchard.Pa len 755406291aSMike Pritchardbytes of data from the user-space address 765406291aSMike Pritchard.Pa uaddr 775406291aSMike Pritchardto the kernel-space address 785406291aSMike Pritchard.Pa kaddr . 795406291aSMike Pritchard.It Fn copyout 805406291aSMike PritchardCopies 815406291aSMike Pritchard.Pa len 825406291aSMike Pritchardbytes of data from the kernel-space address 835406291aSMike Pritchard.Pa kaddr 845406291aSMike Pritchardto the user-space address 855406291aSMike Pritchard.Pa uaddr . 865406291aSMike Pritchard.It Fn copystr 87de635b06SWolfram SchneiderCopies a NUL-terminated string, at most 885406291aSMike Pritchard.Pa len 895406291aSMike Pritchardbytes long, from kernel-space address 905406291aSMike Pritchard.Pa kfaddr 915406291aSMike Pritchardto kernel-space address 925406291aSMike Pritchard.Pa kdaddr . 935406291aSMike PritchardThe number of bytes actually copied, including the terminating 94de635b06SWolfram SchneiderNUL, is returned in 955406291aSMike Pritchard.Pa *done . 965406291aSMike Pritchard.It Fn copyinstr 97de635b06SWolfram SchneiderCopies a NUL-terminated string, at most 985406291aSMike Pritchard.Pa len 995406291aSMike Pritchardbytes long, from user-space address 1005406291aSMike Pritchard.Pa uaddr 1015406291aSMike Pritchardto kernel-space address 1025406291aSMike Pritchard.Pa kaddr . 1035406291aSMike PritchardThe number of bytes actually copied, including the terminating 104de635b06SWolfram SchneiderNUL, is returned in 1055406291aSMike Pritchard.Pa *done . 1065406291aSMike Pritchard.\" .It Fn copyoutstr 10795297e22SJames Raynard.\" Copies a NUL-terminated string, at most 1085406291aSMike Pritchard.\" bytes long, from kernel-space address 1095406291aSMike Pritchard.\" .Pa kaddr 1105406291aSMike Pritchard.\" to user-space address 1115406291aSMike Pritchard.\" .Pa uaddr . 1125406291aSMike Pritchard.\" The number of bytes actually copied, including the terminating 11395297e22SJames Raynard.\" NUL, is returned in 1145406291aSMike Pritchard.\" .Pa *done . 1155406291aSMike Pritchard.El 1165406291aSMike Pritchard.Sh RETURN VALUES 1175406291aSMike PritchardThe 1185406291aSMike Pritchard.Nm 119b92a189eSRuslan Ermilovfunctions return 0 on success or 120b92a189eSRuslan Ermilov.Er EFAULT 121b92a189eSRuslan Ermilovif a bad address is encountered. 1225406291aSMike PritchardIn addition, the 1235406291aSMike Pritchard.Fn copystr , 1245406291aSMike Pritchardand 1255406291aSMike Pritchard.Fn copyinstr 1265406291aSMike Pritchard.\" .Fn copyinstr , 1275406291aSMike Pritchard.\" and 1285406291aSMike Pritchard.\" .Fn copyoutstr 129b92a189eSRuslan Ermilovfunctions return 130b92a189eSRuslan Ermilov.Er ENAMETOOLONG 131b92a189eSRuslan Ermilovif the string is longer than 1325406291aSMike Pritchard.Pa len 1335406291aSMike Pritchardbytes. 1345406291aSMike Pritchard.Sh SEE ALSO 1355406291aSMike Pritchard.Xr fetch 9 , 1366fe89339SBen Smithurst.Xr store 9 137