2 * Copyright (c) 1994-1995 Søren Schmidt
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer
10 * in this position and unchanged.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
32 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/syscallsubr.h>
35 #include <sys/sysproto.h>
37 #include <sys/limits.h>
42 #include "opt_compat.h"
45 #include <machine/../linux32/linux.h>
46 #include <machine/../linux32/linux32_proto.h>
47 #include <machine/../linux32/linux32_ipc64.h>
49 #include <machine/../linux/linux.h>
50 #include <machine/../linux/linux_proto.h>
51 #include <machine/../linux/linux_ipc64.h>
53 #include <compat/linux/linux_ipc.h>
54 #include <compat/linux/linux_util.h>
79 l_ulong shm_tot; /* total allocated shm */
80 l_ulong shm_rss; /* total resident shm */
81 l_ulong shm_swp; /* total swapped shm */
82 l_ulong swap_attempts;
83 l_ulong swap_successes;
98 bsd_to_linux_shminfo( struct shminfo *bpp, struct l_shminfo *lpp)
100 lpp->shmmax = bpp->shmmax;
101 lpp->shmmin = bpp->shmmin;
102 lpp->shmmni = bpp->shmmni;
103 lpp->shmseg = bpp->shmseg;
104 lpp->shmall = bpp->shmall;
108 bsd_to_linux_shm_info( struct shm_info *bpp, struct l_shm_info *lpp)
110 lpp->used_ids = bpp->used_ids ;
111 lpp->shm_tot = bpp->shm_tot ;
112 lpp->shm_rss = bpp->shm_rss ;
113 lpp->shm_swp = bpp->shm_swp ;
114 lpp->swap_attempts = bpp->swap_attempts ;
115 lpp->swap_successes = bpp->swap_successes ;
129 linux_to_bsd_ipc_perm(struct l_ipc_perm *lpp, struct ipc_perm *bpp)
134 bpp->cuid = lpp->cuid;
135 bpp->cgid = lpp->cgid;
136 bpp->mode = lpp->mode;
142 bsd_to_linux_ipc_perm(struct ipc_perm *bpp, struct l_ipc_perm *lpp)
147 lpp->cuid = bpp->cuid;
148 lpp->cgid = bpp->cgid;
149 lpp->mode = bpp->mode;
154 struct l_ipc_perm msg_perm;
155 l_uintptr_t msg_first; /* first message on queue,unused */
156 l_uintptr_t msg_last; /* last message in queue,unused */
157 l_time_t msg_stime; /* last msgsnd time */
158 l_time_t msg_rtime; /* last msgrcv time */
159 l_time_t msg_ctime; /* last change time */
160 l_ulong msg_lcbytes; /* Reuse junk fields for 32 bit */
161 l_ulong msg_lqbytes; /* ditto */
162 l_ushort msg_cbytes; /* current number of bytes on queue */
163 l_ushort msg_qnum; /* number of messages in queue */
164 l_ushort msg_qbytes; /* max number of bytes on queue */
165 l_pid_t msg_lspid; /* pid of last msgsnd */
166 l_pid_t msg_lrpid; /* last receive pid */
168 #if defined(__amd64__) && defined(COMPAT_LINUX32)
174 struct l_ipc_perm sem_perm;
177 l_uintptr_t sem_base;
178 l_uintptr_t sem_pending;
179 l_uintptr_t sem_pending_last;
183 #if defined(__amd64__) && defined(COMPAT_LINUX32)
189 struct l_ipc_perm shm_perm;
198 l_uintptr_t private2;
199 l_uintptr_t private3;
203 linux_to_bsd_semid_ds(struct l_semid_ds *lsp, struct semid_ds *bsp)
205 linux_to_bsd_ipc_perm(&lsp->sem_perm, &bsp->sem_perm);
206 bsp->sem_otime = lsp->sem_otime;
207 bsp->sem_ctime = lsp->sem_ctime;
208 bsp->sem_nsems = lsp->sem_nsems;
209 bsp->sem_base = PTRIN(lsp->sem_base);
213 bsd_to_linux_semid_ds(struct semid_ds *bsp, struct l_semid_ds *lsp)
215 bsd_to_linux_ipc_perm(&bsp->sem_perm, &lsp->sem_perm);
216 lsp->sem_otime = bsp->sem_otime;
217 lsp->sem_ctime = bsp->sem_ctime;
218 lsp->sem_nsems = bsp->sem_nsems;
219 lsp->sem_base = PTROUT(bsp->sem_base);
223 linux_to_bsd_shmid_ds(struct l_shmid_ds *lsp, struct shmid_ds *bsp)
225 linux_to_bsd_ipc_perm(&lsp->shm_perm, &bsp->shm_perm);
226 bsp->shm_segsz = lsp->shm_segsz;
227 bsp->shm_lpid = lsp->shm_lpid;
228 bsp->shm_cpid = lsp->shm_cpid;
229 bsp->shm_nattch = lsp->shm_nattch;
230 bsp->shm_atime = lsp->shm_atime;
231 bsp->shm_dtime = lsp->shm_dtime;
232 bsp->shm_ctime = lsp->shm_ctime;
236 bsd_to_linux_shmid_ds(struct shmid_ds *bsp, struct l_shmid_ds *lsp)
238 bsd_to_linux_ipc_perm(&bsp->shm_perm, &lsp->shm_perm);
239 if (bsp->shm_segsz > INT_MAX)
240 lsp->shm_segsz = INT_MAX;
242 lsp->shm_segsz = bsp->shm_segsz;
243 lsp->shm_lpid = bsp->shm_lpid;
244 lsp->shm_cpid = bsp->shm_cpid;
245 if (bsp->shm_nattch > SHRT_MAX)
246 lsp->shm_nattch = SHRT_MAX;
248 lsp->shm_nattch = bsp->shm_nattch;
249 lsp->shm_atime = bsp->shm_atime;
250 lsp->shm_dtime = bsp->shm_dtime;
251 lsp->shm_ctime = bsp->shm_ctime;
256 linux_to_bsd_msqid_ds(struct l_msqid_ds *lsp, struct msqid_ds *bsp)
258 linux_to_bsd_ipc_perm(&lsp->msg_perm, &bsp->msg_perm);
259 bsp->msg_cbytes = lsp->msg_cbytes;
260 bsp->msg_qnum = lsp->msg_qnum;
261 bsp->msg_qbytes = lsp->msg_qbytes;
262 bsp->msg_lspid = lsp->msg_lspid;
263 bsp->msg_lrpid = lsp->msg_lrpid;
264 bsp->msg_stime = lsp->msg_stime;
265 bsp->msg_rtime = lsp->msg_rtime;
266 bsp->msg_ctime = lsp->msg_ctime;
270 bsd_to_linux_msqid_ds(struct msqid_ds *bsp, struct l_msqid_ds *lsp)
272 bsd_to_linux_ipc_perm(&bsp->msg_perm, &lsp->msg_perm);
273 lsp->msg_cbytes = bsp->msg_cbytes;
274 lsp->msg_qnum = bsp->msg_qnum;
275 lsp->msg_qbytes = bsp->msg_qbytes;
276 lsp->msg_lspid = bsp->msg_lspid;
277 lsp->msg_lrpid = bsp->msg_lrpid;
278 lsp->msg_stime = bsp->msg_stime;
279 lsp->msg_rtime = bsp->msg_rtime;
280 lsp->msg_ctime = bsp->msg_ctime;
284 linux_ipc_perm_to_ipc64_perm(struct l_ipc_perm *in, struct l_ipc64_perm *out)
287 /* XXX: do we really need to do something here? */
291 out->cuid = in->cuid;
292 out->cgid = in->cgid;
293 out->mode = in->mode;
298 linux_msqid_pullup(l_int ver, struct l_msqid_ds *linux_msqid, caddr_t uaddr)
300 struct l_msqid64_ds linux_msqid64;
303 if (ver == LINUX_IPC_64) {
304 error = copyin(uaddr, &linux_msqid64, sizeof(linux_msqid64));
308 bzero(linux_msqid, sizeof(*linux_msqid));
310 linux_msqid->msg_perm.uid = linux_msqid64.msg_perm.uid;
311 linux_msqid->msg_perm.gid = linux_msqid64.msg_perm.gid;
312 linux_msqid->msg_perm.mode = linux_msqid64.msg_perm.mode;
314 if (linux_msqid64.msg_qbytes > USHRT_MAX)
315 linux_msqid->msg_lqbytes = linux_msqid64.msg_qbytes;
317 linux_msqid->msg_qbytes = linux_msqid64.msg_qbytes;
319 error = copyin(uaddr, linux_msqid, sizeof(*linux_msqid));
325 linux_msqid_pushdown(l_int ver, struct l_msqid_ds *linux_msqid, caddr_t uaddr)
327 struct l_msqid64_ds linux_msqid64;
329 if (ver == LINUX_IPC_64) {
330 bzero(&linux_msqid64, sizeof(linux_msqid64));
332 linux_ipc_perm_to_ipc64_perm(&linux_msqid->msg_perm,
333 &linux_msqid64.msg_perm);
335 linux_msqid64.msg_stime = linux_msqid->msg_stime;
336 linux_msqid64.msg_rtime = linux_msqid->msg_rtime;
337 linux_msqid64.msg_ctime = linux_msqid->msg_ctime;
339 if (linux_msqid->msg_cbytes == 0)
340 linux_msqid64.msg_cbytes = linux_msqid->msg_lcbytes;
342 linux_msqid64.msg_cbytes = linux_msqid->msg_cbytes;
344 linux_msqid64.msg_qnum = linux_msqid->msg_qnum;
346 if (linux_msqid->msg_qbytes == 0)
347 linux_msqid64.msg_qbytes = linux_msqid->msg_lqbytes;
349 linux_msqid64.msg_qbytes = linux_msqid->msg_qbytes;
351 linux_msqid64.msg_lspid = linux_msqid->msg_lspid;
352 linux_msqid64.msg_lrpid = linux_msqid->msg_lrpid;
354 return (copyout(&linux_msqid64, uaddr, sizeof(linux_msqid64)));
356 return (copyout(linux_msqid, uaddr, sizeof(*linux_msqid)));
361 linux_semid_pullup(l_int ver, struct l_semid_ds *linux_semid, caddr_t uaddr)
363 struct l_semid64_ds linux_semid64;
366 if (ver == LINUX_IPC_64) {
367 error = copyin(uaddr, &linux_semid64, sizeof(linux_semid64));
371 bzero(linux_semid, sizeof(*linux_semid));
373 linux_semid->sem_perm.uid = linux_semid64.sem_perm.uid;
374 linux_semid->sem_perm.gid = linux_semid64.sem_perm.gid;
375 linux_semid->sem_perm.mode = linux_semid64.sem_perm.mode;
377 error = copyin(uaddr, linux_semid, sizeof(*linux_semid));
383 linux_semid_pushdown(l_int ver, struct l_semid_ds *linux_semid, caddr_t uaddr)
385 struct l_semid64_ds linux_semid64;
387 if (ver == LINUX_IPC_64) {
388 bzero(&linux_semid64, sizeof(linux_semid64));
390 linux_ipc_perm_to_ipc64_perm(&linux_semid->sem_perm,
391 &linux_semid64.sem_perm);
393 linux_semid64.sem_otime = linux_semid->sem_otime;
394 linux_semid64.sem_ctime = linux_semid->sem_ctime;
395 linux_semid64.sem_nsems = linux_semid->sem_nsems;
397 return (copyout(&linux_semid64, uaddr, sizeof(linux_semid64)));
399 return (copyout(linux_semid, uaddr, sizeof(*linux_semid)));
404 linux_shmid_pullup(l_int ver, struct l_shmid_ds *linux_shmid, caddr_t uaddr)
406 struct l_shmid64_ds linux_shmid64;
409 if (ver == LINUX_IPC_64) {
410 error = copyin(uaddr, &linux_shmid64, sizeof(linux_shmid64));
414 bzero(linux_shmid, sizeof(*linux_shmid));
416 linux_shmid->shm_perm.uid = linux_shmid64.shm_perm.uid;
417 linux_shmid->shm_perm.gid = linux_shmid64.shm_perm.gid;
418 linux_shmid->shm_perm.mode = linux_shmid64.shm_perm.mode;
420 error = copyin(uaddr, linux_shmid, sizeof(*linux_shmid));
426 linux_shmid_pushdown(l_int ver, struct l_shmid_ds *linux_shmid, caddr_t uaddr)
428 struct l_shmid64_ds linux_shmid64;
431 * XXX: This is backwards and loses information in shm_nattch
432 * and shm_segsz. We should probably either expose the BSD
433 * shmid structure directly and convert it to either the
434 * non-64 or 64 variant directly or the code should always
435 * convert to the 64 variant and then truncate values into the
436 * non-64 variant if needed since the 64 variant has more
439 if (ver == LINUX_IPC_64) {
440 bzero(&linux_shmid64, sizeof(linux_shmid64));
442 linux_ipc_perm_to_ipc64_perm(&linux_shmid->shm_perm,
443 &linux_shmid64.shm_perm);
445 linux_shmid64.shm_segsz = linux_shmid->shm_segsz;
446 linux_shmid64.shm_atime = linux_shmid->shm_atime;
447 linux_shmid64.shm_dtime = linux_shmid->shm_dtime;
448 linux_shmid64.shm_ctime = linux_shmid->shm_ctime;
449 linux_shmid64.shm_cpid = linux_shmid->shm_cpid;
450 linux_shmid64.shm_lpid = linux_shmid->shm_lpid;
451 linux_shmid64.shm_nattch = linux_shmid->shm_nattch;
453 return (copyout(&linux_shmid64, uaddr, sizeof(linux_shmid64)));
455 return (copyout(linux_shmid, uaddr, sizeof(*linux_shmid)));
460 linux_shminfo_pushdown(l_int ver, struct l_shminfo *linux_shminfo,
463 struct l_shminfo64 linux_shminfo64;
465 if (ver == LINUX_IPC_64) {
466 bzero(&linux_shminfo64, sizeof(linux_shminfo64));
468 linux_shminfo64.shmmax = linux_shminfo->shmmax;
469 linux_shminfo64.shmmin = linux_shminfo->shmmin;
470 linux_shminfo64.shmmni = linux_shminfo->shmmni;
471 linux_shminfo64.shmseg = linux_shminfo->shmseg;
472 linux_shminfo64.shmall = linux_shminfo->shmall;
474 return (copyout(&linux_shminfo64, uaddr,
475 sizeof(linux_shminfo64)));
477 return (copyout(linux_shminfo, uaddr, sizeof(*linux_shminfo)));
482 linux_semop(struct thread *td, struct linux_semop_args *args)
484 struct semop_args /* {
490 bsd_args.semid = args->semid;
491 bsd_args.sops = PTRIN(args->tsops);
492 bsd_args.nsops = args->nsops;
493 return semop(td, &bsd_args);
497 linux_semget(struct thread *td, struct linux_semget_args *args)
499 struct semget_args /* {
507 bsd_args.key = args->key;
508 bsd_args.nsems = args->nsems;
509 bsd_args.semflg = args->semflg;
510 return semget(td, &bsd_args);
514 linux_semctl(struct thread *td, struct linux_semctl_args *args)
516 struct l_semid_ds linux_semid;
517 struct l_seminfo linux_seminfo;
518 struct semid_ds semid;
523 switch (args->cmd & ~LINUX_IPC_64) {
541 semun.val = args->arg.val;
545 error = linux_semid_pullup(args->cmd & LINUX_IPC_64,
546 &linux_semid, PTRIN(args->arg.buf));
549 linux_to_bsd_semid_ds(&linux_semid, &semid);
551 return (kern_semctl(td, args->semid, args->semnum, cmd, &semun,
555 if ((args->cmd & ~LINUX_IPC_64) == LINUX_IPC_STAT)
560 error = kern_semctl(td, args->semid, args->semnum, cmd, &semun,
564 bsd_to_linux_semid_ds(&semid, &linux_semid);
565 error = linux_semid_pushdown(args->cmd & LINUX_IPC_64,
566 &linux_semid, PTRIN(args->arg.buf));
568 td->td_retval[0] = (cmd == SEM_STAT) ? rval : 0;
572 bcopy(&seminfo, &linux_seminfo, sizeof(linux_seminfo) );
573 /* XXX BSD equivalent?
574 #define used_semids 10
576 linux_seminfo.semusz = used_semids;
577 linux_seminfo.semaem = used_sems;
579 error = copyout(&linux_seminfo,
580 PTRIN(args->arg.buf), sizeof(linux_seminfo));
583 td->td_retval[0] = seminfo.semmni;
584 return 0; /* No need for __semctl call */
587 semun.val = args->arg.val;
591 semun.val = args->arg.val;
594 linux_msg(td, "ipc type %d is not implemented",
595 args->cmd & ~LINUX_IPC_64);
598 return (kern_semctl(td, args->semid, args->semnum, cmd, &semun,
603 linux_msgsnd(struct thread *td, struct linux_msgsnd_args *args)
610 if ((l_long)args->msgsz < 0 || args->msgsz > (l_long)msginfo.msgmax)
612 msgp = PTRIN(args->msgp);
613 if ((error = copyin(msgp, &lmtype, sizeof(lmtype))) != 0)
615 mtype = (long)lmtype;
616 return (kern_msgsnd(td, args->msqid,
617 (const char *)msgp + sizeof(lmtype),
618 args->msgsz, args->msgflg, mtype));
622 linux_msgrcv(struct thread *td, struct linux_msgrcv_args *args)
629 if ((l_long)args->msgsz < 0 || args->msgsz > (l_long)msginfo.msgmax)
631 msgp = PTRIN(args->msgp);
632 if ((error = kern_msgrcv(td, args->msqid,
633 (char *)msgp + sizeof(lmtype), args->msgsz,
634 args->msgtyp, args->msgflg, &mtype)) != 0)
636 lmtype = (l_long)mtype;
637 return (copyout(&lmtype, msgp, sizeof(lmtype)));
641 linux_msgget(struct thread *td, struct linux_msgget_args *args)
643 struct msgget_args /* {
648 bsd_args.key = args->key;
649 bsd_args.msgflg = args->msgflg;
650 return msgget(td, &bsd_args);
654 linux_msgctl(struct thread *td, struct linux_msgctl_args *args)
657 struct l_msqid_ds linux_msqid;
658 struct msqid_ds bsd_msqid;
660 bsd_cmd = args->cmd & ~LINUX_IPC_64;
663 case LINUX_MSG_INFO: {
664 struct l_msginfo linux_msginfo;
667 * XXX MSG_INFO uses the same data structure but returns different
668 * dynamic counters in msgpool, msgmap, and msgtql fields.
670 linux_msginfo.msgpool = (long)msginfo.msgmni *
671 (long)msginfo.msgmnb / 1024L; /* XXX MSG_INFO. */
672 linux_msginfo.msgmap = msginfo.msgmnb; /* XXX MSG_INFO. */
673 linux_msginfo.msgmax = msginfo.msgmax;
674 linux_msginfo.msgmnb = msginfo.msgmnb;
675 linux_msginfo.msgmni = msginfo.msgmni;
676 linux_msginfo.msgssz = msginfo.msgssz;
677 linux_msginfo.msgtql = msginfo.msgtql; /* XXX MSG_INFO. */
678 linux_msginfo.msgseg = msginfo.msgseg;
679 error = copyout(&linux_msginfo, PTRIN(args->buf),
680 sizeof(linux_msginfo));
682 td->td_retval[0] = msginfo.msgmni; /* XXX */
688 * TODO: implement this
689 * case LINUX_MSG_STAT:
696 error = linux_msqid_pullup(args->cmd & LINUX_IPC_64,
697 &linux_msqid, PTRIN(args->buf));
700 linux_to_bsd_msqid_ds(&linux_msqid, &bsd_msqid);
712 error = kern_msgctl(td, args->msqid, bsd_cmd, &bsd_msqid);
714 if (bsd_cmd != LINUX_IPC_RMID || error != EINVAL)
717 if (bsd_cmd == LINUX_IPC_STAT) {
718 bsd_to_linux_msqid_ds(&bsd_msqid, &linux_msqid);
719 return (linux_msqid_pushdown(args->cmd & LINUX_IPC_64,
720 &linux_msqid, PTRIN(args->buf)));
727 linux_shmat(struct thread *td, struct linux_shmat_args *args)
729 struct shmat_args /* {
735 #if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
739 bsd_args.shmid = args->shmid;
740 bsd_args.shmaddr = PTRIN(args->shmaddr);
741 bsd_args.shmflg = args->shmflg;
742 if ((error = shmat(td, &bsd_args)))
744 #if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
745 addr = td->td_retval[0];
746 if ((error = copyout(&addr, PTRIN(args->raddr), sizeof(addr))))
748 td->td_retval[0] = 0;
754 linux_shmdt(struct thread *td, struct linux_shmdt_args *args)
756 struct shmdt_args /* {
760 bsd_args.shmaddr = PTRIN(args->shmaddr);
761 return shmdt(td, &bsd_args);
765 linux_shmget(struct thread *td, struct linux_shmget_args *args)
767 struct shmget_args /* {
773 bsd_args.key = args->key;
774 bsd_args.size = args->size;
775 bsd_args.shmflg = args->shmflg;
776 return shmget(td, &bsd_args);
780 linux_shmctl(struct thread *td, struct linux_shmctl_args *args)
782 struct l_shmid_ds linux_shmid;
783 struct l_shminfo linux_shminfo;
784 struct l_shm_info linux_shm_info;
785 struct shmid_ds bsd_shmid;
788 switch (args->cmd & ~LINUX_IPC_64) {
790 case LINUX_IPC_INFO: {
791 struct shminfo bsd_shminfo;
793 /* Perform shmctl wanting removed segments lookup */
794 error = kern_shmctl(td, args->shmid, IPC_INFO,
795 (void *)&bsd_shminfo, NULL);
799 bsd_to_linux_shminfo(&bsd_shminfo, &linux_shminfo);
801 return (linux_shminfo_pushdown(args->cmd & LINUX_IPC_64,
802 &linux_shminfo, PTRIN(args->buf)));
805 case LINUX_SHM_INFO: {
806 struct shm_info bsd_shm_info;
808 /* Perform shmctl wanting removed segments lookup */
809 error = kern_shmctl(td, args->shmid, SHM_INFO,
810 (void *)&bsd_shm_info, NULL);
814 bsd_to_linux_shm_info(&bsd_shm_info, &linux_shm_info);
816 return copyout(&linux_shm_info, PTRIN(args->buf),
817 sizeof(struct l_shm_info));
821 /* Perform shmctl wanting removed segments lookup */
822 error = kern_shmctl(td, args->shmid, IPC_STAT,
823 (void *)&bsd_shmid, NULL);
827 bsd_to_linux_shmid_ds(&bsd_shmid, &linux_shmid);
829 return (linux_shmid_pushdown(args->cmd & LINUX_IPC_64,
830 &linux_shmid, PTRIN(args->buf)));
833 /* Perform shmctl wanting removed segments lookup */
834 error = kern_shmctl(td, args->shmid, IPC_STAT,
835 (void *)&bsd_shmid, NULL);
839 bsd_to_linux_shmid_ds(&bsd_shmid, &linux_shmid);
841 return (linux_shmid_pushdown(args->cmd & LINUX_IPC_64,
842 &linux_shmid, PTRIN(args->buf)));
845 error = linux_shmid_pullup(args->cmd & LINUX_IPC_64,
846 &linux_shmid, PTRIN(args->buf));
850 linux_to_bsd_shmid_ds(&linux_shmid, &bsd_shmid);
852 /* Perform shmctl wanting removed segments lookup */
853 return kern_shmctl(td, args->shmid, IPC_SET,
854 (void *)&bsd_shmid, NULL);
856 case LINUX_IPC_RMID: {
862 error = linux_shmid_pullup(args->cmd & LINUX_IPC_64,
863 &linux_shmid, PTRIN(args->buf));
866 linux_to_bsd_shmid_ds(&linux_shmid, &bsd_shmid);
867 buf = (void *)&bsd_shmid;
869 return kern_shmctl(td, args->shmid, IPC_RMID, buf, NULL);
873 case LINUX_SHM_UNLOCK:
875 linux_msg(td, "ipc type %d not implemented", args->cmd & ~LINUX_IPC_64);
880 MODULE_DEPEND(linux, sysvmsg, 1, 1, 1);
881 MODULE_DEPEND(linux, sysvsem, 1, 1, 1);
882 MODULE_DEPEND(linux, sysvshm, 1, 1, 1);