1997-01-18 04:51:41 +03:00
|
|
|
/* $NetBSD: ibcs2_ipc.c,v 1.7 1997/01/18 01:51:41 mycroft Exp $ */
|
1996-05-03 21:05:16 +04:00
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1995 Scott Bartram
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
|
|
*/
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/filedesc.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/ipc.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/reboot.h>
|
|
|
|
#include <sys/resource.h>
|
|
|
|
#include <sys/resourcevar.h>
|
|
|
|
#include <sys/signal.h>
|
|
|
|
#include <sys/signalvar.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/times.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
#include <sys/unistd.h>
|
|
|
|
#include <sys/msg.h>
|
|
|
|
#include <sys/sem.h>
|
|
|
|
#include <sys/shm.h>
|
|
|
|
#include <sys/syscallargs.h>
|
|
|
|
|
|
|
|
#include <vm/vm.h>
|
|
|
|
|
|
|
|
#include <compat/ibcs2/ibcs2_types.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_signal.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_syscallargs.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_util.h>
|
|
|
|
|
|
|
|
#define IBCS2_IPC_RMID 0
|
|
|
|
#define IBCS2_IPC_SET 1
|
|
|
|
#define IBCS2_IPC_STAT 2
|
|
|
|
|
1997-01-18 04:51:41 +03:00
|
|
|
#ifdef SYSVMSG
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
/*
|
|
|
|
* iBCS2 msgsys call
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct ibcs2_msqid_ds {
|
|
|
|
struct ipc_perm msg_perm;
|
|
|
|
struct msg *msg_first;
|
|
|
|
struct msg *msg_last;
|
|
|
|
u_short msg_cbytes;
|
|
|
|
u_short msg_qnum;
|
|
|
|
u_short msg_qbytes;
|
|
|
|
u_short msg_lspid;
|
|
|
|
u_short msg_lrpid;
|
|
|
|
ibcs2_time_t msg_stime;
|
|
|
|
ibcs2_time_t msg_rtime;
|
|
|
|
ibcs2_time_t msg_ctime;
|
|
|
|
};
|
|
|
|
|
1996-05-03 21:05:16 +04:00
|
|
|
static void cvt_msqid2imsqid __P((struct msqid_ds *, struct ibcs2_msqid_ds *));
|
|
|
|
static void cvt_imsqid2msqid __P((struct ibcs2_msqid_ds *, struct msqid_ds *));
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
static void
|
|
|
|
cvt_msqid2imsqid(bp, ibp)
|
1996-05-03 21:05:16 +04:00
|
|
|
struct msqid_ds *bp;
|
|
|
|
struct ibcs2_msqid_ds *ibp;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
|
|
|
ibp->msg_perm = bp->msg_perm;
|
|
|
|
ibp->msg_first = bp->msg_first;
|
|
|
|
ibp->msg_last = bp->msg_last;
|
|
|
|
ibp->msg_cbytes = (u_short)bp->msg_cbytes;
|
|
|
|
ibp->msg_qnum = (u_short)bp->msg_qnum;
|
|
|
|
ibp->msg_qbytes = (u_short)bp->msg_qbytes;
|
|
|
|
ibp->msg_lspid = (u_short)bp->msg_lspid;
|
|
|
|
ibp->msg_lrpid = (u_short)bp->msg_lrpid;
|
|
|
|
ibp->msg_stime = bp->msg_stime;
|
|
|
|
ibp->msg_rtime = bp->msg_rtime;
|
|
|
|
ibp->msg_ctime = bp->msg_ctime;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cvt_imsqid2msqid(ibp, bp)
|
1996-05-03 21:05:16 +04:00
|
|
|
struct ibcs2_msqid_ds *ibp;
|
|
|
|
struct msqid_ds *bp;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
|
|
|
bp->msg_perm = ibp->msg_perm;
|
|
|
|
bp->msg_first = ibp->msg_first;
|
|
|
|
bp->msg_last = ibp->msg_last;
|
|
|
|
bp->msg_cbytes = ibp->msg_cbytes;
|
|
|
|
bp->msg_qnum = ibp->msg_qnum;
|
|
|
|
bp->msg_qbytes = ibp->msg_qbytes;
|
|
|
|
bp->msg_lspid = ibp->msg_lspid;
|
|
|
|
bp->msg_lrpid = ibp->msg_lrpid;
|
|
|
|
bp->msg_stime = ibp->msg_stime;
|
|
|
|
bp->msg_rtime = ibp->msg_rtime;
|
|
|
|
bp->msg_ctime = ibp->msg_ctime;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_msgsys(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_msgsys_args /* {
|
|
|
|
syscallarg(int) which;
|
|
|
|
syscallarg(int) a2;
|
|
|
|
syscallarg(int) a3;
|
|
|
|
syscallarg(int) a4;
|
|
|
|
syscallarg(int) a5;
|
|
|
|
syscallarg(int) a6;
|
|
|
|
} */ *uap = v;
|
1995-09-20 02:19:01 +04:00
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
switch (SCARG(uap, which)) {
|
1995-06-11 19:07:55 +04:00
|
|
|
#ifdef SYSVMSG
|
1995-03-14 18:12:17 +03:00
|
|
|
case 0: /* msgget */
|
|
|
|
SCARG(uap, which) = 1;
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_10_sys_msgsys(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case 1: { /* msgctl */
|
|
|
|
int error;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct compat_10_sys_msgsys_args margs;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
SCARG(&margs, which) = 0;
|
|
|
|
SCARG(&margs, a2) = SCARG(uap, a2);
|
|
|
|
SCARG(&margs, a4) =
|
|
|
|
(int)stackgap_alloc(&sg, sizeof(struct msqid_ds));
|
|
|
|
SCARG(&margs, a3) = SCARG(uap, a3);
|
|
|
|
switch (SCARG(&margs, a3)) {
|
|
|
|
case IBCS2_IPC_STAT:
|
1995-10-07 09:25:19 +03:00
|
|
|
error = compat_10_sys_msgsys(p, &margs, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
if (!error)
|
1996-05-03 21:05:16 +04:00
|
|
|
cvt_msqid2imsqid((struct msqid_ds *)
|
|
|
|
SCARG(&margs, a4),
|
1995-03-14 18:12:17 +03:00
|
|
|
(struct ibcs2_msqid_ds *)SCARG(uap, a4));
|
|
|
|
return error;
|
|
|
|
case IBCS2_IPC_SET:
|
|
|
|
cvt_imsqid2msqid((struct ibcs2_msqid_ds *)SCARG(uap,
|
|
|
|
a4),
|
1996-05-03 21:05:16 +04:00
|
|
|
(struct msqid_ds *) SCARG(&margs, a4));
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_10_sys_msgsys(p, &margs, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case IBCS2_IPC_RMID:
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_10_sys_msgsys(p, &margs, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
case 2: /* msgrcv */
|
|
|
|
SCARG(uap, which) = 3;
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_10_sys_msgsys(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
case 3: /* msgsnd */
|
|
|
|
SCARG(uap, which) = 2;
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_10_sys_msgsys(p, uap, retval);
|
1995-06-11 19:07:55 +04:00
|
|
|
#endif
|
1995-03-14 18:12:17 +03:00
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-01-18 04:51:41 +03:00
|
|
|
#endif /* SYSVMSG */
|
|
|
|
|
|
|
|
#ifdef SYSVSEM
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* iBCS2 semsys call
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct ibcs2_semid_ds {
|
|
|
|
struct ipc_perm sem_perm;
|
|
|
|
struct ibcs2_sem *sem_base;
|
|
|
|
u_short sem_nsems;
|
|
|
|
int pad1;
|
|
|
|
ibcs2_time_t sem_otime;
|
|
|
|
ibcs2_time_t sem_ctime;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ibcs2_sem {
|
|
|
|
u_short semval;
|
|
|
|
ibcs2_pid_t sempid;
|
|
|
|
u_short semncnt;
|
|
|
|
u_short semzcnt;
|
|
|
|
};
|
|
|
|
|
1996-05-03 21:05:16 +04:00
|
|
|
static void cvt_semid2isemid __P((struct semid_ds *, struct ibcs2_semid_ds *));
|
|
|
|
static void cvt_isemid2semid __P((struct ibcs2_semid_ds *, struct semid_ds *));
|
|
|
|
#ifdef notdef
|
|
|
|
static void cvt_sem2isem __P((struct sem *, struct ibcs2_sem *));
|
|
|
|
static void cvt_isem2sem __P((struct ibcs2_sem *, struct sem *));
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
static void
|
|
|
|
cvt_sem2isem(bp, ibp)
|
1996-05-03 21:05:16 +04:00
|
|
|
struct sem *bp;
|
|
|
|
struct ibcs2_sem *ibp;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
|
|
|
ibp->semval = bp->semval;
|
|
|
|
ibp->sempid = bp->sempid;
|
|
|
|
ibp->semncnt = bp->semncnt;
|
|
|
|
ibp->semzcnt = bp->semzcnt;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cvt_isem2sem(ibp, bp)
|
1996-05-03 21:05:16 +04:00
|
|
|
struct ibcs2_sem *ibp;
|
|
|
|
struct sem *bp;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
|
|
|
bp->semval = ibp->semval;
|
|
|
|
bp->sempid = ibp->sempid;
|
|
|
|
bp->semncnt = ibp->semncnt;
|
|
|
|
bp->semzcnt = ibp->semzcnt;
|
|
|
|
return;
|
|
|
|
}
|
1996-05-03 21:05:16 +04:00
|
|
|
#endif
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
static void
|
|
|
|
cvt_semid2isemid(bp, ibp)
|
1996-05-03 21:05:16 +04:00
|
|
|
struct semid_ds *bp;
|
|
|
|
struct ibcs2_semid_ds *ibp;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
|
|
|
ibp->sem_perm = bp->sem_perm;
|
|
|
|
ibp->sem_base = (struct ibcs2_sem *)bp->sem_base;
|
|
|
|
ibp->sem_nsems = bp->sem_nsems;
|
|
|
|
ibp->sem_otime = bp->sem_otime;
|
|
|
|
ibp->sem_ctime = bp->sem_ctime;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cvt_isemid2semid(ibp, bp)
|
1996-05-03 21:05:16 +04:00
|
|
|
struct ibcs2_semid_ds *ibp;
|
|
|
|
struct semid_ds *bp;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
|
|
|
bp->sem_perm = ibp->sem_perm;
|
|
|
|
bp->sem_base = (struct sem *)ibp->sem_base;
|
|
|
|
bp->sem_nsems = ibp->sem_nsems;
|
|
|
|
bp->sem_otime = ibp->sem_otime;
|
|
|
|
bp->sem_ctime = ibp->sem_ctime;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_semsys(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_semsys_args /* {
|
|
|
|
syscallarg(int) which;
|
|
|
|
syscallarg(int) a2;
|
|
|
|
syscallarg(int) a3;
|
|
|
|
syscallarg(int) a4;
|
|
|
|
syscallarg(int) a5;
|
|
|
|
} */ *uap = v;
|
1995-03-14 18:12:17 +03:00
|
|
|
int error;
|
|
|
|
|
1995-06-11 19:07:55 +04:00
|
|
|
#ifdef SYSVSEM
|
1995-03-14 18:12:17 +03:00
|
|
|
switch (SCARG(uap, which)) {
|
|
|
|
case 0: /* semctl */
|
|
|
|
switch(SCARG(uap, a4)) {
|
|
|
|
case IBCS2_IPC_STAT:
|
|
|
|
{
|
|
|
|
struct ibcs2_semid_ds *isp;
|
|
|
|
struct semid_ds *sp;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
isp = (struct ibcs2_semid_ds *)SCARG(uap, a5);
|
|
|
|
sp = stackgap_alloc(&sg, sizeof(struct semid_ds));
|
|
|
|
SCARG(uap, a5) = (int)sp;
|
1995-10-07 09:25:19 +03:00
|
|
|
error = compat_10_sys_semsys(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
if (!error) {
|
|
|
|
SCARG(uap, a5) = (int)isp;
|
|
|
|
isp = stackgap_alloc(&sg, sizeof(*isp));
|
|
|
|
cvt_semid2isemid(sp, isp);
|
|
|
|
error = copyout((caddr_t)isp,
|
|
|
|
(caddr_t)SCARG(uap, a5),
|
|
|
|
sizeof(*isp));
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
case IBCS2_IPC_SET:
|
|
|
|
{
|
|
|
|
struct ibcs2_semid_ds *isp;
|
|
|
|
struct semid_ds *sp;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
isp = stackgap_alloc(&sg, sizeof(*isp));
|
|
|
|
sp = stackgap_alloc(&sg, sizeof(*sp));
|
|
|
|
error = copyin((caddr_t)SCARG(uap, a5), (caddr_t)isp,
|
|
|
|
sizeof(*isp));
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
cvt_isemid2semid(isp, sp);
|
|
|
|
SCARG(uap, a5) = (int)sp;
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_10_sys_semsys(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
}
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_10_sys_semsys(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
case 1: /* semget */
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_10_sys_semsys(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
case 2: /* semop */
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_10_sys_semsys(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
1995-06-11 19:07:55 +04:00
|
|
|
#endif
|
1995-03-14 18:12:17 +03:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
1997-01-18 04:51:41 +03:00
|
|
|
#endif /* SYSVSEM */
|
|
|
|
|
|
|
|
#ifdef SYSVSHM
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* iBCS2 shmsys call
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct ibcs2_shmid_ds {
|
|
|
|
struct ipc_perm shm_perm;
|
|
|
|
int shm_segsz;
|
|
|
|
int pad1;
|
|
|
|
char pad2[4];
|
|
|
|
u_short shm_lpid;
|
|
|
|
u_short shm_cpid;
|
|
|
|
u_short shm_nattch;
|
|
|
|
u_short shm_cnattch;
|
|
|
|
ibcs2_time_t shm_atime;
|
|
|
|
ibcs2_time_t shm_dtime;
|
|
|
|
ibcs2_time_t shm_ctime;
|
|
|
|
};
|
|
|
|
|
1996-05-03 21:05:16 +04:00
|
|
|
static void cvt_shmid2ishmid __P((struct shmid_ds *, struct ibcs2_shmid_ds *));
|
|
|
|
static void cvt_ishmid2shmid __P((struct ibcs2_shmid_ds *, struct shmid_ds *));
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
static void
|
|
|
|
cvt_shmid2ishmid(bp, ibp)
|
1996-05-03 21:05:16 +04:00
|
|
|
struct shmid_ds *bp;
|
|
|
|
struct ibcs2_shmid_ds *ibp;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
|
|
|
ibp->shm_perm = bp->shm_perm;
|
|
|
|
ibp->shm_segsz = bp->shm_segsz;
|
|
|
|
ibp->shm_lpid = bp->shm_lpid;
|
|
|
|
ibp->shm_cpid = bp->shm_cpid;
|
|
|
|
ibp->shm_nattch = bp->shm_nattch;
|
|
|
|
ibp->shm_cnattch = 0; /* ignored anyway */
|
|
|
|
ibp->shm_atime = bp->shm_atime;
|
|
|
|
ibp->shm_dtime = bp->shm_dtime;
|
|
|
|
ibp->shm_ctime = bp->shm_ctime;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cvt_ishmid2shmid(ibp, bp)
|
1996-05-03 21:05:16 +04:00
|
|
|
struct ibcs2_shmid_ds *ibp;
|
|
|
|
struct shmid_ds *bp;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
|
|
|
bp->shm_perm = ibp->shm_perm;
|
|
|
|
bp->shm_segsz = ibp->shm_segsz;
|
|
|
|
bp->shm_lpid = ibp->shm_lpid;
|
|
|
|
bp->shm_cpid = ibp->shm_cpid;
|
|
|
|
bp->shm_nattch = ibp->shm_nattch;
|
|
|
|
bp->shm_atime = ibp->shm_atime;
|
|
|
|
bp->shm_dtime = ibp->shm_dtime;
|
|
|
|
bp->shm_ctime = ibp->shm_ctime;
|
|
|
|
bp->shm_internal = (void *)0; /* ignored anyway */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_shmsys(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_shmsys_args /* {
|
|
|
|
syscallarg(int) which;
|
|
|
|
syscallarg(int) a2;
|
|
|
|
syscallarg(int) a3;
|
|
|
|
syscallarg(int) a4;
|
|
|
|
} */ *uap = v;
|
1995-03-14 18:12:17 +03:00
|
|
|
int error;
|
|
|
|
|
1995-06-11 19:07:55 +04:00
|
|
|
#ifdef SYSVSHM
|
1995-03-14 18:12:17 +03:00
|
|
|
switch (SCARG(uap, which)) {
|
|
|
|
case 0: /* shmat */
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_10_sys_shmsys(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
case 1: /* shmctl */
|
|
|
|
switch(SCARG(uap, a3)) {
|
|
|
|
case IBCS2_IPC_STAT:
|
|
|
|
{
|
|
|
|
struct ibcs2_shmid_ds *isp;
|
|
|
|
struct shmid_ds *sp;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
isp = (struct ibcs2_shmid_ds *)SCARG(uap, a4);
|
|
|
|
sp = stackgap_alloc(&sg, sizeof(*sp));
|
|
|
|
SCARG(uap, a4) = (int)sp;
|
1995-10-07 09:25:19 +03:00
|
|
|
error = compat_10_sys_shmsys(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
if (!error) {
|
|
|
|
SCARG(uap, a4) = (int)isp;
|
|
|
|
isp = stackgap_alloc(&sg, sizeof(*isp));
|
|
|
|
cvt_shmid2ishmid(sp, isp);
|
|
|
|
error = copyout((caddr_t)isp,
|
|
|
|
(caddr_t)SCARG(uap, a4),
|
|
|
|
sizeof(*isp));
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
case IBCS2_IPC_SET:
|
|
|
|
{
|
|
|
|
struct ibcs2_shmid_ds *isp;
|
|
|
|
struct shmid_ds *sp;
|
1995-06-25 00:18:53 +04:00
|
|
|
caddr_t sg = stackgap_init(p->p_emul);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
isp = stackgap_alloc(&sg, sizeof(*isp));
|
|
|
|
sp = stackgap_alloc(&sg, sizeof(*sp));
|
|
|
|
error = copyin((caddr_t)SCARG(uap, a4), (caddr_t)isp,
|
|
|
|
sizeof(*isp));
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
cvt_ishmid2shmid(isp, sp);
|
|
|
|
SCARG(uap, a4) = (int)sp;
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_10_sys_shmsys(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
}
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_10_sys_shmsys(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
case 2: /* shmdt */
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_10_sys_shmsys(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
case 3: /* shmget */
|
1995-10-07 09:25:19 +03:00
|
|
|
return compat_10_sys_shmsys(p, uap, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
1995-06-11 19:07:55 +04:00
|
|
|
#endif
|
1995-03-14 18:12:17 +03:00
|
|
|
return EINVAL;
|
|
|
|
}
|
1997-01-18 04:51:41 +03:00
|
|
|
|
|
|
|
#endif /* SYSVSHM */
|