summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sysctl.c
diff options
context:
space:
mode:
authorjlemon <jlemon@FreeBSD.org>2001-05-19 05:45:55 +0000
committerjlemon <jlemon@FreeBSD.org>2001-05-19 05:45:55 +0000
commit73537a93c41f552dd00e21af16c60cfdcda3c12f (patch)
tree2296687cab2b84ea546ab5c839d79e177bd58cf9 /sys/kern/kern_sysctl.c
parent19cf17e66bdb51d13bab00923578bca0d84b1767 (diff)
downloadFreeBSD-src-73537a93c41f552dd00e21af16c60cfdcda3c12f.zip
FreeBSD-src-73537a93c41f552dd00e21af16c60cfdcda3c12f.tar.gz
Add convenience function kernel_sysctlbyname() for kernel consumers,
so they don't have to roll their own sysctlbyname function.
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r--sys/kern/kern_sysctl.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 206322c..99f2d69 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -844,7 +844,8 @@ sysctl_new_kernel(struct sysctl_req *req, void *p, size_t l)
}
int
-kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old, size_t *oldlenp, void *new, size_t newlen, size_t *retval)
+kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old,
+ size_t *oldlenp, void *new, size_t newlen, size_t *retval)
{
int error = 0;
struct sysctl_req req;
@@ -902,6 +903,28 @@ kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old, size_t *oldle
return (error);
}
+int
+kernel_sysctlbyname(struct proc *p, char *name, void *old, size_t *oldlenp,
+ void *new, size_t newlen, size_t *retval)
+{
+ int oid[CTL_MAXNAME];
+ size_t oidlen;
+ int error, plen;
+
+ oid[0] = 0; /* sysctl internal magic */
+ oid[1] = 3; /* name2oid */
+ oidlen = sizeof(oid);
+
+ error = kernel_sysctl(p, oid, 2, oid, &oidlen,
+ (void *)name, strlen(name), &plen);
+ if (error)
+ return (error);
+
+ error = kernel_sysctl(p, oid, plen / sizeof(int), old, oldlenp,
+ new, newlen, retval);
+ return (error);
+}
+
/*
* Transfer function to/from user space.
*/
OpenPOWER on IntegriCloud