Module Name: src
Committed By: pgoyette
Date: Sat Mar 21 16:28:57 UTC 2020
Modified Files:
src/sys/compat/linux/common: linux_mod.c linux_sysctl.c linux_sysctl.h
src/sys/compat/linux32/common: linux32_mod.c linux32_sysctl.c
linux32_sysctl.h
Log Message:
Deal with having to teardown sysctl entries in multiple sub-trees.
(This used to work, but I broke it recently.)
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/compat/linux/common/linux_mod.c
cvs rdiff -u -r1.45 -r1.46 src/sys/compat/linux/common/linux_sysctl.c
cvs rdiff -u -r1.7 -r1.8 src/sys/compat/linux/common/linux_sysctl.h
cvs rdiff -u -r1.13 -r1.14 src/sys/compat/linux32/common/linux32_mod.c
cvs rdiff -u -r1.18 -r1.19 src/sys/compat/linux32/common/linux32_sysctl.c
cvs rdiff -u -r1.5 -r1.6 src/sys/compat/linux32/common/linux32_sysctl.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/compat/linux/common/linux_mod.c
diff -u src/sys/compat/linux/common/linux_mod.c:1.12 src/sys/compat/linux/common/linux_mod.c:1.13
--- src/sys/compat/linux/common/linux_mod.c:1.12 Mon Mar 16 21:20:09 2020
+++ src/sys/compat/linux/common/linux_mod.c Sat Mar 21 16:28:56 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_mod.c,v 1.12 2020/03/16 21:20:09 pgoyette Exp $ */
+/* $NetBSD: linux_mod.c,v 1.13 2020/03/21 16:28:56 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_mod.c,v 1.12 2020/03/16 21:20:09 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_mod.c,v 1.13 2020/03/21 16:28:56 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_execfmt.h"
@@ -171,6 +171,7 @@ compat_linux_modcmd(modcmd_t cmd, void *
error = exec_remove(linux_execsw, __arraycount(linux_execsw));
if (error)
return error;
+ linux_sysctl_fini();
linux_futex_fini();
return 0;
Index: src/sys/compat/linux/common/linux_sysctl.c
diff -u src/sys/compat/linux/common/linux_sysctl.c:1.45 src/sys/compat/linux/common/linux_sysctl.c:1.46
--- src/sys/compat/linux/common/linux_sysctl.c:1.45 Mon Mar 16 21:20:09 2020
+++ src/sys/compat/linux/common/linux_sysctl.c Sat Mar 21 16:28:56 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_sysctl.c,v 1.45 2020/03/16 21:20:09 pgoyette Exp $ */
+/* $NetBSD: linux_sysctl.c,v 1.46 2020/03/21 16:28:56 pgoyette Exp $ */
/*-
* Copyright (c) 2003, 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_sysctl.c,v 1.45 2020/03/16 21:20:09 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_sysctl.c,v 1.46 2020/03/21 16:28:56 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -70,26 +70,41 @@ struct sysctlnode linux_sysctl_root = {
extern int linux_enabled;
+/*
+ * We need an additional sysctllog here since each log can only
+ * deal with a single root node.
+ */
+
+static struct sysctllog *linux_clog;
+
+void
+linux_sysctl_fini(void)
+{
+
+ sysctl_teardown(&linux_clog);
+ sysctl_free(&linux_sysctl_root);
+}
+
SYSCTL_SETUP(linux_sysctl_setup, "linux emulation sysctls")
{
const struct sysctlnode *node = &linux_sysctl_root;
- sysctl_createv(clog, 0, &node, &node,
+ sysctl_createv(&linux_clog, 0, &node, &node,
CTLFLAG_PERMANENT,
CTLTYPE_NODE, "kern", NULL,
NULL, 0, NULL, 0,
LINUX_CTL_KERN, CTL_EOL);
- sysctl_createv(clog, 0, &node, NULL,
+ sysctl_createv(&linux_clog, 0, &node, NULL,
CTLFLAG_PERMANENT,
CTLTYPE_STRING, "ostype", NULL,
NULL, 0, linux_sysname, sizeof(linux_sysname),
LINUX_KERN_OSTYPE, CTL_EOL);
- sysctl_createv(clog, 0, &node, NULL,
+ sysctl_createv(&linux_clog, 0, &node, NULL,
CTLFLAG_PERMANENT,
CTLTYPE_STRING, "osrelease", NULL,
NULL, 0, linux_release, sizeof(linux_release),
LINUX_KERN_OSRELEASE, CTL_EOL);
- sysctl_createv(clog, 0, &node, NULL,
+ sysctl_createv(&linux_clog, 0, &node, NULL,
CTLFLAG_PERMANENT,
CTLTYPE_STRING, "version", NULL,
NULL, 0, linux_version, sizeof(linux_version),
Index: src/sys/compat/linux/common/linux_sysctl.h
diff -u src/sys/compat/linux/common/linux_sysctl.h:1.7 src/sys/compat/linux/common/linux_sysctl.h:1.8
--- src/sys/compat/linux/common/linux_sysctl.h:1.7 Mon Mar 16 21:20:09 2020
+++ src/sys/compat/linux/common/linux_sysctl.h Sat Mar 21 16:28:56 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_sysctl.h,v 1.7 2020/03/16 21:20:09 pgoyette Exp $ */
+/* $NetBSD: linux_sysctl.h,v 1.8 2020/03/21 16:28:56 pgoyette Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -466,6 +466,8 @@
#define LINUX_BUS_ISA_PORT_BASE 2
#define LINUX_BUS_ISA_PORT_SHIFT 3
+void linux_sysctl_fini(void);
+
int linux_sysctl_enable(SYSCTLFN_PROTO);
#endif /* !_LINUX_SYSCTL_H */
Index: src/sys/compat/linux32/common/linux32_mod.c
diff -u src/sys/compat/linux32/common/linux32_mod.c:1.13 src/sys/compat/linux32/common/linux32_mod.c:1.14
--- src/sys/compat/linux32/common/linux32_mod.c:1.13 Mon Mar 16 21:20:09 2020
+++ src/sys/compat/linux32/common/linux32_mod.c Sat Mar 21 16:28:56 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_mod.c,v 1.13 2020/03/16 21:20:09 pgoyette Exp $ */
+/* $NetBSD: linux32_mod.c,v 1.14 2020/03/21 16:28:56 pgoyette 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.13 2020/03/16 21:20:09 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_mod.c,v 1.14 2020/03/21 16:28:56 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_execfmt.h"
@@ -132,6 +132,7 @@ compat_linux32_modcmd(modcmd_t cmd, void
exec_remove(linux32_execsw, __arraycount(linux32_execsw));
if (error)
return error;
+ linux32_sysctl_fini();
return 0;
default:
Index: src/sys/compat/linux32/common/linux32_sysctl.c
diff -u src/sys/compat/linux32/common/linux32_sysctl.c:1.18 src/sys/compat/linux32/common/linux32_sysctl.c:1.19
--- src/sys/compat/linux32/common/linux32_sysctl.c:1.18 Mon Mar 16 21:20:09 2020
+++ src/sys/compat/linux32/common/linux32_sysctl.c Sat Mar 21 16:28:56 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_sysctl.c,v 1.18 2020/03/16 21:20:09 pgoyette Exp $ */
+/* $NetBSD: linux32_sysctl.c,v 1.19 2020/03/21 16:28:56 pgoyette 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.18 2020/03/16 21:20:09 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_sysctl.c,v 1.19 2020/03/21 16:28:56 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -70,6 +70,22 @@ struct sysctlnode linux32_sysctl_root =
extern int linux32_enabled;
+/*
+ * We need our own sysctllog here because we deal with two
+ * separate sysctl trees; each clog is restricted to a
+ * single tree.
+ */
+
+static struct sysctllog *linux32_clog;
+
+void
+linux32_sysctl_fini(void)
+{
+
+ sysctl_teardown(&linux32_clog);
+ sysctl_free(&linux32_sysctl_root);
+}
+
SYSCTL_SETUP(linux32_sysctl_init, "linux32 emulation sysctls")
{
const struct sysctlnode *node = &linux32_sysctl_root;
@@ -115,23 +131,23 @@ SYSCTL_SETUP(linux32_sysctl_init, "linux
linux32_sysctl_enable, 0, &linux32_enabled, 0,
CTL_EMUL, EMUL_LINUX32, CTL_CREATE, CTL_EOL);
- sysctl_createv(clog, 0, &node, &node,
+ sysctl_createv(&linux32_clog, 0, &node, &node,
CTLFLAG_PERMANENT,
CTLTYPE_NODE, "kern", NULL,
NULL, 0, NULL, 0,
LINUX_CTL_KERN, CTL_EOL);
- sysctl_createv(clog, 0, &node, NULL,
+ sysctl_createv(&linux32_clog, 0, &node, NULL,
CTLFLAG_PERMANENT,
CTLTYPE_STRING, "ostype", NULL,
NULL, 0, linux32_sysname, sizeof(linux32_sysname),
LINUX_KERN_OSTYPE, CTL_EOL);
- sysctl_createv(clog, 0, &node, NULL,
+ sysctl_createv(&linux32_clog, 0, &node, NULL,
CTLFLAG_PERMANENT,
CTLTYPE_STRING, "osrelease", NULL,
NULL, 0, linux32_release, sizeof(linux32_release),
LINUX_KERN_OSRELEASE, CTL_EOL);
- sysctl_createv(clog, 0, &node, NULL,
+ sysctl_createv(&linux32_clog, 0, &node, NULL,
CTLFLAG_PERMANENT,
CTLTYPE_STRING, "version", NULL,
NULL, 0, linux32_version, sizeof(linux32_version),
Index: src/sys/compat/linux32/common/linux32_sysctl.h
diff -u src/sys/compat/linux32/common/linux32_sysctl.h:1.5 src/sys/compat/linux32/common/linux32_sysctl.h:1.6
--- src/sys/compat/linux32/common/linux32_sysctl.h:1.5 Mon Mar 16 21:20:09 2020
+++ src/sys/compat/linux32/common/linux32_sysctl.h Sat Mar 21 16:28:56 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_sysctl.h,v 1.5 2020/03/16 21:20:09 pgoyette Exp $ */
+/* $NetBSD: linux32_sysctl.h,v 1.6 2020/03/21 16:28:56 pgoyette Exp $ */
/*-
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -44,6 +44,8 @@ extern char linux32_version[];
#define EMUL_LINUX32_KERN_OSRELEASE 2
#define EMUL_LINUX32_KERN_VERSION 3
+void linux32_sysctl_fini(void);
+
int linux32_sysctl_enable(SYSCTLFN_PROTO);
#endif /* !_LINUX32_SYSCTL_H */