mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 01:30:30 -04:00
sysctlbyname allows acces to sysctl variables by name.
The manpage has been sent to linquistic decontamination and will arrive when released from the quarantine Reviewed by: peter
This commit is contained in:
parent
7e2a8bde3e
commit
f3877f2e4e
2 changed files with 35 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
|||
# @(#)Makefile.inc 8.6 (Berkeley) 5/4/95
|
||||
# $Id: Makefile.inc,v 1.31 1997/04/13 15:12:14 davidn Exp $
|
||||
# $Id: Makefile.inc,v 1.33 1997/05/03 03:49:54 jb Exp $
|
||||
|
||||
# machine-independent gen sources
|
||||
.PATH: ${.CURDIR}/../libc/${MACHINE}/gen ${.CURDIR}/../libc/gen
|
||||
|
|
@ -17,7 +17,7 @@ SRCS+= alarm.c assert.c clock.c closedir.c config.c confstr.c crypt.c \
|
|||
scandir.c seekdir.c semconfig.c semctl.c semget.c semop.c \
|
||||
setdomainname.c sethostname.c setjmperr.c setmode.c shmat.c \
|
||||
shmctl.c shmdt.c shmget.c siginterrupt.c siglist.c signal.c \
|
||||
sigsetops.c sleep.c sysconf.c sysctl.c syslog.c \
|
||||
sigsetops.c sleep.c sysconf.c sysctl.c sysctlbyname.c syslog.c \
|
||||
telldir.c termios.c time.c times.c timezone.c ttyname.c ttyslot.c \
|
||||
ualarm.c uname.c unvis.c usleep.c utime.c valloc.c vis.c wait.c \
|
||||
wait3.c waitpid.c
|
||||
|
|
|
|||
33
lib/libc/gen/sysctlbyname.c
Normal file
33
lib/libc/gen/sysctlbyname.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
|
||||
* can do whatever you want with this stuff. If we meet some day, and you think
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
int
|
||||
sysctlbyname(char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen)
|
||||
{
|
||||
int name2oid_oid[2];
|
||||
int real_oid[CTL_MAXNAME+2];
|
||||
int error, oidlen;
|
||||
|
||||
name2oid_oid[0] = 0; /* This is magic & undocumented! */
|
||||
name2oid_oid[1] = 3;
|
||||
|
||||
oidlen = sizeof(real_oid);
|
||||
error = sysctl(name2oid_oid, 2, real_oid, &oidlen, name, strlen(name));
|
||||
if (error < 0)
|
||||
return error;
|
||||
oidlen /= sizeof (int);
|
||||
error = sysctl(real_oid, oidlen, oldp, oldlenp, newp, newlen);
|
||||
return (error);
|
||||
}
|
||||
|
||||
Loading…
Reference in a new issue