diff options
authorMaxime Henrion <mux@FreeBSD.org>2002-08-10 19:56:45 +0000
committerMaxime Henrion <mux@FreeBSD.org>2002-08-10 19:56:45 +0000
commit306e6b83936d0560c96775d3dbf0767138825040 (patch)
parent2f4bfb29bbc532abdce6e56377fe0227ba9a944e (diff)
Introduce a new sysctl flag, CTLFLAG_SKIP, which will cause
sysctl_sysctl_next() to skip this sysctl. The sysctl is still available, but doesn't appear in a "sysctl -a". This is especially useful when you want to deprecate a sysctl, and add a warning into it to warn users that they are using an old interface. Without this flag, the warning would get echoed when running "sysctl -a" (which happens at boot).
Notes: svn path=/head/; revision=101650
2 files changed, 4 insertions, 0 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index eb219dcc4aa0..57c6be808fba 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -542,6 +542,9 @@ sysctl_sysctl_next_ls(struct sysctl_oid_list *lsp, int *name, u_int namelen,
*next = oidp->oid_number;
*oidpp = oidp;
+ if (oidp->oid_kind & CTLFLAG_SKIP)
+ continue;
if (!namelen) {
if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE)
return 0;
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index e0d47aee9557..1fcfd44b8d22 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -86,6 +86,7 @@ struct ctlname {
#define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */
#define CTLFLAG_PRISON 0x04000000 /* Prisoned roots can fiddle */
#define CTLFLAG_DYN 0x02000000 /* Dynamic oid - can be freed */
+#define CTLFLAG_SKIP 0x01000000 /* Skip this sysctl when listing */
* USE THIS instead of a hardwired number from the categories below