3 * $NetBSD: svr4_ipc.c,v 1.7 1998/10/19 22:43:00 tron Exp $ */
8 * Copyright (c) 1995 The NetBSD Foundation, Inc.
11 * This code is derived from software contributed to The NetBSD Foundation
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. All advertising materials mentioning features or use of this software
23 * must display the following acknowledgement:
24 * This product includes software developed by the NetBSD
25 * Foundation, Inc. and its contributors.
26 * 4. Neither the name of The NetBSD Foundation nor the names of its
27 * contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
30 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
31 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
32 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
34 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
35 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
38 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 * POSSIBILITY OF SUCH DAMAGE.
44 * Portions of this code have been derived from software contributed
45 * to the FreeBSD Project by Mark Newton.
47 * Copyright (c) 1999 Mark Newton
48 * All rights reserved.
50 * Redistribution and use in source and binary forms, with or without
51 * modification, are permitted provided that the following conditions
53 * 1. Redistributions of source code must retain the above copyright
54 * notice, this list of conditions and the following disclaimer.
55 * 2. Redistributions in binary form must reproduce the above copyright
56 * notice, this list of conditions and the following disclaimer in the
57 * documentation and/or other materials provided with the distribution.
58 * 3. The name of the author may not be used to endorse or promote products
59 * derived from this software without specific prior written permission
61 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
62 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
63 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
64 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
65 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
66 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
67 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
68 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
69 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
70 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
72 * XXX- This code is presently a no-op on FreeBSD (and isn't compiled due
73 * to preprocessor conditionals). A nice project for a kernel hacking
74 * novice might be to MakeItGo, but I have more important fish to fry
79 #include <sys/types.h>
80 #include <sys/param.h>
81 #include <sys/kernel.h>
88 #include <sys/malloc.h>
90 #include <sys/systm.h>
93 #include <sys/mount.h>
94 #include <sys/sysproto.h>
96 #include <svr4/svr4_types.h>
97 #include <svr4/svr4_signal.h>
98 #include <svr4/svr4_proto.h>
99 #include <svr4/svr4_util.h>
100 #include <svr4/svr4_ipc.h>
102 #if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
103 static void svr4_to_bsd_ipc_perm __P((const struct svr4_ipc_perm *,
105 static void bsd_to_svr4_ipc_perm __P((const struct ipc_perm *,
106 struct svr4_ipc_perm *));
110 static void bsd_to_svr4_semid_ds __P((const struct semid_ds *,
111 struct svr4_semid_ds *));
112 static void svr4_to_bsd_semid_ds __P((const struct svr4_semid_ds *,
114 static int svr4_setsemun __P((caddr_t *sgp, union semun **argp,
116 static int svr4_semop __P((struct proc *, void *, register_t *));
117 static int svr4_semget __P((struct proc *, void *, register_t *));
118 static int svr4_semctl __P((struct proc *, void *, register_t *));
122 static void bsd_to_svr4_msqid_ds __P((const struct msqid_ds *,
123 struct svr4_msqid_ds *));
124 static void svr4_to_bsd_msqid_ds __P((const struct svr4_msqid_ds *,
126 static int svr4_msgsnd __P((struct proc *, void *, register_t *));
127 static int svr4_msgrcv __P((struct proc *, void *, register_t *));
128 static int svr4_msgget __P((struct proc *, void *, register_t *));
129 static int svr4_msgctl __P((struct proc *, void *, register_t *));
133 static void bsd_to_svr4_shmid_ds __P((const struct shmid_ds *,
134 struct svr4_shmid_ds *));
135 static void svr4_to_bsd_shmid_ds __P((const struct svr4_shmid_ds *,
137 static int svr4_shmat __P((struct proc *, void *, register_t *));
138 static int svr4_shmdt __P((struct proc *, void *, register_t *));
139 static int svr4_shmget __P((struct proc *, void *, register_t *));
140 static int svr4_shmctl __P((struct proc *, void *, register_t *));
143 #if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
146 svr4_to_bsd_ipc_perm(spp, bpp)
147 const struct svr4_ipc_perm *spp;
148 struct ipc_perm *bpp;
153 bpp->cuid = spp->cuid;
154 bpp->cgid = spp->cgid;
155 bpp->mode = spp->mode;
160 bsd_to_svr4_ipc_perm(bpp, spp)
161 const struct ipc_perm *bpp;
162 struct svr4_ipc_perm *spp;
167 spp->cuid = bpp->cuid;
168 spp->cgid = bpp->cgid;
169 spp->mode = bpp->mode;
176 bsd_to_svr4_semid_ds(bds, sds)
177 const struct semid_ds *bds;
178 struct svr4_semid_ds *sds;
180 bsd_to_svr4_ipc_perm(&bds->sem_perm, &sds->sem_perm);
181 sds->sem_base = (struct svr4_sem *) bds->sem_base;
182 sds->sem_nsems = bds->sem_nsems;
183 sds->sem_otime = bds->sem_otime;
184 sds->sem_pad1 = bds->sem_pad1;
185 sds->sem_ctime = bds->sem_ctime;
186 sds->sem_pad2 = bds->sem_pad2;
190 svr4_to_bsd_semid_ds(sds, bds)
191 const struct svr4_semid_ds *sds;
192 struct semid_ds *bds;
194 svr4_to_bsd_ipc_perm(&sds->sem_perm, &bds->sem_perm);
195 bds->sem_base = (struct sem *) bds->sem_base;
196 bds->sem_nsems = sds->sem_nsems;
197 bds->sem_otime = sds->sem_otime;
198 bds->sem_pad1 = sds->sem_pad1;
199 bds->sem_ctime = sds->sem_ctime;
200 bds->sem_pad2 = sds->sem_pad2;
204 svr4_setsemun(sgp, argp, usp)
209 *argp = stackgap_alloc(sgp, sizeof(union semun));
210 return copyout((caddr_t)usp, *argp, sizeof(union semun));
213 struct svr4_sys_semctl_args {
214 syscallarg(int) what;
215 syscallarg(int) semid;
216 syscallarg(int) semnum;
218 syscallarg(union semun) arg;
222 svr4_semctl(p, v, retval)
228 struct svr4_sys_semctl_args *uap = v;
229 struct sys___semctl_args ap;
230 struct svr4_semid_ds ss;
231 struct semid_ds bs, *bsp;
232 caddr_t sg = stackgap_init(p->p_emul);
234 SCARG(&ap, semid) = SCARG(uap, semid);
235 SCARG(&ap, semnum) = SCARG(uap, semnum);
237 switch (SCARG(uap, cmd)) {
238 case SVR4_SEM_GETZCNT:
239 case SVR4_SEM_GETNCNT:
240 case SVR4_SEM_GETPID:
241 case SVR4_SEM_GETVAL:
242 switch (SCARG(uap, cmd)) {
243 case SVR4_SEM_GETZCNT:
244 SCARG(&ap, cmd) = GETZCNT;
246 case SVR4_SEM_GETNCNT:
247 SCARG(&ap, cmd) = GETNCNT;
249 case SVR4_SEM_GETPID:
250 SCARG(&ap, cmd) = GETPID;
252 case SVR4_SEM_GETVAL:
253 SCARG(&ap, cmd) = GETVAL;
256 return sys___semctl(p, &ap, retval);
258 case SVR4_SEM_SETVAL:
259 error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
262 SCARG(&ap, cmd) = SETVAL;
263 return sys___semctl(p, &ap, retval);
265 case SVR4_SEM_GETALL:
266 error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
269 SCARG(&ap, cmd) = GETVAL;
270 return sys___semctl(p, &ap, retval);
272 case SVR4_SEM_SETALL:
273 error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
276 SCARG(&ap, cmd) = SETVAL;
277 return sys___semctl(p, &ap, retval);
280 SCARG(&ap, cmd) = IPC_STAT;
281 bsp = stackgap_alloc(&sg, sizeof(bs));
282 error = svr4_setsemun(&sg, &SCARG(&ap, arg),
283 (union semun *)&bsp);
286 if ((error = sys___semctl(p, &ap, retval)) != 0)
288 error = copyin((caddr_t)bsp, (caddr_t)&bs, sizeof(bs));
291 bsd_to_svr4_semid_ds(&bs, &ss);
292 return copyout(&ss, SCARG(uap, arg).buf, sizeof(ss));
295 SCARG(&ap, cmd) = IPC_SET;
296 bsp = stackgap_alloc(&sg, sizeof(bs));
297 error = svr4_setsemun(&sg, &SCARG(&ap, arg),
298 (union semun *)&bsp);
301 error = copyin(SCARG(uap, arg).buf, (caddr_t) &ss, sizeof ss);
304 svr4_to_bsd_semid_ds(&ss, &bs);
305 error = copyout(&bs, bsp, sizeof(bs));
308 return sys___semctl(p, &ap, retval);
311 SCARG(&ap, cmd) = IPC_RMID;
312 bsp = stackgap_alloc(&sg, sizeof(bs));
313 error = svr4_setsemun(&sg, &SCARG(&ap, arg),
314 (union semun *)&bsp);
317 error = copyin(SCARG(uap, arg).buf, &ss, sizeof ss);
320 svr4_to_bsd_semid_ds(&ss, &bs);
321 error = copyout(&bs, bsp, sizeof(bs));
324 return sys___semctl(p, &ap, retval);
331 struct svr4_sys_semget_args {
332 syscallarg(int) what;
333 syscallarg(svr4_key_t) key;
334 syscallarg(int) nsems;
335 syscallarg(int) semflg;
339 svr4_semget(p, v, retval)
344 struct svr4_sys_semget_args *uap = v;
345 struct sys_semget_args ap;
347 SCARG(&ap, key) = SCARG(uap, key);
348 SCARG(&ap, nsems) = SCARG(uap, nsems);
349 SCARG(&ap, semflg) = SCARG(uap, semflg);
351 return sys_semget(p, &ap, retval);
354 struct svr4_sys_semop_args {
355 syscallarg(int) what;
356 syscallarg(int) semid;
357 syscallarg(struct svr4_sembuf *) sops;
358 syscallarg(u_int) nsops;
362 svr4_semop(p, v, retval)
367 struct svr4_sys_semop_args *uap = v;
368 struct sys_semop_args ap;
370 SCARG(&ap, semid) = SCARG(uap, semid);
371 /* These are the same */
372 SCARG(&ap, sops) = (struct sembuf *) SCARG(uap, sops);
373 SCARG(&ap, nsops) = SCARG(uap, nsops);
375 return sys_semop(p, &ap, retval);
379 svr4_sys_semsys(p, v, retval)
384 struct svr4_sys_semsys_args *uap = v;
386 DPRINTF(("svr4_semsys(%d)\n", SCARG(uap, what)));
388 switch (SCARG(uap, what)) {
390 return svr4_semctl(p, v, retval);
392 return svr4_semget(p, v, retval);
394 return svr4_semop(p, v, retval);
403 bsd_to_svr4_msqid_ds(bds, sds)
404 const struct msqid_ds *bds;
405 struct svr4_msqid_ds *sds;
407 bsd_to_svr4_ipc_perm(&bds->msg_perm, &sds->msg_perm);
408 sds->msg_first = (struct svr4_msg *) bds->msg_first;
409 sds->msg_last = (struct svr4_msg *) bds->msg_last;
410 sds->msg_cbytes = bds->msg_cbytes;
411 sds->msg_qnum = bds->msg_qnum;
412 sds->msg_qbytes = bds->msg_qbytes;
413 sds->msg_lspid = bds->msg_lspid;
414 sds->msg_lrpid = bds->msg_lrpid;
415 sds->msg_stime = bds->msg_stime;
416 sds->msg_pad1 = bds->msg_pad1;
417 sds->msg_rtime = bds->msg_rtime;
418 sds->msg_pad2 = bds->msg_pad2;
419 sds->msg_ctime = bds->msg_ctime;
420 sds->msg_pad3 = bds->msg_pad3;
422 /* use the padding for the rest of the fields */
424 const short *pad = (const short *) bds->msg_pad4;
425 sds->msg_cv = pad[0];
426 sds->msg_qnum_cv = pad[1];
431 svr4_to_bsd_msqid_ds(sds, bds)
432 const struct svr4_msqid_ds *sds;
433 struct msqid_ds *bds;
435 svr4_to_bsd_ipc_perm(&sds->msg_perm, &bds->msg_perm);
436 bds->msg_first = (struct msg *) sds->msg_first;
437 bds->msg_last = (struct msg *) sds->msg_last;
438 bds->msg_cbytes = sds->msg_cbytes;
439 bds->msg_qnum = sds->msg_qnum;
440 bds->msg_qbytes = sds->msg_qbytes;
441 bds->msg_lspid = sds->msg_lspid;
442 bds->msg_lrpid = sds->msg_lrpid;
443 bds->msg_stime = sds->msg_stime;
444 bds->msg_pad1 = sds->msg_pad1;
445 bds->msg_rtime = sds->msg_rtime;
446 bds->msg_pad2 = sds->msg_pad2;
447 bds->msg_ctime = sds->msg_ctime;
448 bds->msg_pad3 = sds->msg_pad3;
450 /* use the padding for the rest of the fields */
452 short *pad = (short *) bds->msg_pad4;
453 pad[0] = sds->msg_cv;
454 pad[1] = sds->msg_qnum_cv;
458 struct svr4_sys_msgsnd_args {
459 syscallarg(int) what;
460 syscallarg(int) msqid;
461 syscallarg(void *) msgp;
462 syscallarg(size_t) msgsz;
463 syscallarg(int) msgflg;
467 svr4_msgsnd(p, v, retval)
472 struct svr4_sys_msgsnd_args *uap = v;
473 struct sys_msgsnd_args ap;
475 SCARG(&ap, msqid) = SCARG(uap, msqid);
476 SCARG(&ap, msgp) = SCARG(uap, msgp);
477 SCARG(&ap, msgsz) = SCARG(uap, msgsz);
478 SCARG(&ap, msgflg) = SCARG(uap, msgflg);
480 return sys_msgsnd(p, &ap, retval);
483 struct svr4_sys_msgrcv_args {
484 syscallarg(int) what;
485 syscallarg(int) msqid;
486 syscallarg(void *) msgp;
487 syscallarg(size_t) msgsz;
488 syscallarg(long) msgtyp;
489 syscallarg(int) msgflg;
493 svr4_msgrcv(p, v, retval)
498 struct svr4_sys_msgrcv_args *uap = v;
499 struct sys_msgrcv_args ap;
501 SCARG(&ap, msqid) = SCARG(uap, msqid);
502 SCARG(&ap, msgp) = SCARG(uap, msgp);
503 SCARG(&ap, msgsz) = SCARG(uap, msgsz);
504 SCARG(&ap, msgtyp) = SCARG(uap, msgtyp);
505 SCARG(&ap, msgflg) = SCARG(uap, msgflg);
507 return sys_msgrcv(p, &ap, retval);
510 struct svr4_sys_msgget_args {
511 syscallarg(int) what;
512 syscallarg(svr4_key_t) key;
513 syscallarg(int) msgflg;
517 svr4_msgget(p, v, retval)
522 struct svr4_sys_msgget_args *uap = v;
523 struct sys_msgget_args ap;
525 SCARG(&ap, key) = SCARG(uap, key);
526 SCARG(&ap, msgflg) = SCARG(uap, msgflg);
528 return sys_msgget(p, &ap, retval);
531 struct svr4_sys_msgctl_args {
532 syscallarg(int) what;
533 syscallarg(int) msqid;
535 syscallarg(struct svr4_msqid_ds *) buf;
539 svr4_msgctl(p, v, retval)
545 struct svr4_sys_msgctl_args *uap = v;
546 struct sys_msgctl_args ap;
547 struct svr4_msqid_ds ss;
549 caddr_t sg = stackgap_init(p->p_emul);
551 SCARG(&ap, msqid) = SCARG(uap, msqid);
552 SCARG(&ap, cmd) = SCARG(uap, cmd);
553 SCARG(&ap, buf) = stackgap_alloc(&sg, sizeof(bs));
555 switch (SCARG(uap, cmd)) {
557 SCARG(&ap, cmd) = IPC_STAT;
558 if ((error = sys_msgctl(p, &ap, retval)) != 0)
560 error = copyin(&bs, SCARG(&ap, buf), sizeof bs);
563 bsd_to_svr4_msqid_ds(&bs, &ss);
564 return copyout(&ss, SCARG(uap, buf), sizeof ss);
567 SCARG(&ap, cmd) = IPC_SET;
568 error = copyin(SCARG(uap, buf), &ss, sizeof ss);
571 svr4_to_bsd_msqid_ds(&ss, &bs);
572 error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
575 return sys_msgctl(p, &ap, retval);
578 SCARG(&ap, cmd) = IPC_RMID;
579 error = copyin(SCARG(uap, buf), &ss, sizeof ss);
582 svr4_to_bsd_msqid_ds(&ss, &bs);
583 error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
586 return sys_msgctl(p, &ap, retval);
594 svr4_sys_msgsys(p, v, retval)
599 struct svr4_sys_msgsys_args *uap = v;
601 DPRINTF(("svr4_msgsys(%d)\n", SCARG(uap, what)));
603 switch (SCARG(uap, what)) {
605 return svr4_msgsnd(p, v, retval);
607 return svr4_msgrcv(p, v, retval);
609 return svr4_msgget(p, v, retval);
611 return svr4_msgctl(p, v, retval);
621 bsd_to_svr4_shmid_ds(bds, sds)
622 const struct shmid_ds *bds;
623 struct svr4_shmid_ds *sds;
625 bsd_to_svr4_ipc_perm(&bds->shm_perm, &sds->shm_perm);
626 sds->shm_segsz = bds->shm_segsz;
628 sds->shm_lpid = bds->shm_lpid;
629 sds->shm_cpid = bds->shm_cpid;
630 sds->shm_amp = bds->shm_internal;
631 sds->shm_nattch = bds->shm_nattch;
632 sds->shm_cnattch = 0;
633 sds->shm_atime = bds->shm_atime;
635 sds->shm_dtime = bds->shm_dtime;
637 sds->shm_ctime = bds->shm_ctime;
642 svr4_to_bsd_shmid_ds(sds, bds)
643 const struct svr4_shmid_ds *sds;
644 struct shmid_ds *bds;
646 svr4_to_bsd_ipc_perm(&sds->shm_perm, &bds->shm_perm);
647 bds->shm_segsz = sds->shm_segsz;
648 bds->shm_lpid = sds->shm_lpid;
649 bds->shm_cpid = sds->shm_cpid;
650 bds->shm_internal = sds->shm_amp;
651 bds->shm_nattch = sds->shm_nattch;
652 bds->shm_atime = sds->shm_atime;
653 bds->shm_dtime = sds->shm_dtime;
654 bds->shm_ctime = sds->shm_ctime;
657 struct svr4_sys_shmat_args {
658 syscallarg(int) what;
659 syscallarg(int) shmid;
660 syscallarg(void *) shmaddr;
661 syscallarg(int) shmflg;
665 svr4_shmat(p, v, retval)
670 struct svr4_sys_shmat_args *uap = v;
671 struct sys_shmat_args ap;
673 SCARG(&ap, shmid) = SCARG(uap, shmid);
674 SCARG(&ap, shmaddr) = SCARG(uap, shmaddr);
675 SCARG(&ap, shmflg) = SCARG(uap, shmflg);
677 return sys_shmat(p, &ap, retval);
680 struct svr4_sys_shmdt_args {
681 syscallarg(int) what;
682 syscallarg(void *) shmaddr;
686 svr4_shmdt(p, v, retval)
691 struct svr4_sys_shmdt_args *uap = v;
692 struct sys_shmdt_args ap;
694 SCARG(&ap, shmaddr) = SCARG(uap, shmaddr);
696 return sys_shmdt(p, &ap, retval);
699 struct svr4_sys_shmget_args {
700 syscallarg(int) what;
701 syscallarg(key_t) key;
702 syscallarg(int) size;
703 syscallarg(int) shmflg;
707 svr4_shmget(p, v, retval)
712 struct svr4_sys_shmget_args *uap = v;
713 struct sys_shmget_args ap;
715 SCARG(&ap, key) = SCARG(uap, key);
716 SCARG(&ap, size) = SCARG(uap, size);
717 SCARG(&ap, shmflg) = SCARG(uap, shmflg);
719 return sys_shmget(p, &ap, retval);
722 struct svr4_sys_shmctl_args {
723 syscallarg(int) what;
724 syscallarg(int) shmid;
726 syscallarg(struct svr4_shmid_ds *) buf;
730 svr4_shmctl(p, v, retval)
735 struct svr4_sys_shmctl_args *uap = v;
737 caddr_t sg = stackgap_init(p->p_emul);
738 struct sys_shmctl_args ap;
740 struct svr4_shmid_ds ss;
742 SCARG(&ap, shmid) = SCARG(uap, shmid);
744 if (SCARG(uap, buf) != NULL) {
745 SCARG(&ap, buf) = stackgap_alloc(&sg, sizeof (struct shmid_ds));
746 switch (SCARG(uap, cmd)) {
750 case SVR4_SHM_UNLOCK:
751 error = copyin(SCARG(uap, buf), (caddr_t) &ss,
755 svr4_to_bsd_shmid_ds(&ss, &bs);
756 error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
765 SCARG(&ap, buf) = NULL;
768 switch (SCARG(uap, cmd)) {
770 SCARG(&ap, cmd) = IPC_STAT;
771 if ((error = sys_shmctl(p, &ap, retval)) != 0)
773 if (SCARG(uap, buf) == NULL)
775 error = copyin(&bs, SCARG(&ap, buf), sizeof bs);
778 bsd_to_svr4_shmid_ds(&bs, &ss);
779 return copyout(&ss, SCARG(uap, buf), sizeof ss);
782 SCARG(&ap, cmd) = IPC_SET;
783 return sys_shmctl(p, &ap, retval);
787 case SVR4_SHM_UNLOCK:
788 switch (SCARG(uap, cmd)) {
790 SCARG(&ap, cmd) = IPC_RMID;
793 SCARG(&ap, cmd) = SHM_LOCK;
795 case SVR4_SHM_UNLOCK:
796 SCARG(&ap, cmd) = SHM_UNLOCK;
801 return sys_shmctl(p, &ap, retval);
809 svr4_sys_shmsys(p, v, retval)
814 struct svr4_sys_shmsys_args *uap = v;
816 DPRINTF(("svr4_shmsys(%d)\n", SCARG(uap, what)));
818 switch (SCARG(uap, what)) {
820 return svr4_shmat(p, v, retval);
822 return svr4_shmdt(p, v, retval);
824 return svr4_shmget(p, v, retval);
826 return svr4_shmctl(p, v, retval);