diff options
author | Andreas Kling <kling@serenityos.org> | 2020-08-05 19:43:49 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-05 22:34:50 +0200 |
commit | b187a42e53057f15329fda074581fec0ff1cb072 (patch) | |
tree | 70f1a8197d840b03d9e2f75c06a4f1a507480f73 /DevTools | |
parent | 9d93e208ace5a7c8152bb5933b25330fba180230 (diff) | |
download | serenity-b187a42e53057f15329fda074581fec0ff1cb072.zip |
UserspaceEmulator: Add the ttyname syscall
Diffstat (limited to 'DevTools')
-rw-r--r-- | DevTools/UserspaceEmulator/Emulator.cpp | 12 | ||||
-rw-r--r-- | DevTools/UserspaceEmulator/Emulator.h | 1 |
2 files changed, 13 insertions, 0 deletions
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); |