4 * $NetBSD: svr4_ipc.c,v 1.7 1998/10/19 22:43:00 tron Exp $ */
9 * Copyright (c) 1995 The NetBSD Foundation, Inc.
10 * All rights reserved.
12 * This code is derived from software contributed to The NetBSD Foundation
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. All advertising materials mentioning features or use of this software
24 * must display the following acknowledgement:
25 * This product includes software developed by the NetBSD
26 * Foundation, Inc. and its contributors.
27 * 4. Neither the name of The NetBSD Foundation nor the names of its
28 * contributors may be used to endorse or promote products derived
29 * from this software without specific prior written permission.
31 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
32 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
33 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
34 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
35 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
39 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGE.
45 * Portions of this code have been derived from software contributed
46 * to the FreeBSD Project by Mark Newton.
48 * Copyright (c) 1999 Mark Newton
49 * All rights reserved.
51 * Redistribution and use in source and binary forms, with or without
52 * modification, are permitted provided that the following conditions
54 * 1. Redistributions of source code must retain the above copyright
55 * notice, this list of conditions and the following disclaimer.
56 * 2. Redistributions in binary form must reproduce the above copyright
57 * notice, this list of conditions and the following disclaimer in the
58 * documentation and/or other materials provided with the distribution.
59 * 3. The name of the author may not be used to endorse or promote products
60 * derived from this software without specific prior written permission
62 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
63 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
64 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
65 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
66 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
67 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
68 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
69 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
70 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
71 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
73 * XXX- This code is presently a no-op on FreeBSD (and isn't compiled due
74 * to preprocessor conditionals). A nice project for a kernel hacking
75 * novice might be to MakeItGo, but I have more important fish to fry
80 #include <sys/types.h>
81 #include <sys/param.h>
82 #include <sys/kernel.h>
89 #include <sys/malloc.h>
91 #include <sys/systm.h>
94 #include <sys/mount.h>
95 #include <sys/sysproto.h>
97 #include <svr4/svr4_types.h>
98 #include <svr4/svr4_signal.h>
99 #include <svr4/svr4_proto.h>
100 #include <svr4/svr4_util.h>
101 #include <svr4/svr4_ipc.h>
103 #if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
104 static void svr4_to_bsd_ipc_perm __P((const struct svr4_ipc_perm *,
106 static void bsd_to_svr4_ipc_perm __P((const struct ipc_perm *,
107 struct svr4_ipc_perm *));
111 static void bsd_to_svr4_semid_ds __P((const struct semid_ds *,
112 struct svr4_semid_ds *));
113 static void svr4_to_bsd_semid_ds __P((const struct svr4_semid_ds *,
115 static int svr4_setsemun __P((caddr_t *sgp, union semun **argp,
117 static int svr4_semop __P((struct proc *, void *, register_t *));
118 static int svr4_semget __P((struct proc *, void *, register_t *));
119 static int svr4_semctl __P((struct proc *, void *, register_t *));
123 static void bsd_to_svr4_msqid_ds __P((const struct msqid_ds *,
124 struct svr4_msqid_ds *));
125 static void svr4_to_bsd_msqid_ds __P((const struct svr4_msqid_ds *,
127 static int svr4_msgsnd __P((struct proc *, void *, register_t *));
128 static int svr4_msgrcv __P((struct proc *, void *, register_t *));
129 static int svr4_msgget __P((struct proc *, void *, register_t *));
130 static int svr4_msgctl __P((struct proc *, void *, register_t *));
134 static void bsd_to_svr4_shmid_ds __P((const struct shmid_ds *,
135 struct svr4_shmid_ds *));
136 static void svr4_to_bsd_shmid_ds __P((const struct svr4_shmid_ds *,
138 static int svr4_shmat __P((struct proc *, void *, register_t *));
139 static int svr4_shmdt __P((struct proc *, void *, register_t *));
140 static int svr4_shmget __P((struct proc *, void *, register_t *));
141 static int svr4_shmctl __P((struct proc *, void *, register_t *));
144 #if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
147 svr4_to_bsd_ipc_perm(spp, bpp)
148 const struct svr4_ipc_perm *spp;
149 struct ipc_perm *bpp;
154 bpp->cuid = spp->cuid;
155 bpp->cgid = spp->cgid;
156 bpp->mode = spp->mode;
161 bsd_to_svr4_ipc_perm(bpp, spp)
162 const struct ipc_perm *bpp;
163 struct svr4_ipc_perm *spp;
168 spp->cuid = bpp->cuid;
169 spp->cgid = bpp->cgid;
170 spp->mode = bpp->mode;
177 bsd_to_svr4_semid_ds(bds, sds)
178 const struct semid_ds *bds;
179 struct svr4_semid_ds *sds;
181 bsd_to_svr4_ipc_perm(&bds->sem_perm, &sds->sem_perm);
182 sds->sem_base = (struct svr4_sem *) bds->sem_base;
183 sds->sem_nsems = bds->sem_nsems;
184 sds->sem_otime = bds->sem_otime;
185 sds->sem_pad1 = bds->sem_pad1;
186 sds->sem_ctime = bds->sem_ctime;
187 sds->sem_pad2 = bds->sem_pad2;
191 svr4_to_bsd_semid_ds(sds, bds)
192 const struct svr4_semid_ds *sds;
193 struct semid_ds *bds;
195 svr4_to_bsd_ipc_perm(&sds->sem_perm, &bds->sem_perm);
196 bds->sem_base = (struct sem *) bds->sem_base;
197 bds->sem_nsems = sds->sem_nsems;
198 bds->sem_otime = sds->sem_otime;
199 bds->sem_pad1 = sds->sem_pad1;
200 bds->sem_ctime = sds->sem_ctime;
201 bds->sem_pad2 = sds->sem_pad2;
205 svr4_setsemun(sgp, argp, usp)
210 *argp = stackgap_alloc(sgp, sizeof(union semun));
211 return copyout((caddr_t)usp, *argp, sizeof(union semun));
214 struct svr4_sys_semctl_args {
215 syscallarg(int) what;
216 syscallarg(int) semid;
217 syscallarg(int) semnum;
219 syscallarg(union semun) arg;
223 svr4_semctl(p, v, retval)
229 struct svr4_sys_semctl_args *uap = v;
230 struct sys___semctl_args ap;
231 struct svr4_semid_ds ss;
232 struct semid_ds bs, *bsp;
233 caddr_t sg = stackgap_init(p->p_emul);
235 SCARG(&ap, semid) = SCARG(uap, semid);
236 SCARG(&ap, semnum) = SCARG(uap, semnum);
238 switch (SCARG(uap, cmd)) {
239 case SVR4_SEM_GETZCNT:
240 case SVR4_SEM_GETNCNT:
241 case SVR4_SEM_GETPID:
242 case SVR4_SEM_GETVAL:
243 switch (SCARG(uap, cmd)) {
244 case SVR4_SEM_GETZCNT:
245 SCARG(&ap, cmd) = GETZCNT;
247 case SVR4_SEM_GETNCNT:
248 SCARG(&ap, cmd) = GETNCNT;
250 case SVR4_SEM_GETPID:
251 SCARG(&ap, cmd) = GETPID;
253 case SVR4_SEM_GETVAL:
254 SCARG(&ap, cmd) = GETVAL;
257 return sys___semctl(p, &ap, retval);
259 case SVR4_SEM_SETVAL:
260 error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
263 SCARG(&ap, cmd) = SETVAL;
264 return sys___semctl(p, &ap, retval);
266 case SVR4_SEM_GETALL:
267 error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
270 SCARG(&ap, cmd) = GETVAL;
271 return sys___semctl(p, &ap, retval);
273 case SVR4_SEM_SETALL:
274 error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
277 SCARG(&ap, cmd) = SETVAL;
278 return sys___semctl(p, &ap, retval);
281 SCARG(&ap, cmd) = IPC_STAT;
282 bsp = stackgap_alloc(&sg, sizeof(bs));
283 error = svr4_setsemun(&sg, &SCARG(&ap, arg),
284 (union semun *)&bsp);
287 if ((error = sys___semctl(p, &ap, retval)) != 0)
289 error = copyin((caddr_t)bsp, (caddr_t)&bs, sizeof(bs));
292 bsd_to_svr4_semid_ds(&bs, &ss);
293 return copyout(&ss, SCARG(uap, arg).buf, sizeof(ss));
296 SCARG(&ap, cmd) = IPC_SET;
297 bsp = stackgap_alloc(&sg, sizeof(bs));
298 error = svr4_setsemun(&sg, &SCARG(&ap, arg),
299 (union semun *)&bsp);
302 error = copyin(SCARG(uap, arg).buf, (caddr_t) &ss, sizeof ss);
305 svr4_to_bsd_semid_ds(&ss, &bs);
306 error = copyout(&bs, bsp, sizeof(bs));
309 return sys___semctl(p, &ap, retval);
312 SCARG(&ap, cmd) = IPC_RMID;
313 bsp = stackgap_alloc(&sg, sizeof(bs));
314 error = svr4_setsemun(&sg, &SCARG(&ap, arg),
315 (union semun *)&bsp);
318 error = copyin(SCARG(uap, arg).buf, &ss, sizeof ss);
321 svr4_to_bsd_semid_ds(&ss, &bs);
322 error = copyout(&bs, bsp, sizeof(bs));
325 return sys___semctl(p, &ap, retval);
332 struct svr4_sys_semget_args {
333 syscallarg(int) what;
334 syscallarg(svr4_key_t) key;
335 syscallarg(int) nsems;
336 syscallarg(int) semflg;
340 svr4_semget(p, v, retval)
345 struct svr4_sys_semget_args *uap = v;
346 struct sys_semget_args ap;
348 SCARG(&ap, key) = SCARG(uap, key);
349 SCARG(&ap, nsems) = SCARG(uap, nsems);
350 SCARG(&ap, semflg) = SCARG(uap, semflg);
352 return sys_semget(p, &ap, retval);
355 struct svr4_sys_semop_args {
356 syscallarg(int) what;
357 syscallarg(int) semid;
358 syscallarg(struct svr4_sembuf *) sops;
359 syscallarg(u_int) nsops;
363 svr4_semop(p, v, retval)
368 struct svr4_sys_semop_args *uap = v;
369 struct sys_semop_args ap;
371 SCARG(&ap, semid) = SCARG(uap, semid);
372 /* These are the same */
373 SCARG(&ap, sops) = (struct sembuf *) SCARG(uap, sops);
374 SCARG(&ap, nsops) = SCARG(uap, nsops);
376 return sys_semop(p, &ap, retval);
380 svr4_sys_semsys(p, v, retval)
385 struct svr4_sys_semsys_args *uap = v;
387 DPRINTF(("svr4_semsys(%d)\n", SCARG(uap, what)));
389 switch (SCARG(uap, what)) {
391 return svr4_semctl(p, v, retval);
393 return svr4_semget(p, v, retval);
395 return svr4_semop(p, v, retval);
404 bsd_to_svr4_msqid_ds(bds, sds)
405 const struct msqid_ds *bds;
406 struct svr4_msqid_ds *sds;
408 bsd_to_svr4_ipc_perm(&bds->msg_perm, &sds->msg_perm);
409 sds->msg_first = (struct svr4_msg *) bds->msg_first;
410 sds->msg_last = (struct svr4_msg *) bds->msg_last;
411 sds->msg_cbytes = bds->msg_cbytes;
412 sds->msg_qnum = bds->msg_qnum;
413 sds->msg_qbytes = bds->msg_qbytes;
414 sds->msg_lspid = bds->msg_lspid;
415 sds->msg_lrpid = bds->msg_lrpid;
416 sds->msg_stime = bds->msg_stime;
417 sds->msg_pad1 = bds->msg_pad1;
418 sds->msg_rtime = bds->msg_rtime;
419 sds->msg_pad2 = bds->msg_pad2;
420 sds->msg_ctime = bds->msg_ctime;
421 sds->msg_pad3 = bds->msg_pad3;
423 /* use the padding for the rest of the fields */
425 const short *pad = (const short *) bds->msg_pad4;
426 sds->msg_cv = pad[0];
427 sds->msg_qnum_cv = pad[1];
432 svr4_to_bsd_msqid_ds(sds, bds)
433 const struct svr4_msqid_ds *sds;
434 struct msqid_ds *bds;
436 svr4_to_bsd_ipc_perm(&sds->msg_perm, &bds->msg_perm);
437 bds->msg_first = (struct msg *) sds->msg_first;
438 bds->msg_last = (struct msg *) sds->msg_last;
439 bds->msg_cbytes = sds->msg_cbytes;
440 bds->msg_qnum = sds->msg_qnum;
441 bds->msg_qbytes = sds->msg_qbytes;
442 bds->msg_lspid = sds->msg_lspid;
443 bds->msg_lrpid = sds->msg_lrpid;
444 bds->msg_stime = sds->msg_stime;
445 bds->msg_pad1 = sds->msg_pad1;
446 bds->msg_rtime = sds->msg_rtime;
447 bds->msg_pad2 = sds->msg_pad2;
448 bds->msg_ctime = sds->msg_ctime;
449 bds->msg_pad3 = sds->msg_pad3;
451 /* use the padding for the rest of the fields */
453 short *pad = (short *) bds->msg_pad4;
454 pad[0] = sds->msg_cv;
455 pad[1] = sds->msg_qnum_cv;
459 struct svr4_sys_msgsnd_args {
460 syscallarg(int) what;
461 syscallarg(int) msqid;
462 syscallarg(void *) msgp;
463 syscallarg(size_t) msgsz;
464 syscallarg(int) msgflg;
468 svr4_msgsnd(p, v, retval)
473 struct svr4_sys_msgsnd_args *uap = v;
474 struct sys_msgsnd_args ap;
476 SCARG(&ap, msqid) = SCARG(uap, msqid);
477 SCARG(&ap, msgp) = SCARG(uap, msgp);
478 SCARG(&ap, msgsz) = SCARG(uap, msgsz);
479 SCARG(&ap, msgflg) = SCARG(uap, msgflg);
481 return sys_msgsnd(p, &ap, retval);
484 struct svr4_sys_msgrcv_args {
485 syscallarg(int) what;
486 syscallarg(int) msqid;
487 syscallarg(void *) msgp;
488 syscallarg(size_t) msgsz;
489 syscallarg(long) msgtyp;
490 syscallarg(int) msgflg;
494 svr4_msgrcv(p, v, retval)
499 struct svr4_sys_msgrcv_args *uap = v;
500 struct sys_msgrcv_args ap;
502 SCARG(&ap, msqid) = SCARG(uap, msqid);
503 SCARG(&ap, msgp) = SCARG(uap, msgp);
504 SCARG(&ap, msgsz) = SCARG(uap, msgsz);
505 SCARG(&ap, msgtyp) = SCARG(uap, msgtyp);
506 SCARG(&ap, msgflg) = SCARG(uap, msgflg);
508 return sys_msgrcv(p, &ap, retval);
511 struct svr4_sys_msgget_args {
512 syscallarg(int) what;
513 syscallarg(svr4_key_t) key;
514 syscallarg(int) msgflg;
518 svr4_msgget(p, v, retval)
523 struct svr4_sys_msgget_args *uap = v;
524 struct sys_msgget_args ap;
526 SCARG(&ap, key) = SCARG(uap, key);
527 SCARG(&ap, msgflg) = SCARG(uap, msgflg);
529 return sys_msgget(p, &ap, retval);
532 struct svr4_sys_msgctl_args {
533 syscallarg(int) what;
534 syscallarg(int) msqid;
536 syscallarg(struct svr4_msqid_ds *) buf;
540 svr4_msgctl(p, v, retval)
546 struct svr4_sys_msgctl_args *uap = v;
547 struct sys_msgctl_args ap;
548 struct svr4_msqid_ds ss;
550 caddr_t sg = stackgap_init(p->p_emul);
552 SCARG(&ap, msqid) = SCARG(uap, msqid);
553 SCARG(&ap, cmd) = SCARG(uap, cmd);
554 SCARG(&ap, buf) = stackgap_alloc(&sg, sizeof(bs));
556 switch (SCARG(uap, cmd)) {
558 SCARG(&ap, cmd) = IPC_STAT;
559 if ((error = sys_msgctl(p, &ap, retval)) != 0)
561 error = copyin(&bs, SCARG(&ap, buf), sizeof bs);
564 bsd_to_svr4_msqid_ds(&bs, &ss);
565 return copyout(&ss, SCARG(uap, buf), sizeof ss);
568 SCARG(&ap, cmd) = IPC_SET;
569 error = copyin(SCARG(uap, buf), &ss, sizeof ss);
572 svr4_to_bsd_msqid_ds(&ss, &bs);
573 error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
576 return sys_msgctl(p, &ap, retval);
579 SCARG(&ap, cmd) = IPC_RMID;
580 error = copyin(SCARG(uap, buf), &ss, sizeof ss);
583 svr4_to_bsd_msqid_ds(&ss, &bs);
584 error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
587 return sys_msgctl(p, &ap, retval);
595 svr4_sys_msgsys(p, v, retval)
600 struct svr4_sys_msgsys_args *uap = v;
602 DPRINTF(("svr4_msgsys(%d)\n", SCARG(uap, what)));
604 switch (SCARG(uap, what)) {
606 return svr4_msgsnd(p, v, retval);
608 return svr4_msgrcv(p, v, retval);
610 return svr4_msgget(p, v, retval);
612 return svr4_msgctl(p, v, retval);
622 bsd_to_svr4_shmid_ds(bds, sds)
623 const struct shmid_ds *bds;
624 struct svr4_shmid_ds *sds;
626 bsd_to_svr4_ipc_perm(&bds->shm_perm, &sds->shm_perm);
627 sds->shm_segsz = bds->shm_segsz;
629 sds->shm_lpid = bds->shm_lpid;
630 sds->shm_cpid = bds->shm_cpid;
631 sds->shm_amp = bds->shm_internal;
632 sds->shm_nattch = bds->shm_nattch;
633 sds->shm_cnattch = 0;
634 sds->shm_atime = bds->shm_atime;
636 sds->shm_dtime = bds->shm_dtime;
638 sds->shm_ctime = bds->shm_ctime;
643 svr4_to_bsd_shmid_ds(sds, bds)
644 const struct svr4_shmid_ds *sds;
645 struct shmid_ds *bds;
647 svr4_to_bsd_ipc_perm(&sds->shm_perm, &bds->shm_perm);
648 bds->shm_segsz = sds->shm_segsz;
649 bds->shm_lpid = sds->shm_lpid;
650 bds->shm_cpid = sds->shm_cpid;
651 bds->shm_internal = sds->shm_amp;
652 bds->shm_nattch = sds->shm_nattch;
653 bds->shm_atime = sds->shm_atime;
654 bds->shm_dtime = sds->shm_dtime;
655 bds->shm_ctime = sds->shm_ctime;
658 struct svr4_sys_shmat_args {
659 syscallarg(int) what;
660 syscallarg(int) shmid;
661 syscallarg(void *) shmaddr;
662 syscallarg(int) shmflg;
666 svr4_shmat(p, v, retval)
671 struct svr4_sys_shmat_args *uap = v;
672 struct sys_shmat_args ap;
674 SCARG(&ap, shmid) = SCARG(uap, shmid);
675 SCARG(&ap, shmaddr) = SCARG(uap, shmaddr);
676 SCARG(&ap, shmflg) = SCARG(uap, shmflg);
678 return sys_shmat(p, &ap, retval);
681 struct svr4_sys_shmdt_args {
682 syscallarg(int) what;
683 syscallarg(void *) shmaddr;
687 svr4_shmdt(p, v, retval)
692 struct svr4_sys_shmdt_args *uap = v;
693 struct sys_shmdt_args ap;
695 SCARG(&ap, shmaddr) = SCARG(uap, shmaddr);
697 return sys_shmdt(p, &ap, retval);
700 struct svr4_sys_shmget_args {
701 syscallarg(int) what;
702 syscallarg(key_t) key;
703 syscallarg(int) size;
704 syscallarg(int) shmflg;
708 svr4_shmget(p, v, retval)
713 struct svr4_sys_shmget_args *uap = v;
714 struct sys_shmget_args ap;
716 SCARG(&ap, key) = SCARG(uap, key);
717 SCARG(&ap, size) = SCARG(uap, size);
718 SCARG(&ap, shmflg) = SCARG(uap, shmflg);
720 return sys_shmget(p, &ap, retval);
723 struct svr4_sys_shmctl_args {
724 syscallarg(int) what;
725 syscallarg(int) shmid;
727 syscallarg(struct svr4_shmid_ds *) buf;
731 svr4_shmctl(p, v, retval)
736 struct svr4_sys_shmctl_args *uap = v;
738 caddr_t sg = stackgap_init(p->p_emul);
739 struct sys_shmctl_args ap;
741 struct svr4_shmid_ds ss;
743 SCARG(&ap, shmid) = SCARG(uap, shmid);
745 if (SCARG(uap, buf) != NULL) {
746 SCARG(&ap, buf) = stackgap_alloc(&sg, sizeof (struct shmid_ds));
747 switch (SCARG(uap, cmd)) {
751 case SVR4_SHM_UNLOCK:
752 error = copyin(SCARG(uap, buf), (caddr_t) &ss,
756 svr4_to_bsd_shmid_ds(&ss, &bs);
757 error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
766 SCARG(&ap, buf) = NULL;
769 switch (SCARG(uap, cmd)) {
771 SCARG(&ap, cmd) = IPC_STAT;
772 if ((error = sys_shmctl(p, &ap, retval)) != 0)
774 if (SCARG(uap, buf) == NULL)
776 error = copyin(&bs, SCARG(&ap, buf), sizeof bs);
779 bsd_to_svr4_shmid_ds(&bs, &ss);
780 return copyout(&ss, SCARG(uap, buf), sizeof ss);
783 SCARG(&ap, cmd) = IPC_SET;
784 return sys_shmctl(p, &ap, retval);
788 case SVR4_SHM_UNLOCK:
789 switch (SCARG(uap, cmd)) {
791 SCARG(&ap, cmd) = IPC_RMID;
794 SCARG(&ap, cmd) = SHM_LOCK;
796 case SVR4_SHM_UNLOCK:
797 SCARG(&ap, cmd) = SHM_UNLOCK;
802 return sys_shmctl(p, &ap, retval);
810 svr4_sys_shmsys(p, v, retval)
815 struct svr4_sys_shmsys_args *uap = v;
817 DPRINTF(("svr4_shmsys(%d)\n", SCARG(uap, what)));
819 switch (SCARG(uap, what)) {
821 return svr4_shmat(p, v, retval);
823 return svr4_shmdt(p, v, retval);
825 return svr4_shmget(p, v, retval);
827 return svr4_shmctl(p, v, retval);