diff options
author | des <des@FreeBSD.org> | 1999-01-10 05:33:43 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 1999-01-10 05:33:43 +0000 |
commit | 710c564eff6e3b7b417bf56b31cd34a37a08daed (patch) | |
tree | 406a018672eae5c6ed5b99ff76505419b21b242b | |
parent | e50aa55751caccf7ccaf43d7a09795ff12967ade (diff) | |
download | FreeBSD-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
-rw-r--r-- | sys/conf/NOTES | 5 | ||||
-rw-r--r-- | sys/conf/options | 3 | ||||
-rw-r--r-- | sys/i386/conf/LINT | 5 | ||||
-rw-r--r-- | sys/i386/conf/NOTES | 5 | ||||
-rw-r--r-- | sys/kern/kern_sysctl.c | 51 | ||||
-rw-r--r-- | sys/sys/sysctl.h | 12 |
6 files changed, 73 insertions, 8 deletions
diff --git a/sys/conf/NOTES b/sys/conf/NOTES index fbeb207..7fa3e23 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -2,7 +2,7 @@ # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.528 1999/01/08 17:31:07 eivind Exp $ +# $Id: LINT,v 1.529 1999/01/09 18:12:07 wpaul Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -772,6 +772,9 @@ options VINUMDEBUG #enable Vinum debugging hooks # Size of the kernel message buffer. Should be N * pagesize. options "MSGBUF_SIZE=40960" +# Conserve space by not including sysctl descriptions (see sysctl(8)) +#options NO_SYSCTL_DESCRIPTIONS + ##################################################################### # HARDWARE DEVICE CONFIGURATION diff --git a/sys/conf/options b/sys/conf/options index 8e593d9..d401ef8 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -1,4 +1,4 @@ -# $Id: options,v 1.113 1998/12/28 16:31:26 peter Exp $ +# $Id: options,v 1.114 1999/01/08 17:31:05 eivind Exp $ # # On the handling of kernel options # @@ -254,6 +254,7 @@ DIAGNOSTIC opt_global.h ENABLE_VFS_IOOPT opt_global.h INVARIANT_SUPPORT opt_global.h INVARIANTS opt_global.h +NO_SYSCTL_DESCRIPTIONS opt_global.h SIMPLELOCK_DEBUG opt_global.h VFS_BIO_DEBUG opt_global.h diff --git a/sys/i386/conf/LINT b/sys/i386/conf/LINT index fbeb207..7fa3e23 100644 --- a/sys/i386/conf/LINT +++ b/sys/i386/conf/LINT @@ -2,7 +2,7 @@ # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.528 1999/01/08 17:31:07 eivind Exp $ +# $Id: LINT,v 1.529 1999/01/09 18:12:07 wpaul Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -772,6 +772,9 @@ options VINUMDEBUG #enable Vinum debugging hooks # Size of the kernel message buffer. Should be N * pagesize. options "MSGBUF_SIZE=40960" +# Conserve space by not including sysctl descriptions (see sysctl(8)) +#options NO_SYSCTL_DESCRIPTIONS + ##################################################################### # HARDWARE DEVICE CONFIGURATION diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index fbeb207..7fa3e23 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -2,7 +2,7 @@ # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.528 1999/01/08 17:31:07 eivind Exp $ +# $Id: LINT,v 1.529 1999/01/09 18:12:07 wpaul Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -772,6 +772,9 @@ options VINUMDEBUG #enable Vinum debugging hooks # Size of the kernel message buffer. Should be N * pagesize. options "MSGBUF_SIZE=40960" +# Conserve space by not including sysctl descriptions (see sysctl(8)) +#options NO_SYSCTL_DESCRIPTIONS + ##################################################################### # HARDWARE DEVICE CONFIGURATION 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. */ diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 4c14622..01049d0 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 - * $Id: sysctl.h,v 1.67 1998/12/16 16:06:29 bde Exp $ + * $Id: sysctl.h,v 1.68 1998/12/27 18:03:29 dfr Exp $ */ #ifndef _SYS_SYSCTL_H_ @@ -122,6 +122,9 @@ struct sysctl_oid { const char *oid_name; int (*oid_handler) SYSCTL_HANDLER_ARGS; const char *oid_fmt; +#ifndef NO_SYSCTL_DESCRIPTIONS + const char *oid_descr; +#endif /* !NO_SYSCTL_DESCRIPTIONS */ }; #define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l) @@ -134,10 +137,17 @@ int sysctl_handle_string SYSCTL_HANDLER_ARGS; int sysctl_handle_opaque SYSCTL_HANDLER_ARGS; /* This constructs a "raw" MIB oid. */ +#ifndef NO_SYSCTL_DESCRIPTIONS +#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ + static struct sysctl_oid sysctl__##parent##_##name = { \ + nbr, kind, a1, a2, #name, handler, fmt, descr }; \ + DATA_SET(sysctl_##parent, sysctl__##parent##_##name) +#else #define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ static struct sysctl_oid sysctl__##parent##_##name = { \ nbr, kind, a1, a2, #name, handler, fmt }; \ DATA_SET(sysctl_##parent, sysctl__##parent##_##name) +#endif /* !NO_SYSCTL_DESCRIPTIONS */ /* This constructs a node from which other oids can hang. */ #define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \ |