Add an option "modctl" to capture modctl().

This commit is contained in:
hannken 2018-12-16 14:03:37 +00:00
parent abef26c33c
commit 650b07c895
2 changed files with 54 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: hijack.c,v 1.125 2018/06/28 06:20:36 ozaki-r Exp $ */
/* $NetBSD: hijack.c,v 1.126 2018/12/16 14:03:37 hannken Exp $ */
/*-
* Copyright (c) 2011 Antti Kantee. All Rights Reserved.
@ -34,7 +34,7 @@
#include <rump/rumpuser_port.h>
#if !defined(lint)
__RCSID("$NetBSD: hijack.c,v 1.125 2018/06/28 06:20:36 ozaki-r Exp $");
__RCSID("$NetBSD: hijack.c,v 1.126 2018/12/16 14:03:37 hannken Exp $");
#endif
#include <sys/param.h>
@ -138,6 +138,7 @@ enum dualcall {
#ifdef __NetBSD__
DUALCALL___SYSCTL,
DUALCALL_MODCTL,
#endif
#ifdef __NetBSD__
@ -351,6 +352,7 @@ struct sysnames {
#ifdef __NetBSD__
{ DUALCALL___SYSCTL, "__sysctl", RSYS_NAME(__SYSCTL) },
{ DUALCALL_MODCTL, "modctl", RSYS_NAME(MODCTL) },
#endif
#ifdef __NetBSD__
@ -814,6 +816,30 @@ sysctlparser(char *buf)
errx(1, "sysctl value should be y(es)/n(o), gave: %s", buf);
}
static bool rumpmodctl = false;
static void
modctlparser(char *buf)
{
if (buf == NULL) {
rumpmodctl = true;
return;
}
if (strcasecmp(buf, "y") == 0 || strcasecmp(buf, "yes") == 0 ||
strcasecmp(buf, "yep") == 0 || strcasecmp(buf, "tottakai") == 0) {
rumpmodctl = true;
return;
}
if (strcasecmp(buf, "n") == 0 || strcasecmp(buf, "no") == 0) {
rumpmodctl = false;
return;
}
errx(1, "modctl value should be y(es)/n(o), gave: %s", buf);
}
static void
fdoffparser(char *buf)
{
@ -841,6 +867,7 @@ static struct {
{ blanketparser, "blanket", true },
{ vfsparser, "vfs", true },
{ sysctlparser, "sysctl", false },
{ modctlparser, "modctl", false },
{ fdoffparser, "fdoff", true },
{ NULL, NULL, false },
};
@ -2334,6 +2361,20 @@ __sysctl(const int *name, unsigned int namelen, void *old, size_t *oldlenp,
return op___sysctl(name, namelen, old, oldlenp, new, newlen);
}
int modctl(int, void *);
int
modctl(int operation, void *argp)
{
int (*op_modctl)(int operation, void *argp);
if (rumpmodctl) {
op_modctl = GETSYSCALL(rump, MODCTL);
} else {
op_modctl = GETSYSCALL(host, MODCTL);
}
return op_modctl(operation, argp);
}
#endif
/*

View File

@ -1,4 +1,4 @@
.\" $NetBSD: rumphijack.3,v 1.12 2011/03/14 15:21:22 pooka Exp $
.\" $NetBSD: rumphijack.3,v 1.13 2018/12/16 14:03:37 hannken Exp $
.\"
.\" Copyright (c) 2011 Antti Kantee. All rights reserved.
.\"
@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd March 14, 2011
.Dd December 16, 2018
.Dt RUMPHIJACK 3
.Os
.Sh NAME
@ -173,6 +173,15 @@ Acceptable values are
and
.Dq no ,
meaning to call the rump or the host kernel, respectively.
.It Dq modctl
Direct the
.Fn modctl
call to the rump kernel.
Acceptable values are
.Dq yes
and
.Dq no ,
meaning to call the rump or the host kernel, respectively.
.It Dq fdoff
Adjust the library's fd offset to the specified value.
All rump kernel descriptors have the offset added to them