Deleted Added
full compact
linux_ipc.c (165404) linux_ipc.c (165407)
1/*-
2 * Copyright (c) 1994-1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

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.
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1994-1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

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.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/compat/linux/linux_ipc.c 165404 2006-12-20 19:30:52Z jkim $");
30__FBSDID("$FreeBSD: head/sys/compat/linux/linux_ipc.c 165407 2006-12-20 20:08:45Z jkim $");
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/syscallsubr.h>
35#include <sys/sysproto.h>
36#include <sys/proc.h>
37#include <sys/limits.h>
38#include <sys/msg.h>

--- 39 unchanged lines hidden (view full) ---

78 l_int used_ids;
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;
84};
85
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/syscallsubr.h>
35#include <sys/sysproto.h>
36#include <sys/proc.h>
37#include <sys/limits.h>
38#include <sys/msg.h>

--- 39 unchanged lines hidden (view full) ---

78 l_int used_ids;
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;
84};
85
86struct l_msginfo {
87 l_int msgpool;
88 l_int msgmap;
89 l_int msgmax;
90 l_int msgmnb;
91 l_int msgmni;
92 l_int msgssz;
93 l_int msgtql;
94 l_ushort msgseg;
95};
96
86static void
87bsd_to_linux_shminfo( struct shminfo *bpp, struct l_shminfo *lpp)
88{
89 lpp->shmmax = bpp->shmmax;
90 lpp->shmmin = bpp->shmmin;
91 lpp->shmmni = bpp->shmmni;
92 lpp->shmseg = bpp->shmseg;
93 lpp->shmall = bpp->shmall;

--- 481 unchanged lines hidden (view full) ---

575int
576linux_msgsnd(struct thread *td, struct linux_msgsnd_args *args)
577{
578 const void *msgp;
579 long mtype;
580 l_long lmtype;
581 int error;
582
97static void
98bsd_to_linux_shminfo( struct shminfo *bpp, struct l_shminfo *lpp)
99{
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;

--- 481 unchanged lines hidden (view full) ---

586int
587linux_msgsnd(struct thread *td, struct linux_msgsnd_args *args)
588{
589 const void *msgp;
590 long mtype;
591 l_long lmtype;
592 int error;
593
583 if ((l_long)args->msgsz < 0)
594 if ((l_long)args->msgsz < 0 || args->msgsz > (l_long)msginfo.msgmax)
584 return (EINVAL);
585 msgp = PTRIN(args->msgp);
586 if ((error = copyin(msgp, &lmtype, sizeof(lmtype))) != 0)
587 return (error);
588 mtype = (long)lmtype;
589 return (kern_msgsnd(td, args->msqid,
590 (const char *)msgp + sizeof(lmtype),
591 args->msgsz, args->msgflg, mtype));
592}
593
594int
595linux_msgrcv(struct thread *td, struct linux_msgrcv_args *args)
596{
597 void *msgp;
598 long mtype;
599 l_long lmtype;
600 int error;
601
595 return (EINVAL);
596 msgp = PTRIN(args->msgp);
597 if ((error = copyin(msgp, &lmtype, sizeof(lmtype))) != 0)
598 return (error);
599 mtype = (long)lmtype;
600 return (kern_msgsnd(td, args->msqid,
601 (const char *)msgp + sizeof(lmtype),
602 args->msgsz, args->msgflg, mtype));
603}
604
605int
606linux_msgrcv(struct thread *td, struct linux_msgrcv_args *args)
607{
608 void *msgp;
609 long mtype;
610 l_long lmtype;
611 int error;
612
602 if ((l_long)args->msgsz < 0)
613 if ((l_long)args->msgsz < 0 || args->msgsz > (l_long)msginfo.msgmax)
603 return (EINVAL);
604 msgp = PTRIN(args->msgp);
605 if ((error = kern_msgrcv(td, args->msqid,
606 (char *)msgp + sizeof(lmtype), args->msgsz,
607 args->msgtyp, args->msgflg, &mtype)) != 0)
608 return (error);
609 lmtype = (l_long)mtype;
610 return (copyout(&lmtype, msgp, sizeof(lmtype)));

--- 15 unchanged lines hidden (view full) ---

626int
627linux_msgctl(struct thread *td, struct linux_msgctl_args *args)
628{
629 int error, bsd_cmd;
630 struct l_msqid_ds linux_msqid;
631 struct msqid_ds bsd_msqid;
632
633 bsd_cmd = args->cmd & ~LINUX_IPC_64;
614 return (EINVAL);
615 msgp = PTRIN(args->msgp);
616 if ((error = kern_msgrcv(td, args->msqid,
617 (char *)msgp + sizeof(lmtype), args->msgsz,
618 args->msgtyp, args->msgflg, &mtype)) != 0)
619 return (error);
620 lmtype = (l_long)mtype;
621 return (copyout(&lmtype, msgp, sizeof(lmtype)));

--- 15 unchanged lines hidden (view full) ---

637int
638linux_msgctl(struct thread *td, struct linux_msgctl_args *args)
639{
640 int error, bsd_cmd;
641 struct l_msqid_ds linux_msqid;
642 struct msqid_ds bsd_msqid;
643
644 bsd_cmd = args->cmd & ~LINUX_IPC_64;
634 if (bsd_cmd == LINUX_IPC_SET) {
645 switch (bsd_cmd) {
646 case LINUX_IPC_INFO:
647 case LINUX_MSG_INFO: {
648 struct l_msginfo linux_msginfo;
649
650 /*
651 * XXX MSG_INFO uses the same data structure but returns different
652 * dynamic counters in msgpool, msgmap, and msgtql fields.
653 */
654 linux_msginfo.msgpool = (long)msginfo.msgmni *
655 (long)msginfo.msgmnb / 1024L; /* XXX MSG_INFO. */
656 linux_msginfo.msgmap = msginfo.msgmnb; /* XXX MSG_INFO. */
657 linux_msginfo.msgmax = msginfo.msgmax;
658 linux_msginfo.msgmnb = msginfo.msgmnb;
659 linux_msginfo.msgmni = msginfo.msgmni;
660 linux_msginfo.msgssz = msginfo.msgssz;
661 linux_msginfo.msgtql = msginfo.msgtql; /* XXX MSG_INFO. */
662 linux_msginfo.msgseg = msginfo.msgseg;
663 error = copyout(&linux_msginfo, PTRIN(args->buf),
664 sizeof(linux_msginfo));
665 if (error == 0)
666 td->td_retval[0] = msginfo.msgmni; /* XXX */
667
668 return (error);
669 }
670
671 case LINUX_IPC_SET:
635 error = linux_msqid_pullup(args->cmd & LINUX_IPC_64,
636 &linux_msqid, PTRIN(args->buf));
637 if (error)
638 return (error);
639 linux_to_bsd_msqid_ds(&linux_msqid, &bsd_msqid);
672 error = linux_msqid_pullup(args->cmd & LINUX_IPC_64,
673 &linux_msqid, PTRIN(args->buf));
674 if (error)
675 return (error);
676 linux_to_bsd_msqid_ds(&linux_msqid, &bsd_msqid);
677 break;
640 }
641
642 error = kern_msgctl(td, args->msqid, bsd_cmd, &bsd_msqid);
643 if (error != 0)
644 if (bsd_cmd != LINUX_IPC_RMID || error != EINVAL)
645 return (error);
646
647 if (bsd_cmd == LINUX_IPC_STAT) {

--- 165 unchanged lines hidden ---
678 }
679
680 error = kern_msgctl(td, args->msqid, bsd_cmd, &bsd_msqid);
681 if (error != 0)
682 if (bsd_cmd != LINUX_IPC_RMID || error != EINVAL)
683 return (error);
684
685 if (bsd_cmd == LINUX_IPC_STAT) {

--- 165 unchanged lines hidden ---