2005-12-11 15:16:03 +03:00
|
|
|
/* $NetBSD: svr4_ipc.c,v 1.18 2005/12/11 12:20:26 christos Exp $ */
|
1995-10-14 23:24:14 +03:00
|
|
|
|
1998-09-04 23:54:37 +04:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1995 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Christos Zoulas.
|
1995-10-14 23:24:14 +03:00
|
|
|
*
|
|
|
|
* 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:
|
1998-09-04 23:54:37 +04:00
|
|
|
* 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.
|
1995-10-14 23:24:14 +03:00
|
|
|
*
|
1998-09-04 23:54:37 +04:00
|
|
|
* 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.
|
1995-10-14 23:24:14 +03:00
|
|
|
*/
|
|
|
|
|
2001-11-13 05:07:52 +03:00
|
|
|
#include <sys/cdefs.h>
|
2005-12-11 15:16:03 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: svr4_ipc.c,v 1.18 2005/12/11 12:20:26 christos Exp $");
|
2001-11-13 05:07:52 +03:00
|
|
|
|
2001-05-30 15:37:21 +04:00
|
|
|
#if defined(_KERNEL_OPT)
|
1998-10-20 02:43:00 +04:00
|
|
|
#include "opt_sysv.h"
|
2000-11-30 00:51:49 +03:00
|
|
|
#endif
|
1998-10-20 02:43:00 +04:00
|
|
|
|
1995-10-14 23:24:14 +03:00
|
|
|
#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/uio.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
#include <sys/mount.h>
|
2003-01-18 11:44:26 +03:00
|
|
|
#include <sys/sa.h>
|
1995-10-14 23:24:14 +03:00
|
|
|
#include <sys/syscallargs.h>
|
|
|
|
|
|
|
|
#include <compat/svr4/svr4_types.h>
|
|
|
|
#include <compat/svr4/svr4_signal.h>
|
1999-09-07 22:20:18 +04:00
|
|
|
#include <compat/svr4/svr4_lwp.h>
|
|
|
|
#include <compat/svr4/svr4_ucontext.h>
|
1995-10-14 23:24:14 +03:00
|
|
|
#include <compat/svr4/svr4_syscallargs.h>
|
|
|
|
#include <compat/svr4/svr4_util.h>
|
|
|
|
#include <compat/svr4/svr4_ipc.h>
|
|
|
|
|
|
|
|
#if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
|
|
|
|
static void svr4_to_bsd_ipc_perm __P((const struct svr4_ipc_perm *,
|
|
|
|
struct ipc_perm *));
|
|
|
|
static void bsd_to_svr4_ipc_perm __P((const struct ipc_perm *,
|
|
|
|
struct svr4_ipc_perm *));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SYSVSEM
|
|
|
|
static void bsd_to_svr4_semid_ds __P((const struct semid_ds *,
|
|
|
|
struct svr4_semid_ds *));
|
|
|
|
static void svr4_to_bsd_semid_ds __P((const struct svr4_semid_ds *,
|
|
|
|
struct semid_ds *));
|
2003-01-18 11:44:26 +03:00
|
|
|
static int svr4_semop __P((struct lwp *, void *, register_t *));
|
|
|
|
static int svr4_semget __P((struct lwp *, void *, register_t *));
|
|
|
|
static int svr4_semctl __P((struct lwp *, void *, register_t *));
|
1995-10-14 23:24:14 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SYSVMSG
|
|
|
|
static void bsd_to_svr4_msqid_ds __P((const struct msqid_ds *,
|
|
|
|
struct svr4_msqid_ds *));
|
|
|
|
static void svr4_to_bsd_msqid_ds __P((const struct svr4_msqid_ds *,
|
|
|
|
struct msqid_ds *));
|
2003-01-18 11:44:26 +03:00
|
|
|
static int svr4_msgsnd __P((struct lwp *, void *, register_t *));
|
|
|
|
static int svr4_msgrcv __P((struct lwp *, void *, register_t *));
|
|
|
|
static int svr4_msgget __P((struct lwp *, void *, register_t *));
|
|
|
|
static int svr4_msgctl __P((struct lwp *, void *, register_t *));
|
1995-10-14 23:24:14 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SYSVSHM
|
|
|
|
static void bsd_to_svr4_shmid_ds __P((const struct shmid_ds *,
|
|
|
|
struct svr4_shmid_ds *));
|
|
|
|
static void svr4_to_bsd_shmid_ds __P((const struct svr4_shmid_ds *,
|
|
|
|
struct shmid_ds *));
|
2003-01-18 11:44:26 +03:00
|
|
|
static int svr4_shmat __P((struct lwp *, void *, register_t *));
|
|
|
|
static int svr4_shmdt __P((struct lwp *, void *, register_t *));
|
|
|
|
static int svr4_shmget __P((struct lwp *, void *, register_t *));
|
|
|
|
static int svr4_shmctl __P((struct lwp *, void *, register_t *));
|
1995-10-14 23:24:14 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
|
|
|
|
|
|
|
|
static void
|
|
|
|
svr4_to_bsd_ipc_perm(spp, bpp)
|
|
|
|
const struct svr4_ipc_perm *spp;
|
|
|
|
struct ipc_perm *bpp;
|
|
|
|
{
|
1999-08-25 08:52:06 +04:00
|
|
|
bpp->_key = spp->key;
|
1995-10-14 23:24:14 +03:00
|
|
|
bpp->uid = spp->uid;
|
|
|
|
bpp->gid = spp->gid;
|
|
|
|
bpp->cuid = spp->cuid;
|
|
|
|
bpp->cgid = spp->cgid;
|
|
|
|
bpp->mode = spp->mode;
|
1999-08-25 08:52:06 +04:00
|
|
|
bpp->_seq = spp->seq;
|
1995-10-14 23:24:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bsd_to_svr4_ipc_perm(bpp, spp)
|
|
|
|
const struct ipc_perm *bpp;
|
|
|
|
struct svr4_ipc_perm *spp;
|
|
|
|
{
|
1999-08-25 08:52:06 +04:00
|
|
|
spp->key = bpp->_key;
|
1995-10-14 23:24:14 +03:00
|
|
|
spp->uid = bpp->uid;
|
|
|
|
spp->gid = bpp->gid;
|
|
|
|
spp->cuid = bpp->cuid;
|
|
|
|
spp->cgid = bpp->cgid;
|
|
|
|
spp->mode = bpp->mode;
|
1999-08-25 08:52:06 +04:00
|
|
|
spp->seq = bpp->_seq;
|
1995-10-14 23:24:14 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SYSVSEM
|
|
|
|
static void
|
|
|
|
bsd_to_svr4_semid_ds(bds, sds)
|
|
|
|
const struct semid_ds *bds;
|
|
|
|
struct svr4_semid_ds *sds;
|
|
|
|
{
|
|
|
|
bsd_to_svr4_ipc_perm(&bds->sem_perm, &sds->sem_perm);
|
1999-08-25 08:52:06 +04:00
|
|
|
sds->sem_base = (struct svr4_sem *) bds->_sem_base;
|
1995-10-14 23:24:14 +03:00
|
|
|
sds->sem_nsems = bds->sem_nsems;
|
|
|
|
sds->sem_otime = bds->sem_otime;
|
|
|
|
sds->sem_ctime = bds->sem_ctime;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
svr4_to_bsd_semid_ds(sds, bds)
|
|
|
|
const struct svr4_semid_ds *sds;
|
|
|
|
struct semid_ds *bds;
|
|
|
|
{
|
|
|
|
svr4_to_bsd_ipc_perm(&sds->sem_perm, &bds->sem_perm);
|
1999-08-25 08:52:06 +04:00
|
|
|
bds->_sem_base = (struct __sem *) sds->sem_base;
|
1995-10-14 23:24:14 +03:00
|
|
|
bds->sem_nsems = sds->sem_nsems;
|
|
|
|
bds->sem_otime = sds->sem_otime;
|
|
|
|
bds->sem_ctime = sds->sem_ctime;
|
1998-03-05 07:42:49 +03:00
|
|
|
}
|
|
|
|
|
1995-10-14 23:24:14 +03:00
|
|
|
struct svr4_sys_semctl_args {
|
|
|
|
syscallarg(int) what;
|
|
|
|
syscallarg(int) semid;
|
|
|
|
syscallarg(int) semnum;
|
|
|
|
syscallarg(int) cmd;
|
1999-08-25 08:52:06 +04:00
|
|
|
syscallarg(union __semun) arg;
|
1995-10-14 23:24:14 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2003-01-18 11:44:26 +03:00
|
|
|
svr4_semctl(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-10-14 23:24:14 +03:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct svr4_sys_semctl_args *uap = v;
|
1999-08-25 08:52:06 +04:00
|
|
|
struct semid_ds sembuf;
|
|
|
|
struct svr4_semid_ds ssembuf;
|
|
|
|
int cmd, error;
|
|
|
|
void *pass_arg = NULL;
|
1995-10-14 23:24:14 +03:00
|
|
|
|
1999-08-25 08:52:06 +04:00
|
|
|
cmd = SCARG(uap, cmd);
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case SVR4_IPC_SET:
|
|
|
|
pass_arg = &sembuf;
|
|
|
|
cmd = IPC_SET;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SVR4_IPC_STAT:
|
|
|
|
pass_arg = &sembuf;
|
|
|
|
cmd = IPC_STAT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SVR4_IPC_RMID:
|
|
|
|
cmd = IPC_RMID;
|
|
|
|
break;
|
1995-10-14 23:24:14 +03:00
|
|
|
|
|
|
|
case SVR4_SEM_GETVAL:
|
1999-08-25 08:52:06 +04:00
|
|
|
cmd = GETVAL;
|
|
|
|
break;
|
1995-10-14 23:24:14 +03:00
|
|
|
|
1999-08-25 08:52:06 +04:00
|
|
|
case SVR4_SEM_GETPID:
|
|
|
|
cmd = GETPID;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SVR4_SEM_GETNCNT:
|
|
|
|
cmd = GETNCNT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SVR4_SEM_GETZCNT:
|
|
|
|
cmd = GETZCNT;
|
|
|
|
break;
|
1995-10-14 23:24:14 +03:00
|
|
|
|
|
|
|
case SVR4_SEM_GETALL:
|
1999-08-25 08:52:06 +04:00
|
|
|
pass_arg = &SCARG(uap, arg);
|
|
|
|
cmd = GETALL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SVR4_SEM_SETVAL:
|
|
|
|
pass_arg = &SCARG(uap, arg);
|
|
|
|
cmd = SETVAL;
|
|
|
|
break;
|
1995-10-14 23:24:14 +03:00
|
|
|
|
|
|
|
case SVR4_SEM_SETALL:
|
1999-08-25 08:52:06 +04:00
|
|
|
pass_arg = &SCARG(uap, arg);
|
|
|
|
cmd = SETALL;
|
|
|
|
break;
|
1995-10-14 23:24:14 +03:00
|
|
|
|
1999-08-25 08:52:06 +04:00
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
1995-10-14 23:24:14 +03:00
|
|
|
|
1999-08-25 08:52:06 +04:00
|
|
|
if (cmd == IPC_SET) {
|
|
|
|
error = copyin(SCARG(uap, arg).buf, &ssembuf, sizeof(ssembuf));
|
1995-10-14 23:24:14 +03:00
|
|
|
if (error)
|
1999-08-25 08:52:06 +04:00
|
|
|
return (error);
|
|
|
|
svr4_to_bsd_semid_ds(&ssembuf, &sembuf);
|
|
|
|
}
|
1995-10-14 23:24:14 +03:00
|
|
|
|
2003-01-18 11:44:26 +03:00
|
|
|
error = semctl1(l->l_proc, SCARG(uap, semid), SCARG(uap, semnum), cmd,
|
1999-08-25 08:52:06 +04:00
|
|
|
pass_arg, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
|
1999-08-25 08:52:06 +04:00
|
|
|
if (error == 0 && cmd == IPC_STAT) {
|
|
|
|
bsd_to_svr4_semid_ds(&sembuf, &ssembuf);
|
|
|
|
error = copyout(&ssembuf, SCARG(uap, arg).buf, sizeof(ssembuf));
|
1995-10-14 23:24:14 +03:00
|
|
|
}
|
1999-08-25 08:52:06 +04:00
|
|
|
|
|
|
|
return (error);
|
1995-10-14 23:24:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_semget_args {
|
|
|
|
syscallarg(int) what;
|
|
|
|
syscallarg(svr4_key_t) key;
|
|
|
|
syscallarg(int) nsems;
|
|
|
|
syscallarg(int) semflg;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2003-01-18 11:44:26 +03:00
|
|
|
svr4_semget(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-10-14 23:24:14 +03:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct svr4_sys_semget_args *uap = v;
|
|
|
|
struct sys_semget_args ap;
|
|
|
|
|
|
|
|
SCARG(&ap, key) = SCARG(uap, key);
|
|
|
|
SCARG(&ap, nsems) = SCARG(uap, nsems);
|
|
|
|
SCARG(&ap, semflg) = SCARG(uap, semflg);
|
|
|
|
|
2003-01-18 11:44:26 +03:00
|
|
|
return sys_semget(l, &ap, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_semop_args {
|
|
|
|
syscallarg(int) what;
|
|
|
|
syscallarg(int) semid;
|
|
|
|
syscallarg(struct svr4_sembuf *) sops;
|
|
|
|
syscallarg(u_int) nsops;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2003-01-18 11:44:26 +03:00
|
|
|
svr4_semop(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-10-14 23:24:14 +03:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct svr4_sys_semop_args *uap = v;
|
|
|
|
struct sys_semop_args ap;
|
|
|
|
|
|
|
|
SCARG(&ap, semid) = SCARG(uap, semid);
|
|
|
|
/* These are the same */
|
|
|
|
SCARG(&ap, sops) = (struct sembuf *) SCARG(uap, sops);
|
|
|
|
SCARG(&ap, nsops) = SCARG(uap, nsops);
|
|
|
|
|
2003-01-18 11:44:26 +03:00
|
|
|
return sys_semop(l, &ap, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-01-18 11:44:26 +03:00
|
|
|
svr4_sys_semsys(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-10-14 23:24:14 +03:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct svr4_sys_semsys_args *uap = v;
|
|
|
|
|
|
|
|
DPRINTF(("svr4_semsys(%d)\n", SCARG(uap, what)));
|
|
|
|
|
|
|
|
switch (SCARG(uap, what)) {
|
|
|
|
case SVR4_semctl:
|
2003-01-18 11:44:26 +03:00
|
|
|
return svr4_semctl(l, v, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
case SVR4_semget:
|
2003-01-18 11:44:26 +03:00
|
|
|
return svr4_semget(l, v, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
case SVR4_semop:
|
2003-01-18 11:44:26 +03:00
|
|
|
return svr4_semop(l, v, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SYSVMSG
|
|
|
|
static void
|
|
|
|
bsd_to_svr4_msqid_ds(bds, sds)
|
|
|
|
const struct msqid_ds *bds;
|
|
|
|
struct svr4_msqid_ds *sds;
|
|
|
|
{
|
|
|
|
bsd_to_svr4_ipc_perm(&bds->msg_perm, &sds->msg_perm);
|
1999-08-25 08:52:06 +04:00
|
|
|
sds->msg_first = (struct svr4_msg *) bds->_msg_first;
|
|
|
|
sds->msg_last = (struct svr4_msg *) bds->_msg_last;
|
|
|
|
sds->msg_cbytes = bds->_msg_cbytes;
|
1995-10-14 23:24:14 +03:00
|
|
|
sds->msg_qnum = bds->msg_qnum;
|
|
|
|
sds->msg_qbytes = bds->msg_qbytes;
|
|
|
|
sds->msg_lspid = bds->msg_lspid;
|
|
|
|
sds->msg_lrpid = bds->msg_lrpid;
|
|
|
|
sds->msg_stime = bds->msg_stime;
|
|
|
|
sds->msg_rtime = bds->msg_rtime;
|
|
|
|
sds->msg_ctime = bds->msg_ctime;
|
|
|
|
|
1999-08-25 08:52:06 +04:00
|
|
|
#if 0
|
|
|
|
/* XXX What to put here? */
|
|
|
|
sds->msg_cv = 0;
|
|
|
|
sds->msg_qnum_cv = 0;
|
|
|
|
#endif
|
1995-10-14 23:24:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
svr4_to_bsd_msqid_ds(sds, bds)
|
|
|
|
const struct svr4_msqid_ds *sds;
|
|
|
|
struct msqid_ds *bds;
|
|
|
|
{
|
|
|
|
svr4_to_bsd_ipc_perm(&sds->msg_perm, &bds->msg_perm);
|
1999-08-25 08:52:06 +04:00
|
|
|
bds->_msg_first = (struct __msg *) sds->msg_first;
|
|
|
|
bds->_msg_last = (struct __msg *) sds->msg_last;
|
|
|
|
bds->_msg_cbytes = sds->msg_cbytes;
|
1995-10-14 23:24:14 +03:00
|
|
|
bds->msg_qnum = sds->msg_qnum;
|
|
|
|
bds->msg_qbytes = sds->msg_qbytes;
|
|
|
|
bds->msg_lspid = sds->msg_lspid;
|
|
|
|
bds->msg_lrpid = sds->msg_lrpid;
|
|
|
|
bds->msg_stime = sds->msg_stime;
|
|
|
|
bds->msg_rtime = sds->msg_rtime;
|
|
|
|
bds->msg_ctime = sds->msg_ctime;
|
|
|
|
|
1999-08-25 08:52:06 +04:00
|
|
|
#if 0
|
|
|
|
XXX sds->msg_cv
|
|
|
|
XXX sds->msg_qnum_cv
|
|
|
|
#endif
|
1995-10-14 23:24:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_msgsnd_args {
|
|
|
|
syscallarg(int) what;
|
|
|
|
syscallarg(int) msqid;
|
|
|
|
syscallarg(void *) msgp;
|
|
|
|
syscallarg(size_t) msgsz;
|
|
|
|
syscallarg(int) msgflg;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2003-01-18 11:44:26 +03:00
|
|
|
svr4_msgsnd(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-10-14 23:24:14 +03:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct svr4_sys_msgsnd_args *uap = v;
|
|
|
|
struct sys_msgsnd_args ap;
|
|
|
|
|
|
|
|
SCARG(&ap, msqid) = SCARG(uap, msqid);
|
|
|
|
SCARG(&ap, msgp) = SCARG(uap, msgp);
|
|
|
|
SCARG(&ap, msgsz) = SCARG(uap, msgsz);
|
|
|
|
SCARG(&ap, msgflg) = SCARG(uap, msgflg);
|
|
|
|
|
2003-01-18 11:44:26 +03:00
|
|
|
return sys_msgsnd(l, &ap, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_msgrcv_args {
|
|
|
|
syscallarg(int) what;
|
|
|
|
syscallarg(int) msqid;
|
|
|
|
syscallarg(void *) msgp;
|
|
|
|
syscallarg(size_t) msgsz;
|
|
|
|
syscallarg(long) msgtyp;
|
|
|
|
syscallarg(int) msgflg;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2003-01-18 11:44:26 +03:00
|
|
|
svr4_msgrcv(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-10-14 23:24:14 +03:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct svr4_sys_msgrcv_args *uap = v;
|
|
|
|
struct sys_msgrcv_args ap;
|
|
|
|
|
|
|
|
SCARG(&ap, msqid) = SCARG(uap, msqid);
|
|
|
|
SCARG(&ap, msgp) = SCARG(uap, msgp);
|
|
|
|
SCARG(&ap, msgsz) = SCARG(uap, msgsz);
|
|
|
|
SCARG(&ap, msgtyp) = SCARG(uap, msgtyp);
|
|
|
|
SCARG(&ap, msgflg) = SCARG(uap, msgflg);
|
|
|
|
|
2003-01-18 11:44:26 +03:00
|
|
|
return sys_msgrcv(l, &ap, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
}
|
2005-02-27 01:58:54 +03:00
|
|
|
|
1995-10-14 23:24:14 +03:00
|
|
|
struct svr4_sys_msgget_args {
|
|
|
|
syscallarg(int) what;
|
|
|
|
syscallarg(svr4_key_t) key;
|
|
|
|
syscallarg(int) msgflg;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2003-01-18 11:44:26 +03:00
|
|
|
svr4_msgget(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-10-14 23:24:14 +03:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct svr4_sys_msgget_args *uap = v;
|
|
|
|
struct sys_msgget_args ap;
|
|
|
|
|
|
|
|
SCARG(&ap, key) = SCARG(uap, key);
|
|
|
|
SCARG(&ap, msgflg) = SCARG(uap, msgflg);
|
|
|
|
|
2003-01-18 11:44:26 +03:00
|
|
|
return sys_msgget(l, &ap, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_msgctl_args {
|
|
|
|
syscallarg(int) what;
|
|
|
|
syscallarg(int) msqid;
|
|
|
|
syscallarg(int) cmd;
|
|
|
|
syscallarg(struct svr4_msqid_ds *) buf;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2003-01-18 11:44:26 +03:00
|
|
|
svr4_msgctl(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-10-14 23:24:14 +03:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
struct svr4_sys_msgctl_args *uap = v;
|
2003-01-18 11:44:26 +03:00
|
|
|
struct proc *p = l->l_proc;
|
1999-08-25 08:52:06 +04:00
|
|
|
struct sys___msgctl13_args ap;
|
1995-10-14 23:24:14 +03:00
|
|
|
struct svr4_msqid_ds ss;
|
|
|
|
struct msqid_ds bs;
|
2002-03-16 23:43:48 +03:00
|
|
|
caddr_t sg = stackgap_init(p, 0);
|
1995-10-14 23:24:14 +03:00
|
|
|
|
|
|
|
SCARG(&ap, msqid) = SCARG(uap, msqid);
|
|
|
|
SCARG(&ap, cmd) = SCARG(uap, cmd);
|
2002-03-16 23:43:48 +03:00
|
|
|
SCARG(&ap, buf) = stackgap_alloc(p, &sg, sizeof(bs));
|
1995-10-14 23:24:14 +03:00
|
|
|
|
|
|
|
switch (SCARG(uap, cmd)) {
|
|
|
|
case SVR4_IPC_STAT:
|
|
|
|
SCARG(&ap, cmd) = IPC_STAT;
|
2003-01-18 11:44:26 +03:00
|
|
|
if ((error = sys___msgctl13(l, &ap, retval)) != 0)
|
1995-10-14 23:24:14 +03:00
|
|
|
return error;
|
|
|
|
error = copyin(&bs, SCARG(&ap, buf), sizeof bs);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
bsd_to_svr4_msqid_ds(&bs, &ss);
|
|
|
|
return copyout(&ss, SCARG(uap, buf), sizeof ss);
|
|
|
|
|
|
|
|
case SVR4_IPC_SET:
|
|
|
|
SCARG(&ap, cmd) = IPC_SET;
|
|
|
|
error = copyin(SCARG(uap, buf), &ss, sizeof ss);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
svr4_to_bsd_msqid_ds(&ss, &bs);
|
|
|
|
error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
|
|
|
|
if (error)
|
|
|
|
return error;
|
2003-01-18 11:44:26 +03:00
|
|
|
return sys___msgctl13(l, &ap, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
|
|
|
|
case SVR4_IPC_RMID:
|
|
|
|
SCARG(&ap, cmd) = IPC_RMID;
|
|
|
|
error = copyin(SCARG(uap, buf), &ss, sizeof ss);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
svr4_to_bsd_msqid_ds(&ss, &bs);
|
|
|
|
error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
|
|
|
|
if (error)
|
|
|
|
return error;
|
2003-01-18 11:44:26 +03:00
|
|
|
return sys___msgctl13(l, &ap, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-01-18 11:44:26 +03:00
|
|
|
svr4_sys_msgsys(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-10-14 23:24:14 +03:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct svr4_sys_msgsys_args *uap = v;
|
|
|
|
|
|
|
|
DPRINTF(("svr4_msgsys(%d)\n", SCARG(uap, what)));
|
|
|
|
|
|
|
|
switch (SCARG(uap, what)) {
|
|
|
|
case SVR4_msgsnd:
|
2003-01-18 11:44:26 +03:00
|
|
|
return svr4_msgsnd(l, v, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
case SVR4_msgrcv:
|
2003-01-18 11:44:26 +03:00
|
|
|
return svr4_msgrcv(l, v, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
case SVR4_msgget:
|
2003-01-18 11:44:26 +03:00
|
|
|
return svr4_msgget(l, v, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
case SVR4_msgctl:
|
2003-01-18 11:44:26 +03:00
|
|
|
return svr4_msgctl(l, v, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SYSVSHM
|
|
|
|
|
|
|
|
static void
|
|
|
|
bsd_to_svr4_shmid_ds(bds, sds)
|
|
|
|
const struct shmid_ds *bds;
|
|
|
|
struct svr4_shmid_ds *sds;
|
|
|
|
{
|
|
|
|
bsd_to_svr4_ipc_perm(&bds->shm_perm, &sds->shm_perm);
|
|
|
|
sds->shm_segsz = bds->shm_segsz;
|
|
|
|
sds->shm_lkcnt = 0;
|
|
|
|
sds->shm_lpid = bds->shm_lpid;
|
|
|
|
sds->shm_cpid = bds->shm_cpid;
|
1999-08-25 08:52:06 +04:00
|
|
|
sds->shm_amp = bds->_shm_internal;
|
1995-10-14 23:24:14 +03:00
|
|
|
sds->shm_nattch = bds->shm_nattch;
|
|
|
|
sds->shm_cnattch = 0;
|
|
|
|
sds->shm_atime = bds->shm_atime;
|
|
|
|
sds->shm_pad1 = 0;
|
|
|
|
sds->shm_dtime = bds->shm_dtime;
|
|
|
|
sds->shm_pad2 = 0;
|
|
|
|
sds->shm_ctime = bds->shm_ctime;
|
|
|
|
sds->shm_pad3 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
svr4_to_bsd_shmid_ds(sds, bds)
|
|
|
|
const struct svr4_shmid_ds *sds;
|
|
|
|
struct shmid_ds *bds;
|
|
|
|
{
|
|
|
|
svr4_to_bsd_ipc_perm(&sds->shm_perm, &bds->shm_perm);
|
|
|
|
bds->shm_segsz = sds->shm_segsz;
|
|
|
|
bds->shm_lpid = sds->shm_lpid;
|
|
|
|
bds->shm_cpid = sds->shm_cpid;
|
1999-08-25 08:52:06 +04:00
|
|
|
bds->_shm_internal = sds->shm_amp;
|
1995-10-14 23:24:14 +03:00
|
|
|
bds->shm_nattch = sds->shm_nattch;
|
|
|
|
bds->shm_atime = sds->shm_atime;
|
|
|
|
bds->shm_dtime = sds->shm_dtime;
|
|
|
|
bds->shm_ctime = sds->shm_ctime;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_shmat_args {
|
|
|
|
syscallarg(int) what;
|
|
|
|
syscallarg(int) shmid;
|
|
|
|
syscallarg(void *) shmaddr;
|
|
|
|
syscallarg(int) shmflg;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2003-01-18 11:44:26 +03:00
|
|
|
svr4_shmat(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-10-14 23:24:14 +03:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct svr4_sys_shmat_args *uap = v;
|
|
|
|
struct sys_shmat_args ap;
|
|
|
|
|
|
|
|
SCARG(&ap, shmid) = SCARG(uap, shmid);
|
|
|
|
SCARG(&ap, shmaddr) = SCARG(uap, shmaddr);
|
|
|
|
SCARG(&ap, shmflg) = SCARG(uap, shmflg);
|
|
|
|
|
2003-01-18 11:44:26 +03:00
|
|
|
return sys_shmat(l, &ap, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_shmdt_args {
|
|
|
|
syscallarg(int) what;
|
|
|
|
syscallarg(void *) shmaddr;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2003-01-18 11:44:26 +03:00
|
|
|
svr4_shmdt(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-10-14 23:24:14 +03:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct svr4_sys_shmdt_args *uap = v;
|
|
|
|
struct sys_shmdt_args ap;
|
|
|
|
|
|
|
|
SCARG(&ap, shmaddr) = SCARG(uap, shmaddr);
|
|
|
|
|
2003-01-18 11:44:26 +03:00
|
|
|
return sys_shmdt(l, &ap, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_shmget_args {
|
|
|
|
syscallarg(int) what;
|
|
|
|
syscallarg(key_t) key;
|
|
|
|
syscallarg(int) size;
|
|
|
|
syscallarg(int) shmflg;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2003-01-18 11:44:26 +03:00
|
|
|
svr4_shmget(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-10-14 23:24:14 +03:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct svr4_sys_shmget_args *uap = v;
|
|
|
|
struct sys_shmget_args ap;
|
|
|
|
|
|
|
|
SCARG(&ap, key) = SCARG(uap, key);
|
|
|
|
SCARG(&ap, size) = SCARG(uap, size);
|
|
|
|
SCARG(&ap, shmflg) = SCARG(uap, shmflg);
|
|
|
|
|
2003-01-18 11:44:26 +03:00
|
|
|
return sys_shmget(l, &ap, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_shmctl_args {
|
|
|
|
syscallarg(int) what;
|
|
|
|
syscallarg(int) shmid;
|
|
|
|
syscallarg(int) cmd;
|
|
|
|
syscallarg(struct svr4_shmid_ds *) buf;
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
2003-01-18 11:44:26 +03:00
|
|
|
svr4_shmctl(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-10-14 23:24:14 +03:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct svr4_sys_shmctl_args *uap = v;
|
2003-01-18 11:44:26 +03:00
|
|
|
struct proc *p = l->l_proc;
|
1995-10-14 23:24:14 +03:00
|
|
|
int error;
|
2002-03-16 23:43:48 +03:00
|
|
|
caddr_t sg = stackgap_init(p, 0);
|
1999-08-25 08:52:06 +04:00
|
|
|
struct sys___shmctl13_args ap;
|
1995-10-14 23:24:14 +03:00
|
|
|
struct shmid_ds bs;
|
|
|
|
struct svr4_shmid_ds ss;
|
|
|
|
|
|
|
|
SCARG(&ap, shmid) = SCARG(uap, shmid);
|
1997-03-30 21:21:02 +04:00
|
|
|
|
|
|
|
if (SCARG(uap, buf) != NULL) {
|
2005-02-27 01:58:54 +03:00
|
|
|
SCARG(&ap, buf) = stackgap_alloc(p, &sg,
|
2002-03-18 20:18:28 +03:00
|
|
|
sizeof (struct shmid_ds));
|
1997-03-30 21:21:02 +04:00
|
|
|
switch (SCARG(uap, cmd)) {
|
|
|
|
case SVR4_IPC_SET:
|
|
|
|
case SVR4_IPC_RMID:
|
|
|
|
case SVR4_SHM_LOCK:
|
|
|
|
case SVR4_SHM_UNLOCK:
|
|
|
|
error = copyin(SCARG(uap, buf), (caddr_t) &ss,
|
|
|
|
sizeof ss);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
svr4_to_bsd_shmid_ds(&ss, &bs);
|
|
|
|
error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SCARG(&ap, buf) = NULL;
|
|
|
|
|
|
|
|
|
1995-10-14 23:24:14 +03:00
|
|
|
switch (SCARG(uap, cmd)) {
|
|
|
|
case SVR4_IPC_STAT:
|
|
|
|
SCARG(&ap, cmd) = IPC_STAT;
|
2003-01-18 11:44:26 +03:00
|
|
|
if ((error = sys___shmctl13(l, &ap, retval)) != 0)
|
1995-10-14 23:24:14 +03:00
|
|
|
return error;
|
1997-03-30 21:21:02 +04:00
|
|
|
if (SCARG(uap, buf) == NULL)
|
|
|
|
return 0;
|
1995-10-14 23:24:14 +03:00
|
|
|
error = copyin(&bs, SCARG(&ap, buf), sizeof bs);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
bsd_to_svr4_shmid_ds(&bs, &ss);
|
|
|
|
return copyout(&ss, SCARG(uap, buf), sizeof ss);
|
|
|
|
|
|
|
|
case SVR4_IPC_SET:
|
|
|
|
SCARG(&ap, cmd) = IPC_SET;
|
2003-01-18 11:44:26 +03:00
|
|
|
return sys___shmctl13(l, &ap, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
|
|
|
|
case SVR4_IPC_RMID:
|
|
|
|
case SVR4_SHM_LOCK:
|
|
|
|
case SVR4_SHM_UNLOCK:
|
|
|
|
switch (SCARG(uap, cmd)) {
|
|
|
|
case SVR4_IPC_RMID:
|
|
|
|
SCARG(&ap, cmd) = IPC_RMID;
|
|
|
|
break;
|
|
|
|
case SVR4_SHM_LOCK:
|
|
|
|
SCARG(&ap, cmd) = SHM_LOCK;
|
|
|
|
break;
|
|
|
|
case SVR4_SHM_UNLOCK:
|
|
|
|
SCARG(&ap, cmd) = SHM_UNLOCK;
|
|
|
|
break;
|
1997-03-30 21:21:02 +04:00
|
|
|
default:
|
|
|
|
return EINVAL;
|
1995-10-14 23:24:14 +03:00
|
|
|
}
|
2003-01-18 11:44:26 +03:00
|
|
|
return sys___shmctl13(l, &ap, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-01-18 11:44:26 +03:00
|
|
|
svr4_sys_shmsys(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-10-14 23:24:14 +03:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct svr4_sys_shmsys_args *uap = v;
|
|
|
|
|
|
|
|
DPRINTF(("svr4_shmsys(%d)\n", SCARG(uap, what)));
|
|
|
|
|
|
|
|
switch (SCARG(uap, what)) {
|
|
|
|
case SVR4_shmat:
|
2003-01-18 11:44:26 +03:00
|
|
|
return svr4_shmat(l, v, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
case SVR4_shmdt:
|
2003-01-18 11:44:26 +03:00
|
|
|
return svr4_shmdt(l, v, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
case SVR4_shmget:
|
2003-01-18 11:44:26 +03:00
|
|
|
return svr4_shmget(l, v, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
case SVR4_shmctl:
|
2003-01-18 11:44:26 +03:00
|
|
|
return svr4_shmctl(l, v, retval);
|
1995-10-14 23:24:14 +03:00
|
|
|
default:
|
|
|
|
return ENOSYS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* SYSVSHM */
|