summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2017-06-14 20:35:53 +0000
committerWilliam Pitcock <nenolod@dereferenced.org>2017-06-14 20:35:53 +0000
commit0eea43494add09f1ea2ecda0e6892298c9070630 (patch)
tree3edeebcbe7d5196f2659d930918f05f45c3dfef1
parent979f3bc0d18b71a6bd29557a4af9de3eaa5c34f3 (diff)
downloadgcompat-0eea43494add09f1ea2ecda0e6892298c9070630.tar.gz
gcompat-0eea43494add09f1ea2ecda0e6892298c9070630.tar.bz2
gcompat-0eea43494add09f1ea2ecda0e6892298c9070630.tar.xz
gcompat-0eea43494add09f1ea2ecda0e6892298c9070630.zip
add sysctl()
-rw-r--r--Makefile1
-rw-r--r--libgcompat/sysctl.c28
2 files changed, 29 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index b6e497a..e71ad20 100644
--- a/Makefile
+++ b/Makefile
@@ -11,6 +11,7 @@ LIBGCOMPAT_SRC = \
libgcompat/stdio.c \
libgcompat/stdlib.c \
libgcompat/string.c \
+ libgcompat/sysctl.c \
libgcompat/version.c
LIBGCOMPAT_OBJ = ${LIBGCOMPAT_SRC:.c=.o}
LIBGCOMPAT_SOVERSION = 0
diff --git a/libgcompat/sysctl.c b/libgcompat/sysctl.c
new file mode 100644
index 0000000..5671055
--- /dev/null
+++ b/libgcompat/sysctl.c
@@ -0,0 +1,28 @@
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+
+struct __sysctl_args {
+ int *name;
+ int nlen;
+ void *oldval;
+ size_t *oldlenp;
+ void *newval;
+ size_t newlen;
+};
+
+
+int sysctl (int *name, int nlen, void *oldval, size_t *oldlenp, void *newval, size_t newlen) {
+ struct __sysctl_args args = {
+ .name = name,
+ .nlen = nlen,
+ .oldval = oldval,
+ .oldlenp = oldlenp,
+ .newval = newval,
+ .newlen = newlen
+ };
+
+ return syscall(SYS__sysctl, &args);
+}