Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/librumphijack Add an option "modctl" to capture modctl().



details:   https://anonhg.NetBSD.org/src/rev/b0b1431cee76
branches:  trunk
changeset: 446739:b0b1431cee76
user:      hannken <hannken%NetBSD.org@localhost>
date:      Sun Dec 16 14:03:37 2018 +0000

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

diffstat:

 lib/librumphijack/hijack.c     |  45 ++++++++++++++++++++++++++++++++++++++++-
 lib/librumphijack/rumphijack.3 |  13 ++++++++++-
 2 files changed, 54 insertions(+), 4 deletions(-)

diffs (128 lines):

diff -r e5f5a71b6aec -r b0b1431cee76 lib/librumphijack/hijack.c
--- a/lib/librumphijack/hijack.c        Sun Dec 16 11:40:09 2018 +0000
+++ b/lib/librumphijack/hijack.c        Sun Dec 16 14:03:37 2018 +0000
@@ -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 @@
 
 #ifdef __NetBSD__
        DUALCALL___SYSCTL,
+       DUALCALL_MODCTL,
 #endif
 
 #ifdef __NetBSD__
@@ -351,6 +352,7 @@
 
 #ifdef __NetBSD__
        { DUALCALL___SYSCTL,    "__sysctl",     RSYS_NAME(__SYSCTL)     },
+       { DUALCALL_MODCTL,      "modctl",       RSYS_NAME(MODCTL)       },
 #endif
 
 #ifdef __NetBSD__
@@ -814,6 +816,30 @@
        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 @@
        { blanketparser, "blanket", true },
        { vfsparser, "vfs", true },
        { sysctlparser, "sysctl", false },
+       { modctlparser, "modctl", false },
        { fdoffparser, "fdoff", true },
        { NULL, NULL, false },
 };
@@ -2334,6 +2361,20 @@
 
        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
 
 /*
diff -r e5f5a71b6aec -r b0b1431cee76 lib/librumphijack/rumphijack.3
--- a/lib/librumphijack/rumphijack.3    Sun Dec 16 11:40:09 2018 +0000
+++ b/lib/librumphijack/rumphijack.3    Sun Dec 16 14:03:37 2018 +0000
@@ -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 @@
 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



Home | Main Index | Thread Index | Old Index