Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/hpux Completely rewrite the HP-UX SVID IPC compat...



details:   https://anonhg.NetBSD.org/src/rev/d1439d113664
branches:  trunk
changeset: 475763:d1439d113664
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Aug 25 04:50:08 1999 +0000

description:
Completely rewrite the HP-UX SVID IPC compat calls.

diffstat:

 sys/compat/hpux/files.hpux    |    3 +-
 sys/compat/hpux/hpux.h        |   31 +--
 sys/compat/hpux/hpux_compat.c |  104 +-------
 sys/compat/hpux/hpux_ipc.c    |  611 ++++++++++++++++++++++++++++++++++++++++++
 sys/compat/hpux/hpux_ipc.h    |  180 ++++++++++++
 5 files changed, 795 insertions(+), 134 deletions(-)

diffs (truncated from 986 to 300 lines):

diff -r d402bc15f384 -r d1439d113664 sys/compat/hpux/files.hpux
--- a/sys/compat/hpux/files.hpux        Wed Aug 25 04:48:48 1999 +0000
+++ b/sys/compat/hpux/files.hpux        Wed Aug 25 04:50:08 1999 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.hpux,v 1.5 1998/11/05 12:42:46 frueauf Exp $
+#      $NetBSD: files.hpux,v 1.6 1999/08/25 04:50:08 thorpej Exp $
 #
 # Config file description for machine-independent HPUX compat code.
 # Included by ports that need it.
@@ -10,6 +10,7 @@
 file   compat/hpux/hpux_file.c         compat_hpux
 file   compat/hpux/hpux_errno.c        compat_hpux
 file   compat/hpux/hpux_exec.c         compat_hpux
+file   compat/hpux/hpux_ipc.c          compat_hpux
 file   compat/hpux/hpux_net.c          compat_hpux
 file   compat/hpux/hpux_sig.c          compat_hpux
 file   compat/hpux/hpux_syscalls.c     compat_hpux
diff -r d402bc15f384 -r d1439d113664 sys/compat/hpux/hpux.h
--- a/sys/compat/hpux/hpux.h    Wed Aug 25 04:48:48 1999 +0000
+++ b/sys/compat/hpux/hpux.h    Wed Aug 25 04:50:08 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hpux.h,v 1.14 1998/10/01 06:35:09 thorpej Exp $        */
+/*     $NetBSD: hpux.h,v 1.15 1999/08/25 04:50:08 thorpej Exp $        */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -259,35 +259,6 @@
 #define HPUXF_WRLCK    2
 #define HPUXF_UNLCK    3
 
-/* HP-UX only sysV shmctl() commands */
-#define SHM_LOCK       3       /* Lock segment in core */
-#define SHM_UNLOCK     4       /* Unlock segment */
-
-/* SHM stuff reflecting POSIX types */
-struct hpux_ipc_perm {
-       long    uid;    /* owner's user id */
-       long    gid;    /* owner's group id */
-       long    cuid;   /* creator's user id */
-       long    cgid;   /* creator's group id */
-       u_short mode;   /* access modes */
-       u_short seq;    /* slot usage sequence number */
-       long    key;    /* key */
-};
-
-struct hpux_shmid_ds {
-       struct hpux_ipc_perm shm_perm;  /* operation permission struct */
-       int             shm_segsz;      /* segment size (bytes) */
-       struct pte      *shm_ptbl;      /* ptr to associated page table */
-       long            shm_lpid;       /* pid of last shmop */
-       long            shm_cpid;       /* pid of creator */
-       u_short         shm_nattch;     /* current # attached */
-       u_short         shm_cnattch;    /* in memory # attached */
-       time_t          shm_atime;      /* last shmat time */
-       time_t          shm_dtime;      /* last shmdt time */
-       time_t          shm_ctime;      /* last change time */
-       /* actually longer */
-};
-
 /* HP-UX rtprio values */
 #define RTPRIO_MIN     0
 #define RTPRIO_MAX     127
