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 ;
131 linux_to_bsd_ipc_perm(struct l_ipc_perm *lpp, struct ipc_perm *bpp)
137 bpp->cuid = lpp->cuid;
138 bpp->cgid = lpp->cgid;
139 bpp->mode = lpp->mode;
145 bsd_to_linux_ipc_perm(struct ipc_perm *bpp, struct l_ipc_perm *lpp)
151 lpp->cuid = bpp->cuid;
152 lpp->cgid = bpp->cgid;
153 lpp->mode = bpp->mode;
158 struct l_ipc_perm msg_perm;
159 l_uintptr_t msg_first; /* first message on queue,unused */
160 l_uintptr_t msg_last; /* last message in queue,unused */
161 l_time_t msg_stime; /* last msgsnd time */
162 l_time_t msg_rtime; /* last msgrcv time */
163 l_time_t msg_ctime; /* last change time */
164 l_ulong msg_lcbytes; /* Reuse junk fields for 32 bit */
165 l_ulong msg_lqbytes; /* ditto */
166 l_ushort msg_cbytes; /* current number of bytes on queue */
167 l_ushort msg_qnum; /* number of messages in queue */
168 l_ushort msg_qbytes; /* max number of bytes on queue */
169 l_pid_t msg_lspid; /* pid of last msgsnd */
170 l_pid_t msg_lrpid; /* last receive pid */
172 #if defined(__amd64__) && defined(COMPAT_LINUX32)
178 struct l_ipc_perm sem_perm;
181 l_uintptr_t sem_base;
182 l_uintptr_t sem_pending;
183 l_uintptr_t sem_pending_last;
187 #if defined(__amd64__) && defined(COMPAT_LINUX32)
193 struct l_ipc_perm shm_perm;
202 l_uintptr_t private2;
203 l_uintptr_t private3;
207 linux_to_bsd_semid_ds(struct l_semid_ds *lsp, struct semid_ds *bsp)
210 linux_to_bsd_ipc_perm(&lsp->sem_perm, &bsp->sem_perm);
211 bsp->sem_otime = lsp->sem_otime;
212 bsp->sem_ctime = lsp->sem_ctime;
213 bsp->sem_nsems = lsp->sem_nsems;
214 bsp->sem_base = PTRIN(lsp->sem_base);
218 bsd_to_linux_semid_ds(struct semid_ds *bsp, struct l_semid_ds *lsp)
221 bsd_to_linux_ipc_perm(&bsp->sem_perm, &lsp->sem_perm);
222 lsp->sem_otime = bsp->sem_otime;
223 lsp->sem_ctime = bsp->sem_ctime;
224 lsp->sem_nsems = bsp->sem_nsems;
225 lsp->sem_base = PTROUT(bsp->sem_base);
229 linux_to_bsd_shmid_ds(struct l_shmid_ds *lsp, struct shmid_ds *bsp)
232 linux_to_bsd_ipc_perm(&lsp->shm_perm, &bsp->shm_perm);
233 bsp->shm_segsz = lsp->shm_segsz;
234 bsp->shm_lpid = lsp->shm_lpid;
235 bsp->shm_cpid = lsp->shm_cpid;
236 bsp->shm_nattch = lsp->shm_nattch;
237 bsp->shm_atime = lsp->shm_atime;
238 bsp->shm_dtime = lsp->shm_dtime;
239 bsp->shm_ctime = lsp->shm_ctime;
243 bsd_to_linux_shmid_ds(struct shmid_ds *bsp, struct l_shmid_ds *lsp)
246 bsd_to_linux_ipc_perm(&bsp->shm_perm, &lsp->shm_perm);
247 if (bsp->shm_segsz > INT_MAX)
248 lsp->shm_segsz = INT_MAX;
250 lsp->shm_segsz = bsp->shm_segsz;
251 lsp->shm_lpid = bsp->shm_lpid;
252 lsp->shm_cpid = bsp->shm_cpid;
253 if (bsp->shm_nattch > SHRT_MAX)
254 lsp->shm_nattch = SHRT_MAX;
256 lsp->shm_nattch = bsp->shm_nattch;
257 lsp->shm_atime = bsp->shm_atime;
258 lsp->shm_dtime = bsp->shm_dtime;
259 lsp->shm_ctime = bsp->shm_ctime;
264 linux_to_bsd_msqid_ds(struct l_msqid_ds *lsp, struct msqid_ds *bsp)
267 linux_to_bsd_ipc_perm(&lsp->msg_perm, &bsp->msg_perm);
268 bsp->msg_cbytes = lsp->msg_cbytes;
269 bsp->msg_qnum = lsp->msg_qnum;
270 bsp->msg_qbytes = lsp->msg_qbytes;
271 bsp->msg_lspid = lsp->msg_lspid;
272 bsp->msg_lrpid = lsp->msg_lrpid;
273 bsp->msg_stime = lsp->msg_stime;
274 bsp->msg_rtime = lsp->msg_rtime;
275 bsp->msg_ctime = lsp->msg_ctime;
279 bsd_to_linux_msqid_ds(struct msqid_ds *bsp, struct l_msqid_ds *lsp)
282 bsd_to_linux_ipc_perm(&bsp->msg_perm, &lsp->msg_perm);
283 lsp->msg_cbytes = bsp->msg_cbytes;
284 lsp->msg_qnum = bsp->msg_qnum;
285 lsp->msg_qbytes = bsp->msg_qbytes;
286 lsp->msg_lspid = bsp->msg_lspid;
287 lsp->msg_lrpid = bsp->msg_lrpid;
288 lsp->msg_stime = bsp->msg_stime;
289 lsp->msg_rtime = bsp->msg_rtime;
290 lsp->msg_ctime = bsp->msg_ctime;
294 linux_ipc_perm_to_ipc64_perm(struct l_ipc_perm *in, struct l_ipc64_perm *out)
297 /* XXX: do we really need to do something here? */
301 out->cuid = in->cuid;
302 out->cgid = in->cgid;
303 out->mode = in->mode;
308 linux_msqid_pullup(l_int ver, struct l_msqid_ds *linux_msqid, caddr_t uaddr)
310 struct l_msqid64_ds linux_msqid64;
313 if (ver == LINUX_IPC_64) {
314 error = copyin(uaddr, &linux_msqid64, sizeof(linux_msqid64));
318 bzero(linux_msqid, sizeof(*linux_msqid));
320 linux_msqid->msg_perm.uid = linux_msqid64.msg_perm.uid;
321 linux_msqid->msg_perm.gid = linux_msqid64.msg_perm.gid;
322 linux_msqid->msg_perm.mode = linux_msqid64.msg_perm.mode;
324 if (linux_msqid64.msg_qbytes > USHRT_MAX)
325 linux_msqid->msg_lqbytes = linux_msqid64.msg_qbytes;
327 linux_msqid->msg_qbytes = linux_msqid64.msg_qbytes;
329 error = copyin(uaddr, linux_msqid, sizeof(*linux_msqid));
335 linux_msqid_pushdown(l_int ver, struct l_msqid_ds *linux_msqid, caddr_t uaddr)
337 struct l_msqid64_ds linux_msqid64;
339 if (ver == LINUX_IPC_64) {
340 bzero(&linux_msqid64, sizeof(linux_msqid64));
342 linux_ipc_perm_to_ipc64_perm(&linux_msqid->msg_perm,
343 &linux_msqid64.msg_perm);
345 linux_msqid64.msg_stime = linux_msqid->msg_stime;
346 linux_msqid64.msg_rtime = linux_msqid->msg_rtime;
347 linux_msqid64.msg_ctime = linux_msqid->msg_ctime;
349 if (linux_msqid->msg_cbytes == 0)
350 linux_msqid64.msg_cbytes = linux_msqid->msg_lcbytes;
352 linux_msqid64.msg_cbytes = linux_msqid->msg_cbytes;
354 linux_msqid64.msg_qnum = linux_msqid->msg_qnum;
356 if (linux_msqid->msg_qbytes == 0)
357 linux_msqid64.msg_qbytes = linux_msqid->msg_lqbytes;
359 linux_msqid64.msg_qbytes = linux_msqid->msg_qbytes;
361 linux_msqid64.msg_lspid = linux_msqid->msg_lspid;
362 linux_msqid64.msg_lrpid = linux_msqid->msg_lrpid;
364 return (copyout(&linux_msqid64, uaddr, sizeof(linux_msqid64)));
366 return (copyout(linux_msqid, uaddr, sizeof(*linux_msqid)));
370 linux_semid_pullup(l_int ver, struct l_semid_ds *linux_semid, caddr_t uaddr)
372 struct l_semid64_ds linux_semid64;
375 if (ver == LINUX_IPC_64) {
376 error = copyin(uaddr, &linux_semid64, sizeof(linux_semid64));
380 bzero(linux_semid, sizeof(*linux_semid));
382 linux_semid->sem_perm.uid = linux_semid64.sem_perm.uid;
383 linux_semid->sem_perm.gid = linux_semid64.sem_perm.gid;
384 linux_semid->sem_perm.mode = linux_semid64.sem_perm.mode;
386 error = copyin(uaddr, linux_semid, sizeof(*linux_semid));
392 linux_semid_pushdown(l_int ver, struct l_semid_ds *linux_semid, caddr_t uaddr)
394 struct l_semid64_ds linux_semid64;
396 if (ver == LINUX_IPC_64) {
397 bzero(&linux_semid64, sizeof(linux_semid64));
399 linux_ipc_perm_to_ipc64_perm(&linux_semid->sem_perm,
400 &linux_semid64.sem_perm);
402 linux_semid64.sem_otime = linux_semid->sem_otime;
403 linux_semid64.sem_ctime = linux_semid->sem_ctime;
404 linux_semid64.sem_nsems = linux_semid->sem_nsems;
406 return (copyout(&linux_semid64, uaddr, sizeof(linux_semid64)));
408 return (copyout(linux_semid, uaddr, sizeof(*linux_semid)));
412 linux_shmid_pullup(l_int ver, struct l_shmid_ds *linux_shmid, caddr_t uaddr)
414 struct l_shmid64_ds linux_shmid64;
417 if (ver == LINUX_IPC_64) {
418 error = copyin(uaddr, &linux_shmid64, sizeof(linux_shmid64));
422 bzero(linux_shmid, sizeof(*linux_shmid));
424 linux_shmid->shm_perm.uid = linux_shmid64.shm_perm.uid;
425 linux_shmid->shm_perm.gid = linux_shmid64.shm_perm.gid;
426 linux_shmid->shm_perm.mode = linux_shmid64.shm_perm.mode;
428 error = copyin(uaddr, linux_shmid, sizeof(*linux_shmid));
434 linux_shmid_pushdown(l_int ver, struct l_shmid_ds *linux_shmid, caddr_t uaddr)
436 struct l_shmid64_ds linux_shmid64;
439 * XXX: This is backwards and loses information in shm_nattch
440 * and shm_segsz. We should probably either expose the BSD
441 * shmid structure directly and convert it to either the
442 * non-64 or 64 variant directly or the code should always
443 * convert to the 64 variant and then truncate values into the
444 * non-64 variant if needed since the 64 variant has more
447 if (ver == LINUX_IPC_64) {
448 bzero(&linux_shmid64, sizeof(linux_shmid64));
450 linux_ipc_perm_to_ipc64_perm(&linux_shmid->shm_perm,
451 &linux_shmid64.shm_perm);
453 linux_shmid64.shm_segsz = linux_shmid->shm_segsz;
454 linux_shmid64.shm_atime = linux_shmid->shm_atime;
455 linux_shmid64.shm_dtime = linux_shmid->shm_dtime;
456 linux_shmid64.shm_ctime = linux_shmid->shm_ctime;
457 linux_shmid64.shm_cpid = linux_shmid->shm_cpid;
458 linux_shmid64.shm_lpid = linux_shmid->shm_lpid;
459 linux_shmid64.shm_nattch = linux_shmid->shm_nattch;
461 return (copyout(&linux_shmid64, uaddr, sizeof(linux_shmid64)));
463 return (copyout(linux_shmid, uaddr, sizeof(*linux_shmid)));
467 linux_shminfo_pushdown(l_int ver, struct l_shminfo *linux_shminfo,
470 struct l_shminfo64 linux_shminfo64;
472 if (ver == LINUX_IPC_64) {
473 bzero(&linux_shminfo64, sizeof(linux_shminfo64));
475 linux_shminfo64.shmmax = linux_shminfo->shmmax;
476 linux_shminfo64.shmmin = linux_shminfo->shmmin;
477 linux_shminfo64.shmmni = linux_shminfo->shmmni;
478 linux_shminfo64.shmseg = linux_shminfo->shmseg;
479 linux_shminfo64.shmall = linux_shminfo->shmall;
481 return (copyout(&linux_shminfo64, uaddr,
482 sizeof(linux_shminfo64)));
484 return (copyout(linux_shminfo, uaddr, sizeof(*linux_shminfo)));
488 linux_semop(struct thread *td, struct linux_semop_args *args)
490 struct semop_args /* {
496 bsd_args.semid = args->semid;
497 bsd_args.sops = PTRIN(args->tsops);
498 bsd_args.nsops = args->nsops;
499 return (sys_semop(td, &bsd_args));
503 linux_semget(struct thread *td, struct linux_semget_args *args)
505 struct semget_args /* {
513 bsd_args.key = args->key;
514 bsd_args.nsems = args->nsems;
515 bsd_args.semflg = args->semflg;
516 return (sys_semget(td, &bsd_args));
520 linux_semctl(struct thread *td, struct linux_semctl_args *args)
522 struct l_semid_ds linux_semid;
523 struct l_seminfo linux_seminfo;
524 struct semid_ds semid;
529 switch (args->cmd & ~LINUX_IPC_64) {
547 semun.val = args->arg.val;
551 error = linux_semid_pullup(args->cmd & LINUX_IPC_64,
552 &linux_semid, PTRIN(args->arg.buf));
555 linux_to_bsd_semid_ds(&linux_semid, &semid);
557 return (kern_semctl(td, args->semid, args->semnum, cmd, &semun,
561 if ((args->cmd & ~LINUX_IPC_64) == LINUX_IPC_STAT)
566 error = kern_semctl(td, args->semid, args->semnum, cmd, &semun,
570 bsd_to_linux_semid_ds(&semid, &linux_semid);
571 error = linux_semid_pushdown(args->cmd & LINUX_IPC_64,
572 &linux_semid, PTRIN(args->arg.buf));
574 td->td_retval[0] = (cmd == SEM_STAT) ? rval : 0;
578 bcopy(&seminfo, &linux_seminfo.semmni, sizeof(linux_seminfo) -
579 sizeof(linux_seminfo.semmap) );
581 * Linux does not use the semmap field but populates it with
582 * the defined value from SEMMAP, which really is redefined to
583 * SEMMNS, which they define as SEMMNI * SEMMSL. Try to
584 * simulate this returning our dynamic semmns value.
586 linux_seminfo.semmap = linux_seminfo.semmns;
587 /* XXX BSD equivalent?
588 #define used_semids 10
590 linux_seminfo.semusz = used_semids;
591 linux_seminfo.semaem = used_sems;
593 error = copyout(&linux_seminfo,
594 PTRIN(args->arg.buf), sizeof(linux_seminfo));
597 td->td_retval[0] = seminfo.semmni;
598 return (0); /* No need for __semctl call */
601 semun.val = args->arg.val;
605 semun.val = args->arg.val;
608 linux_msg(td, "ipc type %d is not implemented",
609 args->cmd & ~LINUX_IPC_64);
612 return (kern_semctl(td, args->semid, args->semnum, cmd, &semun,
617 linux_msgsnd(struct thread *td, struct linux_msgsnd_args *args)
624 if ((l_long)args->msgsz < 0 || args->msgsz > (l_long)msginfo.msgmax)
626 msgp = PTRIN(args->msgp);
627 if ((error = copyin(msgp, &lmtype, sizeof(lmtype))) != 0)
629 mtype = (long)lmtype;
630 return (kern_msgsnd(td, args->msqid,
631 (const char *)msgp + sizeof(lmtype),
632 args->msgsz, args->msgflg, mtype));
636 linux_msgrcv(struct thread *td, struct linux_msgrcv_args *args)
643 if ((l_long)args->msgsz < 0 || args->msgsz > (l_long)msginfo.msgmax)
645 msgp = PTRIN(args->msgp);
646 if ((error = kern_msgrcv(td, args->msqid,
647 (char *)msgp + sizeof(lmtype), args->msgsz,
648 args->msgtyp, args->msgflg, &mtype)) != 0)
650 lmtype = (l_long)mtype;
651 return (copyout(&lmtype, msgp, sizeof(lmtype)));
655 linux_msgget(struct thread *td, struct linux_msgget_args *args)
657 struct msgget_args /* {
662 bsd_args.key = args->key;
663 bsd_args.msgflg = args->msgflg;
664 return (sys_msgget(td, &bsd_args));
668 linux_msgctl(struct thread *td, struct linux_msgctl_args *args)
671 struct l_msqid_ds linux_msqid;
672 struct msqid_ds bsd_msqid;
674 bsd_cmd = args->cmd & ~LINUX_IPC_64;
677 case LINUX_MSG_INFO: {
678 struct l_msginfo linux_msginfo;
681 * XXX MSG_INFO uses the same data structure but returns different
682 * dynamic counters in msgpool, msgmap, and msgtql fields.
684 linux_msginfo.msgpool = (long)msginfo.msgmni *
685 (long)msginfo.msgmnb / 1024L; /* XXX MSG_INFO. */
686 linux_msginfo.msgmap = msginfo.msgmnb; /* XXX MSG_INFO. */
687 linux_msginfo.msgmax = msginfo.msgmax;
688 linux_msginfo.msgmnb = msginfo.msgmnb;
689 linux_msginfo.msgmni = msginfo.msgmni;
690 linux_msginfo.msgssz = msginfo.msgssz;
691 linux_msginfo.msgtql = msginfo.msgtql; /* XXX MSG_INFO. */
692 linux_msginfo.msgseg = msginfo.msgseg;
693 error = copyout(&linux_msginfo, PTRIN(args->buf),
694 sizeof(linux_msginfo));
696 td->td_retval[0] = msginfo.msgmni; /* XXX */
702 * TODO: implement this
703 * case LINUX_MSG_STAT:
710 error = linux_msqid_pullup(args->cmd & LINUX_IPC_64,
711 &linux_msqid, PTRIN(args->buf));
714 linux_to_bsd_msqid_ds(&linux_msqid, &bsd_msqid);
726 error = kern_msgctl(td, args->msqid, bsd_cmd, &bsd_msqid);
728 if (bsd_cmd != LINUX_IPC_RMID || error != EINVAL)
731 if (bsd_cmd == LINUX_IPC_STAT) {
732 bsd_to_linux_msqid_ds(&bsd_msqid, &linux_msqid);
733 return (linux_msqid_pushdown(args->cmd & LINUX_IPC_64,
734 &linux_msqid, PTRIN(args->buf)));
741 linux_shmat(struct thread *td, struct linux_shmat_args *args)
743 struct shmat_args /* {
749 #if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
753 bsd_args.shmid = args->shmid;
754 bsd_args.shmaddr = PTRIN(args->shmaddr);
755 bsd_args.shmflg = args->shmflg;
756 if ((error = sys_shmat(td, &bsd_args)))
758 #if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
759 addr = td->td_retval[0];
760 if ((error = copyout(&addr, PTRIN(args->raddr), sizeof(addr))))
762 td->td_retval[0] = 0;
768 linux_shmdt(struct thread *td, struct linux_shmdt_args *args)
770 struct shmdt_args /* {
774 bsd_args.shmaddr = PTRIN(args->shmaddr);
775 return (sys_shmdt(td, &bsd_args));
779 linux_shmget(struct thread *td, struct linux_shmget_args *args)
781 struct shmget_args /* {
787 bsd_args.key = args->key;
788 bsd_args.size = args->size;
789 bsd_args.shmflg = args->shmflg;
790 return (sys_shmget(td, &bsd_args));
794 linux_shmctl(struct thread *td, struct linux_shmctl_args *args)
796 struct l_shmid_ds linux_shmid;
797 struct l_shminfo linux_shminfo;
798 struct l_shm_info linux_shm_info;
799 struct shmid_ds bsd_shmid;
802 switch (args->cmd & ~LINUX_IPC_64) {
804 case LINUX_IPC_INFO: {
805 struct shminfo bsd_shminfo;
807 /* Perform shmctl wanting removed segments lookup */
808 error = kern_shmctl(td, args->shmid, IPC_INFO,
809 (void *)&bsd_shminfo, NULL);
813 bsd_to_linux_shminfo(&bsd_shminfo, &linux_shminfo);
815 return (linux_shminfo_pushdown(args->cmd & LINUX_IPC_64,
816 &linux_shminfo, PTRIN(args->buf)));
819 case LINUX_SHM_INFO: {
820 struct shm_info bsd_shm_info;
822 /* Perform shmctl wanting removed segments lookup */
823 error = kern_shmctl(td, args->shmid, SHM_INFO,
824 (void *)&bsd_shm_info, NULL);
828 bsd_to_linux_shm_info(&bsd_shm_info, &linux_shm_info);
830 return (copyout(&linux_shm_info, PTRIN(args->buf),
831 sizeof(struct l_shm_info)));
835 /* Perform shmctl wanting removed segments lookup */
836 error = kern_shmctl(td, args->shmid, IPC_STAT,
837 (void *)&bsd_shmid, NULL);
841 bsd_to_linux_shmid_ds(&bsd_shmid, &linux_shmid);
843 return (linux_shmid_pushdown(args->cmd & LINUX_IPC_64,
844 &linux_shmid, PTRIN(args->buf)));
847 /* Perform shmctl wanting removed segments lookup */
848 error = kern_shmctl(td, args->shmid, IPC_STAT,
849 (void *)&bsd_shmid, NULL);
853 bsd_to_linux_shmid_ds(&bsd_shmid, &linux_shmid);
855 return (linux_shmid_pushdown(args->cmd & LINUX_IPC_64,
856 &linux_shmid, PTRIN(args->buf)));
859 error = linux_shmid_pullup(args->cmd & LINUX_IPC_64,
860 &linux_shmid, PTRIN(args->buf));
864 linux_to_bsd_shmid_ds(&linux_shmid, &bsd_shmid);
866 /* Perform shmctl wanting removed segments lookup */
867 return (kern_shmctl(td, args->shmid, IPC_SET,
868 (void *)&bsd_shmid, NULL));
870 case LINUX_IPC_RMID: {
876 error = linux_shmid_pullup(args->cmd & LINUX_IPC_64,
877 &linux_shmid, PTRIN(args->buf));
880 linux_to_bsd_shmid_ds(&linux_shmid, &bsd_shmid);
881 buf = (void *)&bsd_shmid;
883 return (kern_shmctl(td, args->shmid, IPC_RMID, buf, NULL));
888 case LINUX_SHM_UNLOCK:
891 linux_msg(td, "ipc type %d not implemented",
892 args->cmd & ~LINUX_IPC_64);
897 MODULE_DEPEND(linux, sysvmsg, 1, 1, 1);
898 MODULE_DEPEND(linux, sysvsem, 1, 1, 1);
899 MODULE_DEPEND(linux, sysvshm, 1, 1, 1);