1999-01-30 06:29:48 +00: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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2005-01-05 22:34:37 +00:00
|
|
|
/*-
|
1999-01-30 06:29:48 +00:00
|
|
|
* Portions of this code have been derived from software contributed
|
|
|
|
* to the FreeBSD Project by Mark Newton.
|
|
|
|
*
|
|
|
|
* Copyright (c) 1999 Mark Newton
|
|
|
|
* 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. 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. 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.
|
|
|
|
*
|
|
|
|
* XXX- This code is presently a no-op on FreeBSD (and isn't compiled due
|
|
|
|
* to preprocessor conditionals). A nice project for a kernel hacking
|
|
|
|
* novice might be to MakeItGo, but I have more important fish to fry
|
|
|
|
* at present.
|
|
|
|
*
|
2003-06-10 21:44:29 +00:00
|
|
|
* Derived from: $NetBSD: svr4_ipc.c,v 1.7 1998/10/19 22:43:00 tron Exp $
|
1999-01-30 06:29:48 +00:00
|
|
|
*/
|
|
|
|
|
2003-06-10 21:44:29 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2005-07-07 19:25:47 +00:00
|
|
|
#include "opt_sysvipc.h"
|
|
|
|
|
1999-01-30 06:29:48 +00:00
|
|
|
#include <sys/param.h>
|
2005-07-07 19:25:47 +00:00
|
|
|
#include <sys/ipc.h>
|
|
|
|
#include <sys/msg.h>
|
1999-01-30 06:29:48 +00:00
|
|
|
#include <sys/proc.h>
|
2005-07-07 19:25:47 +00:00
|
|
|
#include <sys/sem.h>
|
|
|
|
#include <sys/shm.h>
|
|
|
|
#include <sys/syscallsubr.h>
|
|
|
|
#include <sys/sysproto.h>
|
|
|
|
#include <sys/systm.h>
|
1999-01-30 06:29:48 +00:00
|
|
|
#include <sys/time.h>
|
|
|
|
|
2000-08-31 22:54:09 +00:00
|
|
|
#include <compat/svr4/svr4.h>
|
|
|
|
#include <compat/svr4/svr4_types.h>
|
|
|
|
#include <compat/svr4/svr4_signal.h>
|
|
|
|
#include <compat/svr4/svr4_proto.h>
|
|
|
|
#include <compat/svr4/svr4_util.h>
|
|
|
|
#include <compat/svr4/svr4_ipc.h>
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
#if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
|
2002-03-20 05:48:58 +00:00
|
|
|
static void svr4_to_bsd_ipc_perm(const struct svr4_ipc_perm *,
|
|
|
|
struct ipc_perm *);
|
|
|
|
static void bsd_to_svr4_ipc_perm(const struct ipc_perm *,
|
|
|
|
struct svr4_ipc_perm *);
|
1999-01-30 06:29:48 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SYSVSEM
|
2002-03-20 05:48:58 +00:00
|
|
|
static void bsd_to_svr4_semid_ds(const struct semid_ds *,
|
|
|
|
struct svr4_semid_ds *);
|
|
|
|
static void svr4_to_bsd_semid_ds(const struct svr4_semid_ds *,
|
|
|
|
struct semid_ds *);
|
2005-07-07 19:25:47 +00:00
|
|
|
static int svr4_semop(struct thread *, void *);
|
|
|
|
static int svr4_semget(struct thread *, void *);
|
|
|
|
static int svr4_semctl(struct thread *, void *);
|
1999-01-30 06:29:48 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SYSVMSG
|
2002-03-20 05:48:58 +00:00
|
|
|
static void bsd_to_svr4_msqid_ds(const struct msqid_ds *,
|
|
|
|
struct svr4_msqid_ds *);
|
|
|
|
static void svr4_to_bsd_msqid_ds(const struct svr4_msqid_ds *,
|
|
|
|
struct msqid_ds *);
|
2005-07-07 19:25:47 +00:00
|
|
|
static int svr4_msgsnd(struct thread *, void *);
|
|
|
|
static int svr4_msgrcv(struct thread *, void *);
|
|
|
|
static int svr4_msgget(struct thread *, void *);
|
|
|
|
static int svr4_msgctl(struct thread *, void *);
|
1999-01-30 06:29:48 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SYSVSHM
|
2002-03-20 05:48:58 +00:00
|
|
|
static void bsd_to_svr4_shmid_ds(const struct shmid_ds *,
|
|
|
|
struct svr4_shmid_ds *);
|
|
|
|
static void svr4_to_bsd_shmid_ds(const struct svr4_shmid_ds *,
|
|
|
|
struct shmid_ds *);
|
2005-07-07 19:25:47 +00:00
|
|
|
static int svr4_shmat(struct thread *, void *);
|
|
|
|
static int svr4_shmdt(struct thread *, void *);
|
|
|
|
static int svr4_shmget(struct thread *, void *);
|
|
|
|
static int svr4_shmctl(struct thread *, void *);
|
1999-01-30 06:29:48 +00: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;
|
|
|
|
{
|
|
|
|
bpp->key = spp->key;
|
|
|
|
bpp->uid = spp->uid;
|
|
|
|
bpp->gid = spp->gid;
|
|
|
|
bpp->cuid = spp->cuid;
|
|
|
|
bpp->cgid = spp->cgid;
|
|
|
|
bpp->mode = spp->mode;
|
|
|
|
bpp->seq = spp->seq;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bsd_to_svr4_ipc_perm(bpp, spp)
|
|
|
|
const struct ipc_perm *bpp;
|
|
|
|
struct svr4_ipc_perm *spp;
|
|
|
|
{
|
|
|
|
spp->key = bpp->key;
|
|
|
|
spp->uid = bpp->uid;
|
|
|
|
spp->gid = bpp->gid;
|
|
|
|
spp->cuid = bpp->cuid;
|
|
|
|
spp->cgid = bpp->cgid;
|
|
|
|
spp->mode = bpp->mode;
|
|
|
|
spp->seq = bpp->seq;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SYSVSEM
|
|
|
|
static void
|
|
|
|
bsd_to_svr4_semid_ds(bds, sds)
|
|
|
|
const struct semid_ds *bds;
|
|
|
|
struct svr4_semid_ds *sds;
|
|
|
|
{
|
2009-06-24 21:10:52 +00:00
|
|
|
bzero(sds, sizeof(*sds));
|
1999-01-30 06:29:48 +00:00
|
|
|
bsd_to_svr4_ipc_perm(&bds->sem_perm, &sds->sem_perm);
|
|
|
|
sds->sem_base = (struct svr4_sem *) bds->sem_base;
|
|
|
|
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);
|
|
|
|
bds->sem_base = (struct sem *) bds->sem_base;
|
|
|
|
bds->sem_nsems = sds->sem_nsems;
|
|
|
|
bds->sem_otime = sds->sem_otime;
|
|
|
|
bds->sem_ctime = sds->sem_ctime;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_semctl_args {
|
2005-07-07 19:25:47 +00:00
|
|
|
int what;
|
|
|
|
int semid;
|
|
|
|
int semnum;
|
|
|
|
int cmd;
|
|
|
|
union semun arg;
|
1999-01-30 06:29:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2005-07-07 19:25:47 +00:00
|
|
|
svr4_semctl(td, v)
|
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct svr4_sys_semctl_args *uap = v;
|
|
|
|
struct svr4_semid_ds ss;
|
2006-06-27 18:28:50 +00:00
|
|
|
struct semid_ds bs;
|
|
|
|
union semun semun;
|
2006-07-08 19:51:38 +00:00
|
|
|
register_t rval;
|
2006-06-27 18:28:50 +00:00
|
|
|
int cmd, error;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
switch (uap->cmd) {
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_SEM_GETZCNT:
|
2006-06-27 18:28:50 +00:00
|
|
|
cmd = GETZCNT;
|
|
|
|
break;
|
|
|
|
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_SEM_GETNCNT:
|
2006-06-27 18:28:50 +00:00
|
|
|
cmd = GETNCNT;
|
|
|
|
break;
|
|
|
|
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_SEM_GETPID:
|
2006-06-27 18:28:50 +00:00
|
|
|
cmd = GETPID;
|
|
|
|
break;
|
|
|
|
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_SEM_GETVAL:
|
2006-06-27 18:28:50 +00:00
|
|
|
cmd = GETVAL;
|
|
|
|
break;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
case SVR4_SEM_SETVAL:
|
2006-06-27 18:28:50 +00:00
|
|
|
cmd = SETVAL;
|
|
|
|
break;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
case SVR4_SEM_GETALL:
|
2006-06-27 18:28:50 +00:00
|
|
|
cmd = GETVAL;
|
|
|
|
break;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
case SVR4_SEM_SETALL:
|
2006-06-27 18:28:50 +00:00
|
|
|
cmd = SETVAL;
|
|
|
|
break;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
case SVR4_IPC_STAT:
|
2006-06-27 18:28:50 +00:00
|
|
|
cmd = IPC_STAT;
|
|
|
|
semun.buf = &bs;
|
|
|
|
error = kern_semctl(td, uap->semid, uap->semnum, cmd, &semun,
|
2006-07-08 19:51:38 +00:00
|
|
|
&rval);
|
1999-01-30 06:29:48 +00:00
|
|
|
if (error)
|
2006-07-08 19:51:38 +00:00
|
|
|
return (error);
|
1999-01-30 06:29:48 +00:00
|
|
|
bsd_to_svr4_semid_ds(&bs, &ss);
|
2006-07-08 19:51:38 +00:00
|
|
|
error = copyout(&ss, uap->arg.buf, sizeof(ss));
|
|
|
|
if (error == 0)
|
|
|
|
td->td_retval[0] = rval;
|
|
|
|
return (error);
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
case SVR4_IPC_SET:
|
2006-06-27 18:28:50 +00:00
|
|
|
cmd = IPC_SET;
|
2002-12-14 01:56:26 +00:00
|
|
|
error = copyin(uap->arg.buf, (caddr_t) &ss, sizeof ss);
|
1999-01-30 06:29:48 +00:00
|
|
|
if (error)
|
2006-07-08 19:51:38 +00:00
|
|
|
return (error);
|
1999-01-30 06:29:48 +00:00
|
|
|
svr4_to_bsd_semid_ds(&ss, &bs);
|
2006-06-27 18:28:50 +00:00
|
|
|
semun.buf = &bs;
|
2006-07-08 19:51:38 +00:00
|
|
|
return (kern_semctl(td, uap->semid, uap->semnum, cmd, &semun,
|
|
|
|
td->td_retval));
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
case SVR4_IPC_RMID:
|
2006-06-27 18:28:50 +00:00
|
|
|
cmd = IPC_RMID;
|
|
|
|
break;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
2006-06-27 18:28:50 +00:00
|
|
|
|
2006-07-08 19:51:38 +00:00
|
|
|
return (kern_semctl(td, uap->semid, uap->semnum, cmd, &uap->arg,
|
|
|
|
td->td_retval));
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_semget_args {
|
2005-07-07 19:25:47 +00:00
|
|
|
int what;
|
|
|
|
svr4_key_t key;
|
|
|
|
int nsems;
|
|
|
|
int semflg;
|
1999-01-30 06:29:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2005-07-07 19:25:47 +00:00
|
|
|
svr4_semget(td, v)
|
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct svr4_sys_semget_args *uap = v;
|
2005-07-07 19:25:47 +00:00
|
|
|
struct semget_args ap;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
ap.key = uap->key;
|
|
|
|
ap.nsems = uap->nsems;
|
|
|
|
ap.semflg = uap->semflg;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_semget(td, &ap);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_semop_args {
|
2005-07-07 19:25:47 +00:00
|
|
|
int what;
|
|
|
|
int semid;
|
|
|
|
struct svr4_sembuf * sops;
|
|
|
|
u_int nsops;
|
1999-01-30 06:29:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2005-07-07 19:25:47 +00:00
|
|
|
svr4_semop(td, v)
|
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct svr4_sys_semop_args *uap = v;
|
2005-07-07 19:25:47 +00:00
|
|
|
struct semop_args ap;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
ap.semid = uap->semid;
|
1999-01-30 06:29:48 +00:00
|
|
|
/* These are the same */
|
2002-12-14 01:56:26 +00:00
|
|
|
ap.sops = (struct sembuf *) uap->sops;
|
|
|
|
ap.nsops = uap->nsops;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_semop(td, &ap);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-07-07 19:25:47 +00:00
|
|
|
svr4_sys_semsys(td, uap)
|
|
|
|
struct thread *td;
|
|
|
|
struct svr4_sys_semsys_args *uap;
|
1999-01-30 06:29:48 +00:00
|
|
|
{
|
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
DPRINTF(("svr4_semsys(%d)\n", uap->what));
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
switch (uap->what) {
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_semctl:
|
2005-07-07 19:25:47 +00:00
|
|
|
return svr4_semctl(td, uap);
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_semget:
|
2005-07-07 19:25:47 +00:00
|
|
|
return svr4_semget(td, uap);
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_semop:
|
2005-07-07 19:25:47 +00:00
|
|
|
return svr4_semop(td, uap);
|
1999-01-30 06:29:48 +00:00
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
}
|
2005-07-29 19:41:04 +00:00
|
|
|
|
|
|
|
MODULE_DEPEND(svr4elf, sysvsem, 1, 1, 1);
|
1999-01-30 06:29:48 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SYSVMSG
|
|
|
|
static void
|
|
|
|
bsd_to_svr4_msqid_ds(bds, sds)
|
|
|
|
const struct msqid_ds *bds;
|
|
|
|
struct svr4_msqid_ds *sds;
|
|
|
|
{
|
2009-06-24 21:10:52 +00:00
|
|
|
bzero(sds, sizeof(*sds));
|
1999-01-30 06:29:48 +00:00
|
|
|
bsd_to_svr4_ipc_perm(&bds->msg_perm, &sds->msg_perm);
|
|
|
|
sds->msg_first = (struct svr4_msg *) bds->msg_first;
|
|
|
|
sds->msg_last = (struct svr4_msg *) bds->msg_last;
|
|
|
|
sds->msg_cbytes = bds->msg_cbytes;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
bds->msg_first = (struct msg *) sds->msg_first;
|
|
|
|
bds->msg_last = (struct msg *) sds->msg_last;
|
|
|
|
bds->msg_cbytes = sds->msg_cbytes;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_msgsnd_args {
|
2005-07-07 19:25:47 +00:00
|
|
|
int what;
|
|
|
|
int msqid;
|
|
|
|
void * msgp;
|
|
|
|
size_t msgsz;
|
|
|
|
int msgflg;
|
1999-01-30 06:29:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2005-07-07 19:25:47 +00:00
|
|
|
svr4_msgsnd(td, v)
|
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct svr4_sys_msgsnd_args *uap = v;
|
2005-07-07 19:25:47 +00:00
|
|
|
struct msgsnd_args ap;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
ap.msqid = uap->msqid;
|
|
|
|
ap.msgp = uap->msgp;
|
|
|
|
ap.msgsz = uap->msgsz;
|
|
|
|
ap.msgflg = uap->msgflg;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_msgsnd(td, &ap);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_msgrcv_args {
|
2005-07-07 19:25:47 +00:00
|
|
|
int what;
|
|
|
|
int msqid;
|
|
|
|
void * msgp;
|
|
|
|
size_t msgsz;
|
|
|
|
long msgtyp;
|
|
|
|
int msgflg;
|
1999-01-30 06:29:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2005-07-07 19:25:47 +00:00
|
|
|
svr4_msgrcv(td, v)
|
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct svr4_sys_msgrcv_args *uap = v;
|
2005-07-07 19:25:47 +00:00
|
|
|
struct msgrcv_args ap;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
ap.msqid = uap->msqid;
|
|
|
|
ap.msgp = uap->msgp;
|
|
|
|
ap.msgsz = uap->msgsz;
|
|
|
|
ap.msgtyp = uap->msgtyp;
|
|
|
|
ap.msgflg = uap->msgflg;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_msgrcv(td, &ap);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_msgget_args {
|
2005-07-07 19:25:47 +00:00
|
|
|
int what;
|
|
|
|
svr4_key_t key;
|
|
|
|
int msgflg;
|
1999-01-30 06:29:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2005-07-07 19:25:47 +00:00
|
|
|
svr4_msgget(td, v)
|
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct svr4_sys_msgget_args *uap = v;
|
2005-07-07 19:25:47 +00:00
|
|
|
struct msgget_args ap;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
ap.key = uap->key;
|
|
|
|
ap.msgflg = uap->msgflg;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_msgget(td, &ap);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_msgctl_args {
|
2005-07-07 19:25:47 +00:00
|
|
|
int what;
|
|
|
|
int msqid;
|
|
|
|
int cmd;
|
|
|
|
struct svr4_msqid_ds * buf;
|
1999-01-30 06:29:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2005-07-07 19:25:47 +00:00
|
|
|
svr4_msgctl(td, v)
|
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct svr4_sys_msgctl_args *uap = v;
|
|
|
|
struct svr4_msqid_ds ss;
|
|
|
|
struct msqid_ds bs;
|
- Implement svr4_emul_find() using kern_alternate_path(). This changes
the semantics in that the returned filename to use is now a kernel
pointer rather than a user space pointer. This required changing the
arguments to the CHECKALT*() macros some and changing the various system
calls that used pathnames to use the kern_foo() functions that can accept
kernel space filename pointers instead of calling the system call
directly.
- Use kern_open(), kern_access(), kern_msgctl(), kern_execve(),
kern_mkfifo(), kern_mknod(), kern_statfs(), kern_fstatfs(),
kern_setitimer(), kern_stat(), kern_lstat(), kern_fstat(), kern_utimes(),
kern_pathconf(), and kern_unlink().
2005-02-07 21:53:42 +00:00
|
|
|
int error;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
switch (uap->cmd) {
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_IPC_STAT:
|
- Implement svr4_emul_find() using kern_alternate_path(). This changes
the semantics in that the returned filename to use is now a kernel
pointer rather than a user space pointer. This required changing the
arguments to the CHECKALT*() macros some and changing the various system
calls that used pathnames to use the kern_foo() functions that can accept
kernel space filename pointers instead of calling the system call
directly.
- Use kern_open(), kern_access(), kern_msgctl(), kern_execve(),
kern_mkfifo(), kern_mknod(), kern_statfs(), kern_fstatfs(),
kern_setitimer(), kern_stat(), kern_lstat(), kern_fstat(), kern_utimes(),
kern_pathconf(), and kern_unlink().
2005-02-07 21:53:42 +00:00
|
|
|
error = kern_msgctl(td, uap->msqid, IPC_STAT, &bs);
|
1999-01-30 06:29:48 +00:00
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
bsd_to_svr4_msqid_ds(&bs, &ss);
|
2002-12-14 01:56:26 +00:00
|
|
|
return copyout(&ss, uap->buf, sizeof ss);
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
case SVR4_IPC_SET:
|
2002-12-14 01:56:26 +00:00
|
|
|
error = copyin(uap->buf, &ss, sizeof ss);
|
1999-01-30 06:29:48 +00:00
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
svr4_to_bsd_msqid_ds(&ss, &bs);
|
- Implement svr4_emul_find() using kern_alternate_path(). This changes
the semantics in that the returned filename to use is now a kernel
pointer rather than a user space pointer. This required changing the
arguments to the CHECKALT*() macros some and changing the various system
calls that used pathnames to use the kern_foo() functions that can accept
kernel space filename pointers instead of calling the system call
directly.
- Use kern_open(), kern_access(), kern_msgctl(), kern_execve(),
kern_mkfifo(), kern_mknod(), kern_statfs(), kern_fstatfs(),
kern_setitimer(), kern_stat(), kern_lstat(), kern_fstat(), kern_utimes(),
kern_pathconf(), and kern_unlink().
2005-02-07 21:53:42 +00:00
|
|
|
return (kern_msgctl(td, uap->msqid, IPC_SET, &bs));
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
case SVR4_IPC_RMID:
|
2006-07-06 21:38:24 +00:00
|
|
|
return (kern_msgctl(td, uap->msqid, IPC_RMID, NULL));
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-07-07 19:25:47 +00:00
|
|
|
svr4_sys_msgsys(td, uap)
|
|
|
|
struct thread *td;
|
|
|
|
struct svr4_sys_msgsys_args *uap;
|
1999-01-30 06:29:48 +00:00
|
|
|
{
|
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
DPRINTF(("svr4_msgsys(%d)\n", uap->what));
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
switch (uap->what) {
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_msgsnd:
|
2005-07-07 19:25:47 +00:00
|
|
|
return svr4_msgsnd(td, uap);
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_msgrcv:
|
2005-07-07 19:25:47 +00:00
|
|
|
return svr4_msgrcv(td, uap);
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_msgget:
|
2005-07-07 19:25:47 +00:00
|
|
|
return svr4_msgget(td, uap);
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_msgctl:
|
2005-07-07 19:25:47 +00:00
|
|
|
return svr4_msgctl(td, uap);
|
1999-01-30 06:29:48 +00:00
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
}
|
2005-07-29 19:41:04 +00:00
|
|
|
|
|
|
|
MODULE_DEPEND(svr4elf, sysvmsg, 1, 1, 1);
|
1999-01-30 06:29:48 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SYSVSHM
|
|
|
|
|
|
|
|
static void
|
|
|
|
bsd_to_svr4_shmid_ds(bds, sds)
|
|
|
|
const struct shmid_ds *bds;
|
|
|
|
struct svr4_shmid_ds *sds;
|
|
|
|
{
|
2009-06-24 21:10:52 +00:00
|
|
|
bzero(sds, sizeof(*sds));
|
1999-01-30 06:29:48 +00:00
|
|
|
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;
|
2009-06-24 21:10:52 +00:00
|
|
|
sds->shm_amp = 0;
|
1999-01-30 06:29:48 +00:00
|
|
|
sds->shm_nattch = bds->shm_nattch;
|
|
|
|
sds->shm_cnattch = 0;
|
|
|
|
sds->shm_atime = bds->shm_atime;
|
|
|
|
sds->shm_dtime = bds->shm_dtime;
|
|
|
|
sds->shm_ctime = bds->shm_ctime;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
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 {
|
2005-07-07 19:25:47 +00:00
|
|
|
int what;
|
|
|
|
int shmid;
|
|
|
|
void * shmaddr;
|
|
|
|
int shmflg;
|
1999-01-30 06:29:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2005-07-07 19:25:47 +00:00
|
|
|
svr4_shmat(td, v)
|
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct svr4_sys_shmat_args *uap = v;
|
2005-07-07 19:25:47 +00:00
|
|
|
struct shmat_args ap;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
ap.shmid = uap->shmid;
|
|
|
|
ap.shmaddr = uap->shmaddr;
|
|
|
|
ap.shmflg = uap->shmflg;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_shmat(td, &ap);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_shmdt_args {
|
2005-07-07 19:25:47 +00:00
|
|
|
int what;
|
|
|
|
void * shmaddr;
|
1999-01-30 06:29:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2005-07-07 19:25:47 +00:00
|
|
|
svr4_shmdt(td, v)
|
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct svr4_sys_shmdt_args *uap = v;
|
2005-07-07 19:25:47 +00:00
|
|
|
struct shmdt_args ap;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
ap.shmaddr = uap->shmaddr;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_shmdt(td, &ap);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_shmget_args {
|
2005-07-07 19:25:47 +00:00
|
|
|
int what;
|
|
|
|
key_t key;
|
|
|
|
int size;
|
|
|
|
int shmflg;
|
1999-01-30 06:29:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2005-07-07 19:25:47 +00:00
|
|
|
svr4_shmget(td, v)
|
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct svr4_sys_shmget_args *uap = v;
|
2005-07-07 19:25:47 +00:00
|
|
|
struct shmget_args ap;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
ap.key = uap->key;
|
|
|
|
ap.size = uap->size;
|
|
|
|
ap.shmflg = uap->shmflg;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2011-09-16 13:58:51 +00:00
|
|
|
return sys_shmget(td, &ap);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct svr4_sys_shmctl_args {
|
2005-07-07 19:25:47 +00:00
|
|
|
int what;
|
|
|
|
int shmid;
|
|
|
|
int cmd;
|
|
|
|
struct svr4_shmid_ds * buf;
|
1999-01-30 06:29:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int
|
2005-07-07 19:25:47 +00:00
|
|
|
svr4_shmctl(td, v)
|
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct svr4_sys_shmctl_args *uap = v;
|
|
|
|
struct shmid_ds bs;
|
|
|
|
struct svr4_shmid_ds ss;
|
2006-06-27 18:31:36 +00:00
|
|
|
size_t bufsize;
|
|
|
|
int cmd, error;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
if (uap->buf != NULL) {
|
|
|
|
switch (uap->cmd) {
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_IPC_SET:
|
|
|
|
case SVR4_SHM_LOCK:
|
|
|
|
case SVR4_SHM_UNLOCK:
|
2006-06-27 18:31:36 +00:00
|
|
|
error = copyin(uap->buf, &ss, sizeof(ss));
|
1999-01-30 06:29:48 +00:00
|
|
|
if (error)
|
2006-06-27 18:31:36 +00:00
|
|
|
return (error);
|
1999-01-30 06:29:48 +00:00
|
|
|
svr4_to_bsd_shmid_ds(&ss, &bs);
|
|
|
|
break;
|
|
|
|
default:
|
2006-06-27 18:31:36 +00:00
|
|
|
return (EINVAL);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
switch (uap->cmd) {
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_IPC_STAT:
|
2006-06-27 18:31:36 +00:00
|
|
|
cmd = IPC_STAT;
|
|
|
|
break;
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_IPC_SET:
|
2006-06-27 18:31:36 +00:00
|
|
|
cmd = IPC_SET;
|
|
|
|
break;
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_IPC_RMID:
|
2006-06-27 18:31:36 +00:00
|
|
|
cmd = IPC_RMID;
|
|
|
|
break;
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_SHM_LOCK:
|
2006-06-27 18:31:36 +00:00
|
|
|
cmd = SHM_LOCK;
|
|
|
|
break;
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_SHM_UNLOCK:
|
2006-06-27 18:31:36 +00:00
|
|
|
cmd = SHM_UNLOCK;
|
|
|
|
break;
|
1999-01-30 06:29:48 +00:00
|
|
|
default:
|
2006-06-27 18:31:36 +00:00
|
|
|
return (EINVAL);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
2006-06-27 18:31:36 +00:00
|
|
|
|
|
|
|
error = kern_shmctl(td, uap->shmid, cmd, &bs, &bufsize);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
switch (uap->cmd) {
|
|
|
|
case SVR4_IPC_STAT:
|
|
|
|
if (uap->buf != NULL) {
|
|
|
|
bsd_to_svr4_shmid_ds(&bs, &ss);
|
|
|
|
error = copyout(&ss, uap->buf, sizeof(ss));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-07-07 19:25:47 +00:00
|
|
|
svr4_sys_shmsys(td, uap)
|
|
|
|
struct thread *td;
|
|
|
|
struct svr4_sys_shmsys_args *uap;
|
1999-01-30 06:29:48 +00:00
|
|
|
{
|
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
DPRINTF(("svr4_shmsys(%d)\n", uap->what));
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
switch (uap->what) {
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_shmat:
|
2005-07-07 19:25:47 +00:00
|
|
|
return svr4_shmat(td, uap);
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_shmdt:
|
2005-07-07 19:25:47 +00:00
|
|
|
return svr4_shmdt(td, uap);
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_shmget:
|
2005-07-07 19:25:47 +00:00
|
|
|
return svr4_shmget(td, uap);
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_shmctl:
|
2005-07-07 19:25:47 +00:00
|
|
|
return svr4_shmctl(td, uap);
|
1999-01-30 06:29:48 +00:00
|
|
|
default:
|
|
|
|
return ENOSYS;
|
|
|
|
}
|
|
|
|
}
|
2005-07-29 19:41:04 +00:00
|
|
|
|
|
|
|
MODULE_DEPEND(svr4elf, sysvshm, 1, 1, 1);
|
1999-01-30 06:29:48 +00:00
|
|
|
#endif /* SYSVSHM */
|