1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:08:12 +00:00

UserspaceEmulator: Add the ttyname syscall

This commit is contained in:
Andreas Kling 2020-08-05 19:43:49 +02:00
parent 9d93e208ac
commit b187a42e53
2 changed files with 13 additions and 0 deletions

View file

@ -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;
}
}