summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-29 23:07:33 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-30 23:34:40 +0100
commit90aa1abfed5c575f6a60e9f2ac0a0d912c82277d (patch)
treeeb3b4b5b099e9225aa5f011c400b61cc6eabcd0f /Userland
parent9815ad556a81a2a5e332f1c152afdc4447a23b69 (diff)
downloadserenity-90aa1abfed5c575f6a60e9f2ac0a0d912c82277d.zip
LibCore: Add ioctl() syscall wrapper
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibCore/System.cpp12
-rw-r--r--Userland/Libraries/LibCore/System.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp
index b0198294fe..17c6fd5cc0 100644
--- a/Userland/Libraries/LibCore/System.cpp
+++ b/Userland/Libraries/LibCore/System.cpp
@@ -10,6 +10,7 @@
#include <LibSystem/syscall.h>
#include <fcntl.h>
#include <stdarg.h>
+#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <unistd.h>
@@ -229,4 +230,15 @@ ErrorOr<String> gethostname()
return String(&hostname[0]);
}
+ErrorOr<void> ioctl(int fd, unsigned request, ...)
+{
+ va_list ap;
+ va_start(ap, request);
+ FlatPtr arg = va_arg(ap, FlatPtr);
+ va_end(ap);
+ if (::ioctl(fd, request, arg) < 0)
+ return Error::from_syscall("ioctl"sv, -errno);
+ return {};
+}
+
}
diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h
index 121867701c..2dc6665975 100644
--- a/Userland/Libraries/LibCore/System.h
+++ b/Userland/Libraries/LibCore/System.h
@@ -36,5 +36,6 @@ ErrorOr<int> dup(int source_fd);
ErrorOr<int> dup2(int source_fd, int destination_fd);
ErrorOr<String> ptsname(int fd);
ErrorOr<String> gethostname();
+ErrorOr<void> ioctl(int fd, unsigned request, ...);
}