diff -r d402bc15f384 -r d1439d113664 sys/compat/hpux/hpux_compat.c
--- a/sys/compat/hpux/hpux_compat.c     Wed Aug 25 04:48:48 1999 +0000
+++ b/sys/compat/hpux/hpux_compat.c     Wed Aug 25 04:50:08 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hpux_compat.c,v 1.44 1998/12/10 17:13:07 christos Exp $        */
+/*     $NetBSD: hpux_compat.c,v 1.45 1999/08/25 04:50:08 thorpej Exp $ */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -102,8 +102,6 @@
 extern struct sysent hpux_sysent[];
 extern char *hpux_syscallnames[];
 
-int    hpux_shmctl1 __P((struct proc *, struct hpux_sys_shmctl_args *,
-           register_t *, int));
 int    hpuxtobsdioctl __P((u_long));
 
 static int     hpux_scale __P((struct timeval *));
@@ -670,106 +668,6 @@
 }
 #endif
 
-#ifdef SYSVSHM
-#include <sys/shm.h>
-
-int
-hpux_sys_shmctl(p, v, retval)
-       struct proc *p;
-       void *v;
-       register_t *retval;
-{
-       struct hpux_sys_shmctl_args *uap = v;
-
-       return (hpux_shmctl1(p, (struct hpux_sys_shmctl_args *)uap, retval, 0));
-}
-
-int
-hpux_sys_nshmctl(p, v, retval)
-       struct proc *p;
-       void *v;
-       register_t *retval;     /* struct hpux_nshmctl_args * */
-{
-       struct hpux_sys_nshmctl_args *uap = v;
-
-       return (hpux_shmctl1(p, (struct hpux_sys_shmctl_args *)uap, retval, 1));
-}
-
-/*
- * Handle HP-UX specific commands.
- */
-int
-hpux_shmctl1(p, uap, retval, isnew)
-       struct proc *p;
-       struct hpux_sys_shmctl_args *uap;
-       register_t *retval;
-       int isnew;
-{
-       struct shmid_ds *shp;
-       struct ucred *cred = p->p_ucred;
-       struct hpux_shmid_ds sbuf;
-       int error;
-       extern struct shmid_ds *shm_find_segment_by_shmid __P((int));
-
-       if ((shp = shm_find_segment_by_shmid(SCARG(uap, shmid))) == NULL)
-               return EINVAL;
-
-       switch (SCARG(uap, cmd)) {
-       case SHM_LOCK:
-       case SHM_UNLOCK:
-               /* don't really do anything, but make them think we did */
-               if (cred->cr_uid && cred->cr_uid != shp->shm_perm.uid &&
-                   cred->cr_uid != shp->shm_perm.cuid)
-                       return (EPERM);
-               return (0);
-
-       case IPC_STAT:
-               if (!isnew)
-                       break;
-               error = ipcperm(cred, &shp->shm_perm, IPC_R);
-               if (error == 0) {
-                       sbuf.shm_perm.uid = shp->shm_perm.uid;
-                       sbuf.shm_perm.gid = shp->shm_perm.gid;
-                       sbuf.shm_perm.cuid = shp->shm_perm.cuid;
-                       sbuf.shm_perm.cgid = shp->shm_perm.cgid;
-                       sbuf.shm_perm.mode = shp->shm_perm.mode;
-                       sbuf.shm_perm.seq = shp->shm_perm.seq;
-                       sbuf.shm_perm.key = shp->shm_perm.key;
-                       sbuf.shm_segsz = shp->shm_segsz;
-                       sbuf.shm_ptbl = shp->shm_internal;      /* XXX */
-                       sbuf.shm_lpid = shp->shm_lpid;
-                       sbuf.shm_cpid = shp->shm_cpid;
-                       sbuf.shm_nattch = shp->shm_nattch;
-                       sbuf.shm_cnattch = shp->shm_nattch;     /* XXX */
-                       sbuf.shm_atime = shp->shm_atime;
-                       sbuf.shm_dtime = shp->shm_dtime;
-                       sbuf.shm_ctime = shp->shm_ctime;
-                       error = copyout((caddr_t)&sbuf, SCARG(uap, buf),
-                           sizeof sbuf);
-               }
-               return (error);
-
-       case IPC_SET:
-               if (!isnew)
-                       break;
-               if (cred->cr_uid && cred->cr_uid != shp->shm_perm.uid &&
-                   cred->cr_uid != shp->shm_perm.cuid) {
-                       return (EPERM);
-               }
-               error = copyin(SCARG(uap, buf), (caddr_t)&sbuf, sizeof sbuf);
-               if (error == 0) {
-                       shp->shm_perm.uid = sbuf.shm_perm.uid;
-                       shp->shm_perm.gid = sbuf.shm_perm.gid;
-                       shp->shm_perm.mode = (shp->shm_perm.mode & ~0777)
-                               | (sbuf.shm_perm.mode & 0777);
-                       shp->shm_ctime = time.tv_sec;
-               }
-               return (error);
-       }
-       return (sys_shmctl(p, uap, retval));
-}
-#endif
-
 /*
  * HP-UX mmap() emulation (mainly for shared library support).
  */
