From 90aa1abfed5c575f6a60e9f2ac0a0d912c82277d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 29 Nov 2021 23:07:33 +0100 Subject: [PATCH] LibCore: Add ioctl() syscall wrapper --- Userland/Libraries/LibCore/System.cpp | 12 ++++++++++++ Userland/Libraries/LibCore/System.h | 1 + 2 files changed, 13 insertions(+) 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 #include #include +#include #include #include #include @@ -229,4 +230,15 @@ ErrorOr gethostname() return String(&hostname[0]); } +ErrorOr 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 dup(int source_fd); ErrorOr dup2(int source_fd, int destination_fd); ErrorOr ptsname(int fd); ErrorOr gethostname(); +ErrorOr ioctl(int fd, unsigned request, ...); }