Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F145965796
D26833.id78528.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D26833.id78528.diff
View Options
Index: sbin/sysctl/sysctl.c
===================================================================
--- sbin/sysctl/sysctl.c
+++ sbin/sysctl/sysctl.c
@@ -957,6 +957,7 @@
static int
show_var(int *oid, int nlen, bool honor_skip)
{
+ static int skip_len = 0, skip_oid[CTL_MAXNAME];
u_char buf[BUFSIZ], *val, *oval, *p;
char name[BUFSIZ], fmt[BUFSIZ];
const char *sep, *sep1, *prntype;
@@ -1026,9 +1027,21 @@
return (0);
}
+ /* keep track of encountered skip nodes, ignoring descendants */
+ if (skip_len == 0 && (kind & CTLFLAG_SKIP) != 0) {
+ /* Save this oid so we can skip descendants. */
+ skip_len = nlen * sizeof(int);
+ memcpy(skip_oid, oid, skip_len);
+ }
+
/* bail before fetching the value if we're honoring skip */
- if (honor_skip && (kind & CTLFLAG_SKIP) != 0)
- return (1);
+ if (honor_skip) {
+ if (0 < skip_len && skip_len <= nlen * (int)sizeof(int) &&
+ memcmp(skip_oid, oid, skip_len) == 0)
+ return (1);
+ /* Not a skip node or descendant of a skip node. */
+ skip_len = 0;
+ }
/* don't fetch opaques that we don't know how to print */
if (ctltype == CTLTYPE_OPAQUE) {
Index: sys/kern/kern_sysctl.c
===================================================================
--- sys/kern/kern_sysctl.c
+++ sys/kern/kern_sysctl.c
@@ -1126,9 +1126,13 @@
* We have reached a node with a full name match and are
* looking for the next oid in its children.
*
+ * For CTL_SYSCTL_NEXTNOSKIP we are done.
+ *
* For CTL_SYSCTL_NEXT we skip CTLTYPE_NODE (unless it
* has a handler) and move on to the children.
*/
+ if (!honor_skip)
+ return (0);
if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE)
return (0);
if (oidp->oid_handler)
@@ -1163,9 +1167,13 @@
/*
* We have reached the next oid.
*
+ * For CTL_SYSCTL_NEXTNOSKIP we are done.
+ *
* For CTL_SYSCTL_NEXT we skip CTLTYPE_NODE (unless it
* has a handler) and move on to the children.
*/
+ if (!honor_skip)
+ return (0);
if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE)
return (0);
if (oidp->oid_handler)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Feb 27, 2:33 PM (7 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29032942
Default Alt Text
D26833.id78528.diff (2 KB)
Attached To
Mode
D26833: sysctl+kern_sysctl: Honor SKIP for descendant nodes
Attached
Detach File
Event Timeline
Log In to Comment