Source-Changes-HG archive

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

[src/trunk]: src/sys Use the module subsystem's ability to process SYSCTL_SET...



details:   https://anonhg.NetBSD.org/src/rev/9d54716e3776
branches:  trunk
changeset: 745936:9d54716e3776
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Mon Mar 16 21:20:09 2020 +0000

description:
Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself.  These are not changed.

diffstat:

 sys/compat/linux/common/linux_mod.c             |    8 +-
 sys/compat/linux/common/linux_sysctl.c          |   38 ++-----
 sys/compat/linux/common/linux_sysctl.h          |    5 +-
 sys/compat/linux32/common/linux32_mod.c         |    8 +-
 sys/compat/linux32/common/linux32_sysctl.c      |   38 ++-----
 sys/compat/linux32/common/linux32_sysctl.h      |    5 +-
 sys/dev/acpi/acpi_cpu.c                         |   26 +---
 sys/dev/pci/ubsec.c                             |   24 +---
 sys/dev/sysmon/swsensor.c                       |   21 +---
 sys/dev/sysmon/swwdog.c                         |   19 +--
 sys/fs/adosfs/advfsops.c                        |   22 ++--
 sys/fs/autofs/autofs_vfsops.c                   |   29 ++---
 sys/fs/cd9660/cd9660_vfsops.c                   |   44 ++++----
 sys/fs/filecorefs/filecore_vfsops.c             |   34 +++---
 sys/fs/msdosfs/msdosfs_vfsops.c                 |   33 +++---
 sys/fs/nilfs/nilfs_vfsops.c                     |   51 +++++----
 sys/fs/ptyfs/ptyfs_vfsops.c                     |   34 +++---
 sys/fs/smbfs/smbfs_vfsops.c                     |   44 ++++----
 sys/fs/udf/udf_vfsops.c                         |   42 ++++----
 sys/fs/union/union_vfsops.c                     |   34 +++---
 sys/kern/sys_aio.c                              |   30 +----
 sys/kern/sys_mqueue.c                           |   40 ++-----
 sys/kern/vfs_wapbl.c                            |   47 +++-----
 sys/miscfs/fdesc/fdesc_vfsops.c                 |   26 +++--
 sys/miscfs/kernfs/kernfs_vfsops.c               |   34 +++---
 sys/miscfs/nullfs/null_vfsops.c                 |   34 +++---
 sys/miscfs/overlay/overlay_vfsops.c             |   20 ++-
 sys/miscfs/procfs/procfs_vfsops.c               |   33 +++---
 sys/miscfs/umapfs/umap_vfsops.c                 |   34 +++---
 sys/net/bpf.c                                   |   20 +--
 sys/netinet/accf_http.c                         |   67 ++++++-------
 sys/nfs/nfs_vfsops.c                            |   29 +----
 sys/opencrypto/crypto.c                         |   14 +--
 sys/secmodel/bsd44/bsd44.h                      |    4 +-
 sys/secmodel/bsd44/secmodel_bsd44.c             |   10 +-
 sys/secmodel/extensions/secmodel_extensions.c   |   11 +-
 sys/secmodel/overlay/secmodel_overlay.c         |   10 +-
 sys/secmodel/securelevel/secmodel_securelevel.c |   10 +-
 sys/secmodel/securelevel/securelevel.h          |    4 +-
 sys/secmodel/suser/secmodel_suser.c             |   10 +-
 sys/secmodel/suser/suser.h                      |    4 +-
 sys/ufs/ext2fs/ext2fs_vfsops.c                  |   34 +++---
 sys/ufs/ffs/ffs_vfsops.c                        |  117 ++++++++++++-----------
 sys/ufs/lfs/lfs_vfsops.c                        |   11 +-
 sys/ufs/mfs/mfs_vfsops.c                        |   36 +++---
 sys/ufs/ufs/ufs_dirhash.c                       |   23 +--
 46 files changed, 561 insertions(+), 710 deletions(-)

diffs (truncated from 3364 to 300 lines):

