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/svr4_32/svr4_32_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: svr4_32_ipc.c,v 1.20 2008/04/28 20:23:46 martin Exp $  */
    2 
    3 /*-
    4  * Copyright (c) 1995 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Christos Zoulas.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   29  * POSSIBILITY OF SUCH DAMAGE.
   30  */
   31 
   32 #include <sys/cdefs.h>
   33 __KERNEL_RCSID(0, "$NetBSD: svr4_32_ipc.c,v 1.20 2008/04/28 20:23:46 martin Exp $");
   34 
   35 #if defined(_KERNEL_OPT)
   36 #include "opt_sysv.h"
   37 #endif
   38 
   39 #include <sys/param.h>
   40 #include <sys/kernel.h>
   41 #include <sys/shm.h>
   42 #include <sys/msg.h>
   43 #include <sys/sem.h>
   44 #include <sys/proc.h>
   45 #include <sys/uio.h>
   46 #include <sys/time.h>
   47 #include <sys/malloc.h>
   48 #include <sys/mman.h>
   49 #include <sys/systm.h>
   50 #include <sys/stat.h>
   51 
   52 #include <sys/mount.h>
   53 #include <sys/syscallargs.h>
   54 
   55 #include <compat/svr4_32/svr4_32_types.h>
   56 #include <compat/svr4_32/svr4_32_signal.h>
   57 #include <compat/svr4_32/svr4_32_lwp.h>
   58 #include <compat/svr4_32/svr4_32_ucontext.h>
   59 #include <compat/svr4_32/svr4_32_syscallargs.h>
   60 #include <compat/svr4_32/svr4_32_util.h>
   61 #include <compat/svr4_32/svr4_32_ipc.h>
   62 
   63 #if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
   64 static void svr4_32_to_bsd_ipc_perm(const struct svr4_32_ipc_perm *,
   65                                       struct ipc_perm *);
   66 static void bsd_to_svr4_32_ipc_perm(const struct ipc_perm *,
   67                                       struct svr4_32_ipc_perm *);
   68 #endif
   69 
   70 #ifdef SYSVSEM
   71 static void bsd_to_svr4_32_semid_ds(const struct semid_ds *,
   72                                       struct svr4_32_semid_ds *);
   73 static void svr4_32_to_bsd_semid_ds(const struct svr4_32_semid_ds *,
   74                                       struct semid_ds *);
   75 #endif
   76 
   77 #ifdef SYSVMSG
   78 static void bsd_to_svr4_32_msqid_ds(const struct msqid_ds *,
   79                                       struct svr4_32_msqid_ds *);
   80 static void svr4_32_to_bsd_msqid_ds(const struct svr4_32_msqid_ds *,
   81                                       struct msqid_ds *);
   82 #endif
   83 
   84 #ifdef SYSVSHM
   85 static void bsd_to_svr4_32_shmid_ds(const struct shmid_ds *,
   86                                       struct svr4_32_shmid_ds *);
   87 static void svr4_32_to_bsd_shmid_ds(const struct svr4_32_shmid_ds *,
   88                                       struct shmid_ds *);
   89 #endif
   90 
   91 #if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
   92 
   93 static void
   94 svr4_32_to_bsd_ipc_perm(const struct svr4_32_ipc_perm *spp, struct ipc_perm *bpp)
   95 {
   96         bpp->_key = spp->key;
   97         bpp->uid = spp->uid;
   98         bpp->gid = spp->gid;
   99         bpp->cuid = spp->cuid;
  100         bpp->cgid = spp->cgid;
  101         bpp->mode = spp->mode;
  102         bpp->_seq = spp->seq;
  103 }
  104 
  105 static void
  106 bsd_to_svr4_32_ipc_perm(const struct ipc_perm *bpp, struct svr4_32_ipc_perm *spp)
  107 {
  108         spp->key = bpp->_key;
  109         spp->uid = bpp->uid;
  110         spp->gid = bpp->gid;
  111         spp->cuid = bpp->cuid;
  112         spp->cgid = bpp->cgid;
  113         spp->mode = bpp->mode;
  114         spp->seq = bpp->_seq;
  115 }
  116 #endif
  117 
  118 #ifdef SYSVSEM
  119 static void
  120 bsd_to_svr4_32_semid_ds(const struct semid_ds *bds, struct svr4_32_semid_ds *sds)
  121 {
  122         bsd_to_svr4_32_ipc_perm(&bds->sem_perm, &sds->sem_perm);
  123         NETBSD32PTR32(sds->sem_base, bds->_sem_base);
  124         sds->sem_nsems = bds->sem_nsems;
  125         sds->sem_otime = bds->sem_otime;
  126         sds->sem_ctime = bds->sem_ctime;
  127 }
  128 
  129 static void
  130 svr4_32_to_bsd_semid_ds(const struct svr4_32_semid_ds *sds, struct semid_ds *bds)
  131 {
  132         svr4_32_to_bsd_ipc_perm(&sds->sem_perm, &bds->sem_perm);
  133         bds->_sem_base = NETBSD32PTR64(sds->sem_base);
  134         bds->sem_nsems = sds->sem_nsems;
  135         bds->sem_otime = sds->sem_otime;
  136         bds->sem_ctime = sds->sem_ctime;
  137 }
  138 
  139 struct svr4_32_sys_semctl_args {
  140         syscallarg(int) what;
  141         syscallarg(int) semid;
  142         syscallarg(int) semnum;
  143         syscallarg(int) cmd;
  144         syscallarg(union netbsd32_semun) arg;
  145 };
  146 
  147 static int
  148 svr4_32_semctl(struct lwp *l, const struct svr4_32_sys_semctl_args *uap, register_t *retval)
  149 {
  150         struct semid_ds sembuf;
  151         struct svr4_32_semid_ds ssembuf;
  152         int cmd, error;
  153         void *pass_arg = NULL;
  154         union netbsd32_semun arg;
  155 
  156         cmd = SCARG(uap, cmd);
  157 
  158         switch (cmd) {
  159         case SVR4_IPC_SET:
  160                 pass_arg = &sembuf;
  161                 cmd = IPC_SET;
  162                 break;
  163 
  164         case SVR4_IPC_STAT:
  165                 pass_arg = &sembuf;
  166                 cmd = IPC_STAT;
  167                 break;
  168 
  169         case SVR4_IPC_RMID:
  170                 cmd = IPC_RMID;
  171                 break;
  172 
  173         case SVR4_SEM_GETVAL:
  174                 cmd = GETVAL;
  175                 break;
  176 
  177         case SVR4_SEM_GETPID:
  178                 cmd = GETPID;
  179                 break;
  180 
  181         case SVR4_SEM_GETNCNT:
  182                 cmd = GETNCNT;
  183                 break;
  184 
  185         case SVR4_SEM_GETZCNT:
  186                 cmd = GETZCNT;
  187                 break;
  188 
  189         case SVR4_SEM_GETALL:
  190                 arg = SCARG(uap, arg);
  191                 pass_arg = &arg;
  192                 cmd = GETALL;
  193                 break;
  194 
  195         case SVR4_SEM_SETVAL:
  196                 arg = SCARG(uap, arg);
  197                 pass_arg = &arg;
  198                 cmd = SETVAL;
  199                 break;
  200 
  201         case SVR4_SEM_SETALL:
  202                 arg = SCARG(uap, arg);
  203                 pass_arg = &arg;
  204                 cmd = SETALL;
  205                 break;
  206 
  207         default:
  208                 return (EINVAL);
  209         }
  210 
  211         if (cmd == IPC_SET) {
  212                 error = copyin(NETBSD32PTR64(SCARG(uap, arg).buf),
  213                                &ssembuf, sizeof(ssembuf));
  214                 if (error)
  215                         return (error);
  216                 svr4_32_to_bsd_semid_ds(&ssembuf, &sembuf);
  217         }
  218 
  219         error = semctl1(l, SCARG(uap, semid), SCARG(uap, semnum), cmd,
  220             pass_arg, retval);
  221 
  222         if (error == 0 && cmd == IPC_STAT) {
  223                 bsd_to_svr4_32_semid_ds(&sembuf, &ssembuf);
  224                 error = copyout(&ssembuf, NETBSD32PTR64(SCARG(uap, arg).buf),
  225                                 sizeof(ssembuf));
  226         }
  227 
  228         return (error);
  229 }
  230 
  231 struct svr4_32_sys_semget_args {
  232         syscallarg(int) what;
  233         syscallarg(svr4_key_t) key;
  234         syscallarg(int) nsems;
  235         syscallarg(int) semflg;
  236 };
  237 
  238 static int
  239 svr4_32_semget(struct lwp *l, const struct svr4_32_sys_semget_args *uap, register_t *retval)
  240 {
  241         struct sys_semget_args ap;
  242 
  243         SCARG(&ap, key) = SCARG(uap, key);
  244         SCARG(&ap, nsems) = SCARG(uap, nsems);
  245         SCARG(&ap, semflg) = SCARG(uap, semflg);
  246 
  247         return sys_semget(l, &ap, retval);
  248 }
  249 
  250 struct svr4_32_sys_semop_args {
  251         syscallarg(int) what;
  252         syscallarg(int) semid;
  253         syscallarg(svr4_32_sembufp) sops;
  254         syscallarg(u_int) nsops;
  255 };
  256 
  257 static int
  258 svr4_32_semop(struct lwp *l, const struct svr4_32_sys_semop_args *uap, register_t *retval)
  259 {
  260         struct sys_semop_args ap;
  261 
  262         SCARG(&ap, semid) = SCARG(uap, semid);
  263         /* These are the same */
  264         SCARG(&ap, sops) = SCARG_P32(uap, sops);
  265         SCARG(&ap, nsops) = SCARG(uap, nsops);
  266 
  267         return sys_semop(l, &ap, retval);
  268 }
  269 
  270 int
  271 svr4_32_sys_semsys(struct lwp *l, const struct svr4_32_sys_semsys_args *uap, register_t *retval)
  272 {
  273 
  274         DPRINTF(("svr4_32_semsys(%d)\n", SCARG(uap, what)));
  275 
  276         switch (SCARG(uap, what)) {
  277         case SVR4_semctl:
  278                 return svr4_32_semctl(l, (const void *)uap, retval);
  279         case SVR4_semget:
  280                 return svr4_32_semget(l, (const void *)uap, retval);
  281         case SVR4_semop:
  282                 return svr4_32_semop(l, (const void *)uap, retval);
  283         default:
  284                 return EINVAL;
  285         }
  286 }
  287 #endif
  288 
  289 #ifdef SYSVMSG
  290 static void
  291 bsd_to_svr4_32_msqid_ds(const struct msqid_ds *bds, struct svr4_32_msqid_ds *sds)
  292 {
  293         bsd_to_svr4_32_ipc_perm(&bds->msg_perm, &sds->msg_perm);
  294         NETBSD32PTR32(sds->msg_first, bds->_msg_first);
  295         NETBSD32PTR32(sds->msg_last, bds->_msg_last);
  296         sds->msg_cbytes = bds->_msg_cbytes;
  297         sds->msg_qnum = bds->msg_qnum;
  298         sds->msg_qbytes = bds->msg_qbytes;
  299         sds->msg_lspid = bds->msg_lspid;
  300         sds->msg_lrpid = bds->msg_lrpid;
  301         sds->msg_stime = bds->msg_stime;
  302         sds->msg_rtime = bds->msg_rtime;
  303         sds->msg_ctime = bds->msg_ctime;
  304 
  305 #if 0
  306         /* XXX What to put here? */
  307         sds->msg_cv = 0;
  308         sds->msg_qnum_cv = 0;
  309 #endif
  310 }
  311 
  312 static void
  313 svr4_32_to_bsd_msqid_ds(const struct svr4_32_msqid_ds *sds, struct msqid_ds *bds)
  314 {
  315         svr4_32_to_bsd_ipc_perm(&sds->msg_perm, &bds->msg_perm);
  316         bds->_msg_first = NETBSD32PTR64(sds->msg_first);
  317         bds->_msg_last = NETBSD32PTR64(sds->msg_last);
  318         bds->_msg_cbytes = sds->msg_cbytes;
  319         bds->msg_qnum = sds->msg_qnum;
  320         bds->msg_qbytes = sds->msg_qbytes;
  321         bds->msg_lspid = sds->msg_lspid;
  322         bds->msg_lrpid = sds->msg_lrpid;
  323         bds->msg_stime = sds->msg_stime;
  324         bds->msg_rtime = sds->msg_rtime;
  325         bds->msg_ctime = sds->msg_ctime;
  326 
  327 #if 0
  328         XXX sds->msg_cv
  329         XXX sds->msg_qnum_cv
  330 #endif
  331 }
  332 
  333 struct svr4_32_sys_msgsnd_args {
  334         syscallarg(int) what;
  335         syscallarg(int) msqid;
  336         syscallarg(netbsd32_voidp) msgp;
  337         syscallarg(netbsd32_size_t) msgsz;
  338         syscallarg(int) msgflg;
  339 };
  340 
  341 static int
  342 svr4_32_msgsnd(struct lwp *l, const struct svr4_32_sys_msgsnd_args *uap, register_t *retval)
  343 {
  344         struct sys_msgsnd_args ap;
  345 
  346         SCARG(&ap, msqid) = SCARG(uap, msqid);
  347         SCARG(&ap, msgp) = SCARG_P32(uap, msgp);
  348         SCARG(&ap, msgsz) = SCARG(uap, msgsz);
  349         SCARG(&ap, msgflg) = SCARG(uap, msgflg);
  350 
  351         return sys_msgsnd(l, &ap, retval);
  352 }
  353 
  354 struct svr4_32_sys_msgrcv_args {
  355         syscallarg(int) what;
  356         syscallarg(int) msqid;
  357         syscallarg(netbsd32_voidp) msgp;
  358         syscallarg(netbsd32_size_t) msgsz;
  359         syscallarg(netbsd32_long) msgtyp;
  360         syscallarg(int) msgflg;
  361 };
  362 
  363 static int
  364 svr4_32_msgrcv(struct lwp *l, const struct svr4_32_sys_msgrcv_args *uap, register_t *retval)
  365 {
  366         struct sys_msgrcv_args ap;
  367 
  368         SCARG(&ap, msqid) = SCARG(uap, msqid);
  369         SCARG(&ap, msgp) = SCARG_P32(uap, msgp);
  370         SCARG(&ap, msgsz) = SCARG(uap, msgsz);
  371         SCARG(&ap, msgtyp) = SCARG(uap, msgtyp);
  372         SCARG(&ap, msgflg) = SCARG(uap, msgflg);
  373 
  374         return sys_msgrcv(l, &ap, retval);
  375 }
  376 
  377 struct svr4_32_sys_msgget_args {
  378         syscallarg(int) what;
  379         syscallarg(svr4_key_t) key;
  380         syscallarg(int) msgflg;
  381 };
  382 
  383 static int
  384 svr4_32_msgget(struct lwp *l, const struct svr4_32_sys_msgget_args *uap, register_t *retval)
  385 {
  386         struct sys_msgget_args ap;
  387 
  388         SCARG(&ap, key) = SCARG(uap, key);
  389         SCARG(&ap, msgflg) = SCARG(uap, msgflg);
  390 
  391         return sys_msgget(l, &ap, retval);
  392 }
  393 
  394 struct svr4_32_sys_msgctl_args {
  395         syscallarg(int) what;
  396         syscallarg(int) msqid;
  397         syscallarg(int) cmd;
  398         syscallarg(svr4_32_msqid_dsp) buf;
  399 };
  400 
  401 static int
  402 svr4_32_msgctl(struct lwp *l, const struct svr4_32_sys_msgctl_args *uap, register_t *retval)
  403 {
  404         struct svr4_32_msqid_ds ss;
  405         struct msqid_ds bs;
  406         int error;
  407 
  408         switch (SCARG(uap, cmd)) {
  409         case SVR4_IPC_STAT:
  410                 error = msgctl1(l, SCARG(uap, msqid), IPC_STAT, &bs);
  411                 if (error == 0) {
  412                         bsd_to_svr4_32_msqid_ds(&bs, &ss);
  413                         error = copyout(&ss, SCARG_P32(uap, buf), sizeof ss);
  414                 }
  415                 return error;
  416 
  417         case SVR4_IPC_SET:
  418                 error = copyin(SCARG_P32(uap, buf), &ss, sizeof ss);
  419                 if (error)
  420                         return error;
  421                 svr4_32_to_bsd_msqid_ds(&ss, &bs);
  422                 return msgctl1(l, SCARG(uap, msqid), IPC_SET, &bs);
  423 
  424         case SVR4_IPC_RMID:
  425                 return msgctl1(l, SCARG(uap, msqid), IPC_RMID, NULL);
  426 
  427         default:
  428                 return EINVAL;
  429         }
  430 }
  431 
  432 int
  433 svr4_32_sys_msgsys(struct lwp *l, const struct svr4_32_sys_msgsys_args *uap, register_t *retval)
  434 {
  435 
  436         DPRINTF(("svr4_32_msgsys(%d)\n", SCARG(uap, what)));
  437 
  438         switch (SCARG(uap, what)) {
  439         case SVR4_msgsnd:
  440                 return svr4_32_msgsnd(l, (const void *)uap, retval);
  441         case SVR4_msgrcv:
  442                 return svr4_32_msgrcv(l, (const void *)uap, retval);
  443         case SVR4_msgget:
  444                 return svr4_32_msgget(l, (const void *)uap, retval);
  445         case SVR4_msgctl:
  446                 return svr4_32_msgctl(l, (const void *)uap, retval);
  447         default:
  448                 return EINVAL;
  449         }
  450 }
  451 #endif
  452 
  453 #ifdef SYSVSHM
  454 
  455 static void
  456 bsd_to_svr4_32_shmid_ds(const struct shmid_ds *bds, struct svr4_32_shmid_ds *sds)
  457 {
  458         bsd_to_svr4_32_ipc_perm(&bds->shm_perm, &sds->shm_perm);
  459         sds->shm_segsz = bds->shm_segsz;
  460         sds->shm_lkcnt = 0;
  461         sds->shm_lpid = bds->shm_lpid;
  462         sds->shm_cpid = bds->shm_cpid;
  463         NETBSD32PTR32(sds->shm_amp, bds->_shm_internal);
  464         sds->shm_nattch = bds->shm_nattch;
  465         sds->shm_cnattch = 0;
  466         sds->shm_atime = bds->shm_atime;
  467         sds->shm_pad1 = 0;
  468         sds->shm_dtime = bds->shm_dtime;
  469         sds->shm_pad2 = 0;
  470         sds->shm_ctime = bds->shm_ctime;
  471         sds->shm_pad3 = 0;
  472 }
  473 
  474 static void
  475 svr4_32_to_bsd_shmid_ds(const struct svr4_32_shmid_ds *sds, struct shmid_ds *bds)
  476 {
  477         svr4_32_to_bsd_ipc_perm(&sds->shm_perm, &bds->shm_perm);
  478         bds->shm_segsz = sds->shm_segsz;
  479         bds->shm_lpid = sds->shm_lpid;
  480         bds->shm_cpid = sds->shm_cpid;
  481         bds->_shm_internal = NETBSD32PTR64(sds->shm_amp);
  482         bds->shm_nattch = sds->shm_nattch;
  483         bds->shm_atime = sds->shm_atime;
  484         bds->shm_dtime = sds->shm_dtime;
  485         bds->shm_ctime = sds->shm_ctime;
  486 }
  487 
  488 struct svr4_32_sys_shmat_args {
  489         syscallarg(int) what;
  490         syscallarg(int) shmid;
  491         syscallarg(netbsd32_voidp) shmaddr;
  492         syscallarg(int) shmflg;
  493 };
  494 
  495 static int
  496 svr4_32_shmat(struct lwp *l, const struct svr4_32_sys_shmat_args *uap, register_t *retval)
  497 {
  498         struct sys_shmat_args ap;
  499 
  500         SCARG(&ap, shmid) = SCARG(uap, shmid);
  501         SCARG(&ap, shmaddr) = SCARG_P32(uap, shmaddr);
  502         SCARG(&ap, shmflg) = SCARG(uap, shmflg);
  503 
  504         return sys_shmat(l, &ap, retval);
  505 }
  506 
  507 struct svr4_32_sys_shmdt_args {
  508         syscallarg(int) what;
  509         syscallarg(netbsd32_voidp) shmaddr;
  510 };
  511 
  512 static int
  513 svr4_32_shmdt(struct lwp *l, const struct svr4_32_sys_shmdt_args *uap, register_t *retval)
  514 {
  515         struct sys_shmdt_args ap;
  516 
  517         SCARG(&ap, shmaddr) = SCARG_P32(uap, shmaddr);
  518 
  519         return sys_shmdt(l, &ap, retval);
  520 }
  521 
  522 struct svr4_32_sys_shmget_args {
  523         syscallarg(int) what;
  524         syscallarg(netbsd32_key_t) key;
  525         syscallarg(int) size;
  526         syscallarg(int) shmflg;
  527 };
  528 
  529 static int
  530 svr4_32_shmget(struct lwp *l, const struct svr4_32_sys_shmget_args *uap, register_t *retval)
  531 {
  532         struct sys_shmget_args ap;
  533 
  534         SCARG(&ap, key) = SCARG(uap, key);
  535         SCARG(&ap, size) = SCARG(uap, size);
  536         SCARG(&ap, shmflg) = SCARG(uap, shmflg);
  537 
  538         return sys_shmget(l, &ap, retval);
  539 }
  540 
  541 struct svr4_32_sys_shmctl_args {
  542         syscallarg(int) what;
  543         syscallarg(int) shmid;
  544         syscallarg(int) cmd;
  545         syscallarg(svr4_32_shmid_dsp) buf;
  546 };
  547 
  548 static int
  549 svr4_32_shmctl(struct lwp *l, const struct svr4_32_sys_shmctl_args *uap, register_t *retval)
  550 {
  551         struct shmid_ds bs;
  552         struct svr4_32_shmid_ds ss;
  553         int error;
  554 
  555         switch (SCARG(uap, cmd)) {
  556         case SVR4_IPC_STAT:
  557                 error = shmctl1(l, SCARG(uap, shmid), IPC_STAT, &bs);
  558                 if (error == 0) {
  559                         bsd_to_svr4_32_shmid_ds(&bs, &ss);
  560                         error = copyout(&ss, SCARG_P32(uap, buf), sizeof ss);
  561                 }
  562                 return error;
  563 
  564         case SVR4_IPC_SET:
  565                 error = copyin(SCARG_P32(uap, buf), &ss, sizeof ss);
  566                 if (error)
  567                         return error;
  568                 svr4_32_to_bsd_shmid_ds(&ss, &bs);
  569                 return shmctl1(l, SCARG(uap, shmid), IPC_SET, &bs);
  570 
  571         case SVR4_IPC_RMID:
  572                 return shmctl1(l, SCARG(uap, shmid), IPC_RMID, NULL);
  573 
  574         case SVR4_SHM_LOCK:
  575                 return shmctl1(l, SCARG(uap, shmid), SHM_LOCK, NULL);
  576 
  577         case SVR4_SHM_UNLOCK:
  578                 return shmctl1(l, SCARG(uap, shmid), SHM_UNLOCK, NULL);
  579 
  580         default:
  581                 return EINVAL;
  582         }
  583 }
  584 
  585 int
  586 svr4_32_sys_shmsys(struct lwp *l, const struct svr4_32_sys_shmsys_args *uap, register_t *retval)
  587 {
  588 
  589         DPRINTF(("svr4_32_shmsys(%d)\n", SCARG(uap, what)));
  590 
  591         switch (SCARG(uap, what)) {
  592         case SVR4_shmat:
  593                 return svr4_32_shmat(l, (const void *)uap, retval);
  594         case SVR4_shmdt:
  595                 return svr4_32_shmdt(l, (const void *)uap, retval);
  596         case SVR4_shmget:
  597                 return svr4_32_shmget(l, (const void *)uap, retval);
  598         case SVR4_shmctl:
  599                 return svr4_32_shmctl(l, (const void *)uap, retval);
  600         default:
  601                 return ENOSYS;
  602         }
  603 }
  604 #endif /* SYSVSHM */

Cache object: 021eee90e526fc0e856fe5ec3ed3ce8b


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