]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - lib/libc/gen/sysctlbyname.c
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / lib / libc / gen / sysctlbyname.c
1 /*
2  * ----------------------------------------------------------------------------
3  * "THE BEER-WARE LICENSE" (Revision 42):
4  * <phk@FreeBSD.org> wrote this file.  As long as you retain this notice you
5  * can do whatever you want with this stuff. If we meet some day, and you think
6  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
7  * ----------------------------------------------------------------------------
8  *
9  */
10
11 #include <sys/cdefs.h>
12 __FBSDID("$FreeBSD$");
13
14 #include <sys/types.h>
15 #include <sys/sysctl.h>
16
17 int
18 sysctlbyname(const char *name, void *oldp, size_t *oldlenp,
19     const void *newp, size_t newlen)
20 {
21         int real_oid[CTL_MAXNAME+2];
22         int error;
23         size_t oidlen;
24
25         oidlen = sizeof(real_oid) / sizeof(int);
26         error = sysctlnametomib(name, real_oid, &oidlen);
27         if (error < 0) 
28                 return (error);
29         error = sysctl(real_oid, oidlen, oldp, oldlenp, newp, newlen);
30         return (error);
31 }