root/kern/include/copyinout.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
   3  *      The President and Fellows of Harvard College.
   4  *
   5  * Redistribution and use in source and binary forms, with or without
   6  * modification, are permitted provided that the following conditions
   7  * are met:
   8  * 1. Redistributions of source code must retain the above copyright
   9  *    notice, this list of conditions and the following disclaimer.
  10  * 2. Redistributions in binary form must reproduce the above copyright
  11  *    notice, this list of conditions and the following disclaimer in the
  12  *    documentation and/or other materials provided with the distribution.
  13  * 3. Neither the name of the University nor the names of its contributors
  14  *    may be used to endorse or promote products derived from this software
  15  *    without specific prior written permission.
  16  *
  17  * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
  18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
  21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27  * SUCH DAMAGE.
  28  */
  29 
  30 #ifndef _COPYINOUT_H_
  31 #define _COPYINOUT_H_
  32 
  33 
  34 /*
  35  * copyin/copyout/copyinstr/copyoutstr are standard BSD kernel functions.
  36  *
  37  * copyin copies LEN bytes from a user-space address USERSRC to a
  38  * kernel-space address DEST.
  39  *
  40  * copyout copies LEN bytes from a kernel-space address SRC to a
  41  * user-space address USERDEST.
  42  *
  43  * copyinstr copies a null-terminated string of at most LEN bytes from
  44  * a user-space address USERSRC to a kernel-space address DEST, and 
  45  * returns the actual length of string found in GOT. DEST is always
  46  * null-terminated on success. LEN and GOT include the null terminator.
  47  *
  48  * copyoutstr copies a null-terminated string of at most LEN bytes from
  49  * a kernel-space address SRC to a user-space address USERDEST, and 
  50  * returns the actual length of string found in GOT. DEST is always
  51  * null-terminated on success. LEN and GOT include the null terminator.
  52  *
  53  * All of these functions return 0 on success, EFAULT if a memory
  54  * addressing error was encountered, or (for the string versions)
  55  * ENAMETOOLONG if the space available was insufficient.
  56  *
  57  * NOTE that the order of the arguments is the same as bcopy() or 
  58  * cp/mv, that is, source on the left, NOT the same as strcpy().
  59  * The const qualifiers and types will help protect against mistakes
  60  * in this regard but are obviously not foolproof.
  61  *
  62  * These functions are machine-dependent; however, a common version
  63  * that can be used by a number of machine types is found in
  64  * vm/copyinout.c.
  65  */
  66 
  67 int copyin(const_userptr_t usersrc, void *dest, size_t len);
  68 int copyout(const void *src, userptr_t userdest, size_t len);
  69 int copyinstr(const_userptr_t usersrc, char *dest, size_t len, size_t *got);
  70 int copyoutstr(const char *src, userptr_t userdest, size_t len, size_t *got);
  71 
  72 
  73 #endif /* _COPYINOUT_H_ */

/* [<][>][^][v][top][bottom][index][help] */