diff -r fb61ebafeeb8 -r 9d54716e3776 sys/compat/linux/common/linux_mod.c
--- a/sys/compat/linux/common/linux_mod.c       Mon Mar 16 20:51:36 2020 +0000
+++ b/sys/compat/linux/common/linux_mod.c       Mon Mar 16 21:20:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_mod.c,v 1.11 2019/01/27 02:08:40 pgoyette Exp $  */
+/*     $NetBSD: linux_mod.c,v 1.12 2020/03/16 21:20:09 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.11 2019/01/27 02:08:40 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_mod.c,v 1.12 2020/03/16 21:20:09 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_execfmt.h"
@@ -164,17 +164,13 @@
        switch (cmd) {
        case MODULE_CMD_INIT:
                linux_futex_init();
-               linux_sysctl_init();
                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));
                if (error)
                        return error;
-               linux_sysctl_fini();
                linux_futex_fini();
                return 0;
 
diff -r fb61ebafeeb8 -r 9d54716e3776 sys/compat/linux/common/linux_sysctl.c
--- a/sys/compat/linux/common/linux_sysctl.c    Mon Mar 16 20:51:36 2020 +0000
+++ b/sys/compat/linux/common/linux_sysctl.c    Mon Mar 16 21:20:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_sysctl.c,v 1.44 2017/09/29 17:08:00 maxv Exp $   */
+/*     $NetBSD: linux_sysctl.c,v 1.45 2020/03/16 21:20:09 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.44 2017/09/29 17:08:00 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_sysctl.c,v 1.45 2020/03/16 21:20:09 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -68,73 +68,61 @@
        .sysctl_size = sizeof(struct sysctlnode),
 };
 
-static struct sysctllog *linux_clog1;
-static struct sysctllog *linux_clog2;
 extern int linux_enabled;
 
-void
-linux_sysctl_fini(void)
-{
-
-       sysctl_teardown(&linux_clog2);
-       sysctl_teardown(&linux_clog1);
-       sysctl_free(&linux_sysctl_root);
-}
-
-void
-linux_sysctl_init(void)
+SYSCTL_SETUP(linux_sysctl_setup, "linux emulation sysctls")
 {
        const struct sysctlnode *node = &linux_sysctl_root;
 
-       sysctl_createv(&linux_clog1, 0, &node, &node,
+       sysctl_createv(clog, 0, &node, &node,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_NODE, "kern", NULL,
                       NULL, 0, NULL, 0,
                       LINUX_CTL_KERN, CTL_EOL);
-       sysctl_createv(&linux_clog1, 0, &node, NULL,
+       sysctl_createv(clog, 0, &node, NULL,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_STRING, "ostype", NULL,
                       NULL, 0, linux_sysname, sizeof(linux_sysname),
                       LINUX_KERN_OSTYPE, CTL_EOL);
-       sysctl_createv(&linux_clog1, 0, &node, NULL,
+       sysctl_createv(clog, 0, &node, NULL,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_STRING, "osrelease", NULL,
                       NULL, 0, linux_release, sizeof(linux_release),
                       LINUX_KERN_OSRELEASE, CTL_EOL);
-       sysctl_createv(&linux_clog1, 0, &node, NULL,
+       sysctl_createv(clog, 0, &node, NULL,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_STRING, "version", NULL,
                       NULL, 0, linux_version, sizeof(linux_version),
                       LINUX_KERN_VERSION, CTL_EOL);
 
-       sysctl_createv(&linux_clog2, 0, NULL, NULL,
+       sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_NODE, "linux",
                       SYSCTL_DESCR("Linux emulation settings"),
                       NULL, 0, NULL, 0,
                       CTL_EMUL, EMUL_LINUX, CTL_EOL);
 
-       sysctl_createv(&linux_clog2, 0, NULL, NULL,
+       sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_NODE, "kern",
                       SYSCTL_DESCR("Linux kernel emulation settings"),
                       NULL, 0, NULL, 0,
                       CTL_EMUL, EMUL_LINUX, EMUL_LINUX_KERN, CTL_EOL);
-       sysctl_createv(&linux_clog2, 0, NULL, NULL,
+       sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
                       CTLTYPE_STRING, "ostype",
                       SYSCTL_DESCR("Linux operating system type"),
                       NULL, 0, linux_sysname, sizeof(linux_sysname),
                       CTL_EMUL, EMUL_LINUX, EMUL_LINUX_KERN,
                       EMUL_LINUX_KERN_OSTYPE, CTL_EOL);
-       sysctl_createv(&linux_clog2, 0, NULL, NULL,
+       sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
                       CTLTYPE_STRING, "osrelease",
                       SYSCTL_DESCR("Linux operating system release"),
                       NULL, 0, linux_release, sizeof(linux_release),
                       CTL_EMUL, EMUL_LINUX, EMUL_LINUX_KERN,
                       EMUL_LINUX_KERN_OSRELEASE, CTL_EOL);
-       sysctl_createv(&linux_clog2, 0, NULL, NULL,
+       sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
                       CTLTYPE_STRING, "osversion",
                       SYSCTL_DESCR("Linux operating system revision"),
@@ -142,7 +130,7 @@
                       CTL_EMUL, EMUL_LINUX, EMUL_LINUX_KERN,
                       EMUL_LINUX_KERN_VERSION, CTL_EOL);
 
-       sysctl_createv(&linux_clog2, 0, NULL, NULL,
+       sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_READWRITE,
                       CTLTYPE_INT, "enabled",
                       SYSCTL_DESCR("Linux compat enabled."),
diff -r fb61ebafeeb8 -r 9d54716e3776 sys/compat/linux/common/linux_sysctl.h
--- a/sys/compat/linux/common/linux_sysctl.h    Mon Mar 16 20:51:36 2020 +0000
+++ b/sys/compat/linux/common/linux_sysctl.h    Mon Mar 16 21:20:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_sysctl.h,v 1.6 2017/09/29 17:08:00 maxv Exp $    */
+/*     $NetBSD: linux_sysctl.h,v 1.7 2020/03/16 21:20:09 pgoyette Exp $        */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -466,9 +466,6 @@
 #define        LINUX_BUS_ISA_PORT_BASE                                 2
 #define        LINUX_BUS_ISA_PORT_SHIFT                                3
 
