UserspaceEmulator: Implement set_process_name syscall

This commit is contained in:
Ben Wiederhake 2021-03-10 17:55:23 +01:00 committed by Andreas Kling
parent ec8e3edd05
commit d5925f33aa
Notes: sideshowbarker 2024-07-18 21:32:27 +09:00
2 changed files with 12 additions and 0 deletions

View file

@ -125,6 +125,7 @@ private:
int virt$mkdir(FlatPtr path, size_t path_length, mode_t mode);
int virt$unlink(FlatPtr path, size_t path_length);
int virt$get_process_name(FlatPtr buffer, int size);
int virt$set_process_name(FlatPtr buffer, int size);
int virt$set_mmap_name(FlatPtr);
int virt$gettimeofday(FlatPtr);
int virt$clock_gettime(int, FlatPtr);

View file

@ -168,6 +168,8 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
return virt$getsockopt(arg1);
case SC_get_process_name:
return virt$get_process_name(arg1, arg2);
case SC_set_process_name:
return virt$set_process_name(arg1, arg2);
case SC_dbgputstr:
return virt$dbgputstr(arg1, arg2);
case SC_dbgputch:
@ -481,6 +483,15 @@ int Emulator::virt$get_process_name(FlatPtr buffer, int size)
return rc;
}
int Emulator::virt$set_process_name(FlatPtr user_buffer, int size)
{
if (size < 0)
return -EINVAL;
auto host_buffer = mmu().copy_buffer_from_vm(user_buffer, size);
auto name = String::formatted("(UE) {}", StringView { host_buffer.data(), host_buffer.size() });
return syscall(SC_set_process_name, name.characters(), name.length());
}
int Emulator::virt$lseek(int fd, off_t offset, int whence)
{
return syscall(SC_lseek, fd, offset, whence);