Subject: kern/16468: SYSV calls missing from OSF/1 emulation.
To: None <gnats-bugs@gnats.netbsd.org>
From: None <kpneal@pobox.com>
List: netbsd-bugs
Date: 04/23/2002 22:21:00
>Number: 16468
>Category: kern
>Synopsis: OSF/1 emulation lacks msg*() and friends.
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Tue Apr 23 19:22:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Kevin P. Neal
>Release: NetBSD 1.5.2
>Organization:
--
Kevin P. Neal http://www.pobox.com/~kpn/
"You know, I think I can hear the machine screaming from here... \
'help me! hellpp meeee!'" - Heather Flanagan, 14:52:23 Wed Jun 10 1998
>Environment:
System: NetBSD tome.neutralgood.org 1.5.2 NetBSD 1.5.2 (TOME) #51: Tue Jan 15 18:25:56 EST 2002 kpn@neutralgood.org:/local/kernel/compile/TOME alpha
>Description:
If I attempt to run Netscape it crashes because it can't do a msgget().
Nobody else seems to have this problem. In any event, this code (while
not perfect) does get Netscape running and provide a framework for
future development.
>How-To-Repeat:
On my NetBSD 1.5.2/alpha box attempt to run Netscape. Lose.
>Fix:
Add this code to the /sys/compat/osf1/ code. Note that these patches
are for the NetBSD 1.5.2 codebase -- I don't have a -current machine.
Sorry. The pullup shouldn't be very involved.
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# osf1.h.diff
# syscalls.master.diff
# osf1_sysv_ipc.c
#
echo x - osf1.h.diff
sed 's/^X//' >osf1.h.diff << 'END-of-osf1.h.diff'
X*** old/osf1.h Sat Mar 30 21:06:24 2002
X***************
X*** 1,4 ****
X! /* $NetBSD: osf1.h,v 1.20 1999/05/10 21:41:07 cgd Exp $ */
X
X /*
X * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
X--- 1,4 ----
X! /* $NetBSD: osf1.h,v 1.21 1999/06/26 01:21:30 cgd Exp $ */
X
X /*
X * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
X***************
X*** 49,58 ****
X--- 49,62 ----
X * type and structure definitions used by other structures
X */
X
X+ /* XXX osf1_u_int vs osf1_uint ? */
X+
X typedef int16_t osf1_short;
X+ typedef u_int16_t osf1_ushort;
X typedef int32_t osf1_int;
X typedef int64_t osf1_long;
X typedef u_int32_t osf1_u_int;
X+ typedef u_int64_t osf1_ulong;
X
X typedef int32_t osf1_dev_t;
X typedef u_int32_t osf1_ino_t;
X***************
X*** 211,216 ****
X--- 215,245 ----
X #define OSF1_IOC_INOUT (OSF1_IOC_IN|OSF1_IOC_OUT)
X #define OSF1_IOC_DIRMASK 0xe0000000
X
X+ /* ipc.h */
X+
X+ /* control commands */
X+ #define OSF1_IPC_RMID 0
X+ #define OSF1_IPC_SET 1
X+ #define OSF1_IPC_STAT 2
X+
X+ /* common ipc_perm modes */
X+ #define OSF1_IPC_ALLOC 0100000
X+ #define OSF1_IPC_RESERVED 0200000
X+ #define OSF1_IPC_R 0000400
X+ #define OSF1_IPC_W 0000200
X+
X+
X+ /* ipc structures */
X+ struct osf1_ipc_perm {
X+ osf1_uid_t uid;
X+ osf1_gid_t gid;
X+ osf1_uid_t cuid;
X+ osf1_gid_t cgid;
X+ osf1_mode_t mode;
X+ osf1_ushort seq;
X+ osf1_key_t key;
X+ };
X+
X
X /* mman.h */
X
X***************
X*** 338,343 ****
X--- 367,412 ----
X union osf1_mount_info mount_info;
X };
X
X+ /* msg.h */
X+
X+ struct osf1_msg {
X+ struct osf1_msg *msg_next;
X+ osf1_long msg_type;
X+ osf1_long msg_ts;
X+ caddr_t msg_addr;
X+ };
X+
X+ struct osf1_msg_wait {
X+ struct osf1_msg_wait *msg_wait_next;
X+ osf1_long msg_wait_type;
X+ osf1_long msg_wait_cnt;
X+ };
X+
X+ /*
X+ * There is one msg queue id data structure for each q in the system.
X+ */
X+
X+ typedef osf1_ulong osf1_msglen_t;
X+ typedef osf1_ulong osf1_msgqnum_t;
X+ /* XXX secinfo_t */
X+
X+ struct osf1_msqid_ds {
X+ struct osf1_ipc_perm msg_perm;
X+ struct osf1_msg *msg_first;
X+ struct osf1_msg *msg_last;
X+ osf1_msglen_t msg_cbytes;
X+ osf1_msgqnum_t msg_qnum;
X+ osf1_msglen_t msg_qbytes;
X+ osf1_pid_t msg_lspid;
X+ osf1_pid_t msg_lrpid;
X+ osf1_time_t msg_stime;
X+ osf1_time_t msg_rtime;
X+ osf1_time_t msg_ctime;
X+ struct osf1_msg_wait *msg_wait_list;
X+ #if 0
X+ secinfo_t *msg_secattr;
X+ #endif
X+ };
X
X /* reboot.h */
X
END-of-osf1.h.diff
echo x - syscalls.master.diff
sed 's/^X//' >syscalls.master.diff << 'END-of-syscalls.master.diff'
X*** old/syscalls.master Sat Mar 30 21:06:25 2002
X***************
X*** 1,4 ****
X! $NetBSD: syscalls.master,v 1.29 1999/05/10 03:33:04 cgd Exp $
X
X ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
X
X--- 1,4 ----
X! $NetBSD: syscalls.master,v 1.30 1999/05/10 05:58:44 cgd Exp $
X
X ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
X
X***************
X*** 32,37 ****
X--- 32,38 ----
X ; #include's are copied to the syscall names and switch definition files only.
X
X #include "opt_compat_43.h"
X+ #include "opt_sysv.h"
X
X #include <sys/param.h>
X #include <sys/systm.h>
X***************
X*** 223,229 ****
X 129 STD { int osf1_sys_truncate(const char *path, \
X off_t length); }
X 130 STD { int osf1_sys_ftruncate(int fd, off_t length); }
X! 131 UNIMPL flock
X 132 STD { int osf1_sys_setgid(gid_t gid); }
X 133 STD { int osf1_sys_sendto(int s, caddr_t buf, size_t len, \
X int flags, struct sockaddr *to, int tolen); }
X--- 224,230 ----
X 129 STD { int osf1_sys_truncate(const char *path, \
X off_t length); }
X 130 STD { int osf1_sys_ftruncate(int fd, off_t length); }
X! 131 NOARGS { int sys_flock(int fd, int operation); }
X 132 STD { int osf1_sys_setgid(gid_t gid); }
X 133 STD { int osf1_sys_sendto(int s, caddr_t buf, size_t len, \
X int flags, struct sockaddr *to, int tolen); }
X***************
X*** 308,323 ****
X 197 UNIMPL
X 198 UNIMPL
X 199 UNIMPL swapon
X! 200 UNIMPL msgctl
X! 201 UNIMPL msgget
X! 202 UNIMPL msgrcv
X! 203 UNIMPL msgsnd
X! 204 UNIMPL semctl
X! 205 UNIMPL semget
X! 206 UNIMPL semop
X 207 STD { int osf1_sys_uname(struct osf1_uname *name); }
X 208 NOARGS { int sys___posix_lchown(const char *path, int uid, \
X int gid); }
X 209 STD { void *osf1_sys_shmat(int shmid, \
X const void *shmaddr, int shmflg); }
X 210 STD { int osf1_sys_shmctl(int shmid, int cmd, \
X--- 309,344 ----
X 197 UNIMPL
X 198 UNIMPL
X 199 UNIMPL swapon
X! #ifdef SYSVMSG
X! 200 STD { int osf1_sys_msgctl(int msqid, int cmd, \
X! struct osf1_msqid_ds *buf); }
X! 201 STD { int osf1_sys_msgget(osf1_key_t key, int msgflg); }
X! 202 STD { ssize_t osf1_sys_msgrcv(int msqid, void *msgp, \
X! size_t msgsz, long msgtyp, int msgflg); }
X! 203 STD { int osf1_sys_msgsnd(int msqid, const void *msgp, \
X! size_t msgsz, int msgflg); }
X! #else
X! 200 EXCL msgctl
X! 201 EXCL msgget
X! 202 EXCL msgrcv
X! 203 EXCL msgsnd
X! #endif
X! #ifdef SYSVSEM
X! 204 STD { int osf1_sys_semctl(int semid, int semnum, \
X! int cmd, union osf1_semun *arg); }
X! 205 STD { int osf1_sys_semget(osf1_key_t key, int nsems, \
X! int semflg); }
X! 206 STD { int osf1_sys_semop(int semid, \
X! struct osf1_sembuf *sops, size_t nsops); }
X! #else
X! 204 EXCL semctl
X! 205 EXCL semget
X! 206 EXCL semop
X! #endif
X 207 STD { int osf1_sys_uname(struct osf1_uname *name); }
X 208 NOARGS { int sys___posix_lchown(const char *path, int uid, \
X int gid); }
X+ #ifdef SYSVSHM
X 209 STD { void *osf1_sys_shmat(int shmid, \
X const void *shmaddr, int shmflg); }
X 210 STD { int osf1_sys_shmctl(int shmid, int cmd, \
X***************
X*** 325,330 ****
X--- 346,357 ----
X 211 STD { int osf1_sys_shmdt(const void *shmaddr); }
X 212 STD { int osf1_sys_shmget(osf1_key_t key, size_t size, \
X int flags); }
X+ #else
X+ 209 EXCL shmat
X+ 210 EXCL shmctl
X+ 211 EXCL shmdt
X+ 212 EXCL shmget
X+ #endif
X 213 UNIMPL mvalid
X 214 UNIMPL getaddressconf
X 215 UNIMPL msleep
X***************
X*** 378,381 ****
X 258 UNIMPL afs_syscall
X 259 UNIMPL swapctl
X 260 UNIMPL memcntl
X! 261 UNIMPL fdatasync
X--- 405,408 ----
X 258 UNIMPL afs_syscall
X 259 UNIMPL swapctl
X 260 UNIMPL memcntl
X! 261 NOARGS { int sys_fdatasync(int fd); }
END-of-syscalls.master.diff
echo x - osf1_sysv_ipc.c
sed 's/^X//' >osf1_sysv_ipc.c << 'END-of-osf1_sysv_ipc.c'
X/* $NetBSD: osf1_sysv_ipc.c,v 1.2 1999/05/04 05:11:03 cgd Exp $ */
X
X/*
X * Copyright (c) 2002 Kevin P. Neal. All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X * notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X * notice, this list of conditions and the following disclaimer in the
X * documentation and/or other materials provided with the distribution.
X * 3. The name of the author may not be used to endorse or promote products
X * derived from this software without specific prior written permission
X *
X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
X */
X
X/*
X * This code was strongly based on existing emulation code written
X * by cgd and others. -kpn
X */
X
X#include "opt_sysv.h"
X
X#include <sys/param.h>
X#include <sys/systm.h>
X#include <sys/proc.h>
X#include <sys/mount.h>
X
X#include <sys/systm.h>
X
X#ifdef SYSVSEM
X#include <sys/sem.h>
X#endif
X
X#ifdef SYSVSHM
X#include <sys/shm.h>
X#endif
X
X#ifdef SYSVMSG
X#include <sys/msg.h>
X#endif
X
X#include <sys/syscallargs.h>
X
X#include <compat/osf1/osf1.h>
X#include <compat/osf1/osf1_syscallargs.h>
X#include <compat/osf1/osf1_cvt.h>
X
X#ifdef SYSVMSG
Xstatic void msqid_osf1_to_native (struct osf1_msqid_ds *, struct msqid_ds *);
Xstatic void native_to_msqid_osf1 (struct msqid_ds *, struct osf1_msqid_ds *);
Xstatic void ipc_permosf1_to_native (struct osf1_ipc_perm *, struct ipc_perm *);
Xstatic void native_to_ipc_permosf1 (struct ipc_perm *, struct osf1_ipc_perm *);
X#endif
X
X#ifdef SYSVSEM
Xint
Xosf1_sys_semctl(p, v, retval)
X struct proc *p;
X void *v;
X register_t *retval;
X{
X /* XXX */
X return (ENOSYS);
X}
X
Xint
Xosf1_sys_semget(p, v, retval)
X struct proc *p;
X void *v;
X register_t *retval;
X{
X /* XXX */
X return (ENOSYS);
X}
X
Xint
Xosf1_sys_semop(p, v, retval)
X struct proc *p;
X void *v;
X register_t *retval;
X{
X /* XXX */
X return (ENOSYS);
X}
X#endif
X
X#ifdef SYSVSHM
Xint
Xosf1_sys_shmat(p, v, retval)
X struct proc *p;
X void *v;
X register_t *retval;
X{
X /* XXX */
X return (ENOSYS);
X}
X
Xint
Xosf1_sys_shmctl(p, v, retval)
X struct proc *p;
X void *v;
X register_t *retval;
X{
X /* XXX */
X return (ENOSYS);
X}
X
Xint
Xosf1_sys_shmdt(p, v, retval)
X struct proc *p;
X void *v;
X register_t *retval;
X{
X /* XXX */
X return (ENOSYS);
X}
X
Xint
Xosf1_sys_shmget(p, v, retval)
X struct proc *p;
X void *v;
X register_t *retval;
X{
X /* XXX */
X return (ENOSYS);
X}
X#endif
X
X#ifdef SYSVMSG
Xint
Xosf1_sys_msgget(p, v, retval)
X struct proc *p;
X void *v;
X register_t *retval;
X{
X struct osf1_sys_msgget_args *uap = v;
X struct sys_msgget_args a;
X int error;
X
X SCARG(&a, key) = SCARG(uap, key);
X SCARG(&a, msgflg) = SCARG(uap, msgflg);
X
X error = sys_msgget(p, &a, retval);
X
X return (error);
X}
X
X/*
X * Startling how similar this all is to compat_14_sys_msgctl, isn't it?
X */
X
Xstatic void
Xmsqid_osf1_to_native (omsqbuf, msqbuf)
X struct osf1_msqid_ds *omsqbuf;
X struct msqid_ds *msqbuf;
X{
X ipc_permosf1_to_native(&omsqbuf->msg_perm, &msqbuf->msg_perm);
X
X#define CVT(x) msqbuf->x = omsqbuf->x
X CVT(msg_qnum);
X CVT(msg_qbytes);
X CVT(msg_lspid);
X CVT(msg_lrpid);
X CVT(msg_stime);
X CVT(msg_rtime);
X CVT(msg_ctime);
X /* XXX what about msg_first and msg_last? */
X /* XXX what about msg_wait_list? */
X /* XXX what about msg_secattr? */
X#undef CVT
X
X msqbuf->_msg_cbytes = omsqbuf->msg_cbytes;
X
X return;
X}
X
Xstatic void
Xnative_to_msqid_osf1 (msqbuf, omsqbuf)
X struct msqid_ds *msqbuf;
X struct osf1_msqid_ds *omsqbuf;
X{
X native_to_ipc_permosf1(&msqbuf->msg_perm, &omsqbuf->msg_perm);
X
X#define CVT(x) omsqbuf->x = msqbuf->x
X CVT(msg_qnum);
X CVT(msg_qbytes);
X CVT(msg_lspid);
X CVT(msg_lrpid);
X CVT(msg_stime);
X CVT(msg_rtime);
X CVT(msg_ctime);
X /* XXX what about msg_first and msg_last? */
X /* XXX what about msg_wait_list? */
X /* XXX what about msg_secattr? */
X#undef CVT
X
X omsqbuf->msg_cbytes = msqbuf->_msg_cbytes;
X
X return;
X}
X
Xstatic void
Xipc_permosf1_to_native (operm, perm)
X struct osf1_ipc_perm *operm;
X struct ipc_perm *perm;
X{
X#define CVT(x) perm->x = operm->x
X CVT(uid);
X CVT(gid);
X CVT(cuid);
X CVT(cgid);
X CVT(mode);
X#undef CVT
X
X return;
X}
X
Xstatic void
Xnative_to_ipc_permosf1 (perm, operm)
X struct ipc_perm *perm;
X struct osf1_ipc_perm *operm;
X{
X#define CVT(x) operm->x = perm->x
X CVT(uid);
X CVT(gid);
X CVT(cuid);
X CVT(cgid);
X CVT(mode); /* XXX OSF/1 IPC_ALLOC, IPC_RESERVED? */
X#undef CVT
X
X /*
X * Not part of the API, but some programs might look at it.
X */
X operm->seq = perm->_seq;
X operm->key = perm->_key;
X
X return;
X}
X
Xint
Xosf1_sys_msgctl(p, v, retval)
X struct proc *p;
X void *v;
X register_t *retval;
X{
X struct osf1_sys_msgctl_args *uap = v;
X struct osf1_msqid_ds omsqbuf;
X struct msqid_ds msqbuf;
X int ocmd;
X int cmd;
X int error;
X
X ocmd = SCARG(uap, cmd);
X
X cmd = ocmd; /* XXX same, for now. */
X if (ocmd == OSF1_IPC_SET) {
X error = copyin(SCARG(uap, buf), &omsqbuf, sizeof(omsqbuf));
X if (error)
X return (error);
X msqid_osf1_to_native(&omsqbuf, &msqbuf);
X }
X
X error = msgctl1(p, SCARG(uap, msqid), cmd,
X (ocmd == OSF1_IPC_SET || ocmd == OSF1_IPC_STAT) ? &msqbuf : NULL);
X
X if (error == 0 && ocmd == OSF1_IPC_STAT) {
X native_to_msqid_osf1(&msqbuf, &omsqbuf);
X error = copyout(&omsqbuf, SCARG(uap, buf), sizeof(omsqbuf));
X }
X
X return (error);
X}
X
X/* XXX watch out for differences in behavior if a signal is caught (or not). */
Xint
Xosf1_sys_msgrcv(p, v, retval)
X struct proc *p;
X void *v;
X register_t *retval;
X{
X struct osf1_sys_msgrcv_args *uap = v;
X struct sys_msgrcv_args a;
X int error;
X
X SCARG(&a, msqid) = SCARG(uap, msqid);
X SCARG(&a, msgp) = SCARG(uap, msgp);
X SCARG(&a, msgsz) = SCARG(uap, msgsz);
X SCARG(&a, msgtyp) = SCARG(uap, msgtyp);
X SCARG(&a, msgflg) = SCARG(uap, msgflg);
X
X error = sys_msgrcv(p, &a, retval);
X
X return (error);
X}
X
Xint
Xosf1_sys_msgsnd(p, v, retval)
X struct proc *p;
X void *v;
X register_t *retval;
X{
X struct osf1_sys_msgsnd_args *uap = v;
X struct sys_msgsnd_args a;
X int error;
X
X SCARG(&a, msqid) = SCARG(uap, msqid);
X SCARG(&a, msgp) = SCARG(uap, msgp);
X SCARG(&a, msgsz) = SCARG(uap, msgsz);
X SCARG(&a, msgflg) = SCARG(uap, msgflg);
X
X error = sys_msgsnd(p, &a, retval);
X
X return (error);
X}
X#endif
END-of-osf1_sysv_ipc.c
exit
>Release-Note:
>Audit-Trail:
>Unformatted: