From 2ce20fca29d25bddac5172fb7c1ceb73bb7edd93 Mon Sep 17 00:00:00 2001 From: jkim Date: Wed, 20 Dec 2006 19:36:03 +0000 Subject: MFP4: (part of) 110058 Fix 32-bit msgsnd(3) and msgrcv(3) emulations for amd64. --- sys/compat/freebsd32/freebsd32_misc.c | 60 ++++++++++++++++++++++++++++++++--- sys/compat/freebsd32/syscalls.master | 4 +-- 2 files changed, 58 insertions(+), 6 deletions(-) (limited to 'sys/compat/freebsd32') diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index 41cb789..3d49263 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -1335,10 +1335,62 @@ freebsd32_semsys(struct thread *td, struct freebsd32_semsys_args *uap) int freebsd32_msgsys(struct thread *td, struct freebsd32_msgsys_args *uap) { - /* - * Vector through to msgsys if it is loaded. - */ - return sysent[SYS_msgsys].sy_call(td, uap); + switch (uap->which) { + case 2: + return (freebsd32_msgsnd(td, + (struct freebsd32_msgsnd_args *)&uap->a2)); + break; + case 3: + return (freebsd32_msgrcv(td, + (struct freebsd32_msgrcv_args *)&uap->a2)); + break; + default: + /* + * Vector through to msgsys if it is loaded. + */ + return (sysent[SYS_msgsys].sy_call(td, uap)); + break; + } +} + +int +freebsd32_msgsnd(struct thread *td, struct freebsd32_msgsnd_args *uap) +{ + const void *msgp; + long mtype; + int32_t mtype32; + int error; + + if (!SYSCALL_MODULE_PRESENT(msgsnd)) + return (nosys(td, (struct nosys_args *)uap)); + + msgp = PTRIN(uap->msgp); + if ((error = copyin(msgp, &mtype32, sizeof(mtype32))) != 0) + return (error); + mtype = mtype32; + return (kern_msgsnd(td, uap->msqid, + (const char *)msgp + sizeof(mtype32), + uap->msgsz, uap->msgflg, mtype)); +} + +int +freebsd32_msgrcv(struct thread *td, struct freebsd32_msgrcv_args *uap) +{ + void *msgp; + long mtype; + int32_t mtype32; + int error; + + if (!SYSCALL_MODULE_PRESENT(msgrcv)) + return (nosys(td, (struct nosys_args *)uap)); + + msgp = PTRIN(uap->msgp); + if ((error = kern_msgrcv(td, uap->msqid, + (char *)msgp + sizeof(mtype32), uap->msgsz, + uap->msgtyp, uap->msgflg, &mtype)) != 0) + return (error); + mtype32 = (int32_t)mtype; + return (copyout(&mtype32, msgp, sizeof(mtype32))); } int diff --git a/sys/compat/freebsd32/syscalls.master b/sys/compat/freebsd32/syscalls.master index b2e7fe9..7f7a425 100644 --- a/sys/compat/freebsd32/syscalls.master +++ b/sys/compat/freebsd32/syscalls.master @@ -406,9 +406,9 @@ 224 AUE_MSGCTL NOPROTO { int msgctl(int msqid, int cmd, \ struct msqid_ds *buf); } 225 AUE_MSGGET NOPROTO { int msgget(key_t key, int msgflg); } -226 AUE_MSGSND NOPROTO { int msgsnd(int msqid, void *msgp, \ +226 AUE_MSGSND STD { int freebsd32_msgsnd(int msqid, void *msgp, \ size_t msgsz, int msgflg); } -227 AUE_MSGRCV NOPROTO { int msgrcv(int msqid, void *msgp, \ +227 AUE_MSGRCV STD { int freebsd32_msgrcv(int msqid, void *msgp, \ size_t msgsz, long msgtyp, int msgflg); } 228 AUE_SHMAT NOPROTO { int shmat(int shmid, void *shmaddr, \ int shmflg); } -- cgit v1.1