UserspaceEmulator: Implement virt$pipe()

This commit is contained in:
Sergey Bugaev 2020-07-15 14:32:06 +03:00 committed by Andreas Kling
parent 633301323b
commit e12b591509
Notes: sideshowbarker 2024-07-19 04:48:48 +09:00
2 changed files with 13 additions and 0 deletions

View File

@ -221,6 +221,8 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
return virt$madvise(arg1, arg2, arg3);
case SC_open:
return virt$open(arg1);
case SC_pipe:
return virt$pipe(arg1, arg2);
case SC_fcntl:
return virt$fcntl(arg1, arg2, arg3);
case SC_getgroups:
@ -334,6 +336,16 @@ u32 Emulator::virt$open(u32 params_addr)
return fd;
}
int Emulator::virt$pipe(FlatPtr vm_pipefd, int flags)
{
int pipefd[2];
int rc = syscall(SC_pipe, pipefd, flags);
if (rc < 0)
return rc;
mmu().copy_to_vm(vm_pipefd, pipefd, sizeof(pipefd));
return rc;
}
u32 Emulator::virt$munmap(FlatPtr address, u32 size)
{
auto* region = mmu().find_region({ 0x20, address });

View File

@ -70,6 +70,7 @@ private:
u32 virt$mprotect(FlatPtr, size_t, int);
u32 virt$madvise(FlatPtr, size_t, int);
u32 virt$open(u32);
int virt$pipe(FlatPtr pipefd, int flags);
int virt$close(int);
int virt$get_process_name(FlatPtr buffer, int size);
int virt$dbgputstr(FlatPtr characters, int length);