1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:07:44 +00:00

Kernel+LibC+LibCore+UserspaceEmulator: Implement faccessat(2)

Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
This commit is contained in:
sin-ack 2022-10-01 12:24:56 +00:00 committed by Andrew Kaster
parent fa692e13f9
commit 2a502fe232
13 changed files with 89 additions and 39 deletions

View file

@ -42,8 +42,6 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
switch (function) {
case SC_accept4:
return virt$accept4(arg1);
case SC_access:
return virt$access(arg1, arg2, arg3);
case SC_allocate_tls:
return virt$allocate_tls(arg1, arg2);
case SC_anon_create:
@ -83,6 +81,8 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
case SC_exit:
virt$exit((int)arg1);
return 0;
case SC_faccessat:
return virt$faccessat(arg1);
case SC_fchmod:
return virt$fchmod(arg1, arg2);
case SC_fchown:
@ -1462,10 +1462,16 @@ int Emulator::virt$getsid(pid_t pid)
return syscall(SC_getsid, pid);
}
int Emulator::virt$access(FlatPtr path, size_t path_length, int type)
int Emulator::virt$faccessat(FlatPtr params_addr)
{
auto host_path = mmu().copy_buffer_from_vm(path, path_length);
return syscall(SC_access, host_path.data(), host_path.size(), type);
Syscall::SC_faccessat_params params;
mmu().copy_from_vm(&params, params_addr, sizeof(params));
auto host_path = mmu().copy_buffer_from_vm(reinterpret_cast<FlatPtr>(params.pathname.characters), params.pathname.length);
Syscall::SC_faccessat_params host_params = params;
host_params.pathname = { reinterpret_cast<char const*>(host_path.data()), host_path.size() };
return syscall(SC_faccessat, &host_params);
}
int Emulator::virt$waitid(FlatPtr params_addr)