-void   linux_sysctl_init(void);
-void   linux_sysctl_fini(void);
-
 int    linux_sysctl_enable(SYSCTLFN_PROTO);
 
 #endif /* !_LINUX_SYSCTL_H */
diff -r fb61ebafeeb8 -r 9d54716e3776 sys/compat/linux32/common/linux32_mod.c
--- a/sys/compat/linux32/common/linux32_mod.c   Mon Mar 16 20:51:36 2020 +0000
+++ b/sys/compat/linux32/common/linux32_mod.c   Mon Mar 16 21:20:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux32_mod.c,v 1.12 2019/01/27 02:08:40 pgoyette Exp $        */
+/*     $NetBSD: linux32_mod.c,v 1.13 2020/03/16 21:20:09 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.12 2019/01/27 02:08:40 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_mod.c,v 1.13 2020/03/16 21:20:09 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_execfmt.h"
@@ -124,10 +124,7 @@
 
        switch (cmd) {
        case MODULE_CMD_INIT:
-               linux32_sysctl_init();
                error = exec_add(linux32_execsw, __arraycount(linux32_execsw));
-               if (error != 0)          
-                       linux32_sysctl_fini();   
                return error;
 
        case MODULE_CMD_FINI:
@@ -135,7 +132,6 @@
                    exec_remove(linux32_execsw, __arraycount(linux32_execsw));
                if (error)
                        return error;
-               linux32_sysctl_fini();
                return 0;
 
        default:
diff -r fb61ebafeeb8 -r 9d54716e3776 sys/compat/linux32/common/linux32_sysctl.c
--- a/sys/compat/linux32/common/linux32_sysctl.c        Mon Mar 16 20:51:36 2020 +0000
+++ b/sys/compat/linux32/common/linux32_sysctl.c        Mon Mar 16 21:20:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux32_sysctl.c,v 1.17 2017/09/29 17:47:29 maxv Exp $ */
+/*     $NetBSD: linux32_sysctl.c,v 1.18 2020/03/16 21:20:09 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.17 2017/09/29 17:47:29 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_sysctl.c,v 1.18 2020/03/16 21:20:09 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -68,82 +68,70 @@
        .sysctl_size = sizeof(struct sysctlnode),
 };
 
-static struct sysctllog *linux32_clog1;
-static struct sysctllog *linux32_clog2;
 extern int linux32_enabled;
 
-void
-linux32_sysctl_fini(void)
-{
-
-       sysctl_teardown(&linux32_clog2);
-       sysctl_teardown(&linux32_clog1);
-       sysctl_free(&linux32_sysctl_root);
-}
-
-void
-linux32_sysctl_init(void)
+SYSCTL_SETUP(linux32_sysctl_init, "linux32 emulation sysctls")
 {
        const struct sysctlnode *node = &linux32_sysctl_root;
 
-       sysctl_createv(&linux32_clog1, 0, NULL, NULL,
+       sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_NODE, "linux32",
                       SYSCTL_DESCR("Linux 32 bit emulation settings"),
                       NULL, 0, NULL, 0,
                       CTL_EMUL, EMUL_LINUX32, CTL_EOL);
-       sysctl_createv(&linux32_clog1, 0, NULL, NULL,
+       sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_NODE, "kern",
                       SYSCTL_DESCR("Linux 32 bit kernel emulation settings"),
                       NULL, 0, NULL, 0,
                       CTL_EMUL, EMUL_LINUX32, EMUL_LINUX32_KERN, CTL_EOL);
 
-       sysctl_createv(&linux32_clog1, 0, NULL, NULL,
+       sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
                       CTLTYPE_STRING, "ostype",
                       SYSCTL_DESCR("Linux 32 bit operating system type"),
                       NULL, 0, linux32_sysname, sizeof(linux32_sysname),
                       CTL_EMUL, EMUL_LINUX32, EMUL_LINUX32_KERN,
                       EMUL_LINUX32_KERN_OSTYPE, CTL_EOL);
-       sysctl_createv(&linux32_clog1, 0, NULL, NULL,
+       sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
                       CTLTYPE_STRING, "osrelease",
                       SYSCTL_DESCR("Linux 32 bit operating system release"),
                       NULL, 0, linux32_release, sizeof(linux32_release),
                       CTL_EMUL, EMUL_LINUX32, EMUL_LINUX32_KERN,
                       EMUL_LINUX32_KERN_OSRELEASE, CTL_EOL);
-       sysctl_createv(&linux32_clog1, 0, NULL, NULL,
+       sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
                       CTLTYPE_STRING, "osversion",
                       SYSCTL_DESCR("Linux 32 bit operating system revision"),
                       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,
+       sysctl_createv(clog, 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,
+       sysctl_createv(clog, 0, &node, &node,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_NODE, "kern", NULL,
                       NULL, 0, NULL, 0,
                       LINUX_CTL_KERN, CTL_EOL);
 
-       sysctl_createv(&linux32_clog2, 0, &node, NULL,
+       sysctl_createv(clog, 0, &node, NULL,



Home | Main Index | Thread Index | Old Index