summaryrefslogtreecommitdiffstats
path: root/rtems/freebsd/rtems/rtems-bsd-sysctlbyname.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2012-03-07 09:52:04 -0600
committerJoel Sherrill <joel.sherrill@oarcorp.com>2012-03-07 09:52:04 -0600
commita9153ec3040f54fa52b68e14dafed2aba7b780ae (patch)
treefda80e3380dfebf7d97868507aa185757852e882 /rtems/freebsd/rtems/rtems-bsd-sysctlbyname.c
downloadrtems-libbsd-a9153ec3040f54fa52b68e14dafed2aba7b780ae.tar.bz2
Initial import
Code is based on FreeBSD 8.2 with USB support from Sebastian Huber and Thomas Doerfler. Initial TCP/IP stack work is from Kevel Kirspel.
Diffstat (limited to 'rtems/freebsd/rtems/rtems-bsd-sysctlbyname.c')
-rw-r--r--rtems/freebsd/rtems/rtems-bsd-sysctlbyname.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/rtems/freebsd/rtems/rtems-bsd-sysctlbyname.c b/rtems/freebsd/rtems/rtems-bsd-sysctlbyname.c
new file mode 100644
index 00000000..b2953cc2
--- /dev/null
+++ b/rtems/freebsd/rtems/rtems-bsd-sysctlbyname.c
@@ -0,0 +1,43 @@
+/**
+ * @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 <rtems/freebsd/machine/rtems-bsd-config.h>
+
+#include <rtems/freebsd/sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <rtems/freebsd/sys/types.h>
+#include <rtems/freebsd/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);
+}