Date: Tue, 1 Jun 2004 20:29:49 +0200 From: Maxime Henrion <mux@freebsd.org> To: arch@FreeBSD.org Subject: The new dev sysctl tree Message-ID: <20040601182949.GC9228@elvis.mu.org>
next in thread | raw e-mail | index | archive | help
--xgyAXRrhYN0wYx8y Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi all, Dag-Erling recently committed some code that makes it extremely easy and convenient to have per-devices sysctl. I changed the fxp(4) driver to use this new framework for its sysctls, which allows to remove a bit of code from this driver. However, there is a significant drawback. For instance, what used to be "hw.fxp0.int_delay" is now called (on my box) : "dev.root0.nexus0.acpi0.pcib0.pci0.fxp0.int_delay". Obviously, this is really too long to be convenient to use. Furthermore, the name of this sysctl is not unique anymore. This is particularly annoying in some cases. For instance, if someone needs to boot without acpi while he's using it the rest of the time, the sysctl won't be named the same. So I made a patch to flatten this sysctl tree. This doesn't cause any conflict since attached drivers' names are unique. As a consequence, we lose the hierarchy information from the sysctl tree, however I believe this isn't a problem since we can get this information with devinfo(8) already. If for some reason, we really need the hierarchy information in this sysctl tree, I can easily add a .parent sysctl to each device node. I'm attaching the patch that flattens the sysctl tree to this mail. Opinions are of course welcome, but please, this isn't a call for yet another bikeshed of hell, so keep to the point. Cheers, Maxime --xgyAXRrhYN0wYx8y Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="dev_sysctl.patch" Index: subr_bus.c =================================================================== RCS file: /space2/ncvs/src/sys/kern/subr_bus.c,v retrieving revision 1.146 diff -u -p -r1.146 subr_bus.c --- subr_bus.c 26 May 2004 16:36:32 -0000 1.146 +++ subr_bus.c 31 May 2004 23:58:00 -0000 @@ -241,22 +241,13 @@ device_sysctl_handler(SYSCTL_HANDLER_ARG static void device_sysctl_init(device_t dev) { - struct sysctl_oid_list *parent_node; - if (dev->parent) { - if (dev->parent->sysctl_tree == NULL) - device_sysctl_init(dev->parent); - parent_node = SYSCTL_CHILDREN(dev->parent->sysctl_tree); - } else { - parent_node = SYSCTL_STATIC_CHILDREN(_dev); - } - if (dev->sysctl_tree != NULL) { - sysctl_move_oid(dev->sysctl_tree, parent_node); + if (dev->sysctl_tree != NULL) return; - } sysctl_ctx_init(&dev->sysctl_ctx); - dev->sysctl_tree = SYSCTL_ADD_NODE(&dev->sysctl_ctx, parent_node, - OID_AUTO, dev->nameunit, CTLFLAG_RD, 0, ""); + dev->sysctl_tree = SYSCTL_ADD_NODE(&dev->sysctl_ctx, + SYSCTL_STATIC_CHILDREN(_dev), OID_AUTO, dev->nameunit, + CTLFLAG_RD, 0, ""); SYSCTL_ADD_PROC(&dev->sysctl_ctx, SYSCTL_CHILDREN(dev->sysctl_tree), OID_AUTO, "%class", CTLFLAG_RD, dev, DEVICE_SYSCTL_CLASS, device_sysctl_handler, "A", --xgyAXRrhYN0wYx8y--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040601182949.GC9228>