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/compat/freebsd/freebsd_ipc.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 /*      $NetBSD: freebsd_ipc.c,v 1.15 2007/12/20 23:02:47 dsl Exp $     */
    2 
    3 /*
    4  * Copyright (c) 1994 Adam Glass and Charles M. Hannum.  All rights reserved.
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  * 3. All advertising materials mentioning features or use of this software
   15  *    must display the following acknowledgement:
   16  *      This product includes software developed by Adam Glass and Charles M.
   17  *      Hannum.
   18  * 4. The names of the authors may not be used to endorse or promote products
   19  *    derived from this software without specific prior written permission.
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
   22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   24  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   31  */
   32 
   33 #include <sys/cdefs.h>
   34 __KERNEL_RCSID(0, "$NetBSD: freebsd_ipc.c,v 1.15 2007/12/20 23:02:47 dsl Exp $");
   35 
   36 #if defined(_KERNEL_OPT)
   37 #include "opt_sysv.h"
   38 #endif
   39 
   40 #include <sys/param.h>
   41 #include <sys/systm.h>
   42 #include <sys/kernel.h>
   43 #include <sys/proc.h>
   44 #include <sys/sem.h>
   45 #include <sys/malloc.h>
   46 
   47 #include <sys/mount.h>
   48 #include <sys/syscallargs.h>
   49 
   50 #include <compat/sys/shm.h>
   51 #include <compat/freebsd/freebsd_syscallargs.h>
   52 
   53 #ifdef SYSVSEM
   54 int
   55 freebsd_sys_semsys(struct lwp *l, const struct freebsd_sys_semsys_args *uap, register_t *retval)
   56 {
   57         /* {
   58                 syscallarg(int) which;
   59                 syscallarg(int) a2;
   60                 syscallarg(int) a3;
   61                 syscallarg(int) a4;
   62                 syscallarg(int) a5;
   63         } */
   64         struct compat_14_sys___semctl_args /* {
   65                 syscallarg(int) semid;
   66                 syscallarg(int) semnum;
   67                 syscallarg(int) cmd;
   68                 syscallarg(union __semun *) arg;
   69         } */ __semctl_args;
   70         struct sys_semget_args /* {
   71                 syscallarg(key_t) key;
   72                 syscallarg(int) nsems;
   73                 syscallarg(int) semflg;
   74         } */ semget_args;
   75         struct sys_semop_args /* {
   76                 syscallarg(int) semid;
   77                 syscallarg(struct sembuf *) sops;
   78                 syscallarg(u_int) nsops;
   79         } */ semop_args;
   80         struct sys_semconfig_args /* {
   81                 syscallarg(int) flag;
   82         } */ semconfig_args;
   83 
   84         switch (SCARG(uap, which)) {
   85         case 0:                                         /* __semctl() */
   86                 SCARG(&__semctl_args, semid) = SCARG(uap, a2);
   87                 SCARG(&__semctl_args, semnum) = SCARG(uap, a3);
   88                 SCARG(&__semctl_args, cmd) = SCARG(uap, a4);
   89                 SCARG(&__semctl_args, arg) = (union __semun *)SCARG(uap, a5);
   90                 return (compat_14_sys___semctl(l, &__semctl_args, retval));
   91 
   92         case 1:                                         /* semget() */
   93                 SCARG(&semget_args, key) = SCARG(uap, a2);
   94                 SCARG(&semget_args, nsems) = SCARG(uap, a3);
   95                 SCARG(&semget_args, semflg) = SCARG(uap, a4);
   96                 return (sys_semget(l, &semget_args, retval));
   97 
   98         case 2:                                         /* semop() */
   99                 SCARG(&semop_args, semid) = SCARG(uap, a2);
  100                 SCARG(&semop_args, sops) = (struct sembuf *)SCARG(uap, a3);
  101                 SCARG(&semop_args, nsops) = SCARG(uap, a4);
  102                 return (sys_semop(l, &semop_args, retval));
  103 
  104         case 3:                                         /* semconfig() */
  105                 SCARG(&semconfig_args, flag) = SCARG(uap, a2);
  106                 return (sys_semconfig(l, &semconfig_args, retval));
  107 
  108         default:
  109                 return (EINVAL);
  110         }
  111 }
  112 #endif
  113 
  114 #ifdef SYSVSHM
  115 int
  116 freebsd_sys_shmsys(struct lwp *l, const struct freebsd_sys_shmsys_args *uap, register_t *retval)
  117 {
  118         /* {
  119                 syscallarg(int) which;
  120                 syscallarg(int) a2;
  121                 syscallarg(int) a3;
  122                 syscallarg(int) a4;
  123         } */
  124         struct sys_shmat_args /* {
  125                 syscallarg(int) shmid;
  126                 syscallarg(void *) shmaddr;
  127                 syscallarg(int) shmflg;
  128         } */ shmat_args;
  129         struct compat_14_sys_shmctl_args /* {
  130                 syscallarg(int) shmid;
  131                 syscallarg(int) cmd;
  132                 syscallarg(struct shmid_ds14 *) buf;
  133         } */ shmctl_args;
  134         struct sys_shmdt_args /* {
  135                 syscallarg(void *) shmaddr;
  136         } */ shmdt_args;
  137         struct sys_shmget_args /* {
  138                 syscallarg(key_t) key;
  139                 syscallarg(int) size;
  140                 syscallarg(int) shmflg;
  141         } */ shmget_args;
  142 
  143         switch (SCARG(uap, which)) {
  144         case 0:                                         /* shmat() */
  145                 SCARG(&shmat_args, shmid) = SCARG(uap, a2);
  146                 SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a3);
  147                 SCARG(&shmat_args, shmflg) = SCARG(uap, a4);
  148                 return (sys_shmat(l, &shmat_args, retval));
  149 
  150         case 1:                                         /* oshmctl() */
  151                 /* XXX Need to translate shmid_ds format. */
  152                 return (EINVAL);
  153 
  154         case 2:                                         /* shmdt() */
  155                 SCARG(&shmdt_args, shmaddr) = (void *)SCARG(uap, a2);
  156                 return (sys_shmdt(l, &shmdt_args, retval));
  157 
  158         case 3:                                         /* shmget() */
  159                 SCARG(&shmget_args, key) = SCARG(uap, a2);
  160                 SCARG(&shmget_args, size) = SCARG(uap, a3);
  161                 SCARG(&shmget_args, shmflg) = SCARG(uap, a4);
  162                 return (sys_shmget(l, &shmget_args, retval));
  163 
  164         case 4:                                         /* shmctl() */
  165                 SCARG(&shmctl_args, shmid) = SCARG(uap, a2);
  166                 SCARG(&shmctl_args, cmd) = SCARG(uap, a3);
  167                 SCARG(&shmctl_args, buf) = (struct shmid_ds14 *)SCARG(uap, a4);
  168                 return (compat_14_sys_shmctl(l, &shmctl_args, retval));
  169 
  170         default:
  171                 return (EINVAL);
  172         }
  173 }
  174 #endif
  175 
  176 #ifdef SYSVMSG
  177 int
  178 freebsd_sys_msgsys(struct lwp *l, const struct freebsd_sys_msgsys_args *uap, register_t *retval)
  179 {
  180         /* {
  181                 syscallarg(int) which;
  182                 syscallarg(int) a2;
  183                 syscallarg(int) a3;
  184                 syscallarg(int) a4;
  185                 syscallarg(int) a5;
  186                 syscallarg(int) a6;
  187         } */
  188         struct compat_14_sys_msgctl_args /* {
  189                 syscallarg(int) msqid;
  190                 syscallarg(int) cmd;
  191                 syscallarg(struct msqid_ds14 *) buf;
  192         } */ msgctl_args;
  193         struct sys_msgget_args /* {
  194                 syscallarg(key_t) key;
  195                 syscallarg(int) msgflg;
  196         } */ msgget_args;
  197         struct sys_msgsnd_args /* {
  198                 syscallarg(int) msqid;
  199                 syscallarg(void *) msgp;
  200                 syscallarg(size_t) msgsz;
  201                 syscallarg(int) msgflg;
  202         } */ msgsnd_args;
  203         struct sys_msgrcv_args /* {
  204                 syscallarg(int) msqid;
  205                 syscallarg(void *) msgp;
  206                 syscallarg(size_t) msgsz;
  207                 syscallarg(long) msgtyp;
  208                 syscallarg(int) msgflg;
  209         } */ msgrcv_args;
  210 
  211         switch (SCARG(uap, which)) {
  212         case 0:                                 /* msgctl()*/
  213                 SCARG(&msgctl_args, msqid) = SCARG(uap, a2);
  214                 SCARG(&msgctl_args, cmd) = SCARG(uap, a3);
  215                 SCARG(&msgctl_args, buf) =
  216                     (struct msqid_ds14 *)SCARG(uap, a4);
  217                 return (compat_14_sys_msgctl(l, &msgctl_args, retval));
  218 
  219         case 1:                                 /* msgget() */
  220                 SCARG(&msgget_args, key) = SCARG(uap, a2);
  221                 SCARG(&msgget_args, msgflg) = SCARG(uap, a3);
  222                 return (sys_msgget(l, &msgget_args, retval));
  223 
  224         case 2:                                 /* msgsnd() */
  225                 SCARG(&msgsnd_args, msqid) = SCARG(uap, a2);
  226                 SCARG(&msgsnd_args, msgp) = (void *)SCARG(uap, a3);
  227                 SCARG(&msgsnd_args, msgsz) = SCARG(uap, a4);
  228                 SCARG(&msgsnd_args, msgflg) = SCARG(uap, a5);
  229                 return (sys_msgsnd(l, &msgsnd_args, retval));
  230 
  231         case 3:                                 /* msgrcv() */
  232                 SCARG(&msgrcv_args, msqid) = SCARG(uap, a2);
  233                 SCARG(&msgrcv_args, msgp) = (void *)SCARG(uap, a3);
  234                 SCARG(&msgrcv_args, msgsz) = SCARG(uap, a4);
  235                 SCARG(&msgrcv_args, msgtyp) = SCARG(uap, a5);
  236                 SCARG(&msgrcv_args, msgflg) = SCARG(uap, a6);
  237                 return (sys_msgrcv(l, &msgrcv_args, retval));
  238 
  239         default:
  240                 return (EINVAL);
  241         }
  242 }
  243 #endif

Cache object: 44d11348a847ad44e1dee4bcbdd4fd66


[ 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.