2 * $FreeBSD: src/sys/svr4/svr4_ipc.c,v 1.5 1999/12/08 10:51:16 newton Exp $
3 * $DragonFly: src/sys/emulation/svr4/Attic/svr4_ipc.c,v 1.5 2003/08/27 06:07:10 rob Exp $
5 * $NetBSD: svr4_ipc.c,v 1.7 1998/10/19 22:43:00 tron Exp $ */
10 * Copyright (c) 1995 The NetBSD Foundation, Inc.
11 * All rights reserved.
13 * This code is derived from software contributed to The NetBSD Foundation
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. All advertising materials mentioning features or use of this software
25 * must display the following acknowledgement:
26 * This product includes software developed by the NetBSD
27 * Foundation, Inc. and its contributors.
28 * 4. Neither the name of The NetBSD Foundation nor the names of its
29 * contributors may be used to endorse or promote products derived
30 * from this software without specific prior written permission.
32 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
33 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
34 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
36 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
37 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
40 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
41 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGE.
46 * Portions of this code have been derived from software contributed
47 * to the FreeBSD Project by Mark Newton.
49 * Copyright (c) 1999 Mark Newton
50 * All rights reserved.
52 * Redistribution and use in source and binary forms, with or without
53 * modification, are permitted provided that the following conditions
55 * 1. Redistributions of source code must retain the above copyright
56 * notice, this list of conditions and the following disclaimer.
57 * 2. Redistributions in binary form must reproduce the above copyright
58 * notice, this list of conditions and the following disclaimer in the
59 * documentation and/or other materials provided with the distribution.
60 * 3. The name of the author may not be used to endorse or promote products
61 * derived from this software without specific prior written permission
63 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
64 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
65 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
66 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
67 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
68 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
69 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
70 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
71 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
72 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74 * XXX- This code is presently a no-op on FreeBSD (and isn't compiled due
75 * to preprocessor conditionals). A nice project for a kernel hacking
76 * novice might be to MakeItGo, but I have more important fish to fry
81 #include <sys/types.h>
82 #include <sys/param.h>
83 #include <sys/kernel.h>
88 #include "svr4_types.h"
89 #include "svr4_signal.h"
90 #include "svr4_proto.h"
91 #include "svr4_util.h"
94 #if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
95 static void svr4_to_bsd_ipc_perm (const struct svr4_ipc_perm *,
97 static void bsd_to_svr4_ipc_perm (const struct ipc_perm *,
98 struct svr4_ipc_perm *);
102 static void bsd_to_svr4_semid_ds (const struct semid_ds *,
103 struct svr4_semid_ds *);
104 static void svr4_to_bsd_semid_ds (const struct svr4_semid_ds *,
106 static int svr4_setsemun (caddr_t *sgp, union semun **argp,
108 static int svr4_semop (struct proc *, void *, register_t *);
109 static int svr4_semget (struct proc *, void *, register_t *);
110 static int svr4_semctl (struct proc *, void *, register_t *);
114 static void bsd_to_svr4_msqid_ds (const struct msqid_ds *,
115 struct svr4_msqid_ds *);
116 static void svr4_to_bsd_msqid_ds (const struct svr4_msqid_ds *,
118 static int svr4_msgsnd (struct proc *, void *, register_t *);
119 static int svr4_msgrcv (struct proc *, void *, register_t *);
120 static int svr4_msgget (struct proc *, void *, register_t *);
121 static int svr4_msgctl (struct proc *, void *, register_t *);
125 static void bsd_to_svr4_shmid_ds (const struct shmid_ds *,
126 struct svr4_shmid_ds *);
127 static void svr4_to_bsd_shmid_ds (const struct svr4_shmid_ds *,
129 static int svr4_shmat (struct proc *, void *, register_t *);
130 static int svr4_shmdt (struct proc *, void *, register_t *);
131 static int svr4_shmget (struct proc *, void *, register_t *);
132 static int svr4_shmctl (struct proc *, void *, register_t *);
135 #if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
138 svr4_to_bsd_ipc_perm(spp, bpp)
139 const struct svr4_ipc_perm *spp;
140 struct ipc_perm *bpp;
145 bpp->cuid = spp->cuid;
146 bpp->cgid = spp->cgid;
147 bpp->mode = spp->mode;
152 bsd_to_svr4_ipc_perm(bpp, spp)
153 const struct ipc_perm *bpp;
154 struct svr4_ipc_perm *spp;
159 spp->cuid = bpp->cuid;
160 spp->cgid = bpp->cgid;
161 spp->mode = bpp->mode;
168 bsd_to_svr4_semid_ds(bds, sds)
169 const struct semid_ds *bds;
170 struct svr4_semid_ds *sds;
172 bsd_to_svr4_ipc_perm(&bds->sem_perm, &sds->sem_perm);
173 sds->sem_base = (struct svr4_sem *) bds->sem_base;
174 sds->sem_nsems = bds->sem_nsems;
175 sds->sem_otime = bds->sem_otime;
176 sds->sem_pad1 = bds->sem_pad1;
177 sds->sem_ctime = bds->sem_ctime;
178 sds->sem_pad2 = bds->sem_pad2;
182 svr4_to_bsd_semid_ds(sds, bds)
183 const struct svr4_semid_ds *sds;
184 struct semid_ds *bds;
186 svr4_to_bsd_ipc_perm(&sds->sem_perm, &bds->sem_perm);
187 bds->sem_base = (struct sem *) bds->sem_base;
188 bds->sem_nsems = sds->sem_nsems;
189 bds->sem_otime = sds->sem_otime;
190 bds->sem_pad1 = sds->sem_pad1;
191 bds->sem_ctime = sds->sem_ctime;
192 bds->sem_pad2 = sds->sem_pad2;
196 svr4_setsemun(sgp, argp, usp)
201 *argp = stackgap_alloc(sgp, sizeof(union semun));
202 return copyout((caddr_t)usp, *argp, sizeof(union semun));
205 struct svr4_sys_semctl_args {
206 syscallarg(int) what;
207 syscallarg(int) semid;
208 syscallarg(int) semnum;
210 syscallarg(union semun) arg;
214 svr4_semctl(p, v, retval)
220 struct svr4_sys_semctl_args *uap = v;
221 struct sys___semctl_args ap;
222 struct svr4_semid_ds ss;
223 struct semid_ds bs, *bsp;
224 caddr_t sg = stackgap_init(p->p_emul);
226 SCARG(&ap, semid) = SCARG(uap, semid);
227 SCARG(&ap, semnum) = SCARG(uap, semnum);
229 switch (SCARG(uap, cmd)) {
230 case SVR4_SEM_GETZCNT:
231 case SVR4_SEM_GETNCNT:
232 case SVR4_SEM_GETPID:
233 case SVR4_SEM_GETVAL:
234 switch (SCARG(uap, cmd)) {
235 case SVR4_SEM_GETZCNT:
236 SCARG(&ap, cmd) = GETZCNT;
238 case SVR4_SEM_GETNCNT:
239 SCARG(&ap, cmd) = GETNCNT;
241 case SVR4_SEM_GETPID:
242 SCARG(&ap, cmd) = GETPID;
244 case SVR4_SEM_GETVAL:
245 SCARG(&ap, cmd) = GETVAL;
248 return sys___semctl(p, &ap, retval);
250 case SVR4_SEM_SETVAL:
251 error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
254 SCARG(&ap, cmd) = SETVAL;
255 return sys___semctl(p, &ap, retval);
257 case SVR4_SEM_GETALL:
258 error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
261 SCARG(&ap, cmd) = GETVAL;
262 return sys___semctl(p, &ap, retval);
264 case SVR4_SEM_SETALL:
265 error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
268 SCARG(&ap, cmd) = SETVAL;
269 return sys___semctl(p, &ap, retval);
272 SCARG(&ap, cmd) = IPC_STAT;
273 bsp = stackgap_alloc(&sg, sizeof(bs));
274 error = svr4_setsemun(&sg, &SCARG(&ap, arg),
275 (union semun *)&bsp);
278 if ((error = sys___semctl(p, &ap, retval)) != 0)
280 error = copyin((caddr_t)bsp, (caddr_t)&bs, sizeof(bs));
283 bsd_to_svr4_semid_ds(&bs, &ss);
284 return copyout(&ss, SCARG(uap, arg).buf, sizeof(ss));
287 SCARG(&ap, cmd) = IPC_SET;
288 bsp = stackgap_alloc(&sg, sizeof(bs));
289 error = svr4_setsemun(&sg, &SCARG(&ap, arg),
290 (union semun *)&bsp);
293 error = copyin(SCARG(uap, arg).buf, (caddr_t) &ss, sizeof ss);
296 svr4_to_bsd_semid_ds(&ss, &bs);
297 error = copyout(&bs, bsp, sizeof(bs));
300 return sys___semctl(p, &ap, retval);
303 SCARG(&ap, cmd) = IPC_RMID;
304 bsp = stackgap_alloc(&sg, sizeof(bs));
305 error = svr4_setsemun(&sg, &SCARG(&ap, arg),
306 (union semun *)&bsp);
309 error = copyin(SCARG(uap, arg).buf, &ss, sizeof ss);
312 svr4_to_bsd_semid_ds(&ss, &bs);
313 error = copyout(&bs, bsp, sizeof(bs));
316 return sys___semctl(p, &ap, retval);
323 struct svr4_sys_semget_args {
324 syscallarg(int) what;
325 syscallarg(svr4_key_t) key;
326 syscallarg(int) nsems;
327 syscallarg(int) semflg;
331 svr4_semget(p, v, retval)
336 struct svr4_sys_semget_args *uap = v;
337 struct sys_semget_args ap;
339 SCARG(&ap, key) = SCARG(uap, key);
340 SCARG(&ap, nsems) = SCARG(uap, nsems);
341 SCARG(&ap, semflg) = SCARG(uap, semflg);
343 return sys_semget(p, &ap, retval);
346 struct svr4_sys_semop_args {
348 syscallarg(int) what;
349 syscallarg(int) semid;
350 syscallarg(struct svr4_sembuf *) sops;
351 syscallarg(u_int) nsops;
355 svr4_semop(p, v, retval)
360 struct svr4_sys_semop_args *uap = v;
361 struct sys_semop_args ap;
363 SCARG(&ap, semid) = SCARG(uap, semid);
364 /* These are the same */
365 SCARG(&ap, sops) = (struct sembuf *) SCARG(uap, sops);
366 SCARG(&ap, nsops) = SCARG(uap, nsops);
368 return sys_semop(p, &ap, retval);
372 svr4_sys_semsys(p, v, retval)
377 struct svr4_sys_semsys_args *uap = v;
379 DPRINTF(("svr4_semsys(%d)\n", SCARG(uap, what)));
381 switch (SCARG(uap, what)) {
383 return svr4_semctl(p, v, retval);
385 return svr4_semget(p, v, retval);
387 return svr4_semop(p, v, retval);
396 bsd_to_svr4_msqid_ds(bds, sds)
397 const struct msqid_ds *bds;
398 struct svr4_msqid_ds *sds;
400 bsd_to_svr4_ipc_perm(&bds->msg_perm, &sds->msg_perm);
401 sds->msg_first = (struct svr4_msg *) bds->msg_first;
402 sds->msg_last = (struct svr4_msg *) bds->msg_last;
403 sds->msg_cbytes = bds->msg_cbytes;
404 sds->msg_qnum = bds->msg_qnum;
405 sds->msg_qbytes = bds->msg_qbytes;
406 sds->msg_lspid = bds->msg_lspid;
407 sds->msg_lrpid = bds->msg_lrpid;
408 sds->msg_stime = bds->msg_stime;
409 sds->msg_pad1 = bds->msg_pad1;
410 sds->msg_rtime = bds->msg_rtime;
411 sds->msg_pad2 = bds->msg_pad2;
412 sds->msg_ctime = bds->msg_ctime;
413 sds->msg_pad3 = bds->msg_pad3;
415 /* use the padding for the rest of the fields */
417 const short *pad = (const short *) bds->msg_pad4;
418 sds->msg_cv = pad[0];
419 sds->msg_qnum_cv = pad[1];
424 svr4_to_bsd_msqid_ds(sds, bds)
425 const struct svr4_msqid_ds *sds;
426 struct msqid_ds *bds;
428 svr4_to_bsd_ipc_perm(&sds->msg_perm, &bds->msg_perm);
429 bds->msg_first = (struct msg *) sds->msg_first;
430 bds->msg_last = (struct msg *) sds->msg_last;
431 bds->msg_cbytes = sds->msg_cbytes;
432 bds->msg_qnum = sds->msg_qnum;
433 bds->msg_qbytes = sds->msg_qbytes;
434 bds->msg_lspid = sds->msg_lspid;
435 bds->msg_lrpid = sds->msg_lrpid;
436 bds->msg_stime = sds->msg_stime;
437 bds->msg_pad1 = sds->msg_pad1;
438 bds->msg_rtime = sds->msg_rtime;
439 bds->msg_pad2 = sds->msg_pad2;
440 bds->msg_ctime = sds->msg_ctime;
441 bds->msg_pad3 = sds->msg_pad3;
443 /* use the padding for the rest of the fields */
445 short *pad = (short *) bds->msg_pad4;
446 pad[0] = sds->msg_cv;
447 pad[1] = sds->msg_qnum_cv;
451 struct svr4_sys_msgsnd_args {
453 syscallarg(int) what;
454 syscallarg(int) msqid;
455 syscallarg(void *) msgp;
456 syscallarg(size_t) msgsz;
457 syscallarg(int) msgflg;
461 svr4_msgsnd(p, v, retval)
466 struct svr4_sys_msgsnd_args *uap = v;
467 struct sys_msgsnd_args ap;
469 SCARG(&ap, msqid) = SCARG(uap, msqid);
470 SCARG(&ap, msgp) = SCARG(uap, msgp);
471 SCARG(&ap, msgsz) = SCARG(uap, msgsz);
472 SCARG(&ap, msgflg) = SCARG(uap, msgflg);
474 return sys_msgsnd(p, &ap, retval);
477 struct svr4_sys_msgrcv_args {
479 syscallarg(int) what;
480 syscallarg(int) msqid;
481 syscallarg(void *) msgp;
482 syscallarg(size_t) msgsz;
483 syscallarg(long) msgtyp;
484 syscallarg(int) msgflg;
488 svr4_msgrcv(p, v, retval)
493 struct svr4_sys_msgrcv_args *uap = v;
494 struct sys_msgrcv_args ap;
496 SCARG(&ap, msqid) = SCARG(uap, msqid);
497 SCARG(&ap, msgp) = SCARG(uap, msgp);
498 SCARG(&ap, msgsz) = SCARG(uap, msgsz);
499 SCARG(&ap, msgtyp) = SCARG(uap, msgtyp);
500 SCARG(&ap, msgflg) = SCARG(uap, msgflg);
502 return sys_msgrcv(p, &ap, retval);
505 struct svr4_sys_msgget_args {
507 syscallarg(int) what;
508 syscallarg(svr4_key_t) key;
509 syscallarg(int) msgflg;
513 svr4_msgget(p, v, retval)
518 struct svr4_sys_msgget_args *uap = v;
519 struct sys_msgget_args ap;
521 SCARG(&ap, key) = SCARG(uap, key);
522 SCARG(&ap, msgflg) = SCARG(uap, msgflg);
524 return sys_msgget(p, &ap, retval);
527 struct svr4_sys_msgctl_args {
529 syscallarg(int) what;
530 syscallarg(int) msqid;
532 syscallarg(struct svr4_msqid_ds *) buf;
536 svr4_msgctl(p, v, retval)
542 struct svr4_sys_msgctl_args *uap = v;
543 struct sys_msgctl_args ap;
544 struct svr4_msqid_ds ss;
546 caddr_t sg = stackgap_init(p->p_emul);
548 SCARG(&ap, msqid) = SCARG(uap, msqid);
549 SCARG(&ap, cmd) = SCARG(uap, cmd);
550 SCARG(&ap, buf) = stackgap_alloc(&sg, sizeof(bs));
552 switch (SCARG(uap, cmd)) {
554 SCARG(&ap, cmd) = IPC_STAT;
555 if ((error = sys_msgctl(p, &ap, retval)) != 0)
557 error = copyin(&bs, SCARG(&ap, buf), sizeof bs);
560 bsd_to_svr4_msqid_ds(&bs, &ss);
561 return copyout(&ss, SCARG(uap, buf), sizeof ss);
564 SCARG(&ap, cmd) = IPC_SET;
565 error = copyin(SCARG(uap, buf), &ss, sizeof ss);
568 svr4_to_bsd_msqid_ds(&ss, &bs);
569 error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
572 return sys_msgctl(p, &ap, retval);
575 SCARG(&ap, cmd) = IPC_RMID;
576 error = copyin(SCARG(uap, buf), &ss, sizeof ss);
579 svr4_to_bsd_msqid_ds(&ss, &bs);
580 error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
583 return sys_msgctl(p, &ap, retval);
591 svr4_sys_msgsys(p, v, retval)
596 struct svr4_sys_msgsys_args *uap = v;
598 DPRINTF(("svr4_msgsys(%d)\n", SCARG(uap, what)));
600 switch (SCARG(uap, what)) {
602 return svr4_msgsnd(p, v, retval);
604 return svr4_msgrcv(p, v, retval);
606 return svr4_msgget(p, v, retval);
608 return svr4_msgctl(p, v, retval);
618 bsd_to_svr4_shmid_ds(bds, sds)
619 const struct shmid_ds *bds;
620 struct svr4_shmid_ds *sds;
622 bsd_to_svr4_ipc_perm(&bds->shm_perm, &sds->shm_perm);
623 sds->shm_segsz = bds->shm_segsz;
625 sds->shm_lpid = bds->shm_lpid;
626 sds->shm_cpid = bds->shm_cpid;
627 sds->shm_amp = bds->shm_internal;
628 sds->shm_nattch = bds->shm_nattch;
629 sds->shm_cnattch = 0;
630 sds->shm_atime = bds->shm_atime;
632 sds->shm_dtime = bds->shm_dtime;
634 sds->shm_ctime = bds->shm_ctime;
639 svr4_to_bsd_shmid_ds(sds, bds)
640 const struct svr4_shmid_ds *sds;
641 struct shmid_ds *bds;
643 svr4_to_bsd_ipc_perm(&sds->shm_perm, &bds->shm_perm);
644 bds->shm_segsz = sds->shm_segsz;
645 bds->shm_lpid = sds->shm_lpid;
646 bds->shm_cpid = sds->shm_cpid;
647 bds->shm_internal = sds->shm_amp;
648 bds->shm_nattch = sds->shm_nattch;
649 bds->shm_atime = sds->shm_atime;
650 bds->shm_dtime = sds->shm_dtime;
651 bds->shm_ctime = sds->shm_ctime;
654 struct svr4_sys_shmat_args {
655 syscallarg(int) what;
656 syscallarg(int) shmid;
657 syscallarg(void *) shmaddr;
658 syscallarg(int) shmflg;
662 svr4_shmat(p, v, retval)
667 struct svr4_sys_shmat_args *uap = v;
668 struct sys_shmat_args ap;
670 SCARG(&ap, shmid) = SCARG(uap, shmid);
671 SCARG(&ap, shmaddr) = SCARG(uap, shmaddr);
672 SCARG(&ap, shmflg) = SCARG(uap, shmflg);
674 return sys_shmat(p, &ap, retval);
677 struct svr4_sys_shmdt_args {
678 syscallarg(int) what;
679 syscallarg(void *) shmaddr;
683 svr4_shmdt(p, v, retval)
688 struct svr4_sys_shmdt_args *uap = v;
689 struct sys_shmdt_args ap;
691 SCARG(&ap, shmaddr) = SCARG(uap, shmaddr);
693 return sys_shmdt(p, &ap, retval);
696 struct svr4_sys_shmget_args {
697 syscallarg(int) what;
698 syscallarg(key_t) key;
699 syscallarg(int) size;
700 syscallarg(int) shmflg;
704 svr4_shmget(p, v, retval)
709 struct svr4_sys_shmget_args *uap = v;
710 struct sys_shmget_args ap;
712 SCARG(&ap, key) = SCARG(uap, key);
713 SCARG(&ap, size) = SCARG(uap, size);
714 SCARG(&ap, shmflg) = SCARG(uap, shmflg);
716 return sys_shmget(p, &ap, retval);
719 struct svr4_sys_shmctl_args {
720 syscallarg(int) what;
721 syscallarg(int) shmid;
723 syscallarg(struct svr4_shmid_ds *) buf;
727 svr4_shmctl(p, v, retval)
732 struct svr4_sys_shmctl_args *uap = v;
734 caddr_t sg = stackgap_init(p->p_emul);
735 struct sys_shmctl_args ap;
737 struct svr4_shmid_ds ss;
739 SCARG(&ap, shmid) = SCARG(uap, shmid);
741 if (SCARG(uap, buf) != NULL) {
742 SCARG(&ap, buf) = stackgap_alloc(&sg, sizeof (struct shmid_ds));
743 switch (SCARG(uap, cmd)) {
747 case SVR4_SHM_UNLOCK:
748 error = copyin(SCARG(uap, buf), (caddr_t) &ss,
752 svr4_to_bsd_shmid_ds(&ss, &bs);
753 error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
762 SCARG(&ap, buf) = NULL;
765 switch (SCARG(uap, cmd)) {
767 SCARG(&ap, cmd) = IPC_STAT;
768 if ((error = sys_shmctl(p, &ap, retval)) != 0)
770 if (SCARG(uap, buf) == NULL)
772 error = copyin(&bs, SCARG(&ap, buf), sizeof bs);
775 bsd_to_svr4_shmid_ds(&bs, &ss);
776 return copyout(&ss, SCARG(uap, buf), sizeof ss);
779 SCARG(&ap, cmd) = IPC_SET;
780 return sys_shmctl(p, &ap, retval);
784 case SVR4_SHM_UNLOCK:
785 switch (SCARG(uap, cmd)) {
787 SCARG(&ap, cmd) = IPC_RMID;
790 SCARG(&ap, cmd) = SHM_LOCK;
792 case SVR4_SHM_UNLOCK:
793 SCARG(&ap, cmd) = SHM_UNLOCK;
798 return sys_shmctl(p, &ap, retval);
806 svr4_sys_shmsys(p, v, retval)
811 struct svr4_sys_shmsys_args *uap = v;
813 DPRINTF(("svr4_shmsys(%d)\n", SCARG(uap, what)));
815 switch (SCARG(uap, what)) {
817 return svr4_shmat(p, v, retval);
819 return svr4_shmdt(p, v, retval);
821 return svr4_shmget(p, v, retval);
823 return svr4_shmctl(p, v, retval);