1 /*
2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <[email protected]> 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 #ifndef FSTACK
13 __FBSDID("$FreeBSD$");
14 #endif
15
16 #include <sys/types.h>
17 #include <sys/sysctl.h>
18
19 int
sysctlbyname(const char * name,void * oldp,size_t * oldlenp,const void * newp,size_t newlen)20 sysctlbyname(const char *name, void *oldp, size_t *oldlenp,
21 const void *newp, size_t newlen)
22 {
23 int real_oid[CTL_MAXNAME+2];
24 size_t oidlen;
25
26 oidlen = sizeof(real_oid) / sizeof(int);
27 if (sysctlnametomib(name, real_oid, &oidlen) < 0)
28 return (-1);
29 return (sysctl(real_oid, oidlen, oldp, oldlenp, newp, newlen));
30 }
31