Blame SOURCES/0002-evdev-fix-decoding-of-EVIOCGBIT-0.patch

904f19
From c658eb981bfc302aafe5be6e4118a9c0a3f1735e Mon Sep 17 00:00:00 2001
904f19
From: Zhibin Li <08826794brmt@gmail.com>
904f19
Date: Wed, 1 Aug 2018 17:53:57 +0800
904f19
Subject: [PATCH 02/27] evdev: fix decoding of EVIOCGBIT(0, ...)
904f19
904f19
There is a comment in drivers/input/evdev.c which says:
904f19
/* EV_SYN==0 is EV_CNT, _not_ SYN_CNT, see EVIOCGBIT */
904f19
904f19
That is, EVIOCGBIT(0, ...) should return a bit mask with supported
904f19
event types instead of SYN_* event codes.
904f19
904f19
* defs.h (evdev_ev): New prototype.
904f19
* evdev.c: Include "xlat/evdev_ev.h" and remove "xlat/evdev_sync.h".
904f19
(bit_ioctl) <case EV_SYN>: Replace EV_SYN with 0, use evdev_ev
904f19
with XT_SORTED in decode_bitset invocation instead.
904f19
* ioctl.c: Do not include "xlat/evdev_ev.h".
904f19
(evdev_decode_number): Print nr == 0x20 as "0" instead of "EV_SYN".
904f19
* tests/ioctl_evdev.c (main): Use 0 instead of EV_SYN in EVIOCGBIT
904f19
output.
904f19
* xlat/evdev_sync.in: Remove.
904f19
904f19
Additional changes:
904f19
	xlat/evdev_ev.h (auto-generated from xlat/evdev_ev.in)
904f19
904f19
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
904f19
Fixes: v4.10~89 "Add decoding for evdev ioctls"
904f19
---
904f19
 defs.h              | 1 +
904f19
 evdev.c             | 8 ++++----
904f19
 ioctl.c             | 7 ++++---
904f19
 tests/ioctl_evdev.c | 2 +-
904f19
 xlat/evdev_sync.in  | 5 -----
904f19
 5 files changed, 10 insertions(+), 13 deletions(-)
904f19
 delete mode 100644 xlat/evdev_sync.in
904f19
904f19
Index: strace-4.24/defs.h
904f19
===================================================================
904f19
--- strace-4.24.orig/defs.h	2019-03-11 12:34:15.719549018 +0100
904f19
+++ strace-4.24/defs.h	2019-03-11 12:47:05.976567233 +0100
904f19
@@ -330,6 +330,7 @@
904f19
 /** Number of elements in evdev_abs array without the terminating record. */
904f19
 extern const size_t evdev_abs_size;
904f19
 
904f19
+extern const struct xlat evdev_ev[];
904f19
 extern const struct xlat iffflags[];
904f19
 extern const struct xlat ip_type_of_services[];
904f19
 extern const struct xlat ipc_private[];
904f19
Index: strace-4.24/evdev.c
904f19
===================================================================
904f19
--- strace-4.24.orig/evdev.c	2019-03-11 12:34:21.911484926 +0100
904f19
+++ strace-4.24/evdev.c	2019-03-11 12:47:05.976567233 +0100
904f19
@@ -30,6 +30,7 @@
904f19
 #include "defs.h"
904f19
 
904f19
 #include "xlat/evdev_abs.h"
904f19
+#include "xlat/evdev_ev.h"
904f19
 
904f19
 #ifdef HAVE_LINUX_INPUT_H
904f19
 
904f19
@@ -47,7 +48,6 @@
904f19
 # include "xlat/evdev_relative_axes.h"
904f19
 # include "xlat/evdev_snd.h"
904f19
 # include "xlat/evdev_switch.h"
904f19
-# include "xlat/evdev_sync.h"
904f19
 
904f19
 # ifndef SYN_MAX
904f19
 #  define SYN_MAX 0xf
904f19
@@ -258,9 +258,9 @@
904f19
 	  const kernel_ulong_t arg)
