UserspaceEmulator: Add support for setgroups

This commit is contained in:
AnotherTest 2020-10-24 11:23:02 +03:30 committed by Andreas Kling
commit b1d36243e5
Notes: sideshowbarker 2024-07-19 01:45:31 +09:00
2 changed files with 12 additions and 0 deletions

View file

@ -335,6 +335,8 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
return virt$fcntl(arg1, arg2, arg3);
case SC_getgroups:
return virt$getgroups(arg1, arg2);
case SC_setgroups:
return virt$setgroups(arg1, arg2);
case SC_lseek:
return virt$lseek(arg1, arg2, arg3);
case SC_socket:
@ -742,6 +744,15 @@ int Emulator::virt$getgroups(ssize_t count, FlatPtr groups)
return 0;
}
int Emulator::virt$setgroups(ssize_t count, FlatPtr groups)
{
if (!count)
return syscall(SC_setgroups, 0, nullptr);
auto buffer = mmu().copy_buffer_from_vm(groups, count * sizeof(gid_t));
return syscall(SC_setgroups, count, buffer.data());
}
u32 Emulator::virt$fcntl(int fd, int cmd, u32 arg)
{
switch (cmd) {