sysctl
PATCH 1/1 sysctl
Hello,
Since the user-mode qemu doesn't support sysctl (syscall 149) and linuxthreads uses it to check kernel/version, some programs fail. sysctl is an obsolete syscall and seems like a big job to support since you'd have to know what kind of data goes in and out with each parameter, so I'm not surprised why it's not supported. However, implementing only the kernel/version case seems worthwhile. I tested this patch with qemu-arm and it seems to help.
Extending this patch to implement all cases that copy string (or integer) values would be straightforward, but I wanted to keep the patch simple.
Timo
linux-user/syscall.c renamed from linux-user/syscall.c.orig +26 -1
@@ -46,6 +46,7 @@//#include <sys/user.h> #include <netinet/ip.h> #include <netinet/tcp.h> +#include <sys/sysctl.h> #define termios host_termios#define winsize host_winsize
@@ -2565,7 +2566,31 @@ ret =get_errno (fdatasync (arg1));break ;case TARGET_NR__sysctl: - goto unimplemented; + { +struct __sysctl_args *args = (struct __sysctl_args *) arg1; +int *name, nlen, *oldlenp, oldlen, newlen; +void *oldval, *newval; + + name = (int *)tswapl ((long ) args->name); + nlen =tswapl (args->nlen); + oldval = (void *)tswapl ((long ) args->oldval); + oldlenp = (int *)tswapl ((long ) args->oldlenp); + oldlen =tswapl (*oldlenp); + newval = (void *)tswapl ((long ) args->newval); + newlen =tswapl (args->newlen); + +if (nlen ==2 && name[0 ] ==CTL_KERN && name[1 ] ==KERN_VERSION ) { + ret =get_errno ( +sysctl (name, nlen, oldval, &oldlen, newval, newlen)); +if (!is_error (ret)) { + *oldlenp =tswapl (oldlen); + } + }else { +gemu_log ("qemu: Unsupported sysctl name\n" ); + ret = -ENOSYS ; + } + } +break ;case TARGET_NR_sched_setparam: {struct sched_param *target_schp = (void *)arg2;