Prepare for new compat_netbsd32_mqueue module to be split out of

compat_netbsd32.  Refactor the COMPAT_50 code related to mqueue,
and update the syscall definitions.  Remove dependency on mqueue
from the compat_netbsd32 module (the new module will gain this
dependency).

Continuation of work on PR kern/50489
This commit is contained in:
pgoyette 2015-12-01 23:56:43 +00:00
parent 5151d1f84b
commit 1a0fa34dd3
4 changed files with 150 additions and 89 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_compat_50.c,v 1.30 2015/07/24 13:02:52 maxv Exp $ */
/* $NetBSD: netbsd32_compat_50.c,v 1.31 2015/12/01 23:56:43 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -36,7 +36,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.30 2015/07/24 13:02:52 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.31 2015/12/01 23:56:43 pgoyette Exp $");
#if defined(_KERNEL_OPT)
#include "opt_sysv.h"
@ -1079,72 +1079,3 @@ compat_50_netbsd32_quotactl(struct lwp *l, const struct compat_50_netbsd32_quota
return (compat_50_sys_quotactl(l, &ua, retval));
}
int
compat_50_netbsd32_mq_timedsend(struct lwp *l,
const struct compat_50_netbsd32_mq_timedsend_args *uap,
register_t *retval)
{
/* {
syscallarg(mqd_t) mqdes;
syscallarg(const netbsd32_charp) msg_ptr;
syscallarg(netbsd32_size_t) msg_len;
syscallarg(unsigned) msg_prio;
syscallarg(const netbsd32_timespec50p_t) abs_timeout;
} */
struct timespec ts, *tsp;
struct netbsd32_timespec50 ts32;
int error;
/* Get and convert time value */
if (SCARG_P32(uap, abs_timeout)) {
error = copyin(SCARG_P32(uap, abs_timeout), &ts32,
sizeof(ts32));
if (error)
return error;
netbsd32_to_timespec50(&ts32, &ts);
tsp = &ts;
} else {
tsp = NULL;
}
return mq_send1(SCARG(uap, mqdes), SCARG_P32(uap, msg_ptr),
SCARG(uap, msg_len), SCARG(uap, msg_prio), tsp);
}
int
compat_50_netbsd32_mq_timedreceive(struct lwp *l,
const struct compat_50_netbsd32_mq_timedreceive_args *uap,
register_t *retval)
{
/* {
syscallarg(mqd_t) mqdes;
syscallarg(netbsd32_charp) msg_ptr;
syscallarg(netbsd32_size_t) msg_len;
syscallarg(netbsd32_uintp) msg_prio;
syscallarg(const netbsd32_timespec50p_t) abs_timeout;
} */
struct timespec ts, *tsp;
struct netbsd32_timespec50 ts32;
ssize_t mlen;
int error;
/* Get and convert time value */
if (SCARG_P32(uap, abs_timeout)) {
error = copyin(SCARG_P32(uap, abs_timeout), &ts32,
sizeof(ts32));
if (error)
return error;
netbsd32_to_timespec50(&ts32, &ts);
tsp = &ts;
} else {
tsp = NULL;
}
error = mq_recv1(SCARG(uap, mqdes), SCARG_P32(uap, msg_ptr),
SCARG(uap, msg_len), SCARG_P32(uap, msg_prio), tsp, &mlen);
if (error == 0)
*retval = mlen;
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_mod.c,v 1.11 2015/12/01 09:12:23 pgoyette Exp $ */
/* $NetBSD: netbsd32_mod.c,v 1.12 2015/12/01 23:56:43 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.11 2015/12/01 09:12:23 pgoyette Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.12 2015/12/01 23:56:43 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_execfmt.h"
@ -48,7 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.11 2015/12/01 09:12:23 pgoyette E
#include <compat/netbsd32/netbsd32_sysctl.h>
#include <compat/netbsd32/netbsd32_exec.h>
# define DEPS1 "compat,compat_sysv,mqueue,ksem"
# define DEPS1 "compat,compat_sysv,ksem"
#if defined(EXEC_ELF32)
# define DEPS2 ",exec_elf32"

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_mqueue.c,v 1.5 2015/06/30 11:56:27 christos Exp $ */
/* $NetBSD: netbsd32_mqueue.c,v 1.6 2015/12/01 23:56:43 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_mqueue.c,v 1.5 2015/06/30 11:56:27 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_mqueue.c,v 1.6 2015/12/01 23:56:43 pgoyette Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@ -40,12 +40,14 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_mqueue.c,v 1.5 2015/06/30 11:56:27 christos
#include <sys/filedesc.h>
#include <sys/fcntl.h>
#include <sys/module.h>
#include <sys/syscallvar.h>
#include <compat/netbsd32/netbsd32.h>
#include <compat/netbsd32/netbsd32_syscall.h>
#include <compat/netbsd32/netbsd32_syscallargs.h>
#include <compat/netbsd32/netbsd32_conv.h>
extern struct emul emul_netbsd32;
int
netbsd32_mq_open(struct lwp *l, const struct netbsd32_mq_open_args *uap,
@ -322,3 +324,119 @@ netbsd32___mq_timedreceive50(struct lwp *l,
return error;
}
#ifdef COMPAT_50
int
compat_50_netbsd32_mq_timedsend(struct lwp *l,
const struct compat_50_netbsd32_mq_timedsend_args *uap,
register_t *retval)
{
/* {
syscallarg(mqd_t) mqdes;
syscallarg(const netbsd32_charp) msg_ptr;
syscallarg(netbsd32_size_t) msg_len;
syscallarg(unsigned) msg_prio;
syscallarg(const netbsd32_timespec50p_t) abs_timeout;
} */
struct timespec ts, *tsp;
struct netbsd32_timespec50 ts32;
int error;
/* Get and convert time value */
if (SCARG_P32(uap, abs_timeout)) {
error = copyin(SCARG_P32(uap, abs_timeout), &ts32,
sizeof(ts32));
if (error)
return error;
netbsd32_to_timespec50(&ts32, &ts);
tsp = &ts;
} else {
tsp = NULL;
}
return mq_send1(SCARG(uap, mqdes), SCARG_P32(uap, msg_ptr),
SCARG(uap, msg_len), SCARG(uap, msg_prio), tsp);
}
int
compat_50_netbsd32_mq_timedreceive(struct lwp *l,
const struct compat_50_netbsd32_mq_timedreceive_args *uap,
register_t *retval)
{
/* {
syscallarg(mqd_t) mqdes;
syscallarg(netbsd32_charp) msg_ptr;
syscallarg(netbsd32_size_t) msg_len;
syscallarg(netbsd32_uintp) msg_prio;
syscallarg(const netbsd32_timespec50p_t) abs_timeout;
} */
struct timespec ts, *tsp;
struct netbsd32_timespec50 ts32;
ssize_t mlen;
int error;
/* Get and convert time value */
if (SCARG_P32(uap, abs_timeout)) {
error = copyin(SCARG_P32(uap, abs_timeout), &ts32,
sizeof(ts32));
if (error)
return error;
netbsd32_to_timespec50(&ts32, &ts);
tsp = &ts;
} else {
tsp = NULL;
}
error = mq_recv1(SCARG(uap, mqdes), SCARG_P32(uap, msg_ptr),
SCARG(uap, msg_len), SCARG_P32(uap, msg_prio), tsp, &mlen);
if (error == 0)
*retval = mlen;
return error;
}
#endif /* COMPAT_50 */
#define _PKG_ENTRY(name) \
{ NETBSD32_SYS_ ## name, 0, (sy_call_t *)name }
static const struct syscall_package compat_mqueue_syscalls[] = {
_PKG_ENTRY(netbsd32_mq_open),
_PKG_ENTRY(netbsd32_mq_close),
_PKG_ENTRY(netbsd32_mq_unlink),
_PKG_ENTRY(netbsd32_mq_getattr),
_PKG_ENTRY(netbsd32_mq_setattr),
_PKG_ENTRY(netbsd32_mq_notify),
_PKG_ENTRY(netbsd32_mq_send),
_PKG_ENTRY(netbsd32_mq_receive),
_PKG_ENTRY(netbsd32___mq_timedsend50),
_PKG_ENTRY(netbsd32___mq_timedreceive50),
#ifdef COMPAT_50
_PKG_ENTRY(compat_50_netbsd32_mq_timedsend),
_PKG_ENTRY(compat_50_netbsd32_mq_timedreceive),
#endif
{0, 0, NULL}
};
MODULE(MODULE_CLASS_EXEC, compat_netbsd32_mqueue, "mqueue,compat_netbsd32");
static int
compat_netbsd32_mqueue_modcmd(modcmd_t cmd, void *arg)
{
int error;
switch (cmd) {
case MODULE_CMD_INIT:
error = syscall_establish(&emul_netbsd32,
compat_mqueue_syscalls);
break;
case MODULE_CMD_FINI:
error = syscall_disestablish(&emul_netbsd32,
compat_mqueue_syscalls);
break;
default:
error = ENOTTY;
break;
}
return error;
}

View File

@ -1,4 +1,4 @@
$NetBSD: syscalls.master,v 1.110 2015/12/01 09:10:03 pgoyette Exp $
$NetBSD: syscalls.master,v 1.111 2015/12/01 23:56:43 pgoyette Exp $
; from: NetBSD: syscalls.master,v 1.81 1998/07/05 08:49:50 jonathan Exp
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@ -534,30 +534,40 @@
255 STD { int|netbsd32||_ksem_destroy(netbsd32_intptr_t id); }
256 STD { int|netbsd32||_ksem_timedwait(intptr_t id, \
const netbsd32_timespecp_t abstime); }
257 STD { mqd_t|netbsd32||mq_open(const netbsd32_charp name, \
257 STD MODULAR compat_netbsd32_mqueue \
{ mqd_t|netbsd32||mq_open(const netbsd32_charp name, \
int oflag, mode_t mode, \
netbsd32_mq_attrp_t attr); }
258 STD { int|netbsd32||mq_close(mqd_t mqdes); }
259 STD { int|netbsd32||mq_unlink(const netbsd32_charp name); }
260 STD { int|netbsd32||mq_getattr(mqd_t mqdes, \
258 STD MODULAR compat_netbsd32_mqueue \
{ int|netbsd32||mq_close(mqd_t mqdes); }
259 STD MODULAR compat_netbsd32_mqueue \
{ int|netbsd32||mq_unlink(const netbsd32_charp name); }
260 STD MODULAR compat_netbsd32_mqueue \
{ int|netbsd32||mq_getattr(mqd_t mqdes, \
netbsd32_mq_attrp_t mqstat); }
261 STD { int|netbsd32||mq_setattr(mqd_t mqdes, \
261 STD MODULAR compat_netbsd32_mqueue \
{ int|netbsd32||mq_setattr(mqd_t mqdes, \
const netbsd32_mq_attrp_t mqstat, \
netbsd32_mq_attrp_t omqstat); }
262 STD { int|netbsd32||mq_notify(mqd_t mqdes, \
262 STD MODULAR compat_netbsd32_mqueue \
{ int|netbsd32||mq_notify(mqd_t mqdes, \
const netbsd32_sigeventp_t notification); }
263 STD { int|netbsd32||mq_send(mqd_t mqdes, \
263 STD MODULAR compat_netbsd32_mqueue \
{ int|netbsd32||mq_send(mqd_t mqdes, \
const netbsd32_charp msg_ptr, \
netbsd32_size_t msg_len, unsigned msg_prio); }
264 STD { netbsd32_ssize_t|netbsd32||mq_receive(mqd_t mqdes, \
264 STD MODULAR compat_netbsd32_mqueue \
{ netbsd32_ssize_t|netbsd32||mq_receive(mqd_t mqdes, \
netbsd32_charp msg_ptr, \
netbsd32_size_t msg_len, netbsd32_uintp msg_prio); }
265 COMPAT_50 { int|netbsd32||mq_timedsend(mqd_t mqdes, \
265 COMPAT_50 MODULAR compat_netbsd32_mqueue \
{ int|netbsd32||mq_timedsend(mqd_t mqdes, \
const netbsd32_charp msg_ptr, \
netbsd32_size_t msg_len, \
unsigned msg_prio, \
const netbsd32_timespec50p_t abs_timeout); }
266 COMPAT_50 { netbsd32_ssize_t|netbsd32||mq_timedreceive( \
266 COMPAT_50 MODULAR compat_netbsd32_mqueue \
{ netbsd32_ssize_t|netbsd32||mq_timedreceive( \
mqd_t mqdes, \
netbsd32_charp msg_ptr, netbsd32_size_t msg_len, \
netbsd32_uintp msg_prio, \
@ -911,12 +921,14 @@
const netbsd32_sigsetp_t set, \
netbsd32_siginfop_t info, \
netbsd32_timespecp_t timeout); }
432 STD { int|netbsd32|50|mq_timedsend(mqd_t mqdes, \
432 STD MODULAR compat_netbsd32_mqueue \
{ int|netbsd32|50|mq_timedsend(mqd_t mqdes, \
const netbsd32_charp msg_ptr, \
netbsd32_size_t msg_len, \
unsigned msg_prio, \
const netbsd32_timespecp_t abs_timeout); }
433 STD { netbsd32_ssize_t|netbsd32|50|mq_timedreceive( \
433 STD MODULAR compat_netbsd32_mqueue \
{ netbsd32_ssize_t|netbsd32|50|mq_timedreceive( \
mqd_t mqdes, netbsd32_charp msg_ptr, \
netbsd32_size_t msg_len, netbsd32_uintp msg_prio, \
const netbsd32_timespecp_t abs_timeout); }