1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-23 09:37:34 +00:00

UserspaceEmulator: Add the chdir syscall

This commit is contained in:
Andreas Kling 2020-08-07 18:44:51 +02:00
parent ee5e8081da
commit 5dce5fa7c2
2 changed files with 9 additions and 0 deletions

View file

@ -251,6 +251,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); dbgprintf("Syscall: %s (%x)\n", Syscall::to_string((Syscall::Function)function), function);
#endif #endif
switch (function) { switch (function) {
case SC_chdir:
return virt$chdir(arg1, arg2);
case SC_access: case SC_access:
return virt$access(arg1, arg2, arg3); return virt$access(arg1, arg2, arg3);
case SC_waitid: case SC_waitid:
@ -1338,4 +1340,10 @@ int Emulator::virt$waitid(FlatPtr params_addr)
return rc; return rc;
} }
int Emulator::virt$chdir(FlatPtr path, size_t path_length)
{
auto host_path = mmu().copy_buffer_from_vm(path, path_length);
return syscall(SC_chdir, host_path.data(), host_path.size());
}
} }

View file

@ -137,6 +137,7 @@ private:
void virt$exit(int); void virt$exit(int);
ssize_t virt$getrandom(FlatPtr buffer, size_t buffer_size, unsigned int flags); ssize_t virt$getrandom(FlatPtr buffer, size_t buffer_size, unsigned int flags);
int virt$sleep(unsigned); int virt$sleep(unsigned);
int virt$chdir(FlatPtr, size_t);
int virt$getpgrp(); int virt$getpgrp();
int virt$getpgid(pid_t); int virt$getpgid(pid_t);
int virt$setpgid(pid_t pid, pid_t pgid); int virt$setpgid(pid_t pid, pid_t pgid);