summaryrefslogtreecommitdiff
path: root/usr.bin/sysctl/sysctl.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-08-11 05:12:08 -0400
committerIan Moffett <ian@osmora.org>2025-08-11 05:12:08 -0400
commit5c6f79744a8bdf4cfb0e91517847281739c3e624 (patch)
treec5570ca9a5304f5541fb00e30a2eaa6d0e5203a1 /usr.bin/sysctl/sysctl.c
parent90861a9b3594074ac7d21d8fe8752b2df01587d6 (diff)
usr: sysctl: Add parsing for 'proc.*' nodesmainexpt
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'usr.bin/sysctl/sysctl.c')
-rw-r--r--usr.bin/sysctl/sysctl.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/usr.bin/sysctl/sysctl.c b/usr.bin/sysctl/sysctl.c
index 1e7f2c0..4a84484 100644
--- a/usr.bin/sysctl/sysctl.c
+++ b/usr.bin/sysctl/sysctl.c
@@ -46,13 +46,18 @@
#define NAME_NCPU "ncpu"
#define NAME_MACHINE "machine"
+/* Proc var string constants */
+#define NAME_COUNT "count"
+
/* Name start string constants */
#define NAME_KERN "kern"
#define NAME_HW "hw"
+#define NAME_PROC "proc"
/* Name start int constants */
#define NAME_DEF_KERN 0
#define NAME_DEF_HW 1
+#define NAME_DEF_PROC 2
/*
* Print the contents read from a sysctl
@@ -105,6 +110,12 @@ name_to_def(const char *name)
}
return -1;
+ case 'p':
+ if (strcmp(name, NAME_PROC) == 0) {
+ return NAME_DEF_PROC;
+ }
+
+ return -1;
}
return -1;
@@ -178,6 +189,28 @@ hw_node(const char *node, bool *is_str)
}
/*
+ * Handle parsing of 'proc.*' node names
+ *
+ * @node: Node name to parse
+ * @is_str: Set to true if string
+ */
+static int
+proc_node(const char *node, bool *is_str)
+{
+ switch (*node) {
+ case 'c':
+ if (strcmp(node, NAME_COUNT) == 0) {
+ *is_str = false;
+ return PROC_COUNT;
+ }
+
+ return -1;
+ }
+
+ return -1;
+}
+
+/*
* Convert string node to a sysctl name
* definition.
*
@@ -215,6 +248,8 @@ node_to_def(int name, const char *node, bool *is_str)
return kern_node(node, is_str);
case NAME_DEF_HW:
return hw_node(node, is_str);
+ case NAME_DEF_PROC:
+ return proc_node(node, is_str);
}
return -1;