From b187a42e53057f15329fda074581fec0ff1cb072 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 5 Aug 2020 19:43:49 +0200 Subject: UserspaceEmulator: Add the ttyname syscall --- DevTools/UserspaceEmulator/Emulator.cpp | 12 ++++++++++++ DevTools/UserspaceEmulator/Emulator.h | 1 + 2 files changed, 13 insertions(+) (limited to 'DevTools') diff --git a/DevTools/UserspaceEmulator/Emulator.cpp b/DevTools/UserspaceEmulator/Emulator.cpp index a8c36e516f..9157f8da46 100644 --- a/DevTools/UserspaceEmulator/Emulator.cpp +++ b/DevTools/UserspaceEmulator/Emulator.cpp @@ -250,6 +250,8 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3) dbgprintf("Syscall: %s (%x)\n", Syscall::to_string((Syscall::Function)function), function); #endif switch (function) { + case SC_ttyname: + return virt$ttyname(arg1, arg2, arg3); case SC_getpgrp: return virt$getpgrp(); case SC_execve: @@ -1244,4 +1246,14 @@ int Emulator::virt$getpgrp() return syscall(SC_getpgrp); } +int Emulator::virt$ttyname(int fd, FlatPtr buffer, size_t buffer_size) +{ + auto host_buffer = ByteBuffer::create_zeroed(buffer_size); + int rc = syscall(SC_ttyname, fd, host_buffer.data(), host_buffer.size()); + if (rc < 1) + return rc; + mmu().copy_to_vm(buffer, host_buffer.data(), host_buffer.size()); + return rc; +} + } diff --git a/DevTools/UserspaceEmulator/Emulator.h b/DevTools/UserspaceEmulator/Emulator.h index 4158a87c4f..c7e26d9849 100644 --- a/DevTools/UserspaceEmulator/Emulator.h +++ b/DevTools/UserspaceEmulator/Emulator.h @@ -137,6 +137,7 @@ private: ssize_t virt$getrandom(FlatPtr buffer, size_t buffer_size, unsigned int flags); int virt$sleep(unsigned); int virt$getpgrp(); + int virt$ttyname(int fd, FlatPtr buffer, size_t buffer_size); FlatPtr allocate_vm(size_t size, size_t alignment); -- cgit v1.2.3