From: Melchior F. <mf...@kd...> - 2003-05-02 16:35:38
|
The JSIOCGNAME ioctl is currently not supported by valgrind. This function returns human readable joystick names (like "SAITEK CYBORG 3D USB"). The ioctl has two unconventional properties: it has a variable id (with the size of the target buffer encoded in it), and it doesn't necessarily return zero on success, but the number of actually written bytes. I suggest the following patch. m. Index: coregrind/vg_syscalls.c =================================================================== RCS file: /cvsroot/valgrind/valgrind/coregrind/vg_syscalls.c,v retrieving revision 1.32 diff -u -p -r1.32 vg_syscalls.c --- coregrind/vg_syscalls.c 2 May 2003 16:18:06 -0000 1.32 +++ coregrind/vg_syscalls.c 2 May 2003 16:24:03 -0000 @@ -2435,9 +2435,18 @@ void VG_(perform_assumed_nonblocking_sys } KERNEL_DO_SYSCALL(tid,res); if (size > 0 && (dir & _IOC_READ) - && !VG_(is_kerror)(res) && res == 0 - && arg3 != (Addr)NULL) - VG_TRACK( post_mem_write,arg3, size); + && !VG_(is_kerror)(res) + && arg3 != (Addr)NULL) { + /* JSIOCGNAME() returns the number of actually + * written bytes on success. + */ + if ((arg2 & ~(_IOC_SIZEMASK << _IOC_SIZESHIFT)) + == JSIOCGNAME(0)) { + if (res > 0) + VG_TRACK( post_mem_write, arg3, res); + } else if (res == 0) + VG_TRACK( post_mem_write, arg3, size); + } break; } } Index: coregrind/vg_unsafe.h =================================================================== RCS file: /cvsroot/valgrind/valgrind/coregrind/vg_unsafe.h,v retrieving revision 1.12 diff -u -p -r1.12 vg_unsafe.h --- coregrind/vg_unsafe.h 15 Apr 2003 14:57:51 -0000 1.12 +++ coregrind/vg_unsafe.h 2 May 2003 16:24:04 -0000 @@ -60,8 +60,9 @@ #include <sys/stat.h> /* for struct stat */ #undef __USE_LARGEFILE64 -#include <asm/ioctls.h> /* for stuff for dealing with ioctl :( */ -#include <sys/soundcard.h> /* for various soundcard ioctl constants :( */ +#include <asm/ioctls.h> /* for stuff for dealing with ioctl :( */ +#include <linux/joystick.h> /* for JSIOCGNAME joystick ioctl :( */ +#include <sys/soundcard.h> /* for various soundcard ioctl constants :( */ #ifndef GLIBC_2_1 # include <linux/rtc.h> /* for RTC_* ioctls */ |