mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 19:35:08 +00:00
UserspaceEmulator: Add the getcwd syscall
This commit is contained in:
parent
b187a42e53
commit
c497603177
2 changed files with 13 additions and 0 deletions
|
@ -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_getcwd:
|
||||
return virt$getcwd(arg1, arg2);
|
||||
case SC_ttyname:
|
||||
return virt$ttyname(arg1, arg2, arg3);
|
||||
case SC_getpgrp:
|
||||
|
@ -1256,4 +1258,14 @@ int Emulator::virt$ttyname(int fd, FlatPtr buffer, size_t buffer_size)
|
|||
return rc;
|
||||
}
|
||||
|
||||
int Emulator::virt$getcwd(FlatPtr buffer, size_t buffer_size)
|
||||
{
|
||||
auto host_buffer = ByteBuffer::create_zeroed(buffer_size);
|
||||
int rc = syscall(SC_getcwd, host_buffer.data(), host_buffer.size());
|
||||
if (rc < 1)
|
||||
return rc;
|
||||
mmu().copy_to_vm(buffer, host_buffer.data(), host_buffer.size());
|
||||
return rc;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue