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)
101 lpp->shmmax = bpp->shmmax;
102 lpp->shmmin = bpp->shmmin;
103 lpp->shmmni = bpp->shmmni;
104 lpp->shmseg = bpp->shmseg;
105 lpp->shmall = bpp->shmall;
109 bsd_to_linux_shm_info( struct shm_info *bpp, struct l_shm_info *lpp)
112 lpp->used_ids = bpp->used_ids ;
113 lpp->shm_tot = bpp->shm_tot ;
114 lpp->shm_rss = bpp->shm_rss ;
115 lpp->shm_swp = bpp->shm_swp ;
116 lpp->swap_attempts = bpp->swap_attempts ;
117 lpp->swap_successes = bpp->swap_successes ;
121 linux_to_bsd_ipc_perm(struct l_ipc_perm *lpp, struct ipc_perm *bpp)
127 bpp->cuid = lpp->cuid;
128 bpp->cgid = lpp->cgid;
129 bpp->mode = lpp->mode;
134 bsd_to_linux_ipc_perm(struct ipc_perm *bpp, struct l_ipc_perm *lpp)
140 lpp->cuid = bpp->cuid;
141 lpp->cgid = bpp->cgid;
142 lpp->mode = bpp->mode;
147 struct l_ipc_perm msg_perm;
148 l_uintptr_t msg_first; /* first message on queue,unused */
149 l_uintptr_t msg_last; /* last message in queue,unused */
150 l_time_t msg_stime; /* last msgsnd time */
151 l_time_t msg_rtime; /* last msgrcv time */
152 l_time_t msg_ctime; /* last change time */
153 l_ulong msg_lcbytes; /* Reuse junk fields for 32 bit */
154 l_ulong msg_lqbytes; /* ditto */
155 l_ushort msg_cbytes; /* current number of bytes on queue */
156 l_ushort msg_qnum; /* number of messages in queue */
157 l_ushort msg_qbytes; /* max number of bytes on queue */
158 l_pid_t msg_lspid; /* pid of last msgsnd */
159 l_pid_t msg_lrpid; /* last receive pid */
163 struct l_ipc_perm sem_perm;
166 l_uintptr_t sem_base;
167 l_uintptr_t sem_pending;
168 l_uintptr_t sem_pending_last;
174 struct l_ipc_perm shm_perm;
183 l_uintptr_t private2;
184 l_uintptr_t private3;
188 linux_to_bsd_semid_ds(struct l_semid_ds *lsp, struct semid_ds *bsp)
191 linux_to_bsd_ipc_perm(&lsp->sem_perm, &bsp->sem_perm);
192 bsp->sem_otime = lsp->sem_otime;
193 bsp->sem_ctime = lsp->sem_ctime;
194 bsp->sem_nsems = lsp->sem_nsems;
195 bsp->sem_base = PTRIN(lsp->sem_base);
199 bsd_to_linux_semid_ds(struct semid_ds *bsp, struct l_semid_ds *lsp)
202 bsd_to_linux_ipc_perm(&bsp->sem_perm, &lsp->sem_perm);
203 lsp->sem_otime = bsp->sem_otime;
204 lsp->sem_ctime = bsp->sem_ctime;
205 lsp->sem_nsems = bsp->sem_nsems;
206 lsp->sem_base = PTROUT(bsp->sem_base);
210 linux_to_bsd_shmid_ds(struct l_shmid_ds *lsp, struct shmid_ds *bsp)
213 linux_to_bsd_ipc_perm(&lsp->shm_perm, &bsp->shm_perm);
214 bsp->shm_segsz = lsp->shm_segsz;
215 bsp->shm_lpid = lsp->shm_lpid;
216 bsp->shm_cpid = lsp->shm_cpid;
217 bsp->shm_nattch = lsp->shm_nattch;
218 bsp->shm_atime = lsp->shm_atime;
219 bsp->shm_dtime = lsp->shm_dtime;
220 bsp->shm_ctime = lsp->shm_ctime;
224 bsd_to_linux_shmid_ds(struct shmid_ds *bsp, struct l_shmid_ds *lsp)
227 bsd_to_linux_ipc_perm(&bsp->shm_perm, &lsp->shm_perm);
228 if (bsp->shm_segsz > INT_MAX)
229 lsp->shm_segsz = INT_MAX;
231 lsp->shm_segsz = bsp->shm_segsz;
232 lsp->shm_lpid = bsp->shm_lpid;
233 lsp->shm_cpid = bsp->shm_cpid;
234 if (bsp->shm_nattch > SHRT_MAX)
235 lsp->shm_nattch = SHRT_MAX;
237 lsp->shm_nattch = bsp->shm_nattch;
238 lsp->shm_atime = bsp->shm_atime;
239 lsp->shm_dtime = bsp->shm_dtime;
240 lsp->shm_ctime = bsp->shm_ctime;
245 linux_to_bsd_msqid_ds(struct l_msqid_ds *lsp, struct msqid_ds *bsp)
248 linux_to_bsd_ipc_perm(&lsp->msg_perm, &bsp->msg_perm);
249 bsp->msg_cbytes = lsp->msg_cbytes;
250 bsp->msg_qnum = lsp->msg_qnum;
251 bsp->msg_qbytes = lsp->msg_qbytes;
252 bsp->msg_lspid = lsp->msg_lspid;
253 bsp->msg_lrpid = lsp->msg_lrpid;
254 bsp->msg_stime = lsp->msg_stime;
255 bsp->msg_rtime = lsp->msg_rtime;
256 bsp->msg_ctime = lsp->msg_ctime;
260 bsd_to_linux_msqid_ds(struct msqid_ds *bsp, struct l_msqid_ds *lsp)
263 bsd_to_linux_ipc_perm(&bsp->msg_perm, &lsp->msg_perm);
264 lsp->msg_cbytes = bsp->msg_cbytes;
265 lsp->msg_qnum = bsp->msg_qnum;
266 lsp->msg_qbytes = bsp->msg_qbytes;
267 lsp->msg_lspid = bsp->msg_lspid;
268 lsp->msg_lrpid = bsp->msg_lrpid;
269 lsp->msg_stime = bsp->msg_stime;
270 lsp->msg_rtime = bsp->msg_rtime;
271 lsp->msg_ctime = bsp->msg_ctime;
275 linux_ipc_perm_to_ipc64_perm(struct l_ipc_perm *in, struct l_ipc64_perm *out)
278 /* XXX: do we really need to do something here? */
282 out->cuid = in->cuid;
283 out->cgid = in->cgid;
284 out->mode = in->mode;
289 linux_msqid_pullup(l_int ver, struct l_msqid_ds *linux_msqid, caddr_t uaddr)
291 struct l_msqid64_ds linux_msqid64;
294 if (ver == LINUX_IPC_64) {
295 error = copyin(uaddr, &linux_msqid64, sizeof(linux_msqid64));
299 bzero(linux_msqid, sizeof(*linux_msqid));
301 linux_msqid->msg_perm.uid = linux_msqid64.msg_perm.uid;
302 linux_msqid->msg_perm.gid = linux_msqid64.msg_perm.gid;
303 linux_msqid->msg_perm.mode = linux_msqid64.msg_perm.mode;
305 if (linux_msqid64.msg_qbytes > USHRT_MAX)
306 linux_msqid->msg_lqbytes = linux_msqid64.msg_qbytes;
308 linux_msqid->msg_qbytes = linux_msqid64.msg_qbytes;
310 error = copyin(uaddr, linux_msqid, sizeof(*linux_msqid));
316 linux_msqid_pushdown(l_int ver, struct l_msqid_ds *linux_msqid, caddr_t uaddr)
318 struct l_msqid64_ds linux_msqid64;
320 if (ver == LINUX_IPC_64) {
321 bzero(&linux_msqid64, sizeof(linux_msqid64));
323 linux_ipc_perm_to_ipc64_perm(&linux_msqid->msg_perm,
324 &linux_msqid64.msg_perm);
326 linux_msqid64.msg_stime = linux_msqid->msg_stime;
327 linux_msqid64.msg_rtime = linux_msqid->msg_rtime;
328 linux_msqid64.msg_ctime = linux_msqid->msg_ctime;
330 if (linux_msqid->msg_cbytes == 0)
331 linux_msqid64.msg_cbytes = linux_msqid->msg_lcbytes;
333 linux_msqid64.msg_cbytes = linux_msqid->msg_cbytes;
335 linux_msqid64.msg_qnum = linux_msqid->msg_qnum;
337 if (linux_msqid->msg_qbytes == 0)
338 linux_msqid64.msg_qbytes = linux_msqid->msg_lqbytes;
340 linux_msqid64.msg_qbytes = linux_msqid->msg_qbytes;
342 linux_msqid64.msg_lspid = linux_msqid->msg_lspid;
343 linux_msqid64.msg_lrpid = linux_msqid->msg_lrpid;
345 return (copyout(&linux_msqid64, uaddr, sizeof(linux_msqid64)));
347 return (copyout(linux_msqid, uaddr, sizeof(*linux_msqid)));
351 linux_semid_pullup(l_int ver, struct l_semid_ds *linux_semid, caddr_t uaddr)
353 struct l_semid64_ds linux_semid64;
356 if (ver == LINUX_IPC_64) {
357 error = copyin(uaddr, &linux_semid64, sizeof(linux_semid64));
361 bzero(linux_semid, sizeof(*linux_semid));
363 linux_semid->sem_perm.uid = linux_semid64.sem_perm.uid;
364 linux_semid->sem_perm.gid = linux_semid64.sem_perm.gid;
365 linux_semid->sem_perm.mode = linux_semid64.sem_perm.mode;
367 error = copyin(uaddr, linux_semid, sizeof(*linux_semid));
373 linux_semid_pushdown(l_int ver, struct l_semid_ds *linux_semid, caddr_t uaddr)
375 struct l_semid64_ds linux_semid64;
377 if (ver == LINUX_IPC_64) {
378 bzero(&linux_semid64, sizeof(linux_semid64));
380 linux_ipc_perm_to_ipc64_perm(&linux_semid->sem_perm,
381 &linux_semid64.sem_perm);
383 linux_semid64.sem_otime = linux_semid->sem_otime;
384 linux_semid64.sem_ctime = linux_semid->sem_ctime;
385 linux_semid64.sem_nsems = linux_semid->sem_nsems;
387 return (copyout(&linux_semid64, uaddr, sizeof(linux_semid64)));
389 return (copyout(linux_semid, uaddr, sizeof(*linux_semid)));
393 linux_shmid_pullup(l_int ver, struct l_shmid_ds *linux_shmid, caddr_t uaddr)
395 struct l_shmid64_ds linux_shmid64;
398 if (ver == LINUX_IPC_64) {
399 error = copyin(uaddr, &linux_shmid64, sizeof(linux_shmid64));
403 bzero(linux_shmid, sizeof(*linux_shmid));
405 linux_shmid->shm_perm.uid = linux_shmid64.shm_perm.uid;
406 linux_shmid->shm_perm.gid = linux_shmid64.shm_perm.gid;
407 linux_shmid->shm_perm.mode = linux_shmid64.shm_perm.mode;
409 error = copyin(uaddr, linux_shmid, sizeof(*linux_shmid));
415 linux_shmid_pushdown(l_int ver, struct l_shmid_ds *linux_shmid, caddr_t uaddr)
417 struct l_shmid64_ds linux_shmid64;
420 * XXX: This is backwards and loses information in shm_nattch
421 * and shm_segsz. We should probably either expose the BSD
422 * shmid structure directly and convert it to either the
423 * non-64 or 64 variant directly or the code should always
424 * convert to the 64 variant and then truncate values into the
425 * non-64 variant if needed since the 64 variant has more
428 if (ver == LINUX_IPC_64) {
429 bzero(&linux_shmid64, sizeof(linux_shmid64));
431 linux_ipc_perm_to_ipc64_perm(&linux_shmid->shm_perm,
432 &linux_shmid64.shm_perm);
434 linux_shmid64.shm_segsz = linux_shmid->shm_segsz;
435 linux_shmid64.shm_atime = linux_shmid->shm_atime;
436 linux_shmid64.shm_dtime = linux_shmid->shm_dtime;
437 linux_shmid64.shm_ctime = linux_shmid->shm_ctime;
438 linux_shmid64.shm_cpid = linux_shmid->shm_cpid;
439 linux_shmid64.shm_lpid = linux_shmid->shm_lpid;
440 linux_shmid64.shm_nattch = linux_shmid->shm_nattch;
442 return (copyout(&linux_shmid64, uaddr, sizeof(linux_shmid64)));
444 return (copyout(linux_shmid, uaddr, sizeof(*linux_shmid)));
448 linux_shminfo_pushdown(l_int ver, struct l_shminfo *linux_shminfo,
451 struct l_shminfo64 linux_shminfo64;
453 if (ver == LINUX_IPC_64) {
454 bzero(&linux_shminfo64, sizeof(linux_shminfo64));
456 linux_shminfo64.shmmax = linux_shminfo->shmmax;
457 linux_shminfo64.shmmin = linux_shminfo->shmmin;
458 linux_shminfo64.shmmni = linux_shminfo->shmmni;
459 linux_shminfo64.shmseg = linux_shminfo->shmseg;
460 linux_shminfo64.shmall = linux_shminfo->shmall;
462 return (copyout(&linux_shminfo64, uaddr,
463 sizeof(linux_shminfo64)));
465 return (copyout(linux_shminfo, uaddr, sizeof(*linux_shminfo)));
469 linux_semop(struct thread *td, struct linux_semop_args *args)
471 struct semop_args /* {
477 bsd_args.semid = args->semid;
478 bsd_args.sops = PTRIN(args->tsops);
479 bsd_args.nsops = args->nsops;
480 return (sys_semop(td, &bsd_args));
484 linux_semget(struct thread *td, struct linux_semget_args *args)
486 struct semget_args /* {
494 bsd_args.key = args->key;
495 bsd_args.nsems = args->nsems;
496 bsd_args.semflg = args->semflg;
497 return (sys_semget(td, &bsd_args));
501 linux_semctl(struct thread *td, struct linux_semctl_args *args)
503 struct l_semid_ds linux_semid;
504 struct l_seminfo linux_seminfo;
505 struct semid_ds semid;
510 switch (args->cmd & ~LINUX_IPC_64) {
528 semun.val = args->arg.val;
532 error = linux_semid_pullup(args->cmd & LINUX_IPC_64,
533 &linux_semid, PTRIN(args->arg.buf));
536 linux_to_bsd_semid_ds(&linux_semid, &semid);
538 return (kern_semctl(td, args->semid, args->semnum, cmd, &semun,
542 if ((args->cmd & ~LINUX_IPC_64) == LINUX_IPC_STAT)
547 error = kern_semctl(td, args->semid, args->semnum, cmd, &semun,
551 bsd_to_linux_semid_ds(&semid, &linux_semid);
552 error = linux_semid_pushdown(args->cmd & LINUX_IPC_64,
553 &linux_semid, PTRIN(args->arg.buf));
555 td->td_retval[0] = (cmd == SEM_STAT) ? rval : 0;
559 bcopy(&seminfo, &linux_seminfo.semmni, sizeof(linux_seminfo) -
560 sizeof(linux_seminfo.semmap) );
562 * Linux does not use the semmap field but populates it with
563 * the defined value from SEMMAP, which really is redefined to
564 * SEMMNS, which they define as SEMMNI * SEMMSL. Try to
565 * simulate this returning our dynamic semmns value.
567 linux_seminfo.semmap = linux_seminfo.semmns;
568 /* XXX BSD equivalent?
569 #define used_semids 10
571 linux_seminfo.semusz = used_semids;
572 linux_seminfo.semaem = used_sems;
574 error = copyout(&linux_seminfo,
575 PTRIN(args->arg.buf), sizeof(linux_seminfo));
578 td->td_retval[0] = seminfo.semmni;
579 return (0); /* No need for __semctl call */
582 semun.val = args->arg.val;
586 semun.val = args->arg.val;
589 linux_msg(td, "ipc type %d is not implemented",
590 args->cmd & ~LINUX_IPC_64);
593 return (kern_semctl(td, args->semid, args->semnum, cmd, &semun,
598 linux_msgsnd(struct thread *td, struct linux_msgsnd_args *args)
605 if ((l_long)args->msgsz < 0 || args->msgsz > (l_long)msginfo.msgmax)
607 msgp = PTRIN(args->msgp);
608 if ((error = copyin(msgp, &lmtype, sizeof(lmtype))) != 0)
610 mtype = (long)lmtype;
611 return (kern_msgsnd(td, args->msqid,
612 (const char *)msgp + sizeof(lmtype),
613 args->msgsz, args->msgflg, mtype));
617 linux_msgrcv(struct thread *td, struct linux_msgrcv_args *args)
624 if ((l_long)args->msgsz < 0 || args->msgsz > (l_long)msginfo.msgmax)
626 msgp = PTRIN(args->msgp);
627 if ((error = kern_msgrcv(td, args->msqid,
628 (char *)msgp + sizeof(lmtype), args->msgsz,
629 args->msgtyp, args->msgflg, &mtype)) != 0)
631 lmtype = (l_long)mtype;
632 return (copyout(&lmtype, msgp, sizeof(lmtype)));
636 linux_msgget(struct thread *td, struct linux_msgget_args *args)
638 struct msgget_args /* {
643 bsd_args.key = args->key;
644 bsd_args.msgflg = args->msgflg;
645 return (sys_msgget(td, &bsd_args));
649 linux_msgctl(struct thread *td, struct linux_msgctl_args *args)
652 struct l_msqid_ds linux_msqid;
653 struct msqid_ds bsd_msqid;
655 bsd_cmd = args->cmd & ~LINUX_IPC_64;
658 case LINUX_MSG_INFO: {
659 struct l_msginfo linux_msginfo;
662 * XXX MSG_INFO uses the same data structure but returns different
663 * dynamic counters in msgpool, msgmap, and msgtql fields.
665 linux_msginfo.msgpool = (long)msginfo.msgmni *
666 (long)msginfo.msgmnb / 1024L; /* XXX MSG_INFO. */
667 linux_msginfo.msgmap = msginfo.msgmnb; /* XXX MSG_INFO. */
668 linux_msginfo.msgmax = msginfo.msgmax;
669 linux_msginfo.msgmnb = msginfo.msgmnb;
670 linux_msginfo.msgmni = msginfo.msgmni;
671 linux_msginfo.msgssz = msginfo.msgssz;
672 linux_msginfo.msgtql = msginfo.msgtql; /* XXX MSG_INFO. */
673 linux_msginfo.msgseg = msginfo.msgseg;
674 error = copyout(&linux_msginfo, PTRIN(args->buf),
675 sizeof(linux_msginfo));
677 td->td_retval[0] = msginfo.msgmni; /* XXX */
683 * TODO: implement this
684 * case LINUX_MSG_STAT:
691 error = linux_msqid_pullup(args->cmd & LINUX_IPC_64,
692 &linux_msqid, PTRIN(args->buf));
695 linux_to_bsd_msqid_ds(&linux_msqid, &bsd_msqid);
707 error = kern_msgctl(td, args->msqid, bsd_cmd, &bsd_msqid);
709 if (bsd_cmd != LINUX_IPC_RMID || error != EINVAL)
712 if (bsd_cmd == LINUX_IPC_STAT) {
713 bsd_to_linux_msqid_ds(&bsd_msqid, &linux_msqid);
714 return (linux_msqid_pushdown(args->cmd & LINUX_IPC_64,
715 &linux_msqid, PTRIN(args->buf)));
722 linux_shmat(struct thread *td, struct linux_shmat_args *args)
724 struct shmat_args /* {
730 #if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
734 bsd_args.shmid = args->shmid;
735 bsd_args.shmaddr = PTRIN(args->shmaddr);
736 bsd_args.shmflg = args->shmflg;
737 if ((error = sys_shmat(td, &bsd_args)))
739 #if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
740 addr = td->td_retval[0];
741 if ((error = copyout(&addr, PTRIN(args->raddr), sizeof(addr))))
743 td->td_retval[0] = 0;
749 linux_shmdt(struct thread *td, struct linux_shmdt_args *args)
751 struct shmdt_args /* {
755 bsd_args.shmaddr = PTRIN(args->shmaddr);
756 return (sys_shmdt(td, &bsd_args));
760 linux_shmget(struct thread *td, struct linux_shmget_args *args)
762 struct shmget_args /* {
768 bsd_args.key = args->key;
769 bsd_args.size = args->size;
770 bsd_args.shmflg = args->shmflg;
771 return (sys_shmget(td, &bsd_args));
775 linux_shmctl(struct thread *td, struct linux_shmctl_args *args)
777 struct l_shmid_ds linux_shmid;
778 struct l_shminfo linux_shminfo;
779 struct l_shm_info linux_shm_info;
780 struct shmid_ds bsd_shmid;
783 switch (args->cmd & ~LINUX_IPC_64) {
785 case LINUX_IPC_INFO: {
786 struct shminfo bsd_shminfo;
788 /* Perform shmctl wanting removed segments lookup */
789 error = kern_shmctl(td, args->shmid, IPC_INFO,
790 (void *)&bsd_shminfo, NULL);
794 bsd_to_linux_shminfo(&bsd_shminfo, &linux_shminfo);
796 return (linux_shminfo_pushdown(args->cmd & LINUX_IPC_64,
797 &linux_shminfo, PTRIN(args->buf)));
800 case LINUX_SHM_INFO: {
801 struct shm_info bsd_shm_info;
803 /* Perform shmctl wanting removed segments lookup */
804 error = kern_shmctl(td, args->shmid, SHM_INFO,
805 (void *)&bsd_shm_info, NULL);
809 bsd_to_linux_shm_info(&bsd_shm_info, &linux_shm_info);
811 return (copyout(&linux_shm_info, PTRIN(args->buf),
812 sizeof(struct l_shm_info)));
816 /* Perform shmctl wanting removed segments lookup */
817 error = kern_shmctl(td, args->shmid, IPC_STAT,
818 (void *)&bsd_shmid, NULL);
822 bsd_to_linux_shmid_ds(&bsd_shmid, &linux_shmid);
824 return (linux_shmid_pushdown(args->cmd & LINUX_IPC_64,
825 &linux_shmid, PTRIN(args->buf)));
828 /* Perform shmctl wanting removed segments lookup */
829 error = kern_shmctl(td, args->shmid, IPC_STAT,
830 (void *)&bsd_shmid, NULL);
834 bsd_to_linux_shmid_ds(&bsd_shmid, &linux_shmid);
836 return (linux_shmid_pushdown(args->cmd & LINUX_IPC_64,
837 &linux_shmid, PTRIN(args->buf)));
840 error = linux_shmid_pullup(args->cmd & LINUX_IPC_64,
841 &linux_shmid, PTRIN(args->buf));
845 linux_to_bsd_shmid_ds(&linux_shmid, &bsd_shmid);
847 /* Perform shmctl wanting removed segments lookup */
848 return (kern_shmctl(td, args->shmid, IPC_SET,
849 (void *)&bsd_shmid, NULL));
851 case LINUX_IPC_RMID: {
857 error = linux_shmid_pullup(args->cmd & LINUX_IPC_64,
858 &linux_shmid, PTRIN(args->buf));
861 linux_to_bsd_shmid_ds(&linux_shmid, &bsd_shmid);
862 buf = (void *)&bsd_shmid;
864 return (kern_shmctl(td, args->shmid, IPC_RMID, buf, NULL));
869 case LINUX_SHM_UNLOCK:
872 linux_msg(td, "ipc type %d not implemented",
873 args->cmd & ~LINUX_IPC_64);
878 MODULE_DEPEND(linux, sysvmsg, 1, 1, 1);
879 MODULE_DEPEND(linux, sysvsem, 1, 1, 1);
880 MODULE_DEPEND(linux, sysvshm, 1, 1, 1);