summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sysctl.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>1999-01-10 05:33:43 +0000
committerdes <des@FreeBSD.org>1999-01-10 05:33:43 +0000
commit710c564eff6e3b7b417bf56b31cd34a37a08daed (patch)
tree406a018672eae5c6ed5b99ff76505419b21b242b /sys/kern/kern_sysctl.c
parente50aa55751caccf7ccaf43d7a09795ff12967ade (diff)
downloadFreeBSD-src-710c564eff6e3b7b417bf56b31cd34a37a08daed.zip
FreeBSD-src-710c564eff6e3b7b417bf56b31cd34a37a08daed.tar.gz
Add kernel support for sysctl descriptions. The NO_SYSCTL_DESCRIPTIONS option
disables them if they're not wanted; in that case, sysctl_sysctl_descr will always return an empty string. Apporved by: jkh
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r--sys/kern/kern_sysctl.c51
1 files changed, 48 insertions, 3 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 55e583b..26dade4 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -37,7 +37,7 @@
* SUCH DAMAGE.
*
* @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94
- * $Id: kern_sysctl.c,v 1.80 1998/12/13 07:18:54 truckman Exp $
+ * $Id: kern_sysctl.c,v 1.81 1998/12/27 18:03:29 dfr Exp $
*/
#include "opt_compat.h"
@@ -155,9 +155,10 @@ sysctl_order_all(void)
*
* {0,0} printf the entire MIB-tree.
* {0,1,...} return the name of the "..." OID.
- * {0,2,...} return the next OID.
+ * {0,2} return the next OID.
* {0,3} return the OID of the name in "new"
* {0,4,...} return the kind & format info for the "..." OID.
+ * {0,5,...} return the description for the "..." OID.
*/
static void
@@ -489,9 +490,53 @@ found:
return (error);
}
-
SYSCTL_NODE(_sysctl, 4, oidfmt, CTLFLAG_RD, sysctl_sysctl_oidfmt, "");
+static int
+sysctl_sysctl_descr SYSCTL_HANDLER_ARGS
+{
+#ifndef NO_SYSCTL_DESCRIPTIONS
+ int *name = (int *) arg1;
+ u_int namelen = arg2;
+ int i, j, error = 0;
+ struct sysctl_oid **oidpp;
+ struct linker_set *lsp = &sysctl_;
+
+ if (!lsp || !namelen)
+ return (SYSCTL_OUT(req, "", 1));
+
+ while (namelen) {
+ oidpp = (struct sysctl_oid **) lsp->ls_items;
+ j = lsp->ls_length;
+ lsp = 0;
+ for (i = 0; i < j; i++, oidpp++) {
+ if (*oidpp && ((*oidpp)->oid_number != *name))
+ continue;
+
+ namelen--;
+ name++;
+
+ if (((*oidpp)->oid_kind & CTLTYPE) != CTLTYPE_NODE)
+ break;
+
+ if ((*oidpp)->oid_handler)
+ break;
+
+ lsp = (struct linker_set*)(*oidpp)->oid_arg1;
+ break;
+ }
+ }
+
+ error = SYSCTL_OUT(req, (*oidpp)->oid_descr,
+ strlen((*oidpp)->oid_descr) + 1);
+ return (error);
+#else
+ return (SYSCTL_OUT(req, "", 1));
+#endif /* !NO_SYSCTL_DESCRIPTIONS */
+}
+
+SYSCTL_NODE(_sysctl, 5, descr, CTLFLAG_RD, sysctl_sysctl_descr, "");
+
/*
* Default "handler" functions.
*/
OpenPOWER on IntegriCloud