Deleted Added
full compact
linux_ipc.c (140214) linux_ipc.c (140839)
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 140214 2005-01-14 04:44:56Z obrien $");
30__FBSDID("$FreeBSD: head/sys/compat/linux/linux_ipc.c 140839 2005-01-26 00:46:36Z sobomax $");
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>

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

629 bsd_args.key = args->key;
630 bsd_args.msgflg = args->msgflg;
631 return msgget(td, &bsd_args);
632}
633
634int
635linux_msgctl(struct thread *td, struct linux_msgctl_args *args)
636{
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>

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

629 bsd_args.key = args->key;
630 bsd_args.msgflg = args->msgflg;
631 return msgget(td, &bsd_args);
632}
633
634int
635linux_msgctl(struct thread *td, struct linux_msgctl_args *args)
636{
637 struct msgctl_args /* {
638 int msqid;
639 int cmd;
640 struct msqid_ds *buf;
641 } */ bsd_args;
642 int error;
637 int error, bsd_cmd;
643 struct l_msqid_ds linux_msqid;
638 struct l_msqid_ds linux_msqid;
644 caddr_t sg = stackgap_init();
639 struct msqid_ds bsd_msqid;
640 struct msqid_ds *bsd_msqptr;
645
646 error = linux_msqid_pullup(args->cmd & LINUX_IPC_64,
647 &linux_msqid, (caddr_t)PTRIN(args->buf));
648 if (error != 0)
649 return (error);
641
642 error = linux_msqid_pullup(args->cmd & LINUX_IPC_64,
643 &linux_msqid, (caddr_t)PTRIN(args->buf));
644 if (error != 0)
645 return (error);
650 bsd_args.buf = (struct msqid_ds*)stackgap_alloc(&sg,
651 sizeof(struct l_msqid_ds));
652 bsd_args.msqid = args->msqid;
653 bsd_args.cmd = args->cmd & ~LINUX_IPC_64;
654 if (bsd_args.cmd == LINUX_IPC_SET)
655 linux_to_bsd_msqid_ds(&linux_msqid, bsd_args.buf);
646 bsd_cmd = args->cmd & ~LINUX_IPC_64;
647 if (bsd_cmd == LINUX_IPC_SET)
648 linux_to_bsd_msqid_ds(&linux_msqid, &bsd_msqid);
656
649
657 error = msgctl(td, &bsd_args);
650 error = kern_msgctl(td, args->msqid, bsd_cmd, &bsd_msqid, &bsd_msqptr);
658 if (error != 0)
651 if (error != 0)
659 if (bsd_args.cmd != LINUX_IPC_RMID || error != EINVAL)
652 if (bsd_cmd != LINUX_IPC_RMID || error != EINVAL)
660 return (error);
661
653 return (error);
654
662 if (bsd_args.cmd == LINUX_IPC_STAT) {
663 bsd_to_linux_msqid_ds(bsd_args.buf, &linux_msqid);
655 if (bsd_cmd == LINUX_IPC_STAT) {
656 bsd_to_linux_msqid_ds(bsd_msqptr, &linux_msqid);
664 return (linux_msqid_pushdown(args->cmd & LINUX_IPC_64,
665 &linux_msqid, (caddr_t)PTRIN(args->buf)));
666 }
667
668 return (0);
669}
670
671int

--- 153 unchanged lines hidden ---
657 return (linux_msqid_pushdown(args->cmd & LINUX_IPC_64,
658 &linux_msqid, (caddr_t)PTRIN(args->buf)));
659 }
660
661 return (0);
662}
663
664int

--- 153 unchanged lines hidden ---