UserspaceEmulator: Add support for SC_uname and SC_sysconf syscalls

This commit is contained in:
Brendan Coles 2021-11-08 22:06:43 +00:00 committed by Brian Gianforcaro
parent 61d9082da6
commit 1e48cd35a1
Notes: sideshowbarker 2024-07-18 01:22:11 +09:00
2 changed files with 20 additions and 0 deletions

View file

@ -148,6 +148,7 @@ private:
int virt$purge(int mode);
u32 virt$mmap(u32);
FlatPtr virt$mremap(FlatPtr);
u32 virt$sysconf(u32 name);
u32 virt$mount(u32);
u32 virt$munmap(FlatPtr address, size_t size);
u32 virt$gettid();
@ -231,6 +232,7 @@ private:
int virt$beep();
int virt$ftruncate(int fd, FlatPtr length_addr);
mode_t virt$umask(mode_t);
int virt$uname(FlatPtr params_addr);
int virt$anon_create(size_t, int);
int virt$recvfd(int, int);
int virt$sendfd(int, int);

View file

@ -22,6 +22,7 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <sys/utsname.h>
#include <syscall.h>
#include <termios.h>
@ -94,6 +95,8 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
return virt$mremap(arg1);
case SC_gettid:
return virt$gettid();
case SC_sysconf:
return virt$sysconf(arg1);
case SC_getpid:
return virt$getpid();
case SC_getsid:
@ -246,6 +249,8 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
return virt$ftruncate(arg1, arg2);
case SC_umask:
return virt$umask(arg1);
case SC_uname:
return virt$uname(arg1);
case SC_chown:
return virt$chown(arg1);
case SC_msyscall:
@ -487,6 +492,14 @@ int Emulator::virt$ftruncate(int fd, FlatPtr length_addr)
return syscall(SC_ftruncate, fd, &length);
}
int Emulator::virt$uname(FlatPtr params_addr)
{
struct utsname local_uname;
auto rc = syscall(SC_uname, &local_uname);
mmu().copy_to_vm(params_addr, &local_uname, sizeof(local_uname));
return rc;
}
mode_t Emulator::virt$umask(mode_t mask)
{
return syscall(SC_umask, mask);
@ -1596,6 +1609,11 @@ int Emulator::virt$beep()
return syscall(SC_beep);
}
u32 Emulator::virt$sysconf(u32 name)
{
return syscall(SC_sysconf, name);
}
int Emulator::virt$msyscall(FlatPtr)
{
// FIXME: Implement this.