Module Name: src Committed By: kre Date: Sun Dec 10 00:43:05 UTC 2017
Modified Files: src/sys/compat/linux/common: linux_mod.c src/sys/compat/linux32/common: linux32_mod.c Log Message: Finally (hopefully) return completely to the state where compat_linux is enabled by default. While here make it possible to enable this if already enabled, or disable if already disabled, without error. Some minor KNF. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/compat/linux/common/linux_mod.c cvs rdiff -u -r1.10 -r1.11 src/sys/compat/linux32/common/linux32_mod.c 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.9 src/sys/compat/linux/common/linux_mod.c:1.10 --- src/sys/compat/linux/common/linux_mod.c:1.9 Fri Dec 8 15:31:13 2017 +++ src/sys/compat/linux/common/linux_mod.c Sun Dec 10 00:43:05 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_mod.c,v 1.9 2017/12/08 15:31:13 kre Exp $ */ +/* $NetBSD: linux_mod.c,v 1.10 2017/12/10 00:43:05 kre 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.9 2017/12/08 15:31:13 kre Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_mod.c,v 1.10 2017/12/10 00:43:05 kre Exp $"); #ifdef _KERNEL_OPT #include "opt_execfmt.h" @@ -136,13 +136,16 @@ linux_sysctl_enable(SYSCTLFN_ARGS) if (error != 0 || newp == NULL) return error; - if (val == 1) { + if (val == *(int *)rnode->sysctl_data) + return 0; + + if (val == 1) error = exec_add(linux_execsw, __arraycount(linux_execsw)); - } else if (val == 0) { + else if (val == 0) error = exec_remove(linux_execsw, __arraycount(linux_execsw)); - } else { + else error = EINVAL; - } + if (error) return error; @@ -160,7 +163,10 @@ compat_linux_modcmd(modcmd_t cmd, void * case MODULE_CMD_INIT: linux_futex_init(); linux_sysctl_init(); - return 0; + error = exec_add(linux_execsw, __arraycount(linux_execsw)); + if (error != 0) + linux_sysctl_fini(); + return error; case MODULE_CMD_FINI: error = exec_remove(linux_execsw, __arraycount(linux_execsw)); Index: src/sys/compat/linux32/common/linux32_mod.c diff -u src/sys/compat/linux32/common/linux32_mod.c:1.10 src/sys/compat/linux32/common/linux32_mod.c:1.11 --- src/sys/compat/linux32/common/linux32_mod.c:1.10 Fri Dec 8 15:31:13 2017 +++ src/sys/compat/linux32/common/linux32_mod.c Sun Dec 10 00:43:05 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_mod.c,v 1.10 2017/12/08 15:31:13 kre Exp $ */ +/* $NetBSD: linux32_mod.c,v 1.11 2017/12/10 00:43:05 kre 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.10 2017/12/08 15:31:13 kre Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_mod.c,v 1.11 2017/12/10 00:43:05 kre Exp $"); #ifdef _KERNEL_OPT #include "opt_execfmt.h" @@ -95,13 +95,17 @@ linux32_sysctl_enable(SYSCTLFN_ARGS) if (error != 0 || newp == NULL) return error; - if (val == 1) { + if (val == *(int *)rnode->sysctl_data) + return 0; + + if (val == 1) error = exec_add(linux32_execsw, __arraycount(linux32_execsw)); - } else if (val == 0) { - error = exec_remove(linux32_execsw, __arraycount(linux32_execsw)); - } else { + else if (val == 0) + error = + exec_remove(linux32_execsw, __arraycount(linux32_execsw)); + else error = EINVAL; - } + if (error) return error; @@ -118,10 +122,14 @@ compat_linux32_modcmd(modcmd_t cmd, void switch (cmd) { case MODULE_CMD_INIT: linux32_sysctl_init(); - return 0; + error = exec_add(linux32_execsw, __arraycount(linux32_execsw)); + if (error != 0) + linux32_sysctl_fini(); + return error; case MODULE_CMD_FINI: - error = exec_remove(linux32_execsw, __arraycount(linux32_execsw)); + error = + exec_remove(linux32_execsw, __arraycount(linux32_execsw)); if (error) return error; linux32_sysctl_fini();