rtems-libbsd/rtemsbsd/rtems/rtems-bsd-sysctlbyname.c
Sebastian Huber e599318e91 Update files to match FreeBSD layout
Add compatibility with Newlib header files.  Some FreeBSD header files
are mapped by the translation script:

     o rtems/bsd/sys/_types.h
     o rtems/bsd/sys/errno.h
     o rtems/bsd/sys/lock.h
     o rtems/bsd/sys/param.h
     o rtems/bsd/sys/resource.h
     o rtems/bsd/sys/time.h
     o rtems/bsd/sys/timespec.h
     o rtems/bsd/sys/types.h
     o rtems/bsd/sys/unistd.h

It is now possible to include <sys/socket.h> directly for example.

Generate one Makefile which builds everything including tests.
2013-10-10 09:08:23 +02:00

44 lines
1.1 KiB
C

/**
* @file
*
* @ingroup rtems_bsd_rtems
*
* @brief TODO.
*
* File origin from FreeBSD 'lib/libc/gen/sysctlbyname.c'.
*/
/*
* ----------------------------------------------------------------------------
* "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
* ----------------------------------------------------------------------------
*
*/
#include <machine/rtems-bsd-config.h>
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <rtems/bsd/sys/types.h>
#include <sys/sysctl.h>
int
sysctlbyname(const char *name, void *oldp, size_t *oldlenp,
void *newp, size_t newlen)
{
int real_oid[CTL_MAXNAME+2];
int error;
size_t oidlen;
oidlen = sizeof(real_oid) / sizeof(int);
error = sysctlnametomib(name, real_oid, &oidlen);
if (error < 0)
return (error);
error = sysctl(real_oid, oidlen, oldp, oldlenp, newp, newlen);
return (error);
}