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;
135 bsd_to_linux_ipc_perm(struct ipc_perm *bpp, struct l_ipc_perm *lpp)
141 lpp->cuid = bpp->cuid;
142 lpp->cgid = bpp->cgid;
143 lpp->mode = bpp->mode;
148 struct l_ipc_perm msg_perm;
149 l_uintptr_t msg_first; /* first message on queue,unused */
150 l_uintptr_t msg_last; /* last message in queue,unused */
151 l_time_t msg_stime; /* last msgsnd time */
152 l_time_t msg_rtime; /* last msgrcv time */
153 l_time_t msg_ctime; /* last change time */
154 l_ulong msg_lcbytes; /* Reuse junk fields for 32 bit */
155 l_ulong msg_lqbytes; /* ditto */
156 l_ushort msg_cbytes; /* current number of bytes on queue */
157 l_ushort msg_qnum; /* number of messages in queue */
158 l_ushort msg_qbytes; /* max number of bytes on queue */
159 l_pid_t msg_lspid; /* pid of last msgsnd */
160 l_pid_t msg_lrpid; /* last receive pid */
162 #if defined(__amd64__) && defined(COMPAT_LINUX32)
168 struct l_ipc_perm sem_perm;
171 l_uintptr_t sem_base;
172 l_uintptr_t sem_pending;
173 l_uintptr_t sem_pending_last;
177 #if defined(__amd64__) && defined(COMPAT_LINUX32)
183 struct l_ipc_perm shm_perm;
192 l_uintptr_t private2;
193 l_uintptr_t private3;
197 linux_to_bsd_semid_ds(struct l_semid_ds *lsp, struct semid_ds *bsp)
200 linux_to_bsd_ipc_perm(&lsp->sem_perm, &bsp->sem_perm);
201 bsp->sem_otime = lsp->sem_otime;
202 bsp->sem_ctime = lsp->sem_ctime;
203 bsp->sem_nsems = lsp->sem_nsems;
204 bsp->sem_base = PTRIN(lsp->sem_base);
208 bsd_to_linux_semid_ds(struct semid_ds *bsp, struct l_semid_ds *lsp)
211 bsd_to_linux_ipc_perm(&bsp->sem_perm, &lsp->sem_perm);
212 lsp->sem_otime = bsp->sem_otime;
213 lsp->sem_ctime = bsp->sem_ctime;
214 lsp->sem_nsems = bsp->sem_nsems;
215 lsp->sem_base = PTROUT(bsp->sem_base);
219 linux_to_bsd_shmid_ds(struct l_shmid_ds *lsp, struct shmid_ds *bsp)
222 linux_to_bsd_ipc_perm(&lsp->shm_perm, &bsp->shm_perm);
223 bsp->shm_segsz = lsp->shm_segsz;
224 bsp->shm_lpid = lsp->shm_lpid;
225 bsp->shm_cpid = lsp->shm_cpid;
226 bsp->shm_nattch = lsp->shm_nattch;
227 bsp->shm_atime = lsp->shm_atime;
228 bsp->shm_dtime = lsp->shm_dtime;
229 bsp->shm_ctime = lsp->shm_ctime;
233 bsd_to_linux_shmid_ds(struct shmid_ds *bsp, struct l_shmid_ds *lsp)
236 bsd_to_linux_ipc_perm(&bsp->shm_perm, &lsp->shm_perm);
237 if (bsp->shm_segsz > INT_MAX)
238 lsp->shm_segsz = INT_MAX;
240 lsp->shm_segsz = bsp->shm_segsz;
241 lsp->shm_lpid = bsp->shm_lpid;
242 lsp->shm_cpid = bsp->shm_cpid;
243 if (bsp->shm_nattch > SHRT_MAX)
244 lsp->shm_nattch = SHRT_MAX;
246 lsp->shm_nattch = bsp->shm_nattch;
247 lsp->shm_atime = bsp->shm_atime;
248 lsp->shm_dtime = bsp->shm_dtime;
249 lsp->shm_ctime = bsp->shm_ctime;
254 linux_to_bsd_msqid_ds(struct l_msqid_ds *lsp, struct msqid_ds *bsp)
257 linux_to_bsd_ipc_perm(&lsp->msg_perm, &bsp->msg_perm);
258 bsp->msg_cbytes = lsp->msg_cbytes;
259 bsp->msg_qnum = lsp->msg_qnum;
260 bsp->msg_qbytes = lsp->msg_qbytes;
261 bsp->msg_lspid = lsp->msg_lspid;
262 bsp->msg_lrpid = lsp->msg_lrpid;
263 bsp->msg_stime = lsp->msg_stime;
264 bsp->msg_rtime = lsp->msg_rtime;
265 bsp->msg_ctime = lsp->msg_ctime;
269 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)));
360 linux_semid_pullup(l_int ver, struct l_semid_ds *linux_semid, caddr_t uaddr)
362 struct l_semid64_ds linux_semid64;
365 if (ver == LINUX_IPC_64) {
366 error = copyin(uaddr, &linux_semid64, sizeof(linux_semid64));
370 bzero(linux_semid, sizeof(*linux_semid));
372 linux_semid->sem_perm.uid = linux_semid64.sem_perm.uid;
373 linux_semid->sem_perm.gid = linux_semid64.sem_perm.gid;
374 linux_semid->sem_perm.mode = linux_semid64.sem_perm.mode;
376 error = copyin(uaddr, linux_semid, sizeof(*linux_semid));
382 linux_semid_pushdown(l_int ver, struct l_semid_ds *linux_semid, caddr_t uaddr)
384 struct l_semid64_ds linux_semid64;
386 if (ver == LINUX_IPC_64) {
387 bzero(&linux_semid64, sizeof(linux_semid64));
389 linux_ipc_perm_to_ipc64_perm(&linux_semid->sem_perm,
390 &linux_semid64.sem_perm);
392 linux_semid64.sem_otime = linux_semid->sem_otime;
393 linux_semid64.sem_ctime = linux_semid->sem_ctime;
394 linux_semid64.sem_nsems = linux_semid->sem_nsems;
396 return (copyout(&linux_semid64, uaddr, sizeof(linux_semid64)));
398 return (copyout(linux_semid, uaddr, sizeof(*linux_semid)));
402 linux_shmid_pullup(l_int ver, struct l_shmid_ds *linux_shmid, caddr_t uaddr)
404 struct l_shmid64_ds linux_shmid64;
407 if (ver == LINUX_IPC_64) {
408 error = copyin(uaddr, &linux_shmid64, sizeof(linux_shmid64));
412 bzero(linux_shmid, sizeof(*linux_shmid));
414 linux_shmid->shm_perm.uid = linux_shmid64.shm_perm.uid;
415 linux_shmid->shm_perm.gid = linux_shmid64.shm_perm.gid;
416 linux_shmid->shm_perm.mode = linux_shmid64.shm_perm.mode;
418 error = copyin(uaddr, linux_shmid, sizeof(*linux_shmid));
424 linux_shmid_pushdown(l_int ver, struct l_shmid_ds *linux_shmid, caddr_t uaddr)
426 struct l_shmid64_ds linux_shmid64;
429 * XXX: This is backwards and loses information in shm_nattch
430 * and shm_segsz. We should probably either expose the BSD
431 * shmid structure directly and convert it to either the
432 * non-64 or 64 variant directly or the code should always
433 * convert to the 64 variant and then truncate values into the
434 * non-64 variant if needed since the 64 variant has more
437 if (ver == LINUX_IPC_64) {
438 bzero(&linux_shmid64, sizeof(linux_shmid64));
440 linux_ipc_perm_to_ipc64_perm(&linux_shmid->shm_perm,
441 &linux_shmid64.shm_perm);
443 linux_shmid64.shm_segsz = linux_shmid->shm_segsz;
444 linux_shmid64.shm_atime = linux_shmid->shm_atime;
445 linux_shmid64.shm_dtime = linux_shmid->shm_dtime;
446 linux_shmid64.shm_ctime = linux_shmid->shm_ctime;
447 linux_shmid64.shm_cpid = linux_shmid->shm_cpid;
448 linux_shmid64.shm_lpid = linux_shmid->shm_lpid;
449 linux_shmid64.shm_nattch = linux_shmid->shm_nattch;
451 return (copyout(&linux_shmid64, uaddr, sizeof(linux_shmid64)));
453 return (copyout(linux_shmid, uaddr, sizeof(*linux_shmid)));
457 linux_shminfo_pushdown(l_int ver, struct l_shminfo *linux_shminfo,
460 struct l_shminfo64 linux_shminfo64;
462 if (ver == LINUX_IPC_64) {
463 bzero(&linux_shminfo64, sizeof(linux_shminfo64));
465 linux_shminfo64.shmmax = linux_shminfo->shmmax;
466 linux_shminfo64.shmmin = linux_shminfo->shmmin;
467 linux_shminfo64.shmmni = linux_shminfo->shmmni;
468 linux_shminfo64.shmseg = linux_shminfo->shmseg;
469 linux_shminfo64.shmall = linux_shminfo->shmall;
471 return (copyout(&linux_shminfo64, uaddr,
472 sizeof(linux_shminfo64)));
474 return (copyout(linux_shminfo, uaddr, sizeof(*linux_shminfo)));
478 linux_semop(struct thread *td, struct linux_semop_args *args)
480 struct semop_args /* {
486 bsd_args.semid = args->semid;
487 bsd_args.sops = PTRIN(args->tsops);
488 bsd_args.nsops = args->nsops;
489 return (sys_semop(td, &bsd_args));
493 linux_semget(struct thread *td, struct linux_semget_args *args)
495 struct semget_args /* {
503 bsd_args.key = args->key;
504 bsd_args.nsems = args->nsems;
505 bsd_args.semflg = args->semflg;
506 return (sys_semget(td, &bsd_args));
510 linux_semctl(struct thread *td, struct linux_semctl_args *args)
512 struct l_semid_ds linux_semid;
513 struct l_seminfo linux_seminfo;
514 struct semid_ds semid;
519 switch (args->cmd & ~LINUX_IPC_64) {
537 semun.val = args->arg.val;
541 error = linux_semid_pullup(args->cmd & LINUX_IPC_64,
542 &linux_semid, PTRIN(args->arg.buf));
545 linux_to_bsd_semid_ds(&linux_semid, &semid);
547 return (kern_semctl(td, args->semid, args->semnum, cmd, &semun,
551 if ((args->cmd & ~LINUX_IPC_64) == LINUX_IPC_STAT)
556 error = kern_semctl(td, args->semid, args->semnum, cmd, &semun,
560 bsd_to_linux_semid_ds(&semid, &linux_semid);
561 error = linux_semid_pushdown(args->cmd & LINUX_IPC_64,
562 &linux_semid, PTRIN(args->arg.buf));
564 td->td_retval[0] = (cmd == SEM_STAT) ? rval : 0;
568 bcopy(&seminfo, &linux_seminfo.semmni, sizeof(linux_seminfo) -
569 sizeof(linux_seminfo.semmap) );
571 * Linux does not use the semmap field but populates it with
572 * the defined value from SEMMAP, which really is redefined to
573 * SEMMNS, which they define as SEMMNI * SEMMSL. Try to
574 * simulate this returning our dynamic semmns value.
576 linux_seminfo.semmap = linux_seminfo.semmns;
577 /* XXX BSD equivalent?
578 #define used_semids 10
580 linux_seminfo.semusz = used_semids;
581 linux_seminfo.semaem = used_sems;
583 error = copyout(&linux_seminfo,
584 PTRIN(args->arg.buf), sizeof(linux_seminfo));
587 td->td_retval[0] = seminfo.semmni;
588 return (0); /* No need for __semctl call */
591 semun.val = args->arg.val;
595 semun.val = args->arg.val;
598 linux_msg(td, "ipc type %d is not implemented",
599 args->cmd & ~LINUX_IPC_64);
602 return (kern_semctl(td, args->semid, args->semnum, cmd, &semun,
607 linux_msgsnd(struct thread *td, struct linux_msgsnd_args *args)
614 if ((l_long)args->msgsz < 0 || args->msgsz > (l_long)msginfo.msgmax)
616 msgp = PTRIN(args->msgp);
617 if ((error = copyin(msgp, &lmtype, sizeof(lmtype))) != 0)
619 mtype = (long)lmtype;
620 return (kern_msgsnd(td, args->msqid,
621 (const char *)msgp + sizeof(lmtype),
622 args->msgsz, args->msgflg, mtype));
626 linux_msgrcv(struct thread *td, struct linux_msgrcv_args *args)
633 if ((l_long)args->msgsz < 0 || args->msgsz > (l_long)msginfo.msgmax)
635 msgp = PTRIN(args->msgp);
636 if ((error = kern_msgrcv(td, args->msqid,
637 (char *)msgp + sizeof(lmtype), args->msgsz,
638 args->msgtyp, args->msgflg, &mtype)) != 0)
640 lmtype = (l_long)mtype;
641 return (copyout(&lmtype, msgp, sizeof(lmtype)));
645 linux_msgget(struct thread *td, struct linux_msgget_args *args)
647 struct msgget_args /* {
652 bsd_args.key = args->key;
653 bsd_args.msgflg = args->msgflg;
654 return (sys_msgget(td, &bsd_args));
658 linux_msgctl(struct thread *td, struct linux_msgctl_args *args)
661 struct l_msqid_ds linux_msqid;
662 struct msqid_ds bsd_msqid;
664 bsd_cmd = args->cmd & ~LINUX_IPC_64;
667 case LINUX_MSG_INFO: {
668 struct l_msginfo linux_msginfo;
671 * XXX MSG_INFO uses the same data structure but returns different
672 * dynamic counters in msgpool, msgmap, and msgtql fields.
674 linux_msginfo.msgpool = (long)msginfo.msgmni *
675 (long)msginfo.msgmnb / 1024L; /* XXX MSG_INFO. */
676 linux_msginfo.msgmap = msginfo.msgmnb; /* XXX MSG_INFO. */
677 linux_msginfo.msgmax = msginfo.msgmax;
678 linux_msginfo.msgmnb = msginfo.msgmnb;
679 linux_msginfo.msgmni = msginfo.msgmni;
680 linux_msginfo.msgssz = msginfo.msgssz;
681 linux_msginfo.msgtql = msginfo.msgtql; /* XXX MSG_INFO. */
682 linux_msginfo.msgseg = msginfo.msgseg;
683 error = copyout(&linux_msginfo, PTRIN(args->buf),
684 sizeof(linux_msginfo));
686 td->td_retval[0] = msginfo.msgmni; /* XXX */
692 * TODO: implement this
693 * case LINUX_MSG_STAT:
700 error = linux_msqid_pullup(args->cmd & LINUX_IPC_64,
701 &linux_msqid, PTRIN(args->buf));
704 linux_to_bsd_msqid_ds(&linux_msqid, &bsd_msqid);
716 error = kern_msgctl(td, args->msqid, bsd_cmd, &bsd_msqid);
718 if (bsd_cmd != LINUX_IPC_RMID || error != EINVAL)
721 if (bsd_cmd == LINUX_IPC_STAT) {
722 bsd_to_linux_msqid_ds(&bsd_msqid, &linux_msqid);
723 return (linux_msqid_pushdown(args->cmd & LINUX_IPC_64,
724 &linux_msqid, PTRIN(args->buf)));
731 linux_shmat(struct thread *td, struct linux_shmat_args *args)
733 struct shmat_args /* {
739 #if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
743 bsd_args.shmid = args->shmid;
744 bsd_args.shmaddr = PTRIN(args->shmaddr);
745 bsd_args.shmflg = args->shmflg;
746 if ((error = sys_shmat(td, &bsd_args)))
748 #if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
749 addr = td->td_retval[0];
750 if ((error = copyout(&addr, PTRIN(args->raddr), sizeof(addr))))
752 td->td_retval[0] = 0;
758 linux_shmdt(struct thread *td, struct linux_shmdt_args *args)
760 struct shmdt_args /* {
764 bsd_args.shmaddr = PTRIN(args->shmaddr);
765 return (sys_shmdt(td, &bsd_args));
769 linux_shmget(struct thread *td, struct linux_shmget_args *args)
771 struct shmget_args /* {
777 bsd_args.key = args->key;
778 bsd_args.size = args->size;
779 bsd_args.shmflg = args->shmflg;
780 return (sys_shmget(td, &bsd_args));
784 linux_shmctl(struct thread *td, struct linux_shmctl_args *args)
786 struct l_shmid_ds linux_shmid;
787 struct l_shminfo linux_shminfo;
788 struct l_shm_info linux_shm_info;
789 struct shmid_ds bsd_shmid;
792 switch (args->cmd & ~LINUX_IPC_64) {
794 case LINUX_IPC_INFO: {
795 struct shminfo bsd_shminfo;
797 /* Perform shmctl wanting removed segments lookup */
798 error = kern_shmctl(td, args->shmid, IPC_INFO,
799 (void *)&bsd_shminfo, NULL);
803 bsd_to_linux_shminfo(&bsd_shminfo, &linux_shminfo);
805 return (linux_shminfo_pushdown(args->cmd & LINUX_IPC_64,
806 &linux_shminfo, PTRIN(args->buf)));
809 case LINUX_SHM_INFO: {
810 struct shm_info bsd_shm_info;
812 /* Perform shmctl wanting removed segments lookup */
813 error = kern_shmctl(td, args->shmid, SHM_INFO,
814 (void *)&bsd_shm_info, NULL);
818 bsd_to_linux_shm_info(&bsd_shm_info, &linux_shm_info);
820 return (copyout(&linux_shm_info, PTRIN(args->buf),
821 sizeof(struct l_shm_info)));
825 /* Perform shmctl wanting removed segments lookup */
826 error = kern_shmctl(td, args->shmid, IPC_STAT,
827 (void *)&bsd_shmid, NULL);
831 bsd_to_linux_shmid_ds(&bsd_shmid, &linux_shmid);
833 return (linux_shmid_pushdown(args->cmd & LINUX_IPC_64,
834 &linux_shmid, PTRIN(args->buf)));
837 /* Perform shmctl wanting removed segments lookup */
838 error = kern_shmctl(td, args->shmid, IPC_STAT,
839 (void *)&bsd_shmid, NULL);
843 bsd_to_linux_shmid_ds(&bsd_shmid, &linux_shmid);
845 return (linux_shmid_pushdown(args->cmd & LINUX_IPC_64,
846 &linux_shmid, PTRIN(args->buf)));
849 error = linux_shmid_pullup(args->cmd & LINUX_IPC_64,
850 &linux_shmid, PTRIN(args->buf));
854 linux_to_bsd_shmid_ds(&linux_shmid, &bsd_shmid);
856 /* Perform shmctl wanting removed segments lookup */
857 return (kern_shmctl(td, args->shmid, IPC_SET,
858 (void *)&bsd_shmid, NULL));
860 case LINUX_IPC_RMID: {
866 error = linux_shmid_pullup(args->cmd & LINUX_IPC_64,
867 &linux_shmid, PTRIN(args->buf));
870 linux_to_bsd_shmid_ds(&linux_shmid, &bsd_shmid);
871 buf = (void *)&bsd_shmid;
873 return (kern_shmctl(td, args->shmid, IPC_RMID, buf, NULL));
878 case LINUX_SHM_UNLOCK:
881 linux_msg(td, "ipc type %d not implemented",
882 args->cmd & ~LINUX_IPC_64);
887 MODULE_DEPEND(linux, sysvmsg, 1, 1, 1);
888 MODULE_DEPEND(linux, sysvsem, 1, 1, 1);
889 MODULE_DEPEND(linux, sysvshm, 1, 1, 1);