Source-Changes-HG archive

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

[src/trunk]: src/sys Remove compat_linux32 from the autoload list and add a e...



details:   https://anonhg.NetBSD.org/src/rev/0c6102aaf0b7
branches:  trunk
changeset: 826793:0c6102aaf0b7
user:      maxv <maxv%NetBSD.org@localhost>
date:      Fri Sep 29 17:47:29 2017 +0000

description:
Remove compat_linux32 from the autoload list and add a enable/disable
sysctl, like compat_linux.

diffstat:

 sys/compat/linux32/common/linux32_mod.c    |  54 +++++++++++++++++++++++------
 sys/compat/linux32/common/linux32_sysctl.c |  11 +++++-
 sys/compat/linux32/common/linux32_sysctl.h |   4 +-
 sys/kern/kern_exec.c                       |   5 +-
 4 files changed, 56 insertions(+), 18 deletions(-)

diffs (173 lines):

diff -r 60b3cb763b45 -r 0c6102aaf0b7 sys/compat/linux32/common/linux32_mod.c
--- a/sys/compat/linux32/common/linux32_mod.c   Fri Sep 29 17:27:26 2017 +0000
+++ b/sys/compat/linux32/common/linux32_mod.c   Fri Sep 29 17:47:29 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux32_mod.c,v 1.7 2015/12/03 23:51:24 pgoyette Exp $ */
+/*     $NetBSD: linux32_mod.c,v 1.8 2017/09/29 17:47:29 maxv Exp $     */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux32_mod.c,v 1.7 2015/12/03 23:51:24 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_mod.c,v 1.8 2017/09/29 17:47:29 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_execfmt.h"
@@ -44,6 +44,7 @@
 #include <sys/module.h>
 #include <sys/exec.h>
 #include <sys/signalvar.h>
+#include <sys/sysctl.h>
 
 #include <compat/linux/common/linux_exec.h>
 
@@ -77,6 +78,38 @@
 #endif
 };
 
+int linux32_enabled = 0;
+
+int
+linux32_sysctl_enable(SYSCTLFN_ARGS)
+{
+       struct sysctlnode node;
+       int error, val;
+
+       val = *(int *)rnode->sysctl_data;
+
+       node = *rnode;
+       node.sysctl_data = &val;
+
+       error = sysctl_lookup(SYSCTLFN_CALL(&node));
+       if (error != 0 || newp == NULL)
+               return error;
+
+       if (val == 1) {
+               error = exec_add(linux32_execsw, __arraycount(linux32_execsw));
+       } else if (val == 0) {
+               error = exec_remove(linux32_execsw, __arraycount(linux32_execsw));
+       } else {
+               error = EINVAL;
+       }
+       if (error)
+               return error;
+
+       *(int *)rnode->sysctl_data = val;
+
+       return 0;
+}
+
 static int
 compat_linux32_modcmd(modcmd_t cmd, void *arg)
 {
@@ -84,19 +117,16 @@
 
        switch (cmd) {
        case MODULE_CMD_INIT:
+               linux32_enabled = 0;
                linux32_sysctl_init();
-               error = exec_add(linux32_execsw,
-                   __arraycount(linux32_execsw));
-               if (error != 0)
-                       linux32_sysctl_fini();
-               return error;
+               return 0;
 
        case MODULE_CMD_FINI:
-               error = exec_remove(linux32_execsw,
-                   __arraycount(linux32_execsw));
-               if (error == 0)
-                       linux32_sysctl_fini();
-               return error;
+               error = exec_remove(linux32_execsw, __arraycount(linux32_execsw));
+               if (error)
+                       return error;
+               linux32_sysctl_fini();
+               return 0;
 
        default:
                return ENOTTY;
diff -r 60b3cb763b45 -r 0c6102aaf0b7 sys/compat/linux32/common/linux32_sysctl.c
--- a/sys/compat/linux32/common/linux32_sysctl.c        Fri Sep 29 17:27:26 2017 +0000
+++ b/sys/compat/linux32/common/linux32_sysctl.c        Fri Sep 29 17:47:29 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux32_sysctl.c,v 1.16 2014/05/16 12:22:32 martin Exp $ */
+/*     $NetBSD: linux32_sysctl.c,v 1.17 2017/09/29 17:47:29 maxv Exp $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -31,7 +31,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux32_sysctl.c,v 1.16 2014/05/16 12:22:32 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_sysctl.c,v 1.17 2017/09/29 17:47:29 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -70,6 +70,7 @@
 
 static struct sysctllog *linux32_clog1;
 static struct sysctllog *linux32_clog2;
+extern int linux32_enabled;
 
 void
 linux32_sysctl_fini(void)
@@ -119,6 +120,12 @@
                       NULL, 0, linux32_version, sizeof(linux32_version),
                       CTL_EMUL, EMUL_LINUX32, EMUL_LINUX32_KERN,
                       EMUL_LINUX32_KERN_VERSION, CTL_EOL);
+       sysctl_createv(&linux32_clog1, 0, NULL, NULL,
+                      CTLFLAG_READWRITE,
+                      CTLTYPE_INT, "enabled",
+                      SYSCTL_DESCR("Linux 32 bit compat enabled."),
+                      linux32_sysctl_enable, 0, &linux32_enabled, 0,
+                      CTL_EMUL, EMUL_LINUX32, CTL_CREATE, CTL_EOL);
 
        sysctl_createv(&linux32_clog2, 0, &node, &node,
                       CTLFLAG_PERMANENT,
diff -r 60b3cb763b45 -r 0c6102aaf0b7 sys/compat/linux32/common/linux32_sysctl.h
--- a/sys/compat/linux32/common/linux32_sysctl.h        Fri Sep 29 17:27:26 2017 +0000
+++ b/sys/compat/linux32/common/linux32_sysctl.h        Fri Sep 29 17:47:29 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux32_sysctl.h,v 1.2 2008/11/19 18:36:04 ad Exp $ */
+/*     $NetBSD: linux32_sysctl.h,v 1.3 2017/09/29 17:47:29 maxv Exp $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -61,4 +61,6 @@
 void   linux32_sysctl_init(void);
 void   linux32_sysctl_fini(void);
 
+int    linux32_sysctl_enable(SYSCTLFN_PROTO);
+
 #endif /* !_LINUX32_SYSCTL_H */
diff -r 60b3cb763b45 -r 0c6102aaf0b7 sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c      Fri Sep 29 17:27:26 2017 +0000
+++ b/sys/kern/kern_exec.c      Fri Sep 29 17:47:29 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exec.c,v 1.445 2017/09/29 17:08:00 maxv Exp $     */
+/*     $NetBSD: kern_exec.c,v 1.446 2017/09/29 17:47:29 maxv Exp $     */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.445 2017/09/29 17:08:00 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.446 2017/09/29 17:47:29 maxv Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -578,7 +578,6 @@
                "exec_coff",
                "exec_ecoff",
                "compat_aoutm68k",
-               "compat_linux32",
                "compat_netbsd32",
                "compat_sunos",
                "compat_sunos32",



Home | Main Index | Thread Index | Old Index