904f19
 {
904f19
 	switch (ev_nr) {
904f19
-		case EV_SYN:
904f19
-			return decode_bitset(tcp, arg, evdev_sync,
904f19
-					     SYN_MAX, "SYN_???", XT_INDEXED);
904f19
+		case 0:
904f19
+			return decode_bitset(tcp, arg, evdev_ev,
904f19
+					     EV_MAX, "EV_???", XT_SORTED);
904f19
 		case EV_KEY:
904f19
 			return decode_bitset(tcp, arg, evdev_keycode,
904f19
 					     KEY_MAX, "KEY_???", XT_INDEXED);
904f19
Index: strace-4.24/ioctl.c
904f19
===================================================================
904f19
--- strace-4.24.orig/ioctl.c	2019-03-11 12:34:15.719549018 +0100
904f19
+++ strace-4.24/ioctl.c	2019-03-11 12:47:05.976567233 +0100
904f19
@@ -33,8 +33,6 @@
904f19
 #include <linux/ioctl.h>
904f19
 #include "xlat/ioctl_dirs.h"
904f19
 
904f19
-#include "xlat/evdev_ev.h"
904f19
-
904f19
 static int
904f19
 compare(const void *a, const void *b)
904f19
 {
904f19
@@ -99,7 +97,10 @@
904f19
 
904f19
 	if (nr >= 0x20 && nr <= 0x20 + 0x1f) {
904f19
 		tprints("EVIOCGBIT(");
904f19
-		printxval(evdev_ev, nr - 0x20, "EV_???");
904f19
+		if (nr == 0x20)
904f19
+			tprintf("0");
904f19
+		else
904f19
+			printxval(evdev_ev, nr - 0x20, "EV_???");
904f19
 		tprintf(", %u)", _IOC_SIZE(code));
904f19
 		return 1;
904f19
 	} else if (nr >= 0x40 && nr <= 0x40 + 0x3f) {
904f19
Index: strace-4.24/tests/ioctl_evdev.c
904f19
===================================================================
904f19
--- strace-4.24.orig/tests/ioctl_evdev.c	2019-03-11 12:34:15.719549018 +0100
904f19
+++ strace-4.24/tests/ioctl_evdev.c	2019-03-11 12:47:05.977567222 +0100
904f19
@@ -138,7 +138,7 @@
904f19
 	TEST_NULL_ARG_EX(EVIOCGABS(0x3f), "EVIOCGABS(0x3f /* ABS_??? */)");
904f19
 	TEST_NULL_ARG_EX(EVIOCSABS(0x3f), "EVIOCSABS(0x3f /* ABS_??? */)");
904f19
 
904f19
-	TEST_NULL_ARG(EVIOCGBIT(EV_SYN, 0));
904f19
+	TEST_NULL_ARG(EVIOCGBIT(0, 0));
904f19
 	TEST_NULL_ARG(EVIOCGBIT(EV_KEY, 1));
904f19
 	TEST_NULL_ARG(EVIOCGBIT(EV_REL, 2));
904f19
 	TEST_NULL_ARG(EVIOCGBIT(EV_ABS, 3));
904f19
Index: strace-4.24/xlat/evdev_sync.in
904f19
===================================================================
904f19
--- strace-4.24.orig/xlat/evdev_sync.in	2019-03-11 12:34:15.719549018 +0100
904f19
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
904f19
@@ -1,5 +0,0 @@
904f19
-#value_indexed
904f19
-SYN_REPORT	0
904f19
-SYN_CONFIG	1
904f19
-SYN_MT_REPORT	2
904f19
-SYN_DROPPED	3
904f19
Index: strace-4.24/xlat/evdev_ev.h
904f19
===================================================================
904f19
--- strace-4.24.orig/xlat/evdev_ev.h	2018-08-14 02:44:11.000000000 +0200
904f19
+++ strace-4.24/xlat/evdev_ev.h	2019-03-11 12:48:32.390670458 +0100
904f19
@@ -90,13 +90,8 @@
904f19
 
904f19
 #ifndef XLAT_MACROS_ONLY
904f19
 
904f19
-# ifdef IN_MPERS
904f19
+# ifndef IN_MPERS
904f19
 
904f19
-#  error static const struct xlat evdev_ev in mpers mode
904f19
-
904f19
-# else
904f19
-
904f19
-static
904f19
 const struct xlat evdev_ev[] = {
904f19
  XLAT(EV_SYN),
904f19
  XLAT(EV_KEY),
904f19
Index: strace-4.24/tests-m32/ioctl_evdev.c
904f19
===================================================================
904f19
--- strace-4.24.orig/tests-m32/ioctl_evdev.c	2018-06-14 13:00:00.000000000 +0200
904f19
+++ strace-4.24/tests-m32/ioctl_evdev.c	2019-08-29 17:35:59.062591866 +0200
904f19
@@ -138,7 +138,7 @@
904f19
 	TEST_NULL_ARG_EX(EVIOCGABS(0x3f), "EVIOCGABS(0x3f /* ABS_??? */)");
904f19
 	TEST_NULL_ARG_EX(EVIOCSABS(0x3f), "EVIOCSABS(0x3f /* ABS_??? */)");
904f19
 
904f19
-	TEST_NULL_ARG(EVIOCGBIT(EV_SYN, 0));
904f19
+	TEST_NULL_ARG(EVIOCGBIT(0, 0));
904f19
 	TEST_NULL_ARG(EVIOCGBIT(EV_KEY, 1));
904f19
 	TEST_NULL_ARG(EVIOCGBIT(EV_REL, 2));
904f19
 	TEST_NULL_ARG(EVIOCGBIT(EV_ABS, 3));
904f19
Index: strace-4.24/tests-mx32/ioctl_evdev.c
904f19
===================================================================
904f19
--- strace-4.24.orig/tests-mx32/ioctl_evdev.c	2018-06-14 13:00:00.000000000 +0200
904f19
+++ strace-4.24/tests-mx32/ioctl_evdev.c	2019-08-29 17:36:01.222564829 +0200
904f19
@@ -138,7 +138,7 @@
904f19
 	TEST_NULL_ARG_EX(EVIOCGABS(0x3f), "EVIOCGABS(0x3f /* ABS_??? */)");
904f19
 	TEST_NULL_ARG_EX(EVIOCSABS(0x3f), "EVIOCSABS(0x3f /* ABS_??? */)");
904f19
 
904f19
-	TEST_NULL_ARG(EVIOCGBIT(EV_SYN, 0));
904f19
+	TEST_NULL_ARG(EVIOCGBIT(0, 0));
904f19
 	TEST_NULL_ARG(EVIOCGBIT(EV_KEY, 1));
904f19
 	TEST_NULL_ARG(EVIOCGBIT(EV_REL, 2));
904f19
 	TEST_NULL_ARG(EVIOCGBIT(EV_ABS, 3));