Blob Blame History Raw
From c658eb981bfc302aafe5be6e4118a9c0a3f1735e Mon Sep 17 00:00:00 2001
From: Zhibin Li <08826794brmt@gmail.com>
Date: Wed, 1 Aug 2018 17:53:57 +0800
Subject: [PATCH 02/27] evdev: fix decoding of EVIOCGBIT(0, ...)

There is a comment in drivers/input/evdev.c which says:
/* EV_SYN==0 is EV_CNT, _not_ SYN_CNT, see EVIOCGBIT */

That is, EVIOCGBIT(0, ...) should return a bit mask with supported
event types instead of SYN_* event codes.

* defs.h (evdev_ev): New prototype.
* evdev.c: Include "xlat/evdev_ev.h" and remove "xlat/evdev_sync.h".
(bit_ioctl) <case EV_SYN>: Replace EV_SYN with 0, use evdev_ev
with XT_SORTED in decode_bitset invocation instead.
* ioctl.c: Do not include "xlat/evdev_ev.h".
(evdev_decode_number): Print nr == 0x20 as "0" instead of "EV_SYN".
* tests/ioctl_evdev.c (main): Use 0 instead of EV_SYN in EVIOCGBIT
output.
* xlat/evdev_sync.in: Remove.

Additional changes:
	xlat/evdev_ev.h (auto-generated from xlat/evdev_ev.in)

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Fixes: v4.10~89 "Add decoding for evdev ioctls"
---
 defs.h              | 1 +
 evdev.c             | 8 ++++----
 ioctl.c             | 7 ++++---
 tests/ioctl_evdev.c | 2 +-
 xlat/evdev_sync.in  | 5 -----
 5 files changed, 10 insertions(+), 13 deletions(-)
 delete mode 100644 xlat/evdev_sync.in

Index: strace-4.24/defs.h
===================================================================
--- strace-4.24.orig/defs.h	2019-03-11 12:34:15.719549018 +0100
+++ strace-4.24/defs.h	2019-03-11 12:47:05.976567233 +0100
@@ -330,6 +330,7 @@
 /** Number of elements in evdev_abs array without the terminating record. */
 extern const size_t evdev_abs_size;
 
+extern const struct xlat evdev_ev[];
 extern const struct xlat iffflags[];
 extern const struct xlat ip_type_of_services[];
 extern const struct xlat ipc_private[];
Index: strace-4.24/evdev.c
===================================================================
--- strace-4.24.orig/evdev.c	2019-03-11 12:34:21.911484926 +0100
+++ strace-4.24/evdev.c	2019-03-11 12:47:05.976567233 +0100
@@ -30,6 +30,7 @@
 #include "defs.h"
 
 #include "xlat/evdev_abs.h"
+#include "xlat/evdev_ev.h"
 
 #ifdef HAVE_LINUX_INPUT_H
 
@@ -47,7 +48,6 @@
 # include "xlat/evdev_relative_axes.h"
 # include "xlat/evdev_snd.h"
 # include "xlat/evdev_switch.h"
-# include "xlat/evdev_sync.h"
 
 # ifndef SYN_MAX
 #  define SYN_MAX 0xf
@@ -258,9 +258,9 @@
 	  const kernel_ulong_t arg)
 {
 	switch (ev_nr) {
-		case EV_SYN:
-			return decode_bitset(tcp, arg, evdev_sync,
-					     SYN_MAX, "SYN_???", XT_INDEXED);
+		case 0:
+			return decode_bitset(tcp, arg, evdev_ev,
+					     EV_MAX, "EV_???", XT_SORTED);
 		case EV_KEY:
 			return decode_bitset(tcp, arg, evdev_keycode,
 					     KEY_MAX, "KEY_???", XT_INDEXED);
Index: strace-4.24/ioctl.c
===================================================================
--- strace-4.24.orig/ioctl.c	2019-03-11 12:34:15.719549018 +0100
+++ strace-4.24/ioctl.c	2019-03-11 12:47:05.976567233 +0100
@@ -33,8 +33,6 @@
 #include <linux/ioctl.h>
 #include "xlat/ioctl_dirs.h"
 
-#include "xlat/evdev_ev.h"
-
 static int
 compare(const void *a, const void *b)
 {
@@ -99,7 +97,10 @@
 
 	if (nr >= 0x20 && nr <= 0x20 + 0x1f) {
 		tprints("EVIOCGBIT(");
-		printxval(evdev_ev, nr - 0x20, "EV_???");
+		if (nr == 0x20)
+			tprintf("0");
+		else
+			printxval(evdev_ev, nr - 0x20, "EV_???");
 		tprintf(", %u)", _IOC_SIZE(code));
 		return 1;
 	} else if (nr >= 0x40 && nr <= 0x40 + 0x3f) {
Index: strace-4.24/tests/ioctl_evdev.c
===================================================================
--- strace-4.24.orig/tests/ioctl_evdev.c	2019-03-11 12:34:15.719549018 +0100
+++ strace-4.24/tests/ioctl_evdev.c	2019-03-11 12:47:05.977567222 +0100
@@ -138,7 +138,7 @@
 	TEST_NULL_ARG_EX(EVIOCGABS(0x3f), "EVIOCGABS(0x3f /* ABS_??? */)");
 	TEST_NULL_ARG_EX(EVIOCSABS(0x3f), "EVIOCSABS(0x3f /* ABS_??? */)");
 
-	TEST_NULL_ARG(EVIOCGBIT(EV_SYN, 0));
+	TEST_NULL_ARG(EVIOCGBIT(0, 0));
 	TEST_NULL_ARG(EVIOCGBIT(EV_KEY, 1));
 	TEST_NULL_ARG(EVIOCGBIT(EV_REL, 2));
 	TEST_NULL_ARG(EVIOCGBIT(EV_ABS, 3));
Index: strace-4.24/xlat/evdev_sync.in
===================================================================
--- strace-4.24.orig/xlat/evdev_sync.in	2019-03-11 12:34:15.719549018 +0100
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,5 +0,0 @@
-#value_indexed
-SYN_REPORT	0
-SYN_CONFIG	1
-SYN_MT_REPORT	2
-SYN_DROPPED	3
Index: strace-4.24/xlat/evdev_ev.h
===================================================================
--- strace-4.24.orig/xlat/evdev_ev.h	2018-08-14 02:44:11.000000000 +0200
+++ strace-4.24/xlat/evdev_ev.h	2019-03-11 12:48:32.390670458 +0100
@@ -90,13 +90,8 @@
 
 #ifndef XLAT_MACROS_ONLY
 
-# ifdef IN_MPERS
+# ifndef IN_MPERS
 
-#  error static const struct xlat evdev_ev in mpers mode
-
-# else
-
-static
 const struct xlat evdev_ev[] = {
  XLAT(EV_SYN),
  XLAT(EV_KEY),