2 * $FreeBSD: src/sys/svr4/svr4_ipc.c,v 1.5 1999/12/08 10:51:16 newton Exp $
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>
86 #include <svr4/svr4.h>
87 #include <svr4/svr4_types.h>
88 #include <svr4/svr4_signal.h>
89 #include <svr4/svr4_proto.h>
90 #include <svr4/svr4_util.h>
91 #include <svr4/svr4_ipc.h>
93 #if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
94 static void svr4_to_bsd_ipc_perm __P((const struct svr4_ipc_perm *,
96 static void bsd_to_svr4_ipc_perm __P((const struct ipc_perm *,
97 struct svr4_ipc_perm *));
101 static void bsd_to_svr4_semid_ds __P((const struct semid_ds *,
102 struct svr4_semid_ds *));
103 static void svr4_to_bsd_semid_ds __P((const struct svr4_semid_ds *,
105 static int svr4_setsemun __P((caddr_t *sgp, union semun **argp,
107 static int svr4_semop __P((struct proc *, void *, register_t *));
108 static int svr4_semget __P((struct proc *, void *, register_t *));
109 static int svr4_semctl __P((struct proc *, void *, register_t *));
113 static void bsd_to_svr4_msqid_ds __P((const struct msqid_ds *,
114 struct svr4_msqid_ds *));
115 static void svr4_to_bsd_msqid_ds __P((const struct svr4_msqid_ds *,
117 static int svr4_msgsnd __P((struct proc *, void *, register_t *));
118 static int svr4_msgrcv __P((struct proc *, void *, register_t *));
119 static int svr4_msgget __P((struct proc *, void *, register_t *));
120 static int svr4_msgctl __P((struct proc *, void *, register_t *));
124 static void bsd_to_svr4_shmid_ds __P((const struct shmid_ds *,
125 struct svr4_shmid_ds *));
126 static void svr4_to_bsd_shmid_ds __P((const struct svr4_shmid_ds *,
128 static int svr4_shmat __P((struct proc *, void *, register_t *));
129 static int svr4_shmdt __P((struct proc *, void *, register_t *));
130 static int svr4_shmget __P((struct proc *, void *, register_t *));
131 static int svr4_shmctl __P((struct proc *, void *, register_t *));
134 #if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
137 svr4_to_bsd_ipc_perm(spp, bpp)
138 const struct svr4_ipc_perm *spp;
139 struct ipc_perm *bpp;
144 bpp->cuid = spp->cuid;
145 bpp->cgid = spp->cgid;
146 bpp->mode = spp->mode;
151 bsd_to_svr4_ipc_perm(bpp, spp)
152 const struct ipc_perm *bpp;
153 struct svr4_ipc_perm *spp;
158 spp->cuid = bpp->cuid;
159 spp->cgid = bpp->cgid;
160 spp->mode = bpp->mode;
167 bsd_to_svr4_semid_ds(bds, sds)
168 const struct semid_ds *bds;
169 struct svr4_semid_ds *sds;
171 bsd_to_svr4_ipc_perm(&bds->sem_perm, &sds->sem_perm);
172 sds->sem_base = (struct svr4_sem *) bds->sem_base;
173 sds->sem_nsems = bds->sem_nsems;
174 sds->sem_otime = bds->sem_otime;
175 sds->sem_pad1 = bds->sem_pad1;
176 sds->sem_ctime = bds->sem_ctime;
177 sds->sem_pad2 = bds->sem_pad2;
181 svr4_to_bsd_semid_ds(sds, bds)
182 const struct svr4_semid_ds *sds;
183 struct semid_ds *bds;
185 svr4_to_bsd_ipc_perm(&sds->sem_perm, &bds->sem_perm);
186 bds->sem_base = (struct sem *) bds->sem_base;
187 bds->sem_nsems = sds->sem_nsems;
188 bds->sem_otime = sds->sem_otime;
189 bds->sem_pad1 = sds->sem_pad1;
190 bds->sem_ctime = sds->sem_ctime;
191 bds->sem_pad2 = sds->sem_pad2;
195 svr4_setsemun(sgp, argp, usp)
200 *argp = stackgap_alloc(sgp, sizeof(union semun));
201 return copyout((caddr_t)usp, *argp, sizeof(union semun));
204 struct svr4_sys_semctl_args {
205 syscallarg(int) what;
206 syscallarg(int) semid;
207 syscallarg(int) semnum;
209 syscallarg(union semun) arg;
213 svr4_semctl(p, v, retval)
219 struct svr4_sys_semctl_args *uap = v;
220 struct sys___semctl_args ap;
221 struct svr4_semid_ds ss;
222 struct semid_ds bs, *bsp;
223 caddr_t sg = stackgap_init(p->p_emul);
225 SCARG(&ap, semid) = SCARG(uap, semid);
226 SCARG(&ap, semnum) = SCARG(uap, semnum);
228 switch (SCARG(uap, cmd)) {
229 case SVR4_SEM_GETZCNT:
230 case SVR4_SEM_GETNCNT:
231 case SVR4_SEM_GETPID:
232 case SVR4_SEM_GETVAL:
233 switch (SCARG(uap, cmd)) {
234 case SVR4_SEM_GETZCNT:
235 SCARG(&ap, cmd) = GETZCNT;
237 case SVR4_SEM_GETNCNT:
238 SCARG(&ap, cmd) = GETNCNT;
240 case SVR4_SEM_GETPID:
241 SCARG(&ap, cmd) = GETPID;
243 case SVR4_SEM_GETVAL:
244 SCARG(&ap, cmd) = GETVAL;
247 return sys___semctl(p, &ap, retval);
249 case SVR4_SEM_SETVAL:
250 error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
253 SCARG(&ap, cmd) = SETVAL;
254 return sys___semctl(p, &ap, retval);
256 case SVR4_SEM_GETALL:
257 error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
260 SCARG(&ap, cmd) = GETVAL;
261 return sys___semctl(p, &ap, retval);
263 case SVR4_SEM_SETALL:
264 error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
267 SCARG(&ap, cmd) = SETVAL;
268 return sys___semctl(p, &ap, retval);
271 SCARG(&ap, cmd) = IPC_STAT;
272 bsp = stackgap_alloc(&sg, sizeof(bs));
273 error = svr4_setsemun(&sg, &SCARG(&ap, arg),
274 (union semun *)&bsp);
277 if ((error = sys___semctl(p, &ap, retval)) != 0)
279 error = copyin((caddr_t)bsp, (caddr_t)&bs, sizeof(bs));
282 bsd_to_svr4_semid_ds(&bs, &ss);
283 return copyout(&ss, SCARG(uap, arg).buf, sizeof(ss));
286 SCARG(&ap, cmd) = IPC_SET;
287 bsp = stackgap_alloc(&sg, sizeof(bs));
288 error = svr4_setsemun(&sg, &SCARG(&ap, arg),
289 (union semun *)&bsp);
292 error = copyin(SCARG(uap, arg).buf, (caddr_t) &ss, sizeof ss);
295 svr4_to_bsd_semid_ds(&ss, &bs);
296 error = copyout(&bs, bsp, sizeof(bs));
299 return sys___semctl(p, &ap, retval);
302 SCARG(&ap, cmd) = IPC_RMID;
303 bsp = stackgap_alloc(&sg, sizeof(bs));
304 error = svr4_setsemun(&sg, &SCARG(&ap, arg),
305 (union semun *)&bsp);
308 error = copyin(SCARG(uap, arg).buf, &ss, sizeof ss);
311 svr4_to_bsd_semid_ds(&ss, &bs);
312 error = copyout(&bs, bsp, sizeof(bs));
315 return sys___semctl(p, &ap, retval);
322 struct svr4_sys_semget_args {
323 syscallarg(int) what;
324 syscallarg(svr4_key_t) key;
325 syscallarg(int) nsems;
326 syscallarg(int) semflg;
330 svr4_semget(p, v, retval)
335 struct svr4_sys_semget_args *uap = v;
336 struct sys_semget_args ap;
338 SCARG(&ap, key) = SCARG(uap, key);
339 SCARG(&ap, nsems) = SCARG(uap, nsems);
340 SCARG(&ap, semflg) = SCARG(uap, semflg);
342 return sys_semget(p, &ap, retval);
345 struct svr4_sys_semop_args {
346 syscallarg(int) what;
347 syscallarg(int) semid;
348 syscallarg(struct svr4_sembuf *) sops;
349 syscallarg(u_int) nsops;
353 svr4_semop(p, v, retval)
358 struct svr4_sys_semop_args *uap = v;
359 struct sys_semop_args ap;
361 SCARG(&ap, semid) = SCARG(uap, semid);
362 /* These are the same */
363 SCARG(&ap, sops) = (struct sembuf *) SCARG(uap, sops);
364 SCARG(&ap, nsops) = SCARG(uap, nsops);
366 return sys_semop(p, &ap, retval);
370 svr4_sys_semsys(p, v, retval)
375 struct svr4_sys_semsys_args *uap = v;
377 DPRINTF(("svr4_semsys(%d)\n", SCARG(uap, what)));
379 switch (SCARG(uap, what)) {
381 return svr4_semctl(p, v, retval);
383 return svr4_semget(p, v, retval);
385 return svr4_semop(p, v, retval);
394 bsd_to_svr4_msqid_ds(bds, sds)
395 const struct msqid_ds *bds;
396 struct svr4_msqid_ds *sds;
398 bsd_to_svr4_ipc_perm(&bds->msg_perm, &sds->msg_perm);
399 sds->msg_first = (struct svr4_msg *) bds->msg_first;
400 sds->msg_last = (struct svr4_msg *) bds->msg_last;
401 sds->msg_cbytes = bds->msg_cbytes;
402 sds->msg_qnum = bds->msg_qnum;
403 sds->msg_qbytes = bds->msg_qbytes;
404 sds->msg_lspid = bds->msg_lspid;
405 sds->msg_lrpid = bds->msg_lrpid;
406 sds->msg_stime = bds->msg_stime;
407 sds->msg_pad1 = bds->msg_pad1;
408 sds->msg_rtime = bds->msg_rtime;
409 sds->msg_pad2 = bds->msg_pad2;
410 sds->msg_ctime = bds->msg_ctime;
411 sds->msg_pad3 = bds->msg_pad3;
413 /* use the padding for the rest of the fields */
415 const short *pad = (const short *) bds->msg_pad4;
416 sds->msg_cv = pad[0];
417 sds->msg_qnum_cv = pad[1];
422 svr4_to_bsd_msqid_ds(sds, bds)
423 const struct svr4_msqid_ds *sds;
424 struct msqid_ds *bds;
426 svr4_to_bsd_ipc_perm(&sds->msg_perm, &bds->msg_perm);
427 bds->msg_first = (struct msg *) sds->msg_first;
428 bds->msg_last = (struct msg *) sds->msg_last;
429 bds->msg_cbytes = sds->msg_cbytes;
430 bds->msg_qnum = sds->msg_qnum;
431 bds->msg_qbytes = sds->msg_qbytes;
432 bds->msg_lspid = sds->msg_lspid;
433 bds->msg_lrpid = sds->msg_lrpid;
434 bds->msg_stime = sds->msg_stime;
435 bds->msg_pad1 = sds->msg_pad1;
436 bds->msg_rtime = sds->msg_rtime;
437 bds->msg_pad2 = sds->msg_pad2;
438 bds->msg_ctime = sds->msg_ctime;
439 bds->msg_pad3 = sds->msg_pad3;
441 /* use the padding for the rest of the fields */
443 short *pad = (short *) bds->msg_pad4;
444 pad[0] = sds->msg_cv;
445 pad[1] = sds->msg_qnum_cv;
449 struct svr4_sys_msgsnd_args {
450 syscallarg(int) what;
451 syscallarg(int) msqid;
452 syscallarg(void *) msgp;
453 syscallarg(size_t) msgsz;
454 syscallarg(int) msgflg;
458 svr4_msgsnd(p, v, retval)
463 struct svr4_sys_msgsnd_args *uap = v;
464 struct sys_msgsnd_args ap;
466 SCARG(&ap, msqid) = SCARG(uap, msqid);
467 SCARG(&ap, msgp) = SCARG(uap, msgp);
468 SCARG(&ap, msgsz) = SCARG(uap, msgsz);
469 SCARG(&ap, msgflg) = SCARG(uap, msgflg);
471 return sys_msgsnd(p, &ap, retval);
474 struct svr4_sys_msgrcv_args {
475 syscallarg(int) what;
476 syscallarg(int) msqid;
477 syscallarg(void *) msgp;
478 syscallarg(size_t) msgsz;
479 syscallarg(long) msgtyp;
480 syscallarg(int) msgflg;
484 svr4_msgrcv(p, v, retval)
489 struct svr4_sys_msgrcv_args *uap = v;
490 struct sys_msgrcv_args ap;
492 SCARG(&ap, msqid) = SCARG(uap, msqid);
493 SCARG(&ap, msgp) = SCARG(uap, msgp);
494 SCARG(&ap, msgsz) = SCARG(uap, msgsz);
495 SCARG(&ap, msgtyp) = SCARG(uap, msgtyp);
496 SCARG(&ap, msgflg) = SCARG(uap, msgflg);
498 return sys_msgrcv(p, &ap, retval);
501 struct svr4_sys_msgget_args {
502 syscallarg(int) what;
503 syscallarg(svr4_key_t) key;
504 syscallarg(int) msgflg;
508 svr4_msgget(p, v, retval)
513 struct svr4_sys_msgget_args *uap = v;
514 struct sys_msgget_args ap;
516 SCARG(&ap, key) = SCARG(uap, key);
517 SCARG(&ap, msgflg) = SCARG(uap, msgflg);
519 return sys_msgget(p, &ap, retval);
522 struct svr4_sys_msgctl_args {
523 syscallarg(int) what;
524 syscallarg(int) msqid;
526 syscallarg(struct svr4_msqid_ds *) buf;
530 svr4_msgctl(p, v, retval)
536 struct svr4_sys_msgctl_args *uap = v;
537 struct sys_msgctl_args ap;
538 struct svr4_msqid_ds ss;
540 caddr_t sg = stackgap_init(p->p_emul);
542 SCARG(&ap, msqid) = SCARG(uap, msqid);
543 SCARG(&ap, cmd) = SCARG(uap, cmd);
544 SCARG(&ap, buf) = stackgap_alloc(&sg, sizeof(bs));
546 switch (SCARG(uap, cmd)) {
548 SCARG(&ap, cmd) = IPC_STAT;
549 if ((error = sys_msgctl(p, &ap, retval)) != 0)
551 error = copyin(&bs, SCARG(&ap, buf), sizeof bs);
554 bsd_to_svr4_msqid_ds(&bs, &ss);
555 return copyout(&ss, SCARG(uap, buf), sizeof ss);
558 SCARG(&ap, cmd) = IPC_SET;
559 error = copyin(SCARG(uap, buf), &ss, sizeof ss);
562 svr4_to_bsd_msqid_ds(&ss, &bs);
563 error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
566 return sys_msgctl(p, &ap, retval);
569 SCARG(&ap, cmd) = IPC_RMID;
570 error = copyin(SCARG(uap, buf), &ss, sizeof ss);
573 svr4_to_bsd_msqid_ds(&ss, &bs);
574 error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
577 return sys_msgctl(p, &ap, retval);
585 svr4_sys_msgsys(p, v, retval)
590 struct svr4_sys_msgsys_args *uap = v;
592 DPRINTF(("svr4_msgsys(%d)\n", SCARG(uap, what)));
594 switch (SCARG(uap, what)) {
596 return svr4_msgsnd(p, v, retval);
598 return svr4_msgrcv(p, v, retval);
600 return svr4_msgget(p, v, retval);
602 return svr4_msgctl(p, v, retval);
612 bsd_to_svr4_shmid_ds(bds, sds)
613 const struct shmid_ds *bds;
614 struct svr4_shmid_ds *sds;
616 bsd_to_svr4_ipc_perm(&bds->shm_perm, &sds->shm_perm);
617 sds->shm_segsz = bds->shm_segsz;
619 sds->shm_lpid = bds->shm_lpid;
620 sds->shm_cpid = bds->shm_cpid;
621 sds->shm_amp = bds->shm_internal;
622 sds->shm_nattch = bds->shm_nattch;
623 sds->shm_cnattch = 0;
624 sds->shm_atime = bds->shm_atime;
626 sds->shm_dtime = bds->shm_dtime;
628 sds->shm_ctime = bds->shm_ctime;
633 svr4_to_bsd_shmid_ds(sds, bds)
634 const struct svr4_shmid_ds *sds;
635 struct shmid_ds *bds;
637 svr4_to_bsd_ipc_perm(&sds->shm_perm, &bds->shm_perm);
638 bds->shm_segsz = sds->shm_segsz;
639 bds->shm_lpid = sds->shm_lpid;
640 bds->shm_cpid = sds->shm_cpid;
641 bds->shm_internal = sds->shm_amp;
642 bds->shm_nattch = sds->shm_nattch;
643 bds->shm_atime = sds->shm_atime;
644 bds->shm_dtime = sds->shm_dtime;
645 bds->shm_ctime = sds->shm_ctime;
648 struct svr4_sys_shmat_args {
649 syscallarg(int) what;
650 syscallarg(int) shmid;
651 syscallarg(void *) shmaddr;
652 syscallarg(int) shmflg;
656 svr4_shmat(p, v, retval)
661 struct svr4_sys_shmat_args *uap = v;
662 struct sys_shmat_args ap;
664 SCARG(&ap, shmid) = SCARG(uap, shmid);
665 SCARG(&ap, shmaddr) = SCARG(uap, shmaddr);
666 SCARG(&ap, shmflg) = SCARG(uap, shmflg);
668 return sys_shmat(p, &ap, retval);
671 struct svr4_sys_shmdt_args {
672 syscallarg(int) what;
673 syscallarg(void *) shmaddr;
677 svr4_shmdt(p, v, retval)
682 struct svr4_sys_shmdt_args *uap = v;
683 struct sys_shmdt_args ap;
685 SCARG(&ap, shmaddr) = SCARG(uap, shmaddr);
687 return sys_shmdt(p, &ap, retval);
690 struct svr4_sys_shmget_args {
691 syscallarg(int) what;
692 syscallarg(key_t) key;
693 syscallarg(int) size;
694 syscallarg(int) shmflg;
698 svr4_shmget(p, v, retval)
703 struct svr4_sys_shmget_args *uap = v;
704 struct sys_shmget_args ap;
706 SCARG(&ap, key) = SCARG(uap, key);
707 SCARG(&ap, size) = SCARG(uap, size);
708 SCARG(&ap, shmflg) = SCARG(uap, shmflg);
710 return sys_shmget(p, &ap, retval);
713 struct svr4_sys_shmctl_args {
714 syscallarg(int) what;
715 syscallarg(int) shmid;
717 syscallarg(struct svr4_shmid_ds *) buf;
721 svr4_shmctl(p, v, retval)
726 struct svr4_sys_shmctl_args *uap = v;
728 caddr_t sg = stackgap_init(p->p_emul);
729 struct sys_shmctl_args ap;
731 struct svr4_shmid_ds ss;
733 SCARG(&ap, shmid) = SCARG(uap, shmid);
735 if (SCARG(uap, buf) != NULL) {
736 SCARG(&ap, buf) = stackgap_alloc(&sg, sizeof (struct shmid_ds));
737 switch (SCARG(uap, cmd)) {
741 case SVR4_SHM_UNLOCK:
742 error = copyin(SCARG(uap, buf), (caddr_t) &ss,
746 svr4_to_bsd_shmid_ds(&ss, &bs);
747 error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
756 SCARG(&ap, buf) = NULL;
759 switch (SCARG(uap, cmd)) {
761 SCARG(&ap, cmd) = IPC_STAT;
762 if ((error = sys_shmctl(p, &ap, retval)) != 0)
764 if (SCARG(uap, buf) == NULL)
766 error = copyin(&bs, SCARG(&ap, buf), sizeof bs);
769 bsd_to_svr4_shmid_ds(&bs, &ss);
770 return copyout(&ss, SCARG(uap, buf), sizeof ss);
773 SCARG(&ap, cmd) = IPC_SET;
774 return sys_shmctl(p, &ap, retval);
778 case SVR4_SHM_UNLOCK:
779 switch (SCARG(uap, cmd)) {
781 SCARG(&ap, cmd) = IPC_RMID;
784 SCARG(&ap, cmd) = SHM_LOCK;
786 case SVR4_SHM_UNLOCK:
787 SCARG(&ap, cmd) = SHM_UNLOCK;
792 return sys_shmctl(p, &ap, retval);
800 svr4_sys_shmsys(p, v, retval)
805 struct svr4_sys_shmsys_args *uap = v;
807 DPRINTF(("svr4_shmsys(%d)\n", SCARG(uap, what)));
809 switch (SCARG(uap, what)) {
811 return svr4_shmat(p, v, retval);
813 return svr4_shmdt(p, v, retval);
815 return svr4_shmget(p, v, retval);
817 return svr4_shmctl(p, v, retval);