NetBSD Problem Report #16468

Received: (qmail 18762 invoked from network); 24 Apr 2002 02:21:19 -0000
Message-Id: <200204240221.g3O2L0F10902@mail.neutralgood.org>
Date: Tue, 23 Apr 2002 22:21:00 -0400 (EDT)
From: kpneal@pobox.com
To: gnats-bugs@gnats.netbsd.org
Subject: SYSV calls missing from OSF/1 emulation.
X-Send-Pr-Version: 3.95

>Number:         16468
>Category:       kern
>Synopsis:       OSF/1 emulation lacks msg*() and friends.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 24 02:22:00 +0000 2002
>Closed-Date:    Mon Jun 10 06:37:33 +0000 2019
>Last-Modified:  Mon Jun 10 06:37:33 +0000 2019
>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--- osf1.h	Tue Apr 23 21:38:27 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--- syscalls.master	Mon Apr 15 00:28:28 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:

From: kpneal@pobox.com
To: gnats-bugs@netbsd.org
Cc:  
Subject: Re: kern/16468
Date: Tue, 22 Oct 2002 23:43:50 -0400

 Here are updated patches. These patches apply against 1.6 source.
 I would appreciate it if these were pulled into the 1.6 branch as
 well. Thanks.

 --- osf1.h.orig	Tue Oct 22 23:31:16 2002
 +++ osf1.h	Sun Oct 20 23:35:47 2002
 @@ -49,10 +49,14 @@
   * type and structure definitions used by other structures
   */

 +/* XXX osf1_u_int vs osf1_uint ? */
 +
  typedef int16_t		osf1_short;
 +typedef u_int16_t	osf1_ushort;
  typedef int32_t		osf1_int;
 -typedef int64_t		osf1_long;
  typedef u_int32_t	osf1_u_int;
 +typedef int64_t		osf1_long;
 +typedef u_int64_t	osf1_ulong;

  typedef int32_t		osf1_dev_t;
  typedef u_int32_t	osf1_ino_t;
 @@ -213,6 +217,30 @@
  #define OSF1_IOC_INOUT		(OSF1_IOC_IN|OSF1_IOC_OUT)
  #define OSF1_IOC_DIRMASK	0xe0000000

 +/* ipc.h */
 +
 +/* control commands */
 +#define OSF1_IPC_RMID		0
 +#define OSF1_IPC_SET		1
 +#define OSF1_IPC_STAT		2
 +
 +/* common ipc_perm modes */
 +#define OSF1_IPC_ALLOC		0100000
 +#define OSF1_IPC_RESERVED	0200000
 +#define OSF1_IPC_R		0000400
 +#define OSF1_IPC_W		0000200
 +
 +
 +/* ipc structures */
 +struct osf1_ipc_perm {
 +	osf1_uid_t		uid;
 +	osf1_gid_t		gid;
 +	osf1_uid_t		cuid;
 +	osf1_gid_t		cgid;
 +	osf1_mode_t		mode;
 +	osf1_ushort		seq;
 +	osf1_key_t		key;
 +};      

  /* mman.h */

 @@ -340,6 +368,46 @@
  	union osf1_mount_info mount_info;
  };

 +/* msg.h */
 +
 +struct osf1_msg {
 +        struct osf1_msg     *msg_next;
 +        osf1_long            msg_type;
 +        osf1_long            msg_ts;
 +        caddr_t              msg_addr;
 +};
 +
 +struct osf1_msg_wait {
 +        struct osf1_msg_wait *msg_wait_next;
 +        osf1_long            msg_wait_type;
 +        osf1_long            msg_wait_cnt; 
 +}; 
 +
 +/*
 + *      There is one msg queue id data structure for each q in the system.
 + */
 +
 +typedef osf1_ulong             osf1_msglen_t;
 +typedef osf1_ulong             osf1_msgqnum_t;
 +/* XXX secinfo_t */
 +
 +struct osf1_msqid_ds {
 +	struct osf1_ipc_perm	 msg_perm;
 +	struct osf1_msg		*msg_first;
 +	struct osf1_msg		*msg_last;
 +	osf1_msglen_t		 msg_cbytes;
 +	osf1_msgqnum_t		 msg_qnum;
 +	osf1_msglen_t		 msg_qbytes;
 +	osf1_pid_t		 msg_lspid;
 +	osf1_pid_t		 msg_lrpid;
 +	osf1_time_t		 msg_stime;
 +	osf1_time_t		 msg_rtime;
 +	osf1_time_t		 msg_ctime;
 +	struct osf1_msg_wait 	*msg_wait_list; 
 +#if 0
 +        secinfo_t		*msg_secattr;
 +#endif
 +};

  /* reboot.h */


 --- osf1_sysv_ipc.c.orig	Tue Oct 22 23:31:28 2002
 +++ osf1_sysv_ipc.c	Tue Oct 22 23:37:30 2002
 @@ -2,6 +2,7 @@

  /*
   * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
 + * Copyright (c) 2002 Kevin P. Neal. All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
 @@ -30,28 +31,87 @@
   * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   */

 +/*
 + *  This code was strongly based on existing emulation code written
 + *  by cgd and others. -kpn
 + */
 +
  #include <sys/cdefs.h>
  __KERNEL_RCSID(0, "$NetBSD: osf1_sysv_ipc.c,v 1.3 2001/11/13 02:09:16 lukem Exp $");

 +#include "opt_sysv.h" 
 +
  #include <sys/param.h>
  #include <sys/systm.h>
 -#include <sys/namei.h>
  #include <sys/proc.h>
 -#include <sys/file.h>
  #include <sys/mount.h>
 +
 +#include <sys/systm.h>
 +
 +#ifdef SYSVSEM
 +#include <sys/sem.h>
 +#endif
 +
 +#ifdef SYSVSHM
 +#include <sys/shm.h>
 +#endif
 +
 +#ifdef SYSVMSG
 +#include <sys/msg.h>
 +#endif
 +
  #include <sys/syscallargs.h>

  #include <compat/osf1/osf1.h>
  #include <compat/osf1/osf1_syscallargs.h>
  #include <compat/osf1/osf1_cvt.h>

 +#ifdef SYSVMSG
 +static void msqid_osf1_to_native (struct osf1_msqid_ds *, struct msqid_ds *);
 +static void native_to_msqid_osf1 (struct msqid_ds *, struct osf1_msqid_ds *);
 +static void ipc_permosf1_to_native (struct osf1_ipc_perm *, struct ipc_perm *);
 +static void native_to_ipc_permosf1 (struct ipc_perm *, struct osf1_ipc_perm *);
 +#endif
 +
 +#ifdef SYSVSEM
 +int     
 +osf1_sys_semctl(p, v, retval)
 +        struct proc *p;
 +        void *v;
 +        register_t *retval;
 +{
 +        /* XXX */
 +        return (ENOSYS);
 +}
 +
 +int     
 +osf1_sys_semget(p, v, retval)
 +        struct proc *p;
 +        void *v;
 +        register_t *retval;
 +{
 +        /* XXX */                     
 +        return (ENOSYS);
 +}
 +
 +int
 +osf1_sys_semop(p, v, retval)
 +        struct proc *p;
 +        void *v;
 +        register_t *retval;
 +{
 +        /* XXX */
 +        return (ENOSYS);
 +}
 +#endif
 +
 +#ifdef SYSVSHM
  int
  osf1_sys_shmat(p, v, retval)
  	struct proc *p;
  	void *v;
  	register_t *retval;
  {
 -
  	/* XXX */
  	return (ENOSYS);
  }
 @@ -62,7 +122,6 @@
  	void *v;
  	register_t *retval;
  {
 -
  	/* XXX */
  	return (ENOSYS);
  }
 @@ -73,7 +132,6 @@
  	void *v;
  	register_t *retval;
  {
 -
  	/* XXX */
  	return (ENOSYS);
  }
 @@ -84,7 +142,195 @@
  	void *v;
  	register_t *retval;
  {
 -
  	/* XXX */
  	return (ENOSYS);
  }
 +#endif
 +
 +#ifdef SYSVMSG
 +int
 +osf1_sys_msgget(p, v, retval)
 +	struct proc *p;
 +	void *v;
 +	register_t *retval;
 +{
 +	struct osf1_sys_msgget_args *uap = v;
 +	struct sys_msgget_args a;
 +	int error;
 +
 +	SCARG(&a, key) = SCARG(uap, key);
 +	SCARG(&a, msgflg) = SCARG(uap, msgflg);
 +
 +	error = sys_msgget(p, &a, retval);
 +
 +	return (error);
 +}
 +
 +/*
 + * Startling how similar this all is to compat_14_sys_msgctl, isn't it?
 + */
 +
 +static void 
 +msqid_osf1_to_native (omsqbuf, msqbuf)
 +	struct osf1_msqid_ds *omsqbuf; 
 +	struct msqid_ds *msqbuf;
 +{
 +	ipc_permosf1_to_native(&omsqbuf->msg_perm, &msqbuf->msg_perm); 
 +
 +#define CVT(x) msqbuf->x = omsqbuf->x
 +	CVT(msg_qnum);
 +	CVT(msg_qbytes);
 +	CVT(msg_lspid);
 +	CVT(msg_lrpid);
 +	CVT(msg_stime);
 +	CVT(msg_rtime);
 +	CVT(msg_ctime);
 +	/* XXX what about msg_first and msg_last? */
 +	/* XXX what about msg_wait_list? */
 +	/* XXX what about msg_secattr? */
 +#undef CVT
 +
 +	msqbuf->_msg_cbytes = omsqbuf->msg_cbytes;
 +
 +	return;
 +}
 +
 +static void 
 +native_to_msqid_osf1 (msqbuf, omsqbuf)
 +	struct msqid_ds *msqbuf;
 +	struct osf1_msqid_ds *omsqbuf; 
 +{
 +	native_to_ipc_permosf1(&msqbuf->msg_perm, &omsqbuf->msg_perm); 
 +
 +#define CVT(x) omsqbuf->x = msqbuf->x
 +	CVT(msg_qnum);
 +	CVT(msg_qbytes);
 +	CVT(msg_lspid);
 +	CVT(msg_lrpid);
 +	CVT(msg_stime);
 +	CVT(msg_rtime);
 +	CVT(msg_ctime);
 +	/* XXX what about msg_first and msg_last? */
 +	/* XXX what about msg_wait_list? */
 +	/* XXX what about msg_secattr? */
 +#undef CVT
 +
 +	omsqbuf->msg_cbytes = msqbuf->_msg_cbytes;
 +
 +	return;
 +}
 +
 +static void
 +ipc_permosf1_to_native (operm, perm)
 +	struct osf1_ipc_perm *operm;
 +	struct ipc_perm *perm;
 +{
 +#define CVT(x)  perm->x = operm->x
 +	CVT(uid);
 +	CVT(gid);
 +	CVT(cuid);
 +	CVT(cgid);
 +	CVT(mode);
 +#undef CVT
 +
 +	return;
 +}
 +
 +static void
 +native_to_ipc_permosf1 (perm, operm)
 +	struct ipc_perm *perm;
 +	struct osf1_ipc_perm *operm;
 +{
 +#define CVT(x)  operm->x = perm->x    
 +	CVT(uid);
 +	CVT(gid);
 +	CVT(cuid);
 +	CVT(cgid);
 +	CVT(mode); /* XXX OSF/1 IPC_ALLOC, IPC_RESERVED? */
 +#undef CVT
 +
 +	/*
 +	 * Not part of the API, but some programs might look at it.     
 +	 */
 +	operm->seq = perm->_seq;      
 +	operm->key = perm->_key;      
 +
 +	return;
 +}
 +
 +int
 +osf1_sys_msgctl(p, v, retval)
 +	struct proc *p;
 +	void *v;
 +	register_t *retval;
 +{
 +	struct osf1_sys_msgctl_args *uap = v;
 +	struct osf1_msqid_ds omsqbuf;
 +	struct msqid_ds msqbuf;
 +	int ocmd;
 +	int cmd;
 +	int error;
 +
 +	ocmd = SCARG(uap, cmd);
 +
 +	cmd = ocmd; /* XXX same, for now. */
 +	if (ocmd == OSF1_IPC_SET) {
 +		error = copyin(SCARG(uap, buf), &omsqbuf, sizeof(omsqbuf));
 +		if (error)
 +			return (error);
 +		msqid_osf1_to_native(&omsqbuf, &msqbuf);
 +	}
 +
 +	error = msgctl1(p, SCARG(uap, msqid), cmd, 
 +	    (ocmd == OSF1_IPC_SET || ocmd == OSF1_IPC_STAT) ? &msqbuf : NULL);
 +
 +	if (error == 0 && ocmd == OSF1_IPC_STAT) {
 +		native_to_msqid_osf1(&msqbuf, &omsqbuf);
 +		error = copyout(&omsqbuf, SCARG(uap, buf), sizeof(omsqbuf));
 +	}
 +
 +	return (error);
 +}
 +
 +/* XXX watch out for differences in behavior if a signal is caught (or not). */
 +int
 +osf1_sys_msgrcv(p, v, retval)
 +	struct proc *p;
 +	void *v;
 +	register_t *retval;
 +{
 +	struct osf1_sys_msgrcv_args *uap = v;
 +	struct sys_msgrcv_args a; 
 +	int error;
 +
 +	SCARG(&a, msqid) = SCARG(uap, msqid);
 +	SCARG(&a, msgp) = SCARG(uap, msgp);
 +	SCARG(&a, msgsz) = SCARG(uap, msgsz);
 +	SCARG(&a, msgtyp) = SCARG(uap, msgtyp);
 +	SCARG(&a, msgflg) = SCARG(uap, msgflg);
 +
 +        error = sys_msgrcv(p, &a, retval);
 +
 +	return (error);
 +}
 +
 +int
 +osf1_sys_msgsnd(p, v, retval)
 +	struct proc *p;
 +	void *v;
 +	register_t *retval;
 +{
 +	struct osf1_sys_msgsnd_args *uap = v;
 +	struct sys_msgsnd_args a;
 +	int error;
 +
 +	SCARG(&a, msqid) = SCARG(uap, msqid);
 +	SCARG(&a, msgp) = SCARG(uap, msgp);
 +	SCARG(&a, msgsz) = SCARG(uap, msgsz);
 +	SCARG(&a, msgflg) = SCARG(uap, msgflg);
 +
 +	error = sys_msgsnd(p, &a, retval);
 +
 +	return (error);
 +}
 +#endif

 --- syscalls.master.orig	Tue Oct 22 23:31:35 2002
 +++ syscalls.master	Sun Oct 20 23:39:07 2002
 @@ -33,6 +33,7 @@

  #if defined(_KERNEL_OPT)
  #include "opt_compat_43.h"
 +#include "opt_sysv.h"
  #endif

  #include <sys/param.h>
 @@ -312,16 +313,36 @@
  197	UNIMPL
  198	UNIMPL
  199	UNIMPL		swapon
 -200	UNIMPL		msgctl
 -201	UNIMPL		msgget
 -202	UNIMPL		msgrcv
 -203	UNIMPL		msgsnd
 -204	UNIMPL		semctl
 -205	UNIMPL		semget
 -206	UNIMPL		semop
 +#ifdef SYSVMSG
 +200	STD		{ int osf1_sys_msgctl(int msqid, int cmd, \
 +			    struct osf1_msqid_ds *buf); }  
 +201	STD		{ int osf1_sys_msgget(osf1_key_t key, int msgflg); }
 +202	STD		{ ssize_t osf1_sys_msgrcv(int msqid, void *msgp, \
 +			    size_t msgsz, long msgtyp, int msgflg); }   
 +203	STD		{ int osf1_sys_msgsnd(int msqid, const void *msgp, \
 +			    size_t msgsz, int msgflg); }
 +#else
 +200	EXCL		msgctl
 +201	EXCL		msgget
 +202	EXCL		msgrcv
 +203	EXCL		msgsnd
 +#endif
 +#ifdef SYSVSEM
 +204	STD		{ int osf1_sys_semctl(int semid, int semnum, \
 +			    int cmd, union osf1_semun *arg); }
 +205	STD		{ int osf1_sys_semget(osf1_key_t key, int nsems, \
 +			    int semflg); }
 +206	STD		{ int osf1_sys_semop(int semid, \
 +			    struct osf1_sembuf *sops, size_t nsops); }  
 +#else
 +204	EXCL		semctl
 +205	EXCL		semget
 +206	EXCL		semop
 +#endif
  207	STD		{ int osf1_sys_uname(struct osf1_uname *name); }
  208	NOARGS		{ int sys___posix_lchown(const char *path, int uid, \
  			    int gid); }
 +#ifdef SYSVSHM
  209	STD		{ void *osf1_sys_shmat(int shmid, \
  			    const void *shmaddr, int shmflg); }
  210	STD		{ int osf1_sys_shmctl(int shmid, int cmd, \
 @@ -329,6 +350,12 @@
  211	STD		{ int osf1_sys_shmdt(const void *shmaddr); }
  212	STD		{ int osf1_sys_shmget(osf1_key_t key, size_t size, \
  			    int flags); } 
 +#else
 +209	EXCL		shmat
 +210	EXCL		shmctl
 +211	EXCL		shmdt
 +212	EXCL		shmget
 +#endif
  213	UNIMPL		mvalid
  214	UNIMPL		getaddressconf
  215	UNIMPL		msleep

State-Changed-From-To: open->closed
State-Changed-By: maxv@NetBSD.org
State-Changed-When: Mon, 10 Jun 2019 06:37:33 +0000
State-Changed-Why:
compat_osf1 was removed several months ago...


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.