Completely rewrite the HP-UX SVID IPC compat calls.
This commit is contained in:
parent
c1f3fb3299
commit
0d32655143
@ -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_compat.c compat_hpux
|
||||
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
|
||||
|
@ -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 @@ struct hpux_flock {
|
||||
#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
|
||||
|
@ -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 char sigcode[], esigcode[];
|
||||
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 @@ hpux_sys_ptrace(p, v, retval)
|
||||
}
|
||||
#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).
|
||||
*/
|
||||
|
611
sys/compat/hpux/hpux_ipc.c
Normal file
611
sys/compat/hpux/hpux_ipc.c
Normal file
@ -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
|
||||
hpux_to_bsd_ipc_perm(hp, bp)
|
||||
const struct hpux_ipc_perm *hp;
|
||||
struct ipc_perm *bp;
|
||||
{
|
||||
|
||||
bp->uid = hp->uid;
|
||||
bp->gid = hp->gid;
|
||||
bp->cuid = hp->cuid;
|
||||
bp->cgid = hp->cgid;
|
||||
bp->mode = hp->mode;
|
||||
bp->_seq = hp->seq;
|
||||
bp->_key = hp->key;
|
||||
}
|
||||
|
||||
void
|
||||
hpux_to_bsd_oipc_perm(hp, bp)
|
||||
const struct hpux_oipc_perm *hp;
|
||||
struct ipc_perm *bp;
|
||||
{
|
||||
|
||||
bp->uid = hp->uid;
|
||||
bp->gid = hp->gid;
|
||||
bp->cuid = hp->cuid;
|
||||
bp->cgid = hp->cgid;
|
||||
bp->mode = hp->mode;
|
||||
bp->_seq = hp->seq;
|
||||
bp->_key = hp->key;
|
||||
}
|
||||
#endif /* SYSVMSG || SYSVSEM || SYSVSHM */
|
||||
|
||||
#ifdef SYSVMSG
|
||||
void bsd_to_hpux_msqid_ds __P((const struct msqid_ds *,
|
||||
struct hpux_msqid_ds *));
|
||||
void bsd_to_hpux_omsqid_ds __P((const struct msqid_ds *,
|
||||
struct hpux_omsqid_ds *));
|
||||
|
||||
void hpux_to_bsd_msqid_ds __P((const struct hpux_msqid_ds *,
|
||||
struct msqid_ds *));
|
||||
void hpux_to_bsd_omsqid_ds __P((const struct hpux_omsqid_ds *,
|
||||
struct msqid_ds *));
|
||||
|
||||
void
|
||||
bsd_to_hpux_msqid_ds(bp, hp)
|
||||
const struct msqid_ds *bp;
|
||||
struct hpux_msqid_ds *hp;
|
||||
{
|
||||
|
||||
bsd_to_hpux_ipc_perm(&bp->msg_perm, &hp->msg_perm);
|
||||
hp->msg_first = bp->_msg_first;
|
||||
hp->msg_last = bp->_msg_last;
|
||||
hp->msg_qnum = bp->msg_qnum;
|
||||
hp->msg_qbytes = bp->msg_qbytes;
|
||||
hp->msg_lspid = bp->msg_lspid;
|
||||
hp->msg_lrpid = bp->msg_lrpid;
|
||||
hp->msg_stime = bp->msg_stime;
|
||||
hp->msg_rtime = bp->msg_rtime;
|
||||
hp->msg_ctime = bp->msg_ctime;
|
||||
hp->msg_cbytes = bp->_msg_cbytes;
|
||||
}
|
||||
|
||||
void
|
||||
bsd_to_hpux_omsqid_ds(bp, hp)
|
||||
const struct msqid_ds *bp;
|
||||
struct hpux_omsqid_ds *hp;
|
||||
{
|
||||
|
||||
bsd_to_hpux_oipc_perm(&bp->msg_perm, &hp->msg_perm);
|
||||
hp->msg_first = bp->_msg_first;
|
||||
hp->msg_last = bp->_msg_last;
|
||||
hp->msg_cbytes = bp->_msg_cbytes;
|
||||
hp->msg_qnum = bp->msg_qnum;
|
||||
hp->msg_qbytes = bp->msg_qbytes;
|
||||
hp->msg_lspid = bp->msg_lspid;
|
||||
hp->msg_lrpid = bp->msg_lrpid;
|
||||
hp->msg_rtime = bp->msg_rtime;
|
||||
hp->msg_ctime = bp->msg_ctime;
|
||||
}
|
||||
|
||||
void
|
||||
hpux_to_bsd_msqid_ds(hp, bp)
|
||||
const struct hpux_msqid_ds *hp;
|
||||
struct msqid_ds *bp;
|
||||
{
|
||||
|
||||
hpux_to_bsd_ipc_perm(&hp->msg_perm, &bp->msg_perm);
|
||||
bp->msg_qnum = hp->msg_qnum;
|
||||
bp->msg_qbytes = hp->msg_qbytes;
|
||||
bp->msg_lspid = hp->msg_lspid;
|
||||
bp->msg_lrpid = hp->msg_lrpid;
|
||||
bp->msg_stime = hp->msg_stime;
|
||||
bp->msg_rtime = hp->msg_rtime;
|
||||
bp->msg_ctime = hp->msg_ctime;
|
||||
bp->_msg_first = hp->msg_first;
|
||||
bp->_msg_last = hp->msg_last;
|
||||
bp->_msg_cbytes = hp->msg_cbytes;
|
||||
}
|
||||
|
||||
void
|
||||
hpux_to_bsd_omsqid_ds(hp, bp)
|
||||
const struct hpux_omsqid_ds *hp;
|
||||
struct msqid_ds *bp;
|
||||
{
|
||||
|
||||
hpux_to_bsd_oipc_perm(&hp->msg_perm, &bp->msg_perm);
|
||||
bp->msg_qnum = hp->msg_qnum;
|
||||
bp->msg_qbytes = hp->msg_qbytes;
|
||||
bp->msg_lspid = hp->msg_lspid;
|
||||
bp->msg_lrpid = hp->msg_lrpid;
|
||||
bp->msg_stime = hp->msg_stime;
|
||||
bp->msg_rtime = hp->msg_rtime;
|
||||
bp->msg_ctime = hp->msg_ctime;
|
||||
bp->_msg_first = hp->msg_first;
|
||||
bp->_msg_last = hp->msg_last;
|
||||
bp->_msg_cbytes = hp->msg_cbytes;
|
||||
}
|
||||
|
||||
int
|
||||
hpux_sys_omsgctl(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
struct hpux_sys_omsgctl_args /* {
|
||||
syscallarg(int) msqid;
|
||||
syscallarg(int) cmd;
|
||||
syscallarg(struct hpux_omsqid_ds *) buf;
|
||||
} */ *uap = v;
|
||||
struct msqid_ds msqbuf;
|
||||
struct hpux_omsqid_ds hmsqbuf;
|
||||
int cmd, error;
|
||||
|
||||
cmd = SCARG(uap, cmd);
|
||||
|
||||
if (cmd == IPC_SET) {
|
||||
error = copyin(SCARG(uap, buf), &hmsqbuf, sizeof(hmsqbuf));
|
||||
if (error)
|
||||
return (error);
|
||||
hpux_to_bsd_omsqid_ds(&hmsqbuf, &msqbuf);
|
||||
}
|
||||
|
||||
error = msgctl1(p, SCARG(uap, msqid), cmd,
|
||||
(cmd == IPC_SET || cmd == IPC_STAT) ? &msqbuf : NULL);
|
||||
|
||||
if (error == 0 && cmd == IPC_STAT) {
|
||||
bsd_to_hpux_omsqid_ds(&msqbuf, &hmsqbuf);
|
||||
error = copyout(&hmsqbuf, SCARG(uap, buf), sizeof(hmsqbuf));
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
hpux_sys_msgctl(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
struct hpux_sys_msgctl_args /* {
|
||||
syscallarg(int) msqid;
|
||||
syscallarg(int) cmd;
|
||||
syscallarg(struct hpux_msqid_ds *) buf;
|
||||
} */ *uap = v;
|
||||
struct msqid_ds msqbuf;
|
||||
struct hpux_msqid_ds hmsqbuf;
|
||||
int cmd, error;
|
||||
|
||||
cmd = SCARG(uap, cmd);
|
||||
|
||||
if (cmd == IPC_SET) {
|
||||
error = copyin(SCARG(uap, buf), &hmsqbuf, sizeof(hmsqbuf));
|
||||
if (error)
|
||||
return (error);
|
||||
hpux_to_bsd_msqid_ds(&hmsqbuf, &msqbuf);
|
||||
}
|
||||
|
||||
error = msgctl1(p, SCARG(uap, msqid), cmd,
|
||||
(cmd == IPC_SET || cmd == IPC_STAT) ? &msqbuf : NULL);
|
||||
|
||||
if (error == 0 && cmd == IPC_STAT) {
|
||||
bsd_to_hpux_msqid_ds(&msqbuf, &hmsqbuf);
|
||||
error = copyout(&hmsqbuf, SCARG(uap, buf), sizeof(hmsqbuf));
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
#endif /* SYSVMSG */
|
||||
|
||||
#ifdef SYSVSEM
|
||||
void bsd_to_hpux_semid_ds __P((const struct semid_ds *,
|
||||
struct hpux_semid_ds *));
|
||||
void bsd_to_hpux_osemid_ds __P((const struct semid_ds *,
|
||||
struct hpux_osemid_ds *));
|
||||
|
||||
void hpux_to_bsd_semid_ds __P((const struct hpux_semid_ds *,
|
||||
struct semid_ds *));
|
||||
void hpux_to_bsd_osemid_ds __P((const struct hpux_osemid_ds *,
|
||||
struct semid_ds *));
|
||||
|
||||
void
|
||||
bsd_to_hpux_semid_ds(bp, hp)
|
||||
const struct semid_ds *bp;
|
||||
struct hpux_semid_ds *hp;
|
||||
{
|
||||
|
||||
bsd_to_hpux_ipc_perm(&bp->sem_perm, &hp->sem_perm);
|
||||
hp->sem_base = bp->_sem_base;
|
||||
hp->sem_otime = bp->sem_otime;
|
||||
hp->sem_ctime = bp->sem_ctime;
|
||||
hp->sem_nsems = bp->sem_nsems;
|
||||
}
|
||||
|
||||
void
|
||||
bsd_to_hpux_osemid_ds(bp, hp)
|
||||
const struct semid_ds *bp;
|
||||
struct hpux_osemid_ds *hp;
|
||||
{
|
||||
|
||||
bsd_to_hpux_oipc_perm(&bp->sem_perm, &hp->sem_perm);
|
||||
hp->sem_base = bp->_sem_base;
|
||||
hp->sem_otime = bp->sem_otime;
|
||||
hp->sem_ctime = bp->sem_ctime;
|
||||
hp->sem_nsems = bp->sem_nsems;
|
||||
}
|
||||
|
||||
void
|
||||
hpux_to_bsd_semid_ds(hp, bp)
|
||||
const struct hpux_semid_ds *hp;
|
||||
struct semid_ds *bp;
|
||||
{
|
||||
|
||||
hpux_to_bsd_ipc_perm(&hp->sem_perm, &bp->sem_perm);
|
||||
bp->sem_nsems = hp->sem_nsems;
|
||||
bp->sem_otime = hp->sem_otime;
|
||||
bp->sem_ctime = hp->sem_ctime;
|
||||
bp->_sem_base = hp->sem_base;
|
||||
}
|
||||
|
||||
void
|
||||
hpux_to_bsd_osemid_ds(hp, bp)
|
||||
const struct hpux_osemid_ds *hp;
|
||||
struct semid_ds *bp;
|
||||
{
|
||||
|
||||
hpux_to_bsd_oipc_perm(&hp->sem_perm, &bp->sem_perm);
|
||||
bp->sem_nsems = hp->sem_nsems;
|
||||
bp->sem_otime = hp->sem_otime;
|
||||
bp->sem_ctime = hp->sem_ctime;
|
||||
bp->_sem_base = hp->sem_base;
|
||||
}
|
||||
|
||||
int
|
||||
hpux_sys_osemctl(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
struct hpux_sys_osemctl_args /* {
|
||||
syscallarg(int) semid;
|
||||
syscallarg(int) semnum;
|
||||
syscallarg(int) cmd;
|
||||
syscallarg(union __semun) arg;
|
||||
} */ *uap = v;
|
||||
struct hpux_osemid_ds hsembuf;
|
||||
struct semid_ds sembuf;
|
||||
int cmd, error;
|
||||
void *pass_arg = NULL;
|
||||
|
||||
cmd = SCARG(uap, cmd);
|
||||
|
||||
switch (cmd) {
|
||||
case IPC_SET:
|
||||
case IPC_STAT:
|
||||
pass_arg = &sembuf;
|
||||
break;
|
||||
|
||||
case GETALL:
|
||||
case SETVAL:
|
||||
case SETALL:
|
||||
pass_arg = &SCARG(uap, arg);
|
||||
break;
|
||||
}
|
||||
|
||||
if (cmd == IPC_SET) {
|
||||
error = copyin(SCARG(uap, arg).buf, &hsembuf, sizeof(hsembuf));
|
||||
if (error)
|
||||
return (error);
|
||||
hpux_to_bsd_osemid_ds(&hsembuf, &sembuf);
|
||||
}
|
||||
|
||||
error = semctl1(p, SCARG(uap, semid), SCARG(uap, semnum), cmd,
|
||||
pass_arg, retval);
|
||||
|
||||
if (error == 0 && cmd == IPC_STAT) {
|
||||
bsd_to_hpux_osemid_ds(&sembuf, &hsembuf);
|
||||
error = copyout(&hsembuf, SCARG(uap, arg).buf, sizeof(hsembuf));
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
hpux_sys_semctl(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
struct hpux_sys_semctl_args /* {
|
||||
syscallarg(int) semid;
|
||||
syscallarg(int) semnum;
|
||||
syscallarg(int) cmd;
|
||||
syscallarg(union __semun) arg;
|
||||
} */ *uap = v;
|
||||
struct hpux_semid_ds hsembuf;
|
||||
struct semid_ds sembuf;
|
||||
int cmd, error;
|
||||
void *pass_arg = NULL;
|
||||
|
||||
cmd = SCARG(uap, cmd);
|
||||
|
||||
switch (cmd) {
|
||||
case IPC_SET:
|
||||
case IPC_STAT:
|
||||
pass_arg = &sembuf;
|
||||
break;
|
||||
|
||||
case GETALL:
|
||||
case SETVAL:
|
||||
case SETALL:
|
||||
pass_arg = &SCARG(uap, arg);
|
||||
break;
|
||||
}
|
||||
|
||||
if (cmd == IPC_SET) {
|
||||
error = copyin(SCARG(uap, arg).buf, &hsembuf, sizeof(hsembuf));
|
||||
if (error)
|
||||
return (error);
|
||||
hpux_to_bsd_semid_ds(&hsembuf, &sembuf);
|
||||
}
|
||||
|
||||
error = semctl1(p, SCARG(uap, semid), SCARG(uap, semnum), cmd,
|
||||
pass_arg, retval);
|
||||
|
||||
if (error == 0 && cmd == IPC_STAT) {
|
||||
bsd_to_hpux_semid_ds(&sembuf, &hsembuf);
|
||||
error = copyout(&hsembuf, SCARG(uap, arg).buf, sizeof(hsembuf));
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
#endif /* SYSVSEM */
|
||||
|
||||
#ifdef SYSVSHM
|
||||
void bsd_to_hpux_shmid_ds __P((const struct shmid_ds *,
|
||||
struct hpux_shmid_ds *));
|
||||
void bsd_to_hpux_oshmid_ds __P((const struct shmid_ds *,
|
||||
struct hpux_oshmid_ds *));
|
||||
|
||||
void hpux_to_bsd_shmid_ds __P((const struct hpux_shmid_ds *,
|
||||
struct shmid_ds *));
|
||||
void hpux_to_bsd_oshmid_ds __P((const struct hpux_oshmid_ds *,
|
||||
struct shmid_ds *));
|
||||
|
||||
void
|
||||
bsd_to_hpux_shmid_ds(bp, hp)
|
||||
const struct shmid_ds *bp;
|
||||
struct hpux_shmid_ds *hp;
|
||||
{
|
||||
|
||||
bsd_to_hpux_ipc_perm(&bp->shm_perm, &hp->shm_perm);
|
||||
hp->shm_segsz = bp->shm_segsz;
|
||||
hp->shm_vas = NULL;
|
||||
hp->shm_lpid = bp->shm_lpid;
|
||||
hp->shm_cpid = bp->shm_cpid;
|
||||
hp->shm_nattch = bp->shm_nattch;
|
||||
hp->shm_cnattch = bp->shm_nattch;
|
||||
hp->shm_atime = bp->shm_atime;
|
||||
hp->shm_dtime = bp->shm_dtime;
|
||||
hp->shm_ctime = bp->shm_ctime;
|
||||
}
|
||||
|
||||
void
|
||||
bsd_to_hpux_oshmid_ds(bp, hp)
|
||||
const struct shmid_ds *bp;
|
||||
struct hpux_oshmid_ds *hp;
|
||||
{
|
||||
|
||||
bsd_to_hpux_oipc_perm(&bp->shm_perm, &hp->shm_perm);
|
||||
hp->shm_segsz = bp->shm_segsz;
|
||||
hp->shm_vas = NULL;
|
||||
hp->shm_lpid = bp->shm_lpid;
|
||||
hp->shm_cpid = bp->shm_cpid;
|
||||
hp->shm_nattch = bp->shm_nattch;
|
||||
hp->shm_cnattch = bp->shm_nattch;
|
||||
hp->shm_atime = bp->shm_atime;
|
||||
hp->shm_dtime = bp->shm_dtime;
|
||||
hp->shm_ctime = bp->shm_ctime;
|
||||
}
|
||||
|
||||
void
|
||||
hpux_to_bsd_shmid_ds(hp, bp)
|
||||
const struct hpux_shmid_ds *hp;
|
||||
struct shmid_ds *bp;
|
||||
{
|
||||
|
||||
hpux_to_bsd_ipc_perm(&hp->shm_perm, &bp->shm_perm);
|
||||
bp->shm_segsz = hp->shm_segsz;
|
||||
bp->shm_lpid = hp->shm_lpid;
|
||||
bp->shm_cpid = hp->shm_cpid;
|
||||
bp->shm_nattch = hp->shm_nattch;
|
||||
bp->shm_atime = hp->shm_atime;
|
||||
bp->shm_dtime = hp->shm_dtime;
|
||||
bp->shm_ctime = hp->shm_ctime;
|
||||
bp->_shm_internal = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
hpux_to_bsd_oshmid_ds(hp, bp)
|
||||
const struct hpux_oshmid_ds *hp;
|
||||
struct shmid_ds *bp;
|
||||
{
|
||||
|
||||
hpux_to_bsd_oipc_perm(&hp->shm_perm, &bp->shm_perm);
|
||||
bp->shm_segsz = hp->shm_segsz;
|
||||
bp->shm_lpid = hp->shm_lpid;
|
||||
bp->shm_cpid = hp->shm_cpid;
|
||||
bp->shm_nattch = hp->shm_nattch;
|
||||
bp->shm_atime = hp->shm_atime;
|
||||
bp->shm_dtime = hp->shm_dtime;
|
||||
bp->shm_ctime = hp->shm_ctime;
|
||||
bp->_shm_internal = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
hpux_sys_oshmctl(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
struct hpux_sys_oshmctl_args /* {
|
||||
syscallarg(int) shmid;
|
||||
syscallarg(int) cmd;
|
||||
syscallarg(struct hpux_oshmid_ds *) buf;
|
||||
} */ *uap = v;
|
||||
struct shmid_ds shmbuf;
|
||||
struct hpux_oshmid_ds hshmbuf;
|
||||
int cmd, error;
|
||||
|
||||
cmd = SCARG(uap, cmd);
|
||||
|
||||
if (cmd == IPC_SET) {
|
||||
error = copyin(SCARG(uap, buf), &hshmbuf, sizeof(hshmbuf));
|
||||
if (error)
|
||||
return (error);
|
||||
hpux_to_bsd_oshmid_ds(&hshmbuf, &shmbuf);
|
||||
}
|
||||
|
||||
error = shmctl1(p, SCARG(uap, shmid), cmd,
|
||||
(cmd == IPC_SET || cmd == IPC_STAT) ? &shmbuf : NULL);
|
||||
|
||||
if (error == 0 && cmd == IPC_STAT) {
|
||||
bsd_to_hpux_oshmid_ds(&shmbuf, &hshmbuf);
|
||||
error = copyout(&hshmbuf, SCARG(uap, buf), sizeof(hshmbuf));
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
hpux_sys_shmctl(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
struct hpux_sys_shmctl_args /* {
|
||||
syscallarg(int) shmid;
|
||||
syscallarg(int) cmd;
|
||||
syscallarg(struct hpux_shmid_ds *) buf;
|
||||
} */ *uap = v;
|
||||
struct shmid_ds shmbuf;
|
||||
struct hpux_shmid_ds hshmbuf;
|
||||
int cmd, error;
|
||||
|
||||
cmd = SCARG(uap, cmd);
|
||||
|
||||
if (cmd == IPC_SET) {
|
||||
error = copyin(SCARG(uap, buf), &hshmbuf, sizeof(hshmbuf));
|
||||
if (error)
|
||||
return (error);
|
||||
hpux_to_bsd_shmid_ds(&hshmbuf, &shmbuf);
|
||||
}
|
||||
|
||||
error = shmctl1(p, SCARG(uap, shmid), cmd,
|
||||
(cmd == IPC_SET || cmd == IPC_STAT) ? &shmbuf : NULL);
|
||||
|
||||
if (error == 0 && cmd == IPC_STAT) {
|
||||
bsd_to_hpux_shmid_ds(&shmbuf, &hshmbuf);
|
||||
error = copyout(&hshmbuf, SCARG(uap, buf), sizeof(hshmbuf));
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
#endif /* SYSVSHM */
|
180
sys/compat/hpux/hpux_ipc.h
Normal file
180
sys/compat/hpux/hpux_ipc.h
Normal file
@ -0,0 +1,180 @@
|
||||
/* $NetBSD: hpux_ipc.h,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.
|
||||
*/
|
||||
|
||||
#ifndef _COMPAT_HPUX_HPUX_IPC_H_
|
||||
#define _COMPAT_HPUX_HPUX_IPC_H_
|
||||
|
||||
/*
|
||||
* HP-UX 9.x hp9000s300 compatible IPC data structures.
|
||||
*/
|
||||
|
||||
#include <compat/hpux/hpux_types.h>
|
||||
|
||||
struct hpux_ipc_perm {
|
||||
hpux_uid_t uid;
|
||||
hpux_gid_t gid;
|
||||
hpux_uid_t cuid;
|
||||
hpux_gid_t cgid;
|
||||
hpux_mode_t mode;
|
||||
u_short seq;
|
||||
hpux_key_t key;
|
||||
char pad[20];
|
||||
};
|
||||
|
||||
#define HPUX_IPC_CREAT 0001000 /* same as NetBSD */
|
||||
#define HPUX_IPC_EXCL 0002000 /* same as NetBSD */
|
||||
#define HPUX_IPC_NOWAIT 0004000 /* same as NetBSD */
|
||||
|
||||
#define HPUX_IPC_PRIVATE (hpux_key_t)0 /* same as NetBSD */
|
||||
|
||||
#define HPUX_IPC_RMID 0 /* same as NetBSD */
|
||||
#define HPUX_IPC_SET 1 /* same as NetBSD */
|
||||
#define HPUX_IPC_STAT 2 /* same as NetBSD */
|
||||
|
||||
struct hpux_oipc_perm {
|
||||
u_short uid;
|
||||
u_short gid;
|
||||
u_short cuid;
|
||||
u_short cgid;
|
||||
u_short mode;
|
||||
u_short seq;
|
||||
hpux_key_t key;
|
||||
};
|
||||
|
||||
struct hpux_msqid_ds {
|
||||
struct hpux_ipc_perm msg_perm;
|
||||
void *msg_first;
|
||||
void *msg_last;
|
||||
u_short msg_qnum;
|
||||
u_short msg_qbytes;
|
||||
hpux_pid_t msg_lspid;
|
||||
hpux_pid_t msg_lrpid;
|
||||
hpux_time_t msg_stime;
|
||||
hpux_time_t msg_rtime;
|
||||
hpux_time_t msg_ctime;
|
||||
u_short msg_cbytes;
|
||||
char pad[22];
|
||||
};
|
||||
|
||||
struct hpux_omsqid_ds {
|
||||
struct hpux_oipc_perm msg_perm;
|
||||
void *msg_first;
|
||||
void *msg_last;
|
||||
u_short msg_cbytes;
|
||||
u_short msg_qnum;
|
||||
u_short msg_qbytes;
|
||||
u_short msg_lspid;
|
||||
u_short msg_lrpid;
|
||||
hpux_time_t msg_stime;
|
||||
hpux_time_t msg_rtime;
|
||||
hpux_time_t msg_ctime;
|
||||
};
|
||||
|
||||
#define HPUX_SEM_UNDO 010000 /* same as NetBSD */
|
||||
#define HPUX_GETNCNT 3 /* same as NetBSD */
|
||||
#define HPUX_GETPID 4 /* same as NetBSD */
|
||||
#define HPUX_GETVAL 5 /* same as NetBSD */
|
||||
#define HPUX_GETALL 6 /* same as NetBSD */
|
||||
#define HPUX_GETZCNT 7 /* same as NetBSD */
|
||||
#define HPUX_SETVAL 8 /* same as NetBSD */
|
||||
#define HPUX_SETALL 9 /* same as NetBSD */
|
||||
|
||||
struct hpux_semid_ds {
|
||||
struct hpux_ipc_perm sem_perm;
|
||||
void *sem_base;
|
||||
hpux_time_t sem_otime;
|
||||
hpux_time_t sem_ctime;
|
||||
u_short sem_nsems;
|
||||
char pad[22];
|
||||
};
|
||||
|
||||
struct hpux_sembuf { /* same as NetBSD */
|
||||
u_short sem_num;
|
||||
short sem_op;
|
||||
short sem_flg;
|
||||
};
|
||||
|
||||
struct hpux_osemid_ds {
|
||||
struct hpux_oipc_perm sem_perm;
|
||||
void *sem_base;
|
||||
u_short sem_nsems;
|
||||
hpux_time_t sem_otime;
|
||||
hpux_time_t sem_ctime;
|
||||
};
|
||||
|
||||
/*
|
||||
* This is not always the same on NetBSD's m68k platforms, but should
|
||||
* always be the same on any NetBSD platform that can run HP-UX binaries.
|
||||
*/
|
||||
#define HPUX_SHMLBA 4096
|
||||
|
||||
#define HPUX_SHM_RDONLY 010000 /* same as NetBSD */
|
||||
#define HPUX_SHM_RND 020000 /* same as NetBSD */
|
||||
|
||||
struct hpux_shmid_ds {
|
||||
struct hpux_ipc_perm shm_perm;
|
||||
int shm_segsz;
|
||||
void *shm_vas;
|
||||
hpux_pid_t shm_lpid;
|
||||
hpux_pid_t shm_cpid;
|
||||
u_short shm_nattch; /* current # attached (accurate) */
|
||||
u_short shm_cnattch; /* in memory # attached (inaccurate) */
|
||||
hpux_time_t shm_atime;
|
||||
hpux_time_t shm_dtime;
|
||||
hpux_time_t shm_ctime;
|
||||
char pad[24];
|
||||
};
|
||||
|
||||
struct hpux_oshmid_ds {
|
||||
struct hpux_oipc_perm shm_perm;
|
||||
int shm_segsz;
|
||||
void *shm_vas;
|
||||
u_short shm_lpid;
|
||||
u_short shm_cpid;
|
||||
u_short shm_nattch;
|
||||
u_short shm_cnattch;
|
||||
hpux_time_t shm_atime;
|
||||
hpux_time_t shm_dtime;
|
||||
hpux_time_t shm_ctime;
|
||||
char pad[60];
|
||||
};
|
||||
|
||||
#define HPUX_SHM_LOCK 3 /* same as NetBSD */
|
||||
#define HPUX_SHM_UNLOCK 4 /* same as NetBSD */
|
||||
|
||||
#endif /* _COMPAT_HPUX_HPUX_IPC_H_ */
|
Loading…
Reference in New Issue
Block a user