From 2ac5c2278dc9bd1461c5a642ebe1b2c476188e06 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 27 Jul 2020 23:38:50 +0200 Subject: [PATCH] UserspaceEmulator: Support ioctl(TIOCGWINSZ) This is very commonly used by terminal programs, and easy to support. --- DevTools/UserspaceEmulator/Emulator.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/DevTools/UserspaceEmulator/Emulator.cpp b/DevTools/UserspaceEmulator/Emulator.cpp index dcbb5eeef7..26b64065cd 100644 --- a/DevTools/UserspaceEmulator/Emulator.cpp +++ b/DevTools/UserspaceEmulator/Emulator.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -864,6 +865,14 @@ int Emulator::virt$ioctl(int fd, unsigned request, FlatPtr arg) { (void)fd; (void)arg; + if (request == TIOCGWINSZ) { + struct winsize ws; + int rc = syscall(SC_ioctl, fd, TIOCGWINSZ, &ws); + if (rc < 0) + return rc; + mmu().copy_to_vm(arg, &ws, sizeof(winsize)); + return 0; + } dbg() << "Unsupported ioctl: " << request; dump_backtrace(); TODO();