From beb4669eb665f98b45640fbacfc7c6b254c7ca91 Mon Sep 17 00:00:00 2001 From: Peter Korsgaard Date: Wed, 28 Apr 2010 16:38:32 +0200 Subject: [PATCH] syswrap-linux.c: support evdev EVIOCG* ioctls The Linux kernel evdev input subsystem provides a number of EVIOCG* ioctls, which are variable length (returning strings and bitmasks) and returns the length written instead of the more common 0 on success. Add special case handling of these in POST(ioctl) so we don't get unitialized value(s) warnings when these are used. Signed-off-by: Peter Korsgaard --- coregrind/m_syswrap/syswrap-linux.c | 30 +++++++++++++++++++++++++++++- include/vki/vki-linux.h | 25 +++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletions(-) diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index e6ee2e7..32af62a 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -5607,7 +5607,35 @@ POST(sys_ioctl) break; default: - ML_(POST_unknown_ioctl)(tid, RES, ARG2, ARG3); + /* EVIOC* are variable length and return size written on success */ + switch (ARG2 & ~(_VKI_IOC_SIZEMASK << _VKI_IOC_SIZESHIFT)) { + case VKI_EVIOCGNAME: + case VKI_EVIOCGPHYS: + case VKI_EVIOCGUNIQ: + case VKI_EVIOCGKEY: + case VKI_EVIOCGLED: + case VKI_EVIOCGSND: + case VKI_EVIOCGSW: + case VKI_EVIOCGBIT_SYN: + case VKI_EVIOCGBIT_KEY: + case VKI_EVIOCGBIT_REL: + case VKI_EVIOCGBIT_ABS: + case VKI_EVIOCGBIT_MSC: + case VKI_EVIOCGBIT_SW: + case VKI_EVIOCGBIT_LED: + case VKI_EVIOCGBIT_SND: + case VKI_EVIOCGBIT_REP: + case VKI_EVIOCGBIT_FF: + case VKI_EVIOCGBIT_PWR: + case VKI_EVIOCGBIT_FFSTATUS: + if (RES > 0) + POST_MEM_WRITE(ARG3, RES); + break; + + default: + ML_(POST_unknown_ioctl)(tid, RES, ARG2, ARG3); + break; + } break; } } diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h index 7ea6e2a..23b257c 100644 --- a/include/vki/vki-linux.h +++ b/include/vki/vki-linux.h @@ -2643,6 +2643,31 @@ struct vki_getcpu_cache { unsigned long blob[128 / sizeof(long)]; }; +//---------------------------------------------------------------------- +// From linux-2.6.33.3/include/linux/input.h +//---------------------------------------------------------------------- + +/* EVIOC* are variable length and return size written on success */ +#define VKI_EVIOCGNAME _VKI_IOC(_VKI_IOC_READ, 'E', 0x06, 0) +#define VKI_EVIOCGPHYS _VKI_IOC(_VKI_IOC_READ, 'E', 0x07, 0) +#define VKI_EVIOCGUNIQ _VKI_IOC(_VKI_IOC_READ, 'E', 0x08, 0) +#define VKI_EVIOCGKEY _VKI_IOC(_VKI_IOC_READ, 'E', 0x18, 0) +#define VKI_EVIOCGLED _VKI_IOC(_VKI_IOC_READ, 'E', 0x19, 0) +#define VKI_EVIOCGSND _VKI_IOC(_VKI_IOC_READ, 'E', 0x1a, 0) +#define VKI_EVIOCGSW _VKI_IOC(_VKI_IOC_READ, 'E', 0x1b, 0) +#define VKI_EVIOCGBIT_SYN _VKI_IOC(_VKI_IOC_READ, 'E', 0x20, 0) +#define VKI_EVIOCGBIT_KEY _VKI_IOC(_VKI_IOC_READ, 'E', 0x21, 0) +#define VKI_EVIOCGBIT_REL _VKI_IOC(_VKI_IOC_READ, 'E', 0x22, 0) +#define VKI_EVIOCGBIT_ABS _VKI_IOC(_VKI_IOC_READ, 'E', 0x23, 0) +#define VKI_EVIOCGBIT_MSC _VKI_IOC(_VKI_IOC_READ, 'E', 0x24, 0) +#define VKI_EVIOCGBIT_SW _VKI_IOC(_VKI_IOC_READ, 'E', 0x25, 0) +#define VKI_EVIOCGBIT_LED _VKI_IOC(_VKI_IOC_READ, 'E', 0x31, 0) +#define VKI_EVIOCGBIT_SND _VKI_IOC(_VKI_IOC_READ, 'E', 0x32, 0) +#define VKI_EVIOCGBIT_REP _VKI_IOC(_VKI_IOC_READ, 'E', 0x34, 0) +#define VKI_EVIOCGBIT_FF _VKI_IOC(_VKI_IOC_READ, 'E', 0x35, 0) +#define VKI_EVIOCGBIT_PWR _VKI_IOC(_VKI_IOC_READ, 'E', 0x36, 0) +#define VKI_EVIOCGBIT_FFSTATUS _VKI_IOC(_VKI_IOC_READ, 'E', 0x37, 0) + #endif // __VKI_LINUX_H /*--------------------------------------------------------------------*/ -- 1.7.0