The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/kernel/system/do_copy.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* The kernel call implemented in this file:
    2  *   m_type:    SYS_VIRCOPY, SYS_PHYSCOPY
    3  *
    4  * The parameters for this kernel call are:
    5  *    m5_c1:    CP_SRC_SPACE            source virtual segment
    6  *    m5_l1:    CP_SRC_ADDR             source offset within segment
    7  *    m5_i1:    CP_SRC_PROC_NR          source process number
    8  *    m5_c2:    CP_DST_SPACE            destination virtual segment
    9  *    m5_l2:    CP_DST_ADDR             destination offset within segment
   10  *    m5_i2:    CP_DST_PROC_NR          destination process number
   11  *    m5_l3:    CP_NR_BYTES             number of bytes to copy
   12  */
   13 
   14 #include "../system.h"
   15 #include <minix/type.h>
   16 
   17 #if (USE_VIRCOPY || USE_PHYSCOPY)
   18 
   19 /*===========================================================================*
   20  *                              do_copy                                      *
   21  *===========================================================================*/
   22 PUBLIC int do_copy(m_ptr)
   23 register message *m_ptr;        /* pointer to request message */
   24 {
   25 /* Handle sys_vircopy() and sys_physcopy().  Copy data using virtual or
   26  * physical addressing. Although a single handler function is used, there 
   27  * are two different kernel calls so that permissions can be checked. 
   28  */
   29   struct vir_addr vir_addr[2];  /* virtual source and destination address */
   30   phys_bytes bytes;             /* number of bytes to copy */
   31   int i;
   32 
   33   /* Dismember the command message. */
   34   vir_addr[_SRC_].proc_nr = m_ptr->CP_SRC_PROC_NR;
   35   vir_addr[_SRC_].segment = m_ptr->CP_SRC_SPACE;
   36   vir_addr[_SRC_].offset = (vir_bytes) m_ptr->CP_SRC_ADDR;
   37   vir_addr[_DST_].proc_nr = m_ptr->CP_DST_PROC_NR;
   38   vir_addr[_DST_].segment = m_ptr->CP_DST_SPACE;
   39   vir_addr[_DST_].offset = (vir_bytes) m_ptr->CP_DST_ADDR;
   40   bytes = (phys_bytes) m_ptr->CP_NR_BYTES;
   41 
   42   /* Now do some checks for both the source and destination virtual address.
   43    * This is done once for _SRC_, then once for _DST_. 
   44    */
   45   for (i=_SRC_; i<=_DST_; i++) {
   46 
   47       /* Check if process number was given implictly with SELF and is valid. */
   48       if (vir_addr[i].proc_nr == SELF) vir_addr[i].proc_nr = m_ptr->m_source;
   49       if (! isokprocn(vir_addr[i].proc_nr) && vir_addr[i].segment != PHYS_SEG) 
   50           return(EINVAL); 
   51 
   52       /* Check if physical addressing is used without SYS_PHYSCOPY. */
   53       if ((vir_addr[i].segment & PHYS_SEG) &&
   54           m_ptr->m_type != SYS_PHYSCOPY) return(EPERM);
   55   }
   56 
   57   /* Check for overflow. This would happen for 64K segments and 16-bit 
   58    * vir_bytes. Especially copying by the PM on do_fork() is affected. 
   59    */
   60   if (bytes != (vir_bytes) bytes) return(E2BIG);
   61 
   62   /* Now try to make the actual virtual copy. */
   63   return( virtual_copy(&vir_addr[_SRC_], &vir_addr[_DST_], bytes) );
   64 }
   65 #endif /* (USE_VIRCOPY || USE_PHYSCOPY) */
   66 

Cache object: 4746129a1ea7f8e3109fb68828bf66e4


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.