summaryrefslogtreecommitdiffstats
path: root/rtems/freebsd/rtems/rtems-bsd-sysctl.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-sysctl.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-sysctl.c')
-rw-r--r--rtems/freebsd/rtems/rtems-bsd-sysctl.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/rtems/freebsd/rtems/rtems-bsd-sysctl.c b/rtems/freebsd/rtems/rtems-bsd-sysctl.c
new file mode 100644
index 00000000..dcf963f9
--- /dev/null
+++ b/rtems/freebsd/rtems/rtems-bsd-sysctl.c
@@ -0,0 +1,64 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_rtems
+ *
+ * @brief TODO.
+ */
+
+/*
+ * Copyright (c) 2010 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <rtems/freebsd/machine/rtems-bsd-config.h>
+
+#include <rtems/freebsd/sys/types.h>
+#include <rtems/freebsd/sys/sysctl.h>
+
+int sysctl(
+ int *name,
+ u_int namelen,
+ void *oldp,
+ size_t *oldlenp,
+ void *newp,
+ size_t newlen
+)
+{
+ int eno = EINVAL;
+
+ if (namelen <= CTL_MAXNAME) {
+ int namedup [CTL_MAXNAME];
+
+ memcpy(namedup, name, namelen * sizeof(*name));
+
+ eno = kernel_sysctl(
+ NULL,
+ namedup,
+ namelen,
+ oldp,
+ oldlenp,
+ newp,
+ newlen,
+ oldlenp,
+ 0
+ );
+ }
+
+ if (eno == 0) {
+ return 0;
+ } else {
+ errno = eno;
+
+ return -1;
+ }
+}