diff -r d402bc15f384 -r d1439d113664 sys/compat/hpux/hpux_ipc.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/hpux/hpux_ipc.c        Wed Aug 25 04:50:08 1999 +0000
@@ -0,0 +1,611 @@
+/*     $NetBSD: hpux_ipc.c,v 1.1 1999/08/25 04:50:08 thorpej Exp $     */
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the NetBSD
+ *     Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * HP-UX System V IPC compatibility module.
+ *
+ * The HP-UX System V IPC calls are essentially compatible with the
+ * native NetBSD calls; the flags, commands, and data types are the same.
+ * The only differences are the structures used for IPC_SET and IPC_STAT.
+ *
+ * HP-UX has both `old' (before HP-UX A8.00) and `new' variants of these
+ * calls.
+ */
+
+#include "opt_sysv.h"
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/shm.h>
+#include <sys/msg.h>
+#include <sys/sem.h>
+#include <sys/proc.h>
+#include <sys/systm.h>
+
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+#include <compat/hpux/hpux.h>
+#include <compat/hpux/hpux_types.h>
+#include <compat/hpux/hpux_ipc.h>
+#include <compat/hpux/hpux_syscallargs.h>
+
+#if defined(SYSVMSG) || defined(SYSVSEM) || defined(SYSVSHM)
+void   bsd_to_hpux_ipc_perm __P((const struct ipc_perm *,
+           struct hpux_ipc_perm *));
+void   bsd_to_hpux_oipc_perm __P((const struct ipc_perm *,
+           struct hpux_oipc_perm *));
+void   hpux_to_bsd_ipc_perm __P((const struct hpux_ipc_perm *,
+           struct ipc_perm *));
+void   hpux_to_bsd_oipc_perm __P((const struct hpux_oipc_perm *,
+           struct ipc_perm *));
+
+void
+bsd_to_hpux_ipc_perm(bp, hp)
+       const struct ipc_perm *bp;
+       struct hpux_ipc_perm *hp;
+{
+
+       hp->uid = bp->uid;
+       hp->gid = bp->gid;
+       hp->cuid = bp->cuid;
+       hp->cgid = bp->cgid;
+       hp->mode = bp->mode;
+       hp->seq = bp->_seq;
+       hp->key = bp->_key;
+}
+
+void
+bsd_to_hpux_oipc_perm(bp, hp)
+       const struct ipc_perm *bp;
+       struct hpux_oipc_perm *hp;
+{
+
+       hp->uid = bp->uid;
+       hp->gid = bp->gid;
+       hp->cuid = bp->cuid;
+       hp->cgid = bp->cgid;
+       hp->mode = bp->mode;
+       hp->seq = bp->_seq;
+       hp->key = bp->_key;
+}
+
+void



Home | Main Index | Thread Index | Old Index