Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat Deal with having to teardown sysctl entries in mu...
details: https://anonhg.NetBSD.org/src/rev/1ca8dc89afdc
branches: trunk
changeset: 1008387:1ca8dc89afdc
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Sat Mar 21 16:28:56 2020 +0000
description:
Deal with having to teardown sysctl entries in multiple sub-trees.
(This used to work, but I broke it recently.)
diffstat:
sys/compat/linux/common/linux_mod.c | 5 +++--
sys/compat/linux/common/linux_sysctl.c | 27 +++++++++++++++++++++------
sys/compat/linux/common/linux_sysctl.h | 4 +++-
sys/compat/linux32/common/linux32_mod.c | 5 +++--
sys/compat/linux32/common/linux32_sysctl.c | 28 ++++++++++++++++++++++------
sys/compat/linux32/common/linux32_sysctl.h | 4 +++-
6 files changed, 55 insertions(+), 18 deletions(-)
diffs (221 lines):
diff -r 5aad8d6bbda3 -r 1ca8dc89afdc sys/compat/linux/common/linux_mod.c
--- a/sys/compat/linux/common/linux_mod.c Sat Mar 21 16:17:08 2020 +0000
+++ b/sys/compat/linux/common/linux_mod.c Sat Mar 21 16:28:56 2020 +0000
@@ -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 @@
error = exec_remove(linux_execsw, __arraycount(linux_execsw));
if (error)
return error;
+ linux_sysctl_fini();
linux_futex_fini();
return 0;
diff -r 5aad8d6bbda3 -r 1ca8dc89afdc sys/compat/linux/common/linux_sysctl.c
--- a/sys/compat/linux/common/linux_sysctl.c Sat Mar 21 16:17:08 2020 +0000
+++ b/sys/compat/linux/common/linux_sysctl.c Sat Mar 21 16:28:56 2020 +0000
@@ -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 @@
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),
diff -r 5aad8d6bbda3 -r 1ca8dc89afdc sys/compat/linux/common/linux_sysctl.h
--- a/sys/compat/linux/common/linux_sysctl.h Sat Mar 21 16:17:08 2020 +0000
+++ b/sys/compat/linux/common/linux_sysctl.h Sat Mar 21 16:28:56 2020 +0000
@@ -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 */
diff -r 5aad8d6bbda3 -r 1ca8dc89afdc sys/compat/linux32/common/linux32_mod.c
--- a/sys/compat/linux32/common/linux32_mod.c Sat Mar 21 16:17:08 2020 +0000
+++ b/sys/compat/linux32/common/linux32_mod.c Sat Mar 21 16:28:56 2020 +0000
@@ -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 @@
exec_remove(linux32_execsw, __arraycount(linux32_execsw));
if (error)
return error;
+ linux32_sysctl_fini();
return 0;
default:
diff -r 5aad8d6bbda3 -r 1ca8dc89afdc sys/compat/linux32/common/linux32_sysctl.c
--- a/sys/compat/linux32/common/linux32_sysctl.c Sat Mar 21 16:17:08 2020 +0000
+++ b/sys/compat/linux32/common/linux32_sysctl.c Sat Mar 21 16:28:56 2020 +0000
@@ -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 @@
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 @@
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),
diff -r 5aad8d6bbda3 -r 1ca8dc89afdc sys/compat/linux32/common/linux32_sysctl.h
--- a/sys/compat/linux32/common/linux32_sysctl.h Sat Mar 21 16:17:08 2020 +0000
+++ b/sys/compat/linux32/common/linux32_sysctl.h Sat Mar 21 16:28:56 2020 +0000
@@ -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 @@
#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 */
Home |
Main Index |
Thread Index |
Old Index