blob: 2a610dc7d8760bd90b0b96f2ba890b6242de55dd [file] [log] [blame]
Etienne Gemsa4f750b92015-02-20 17:14:10 +01001/*
2 * Copyright (c) 2015 Etienne Gemsa <etienne.gemsa@lse.epita.fr>
3 * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include "defs.h"
30
31#ifdef HAVE_LINUX_INPUT_H
Etienne Gemsa4f750b92015-02-20 17:14:10 +010032
Dmitry V. Levin8d85c232016-05-27 00:39:33 +000033# include <linux/ioctl.h>
34# include <linux/input.h>
35# include "xlat/evdev_abs.h"
36# include "xlat/evdev_autorepeat.h"
37# include "xlat/evdev_ff_status.h"
38# include "xlat/evdev_ff_types.h"
39# include "xlat/evdev_keycode.h"
40# include "xlat/evdev_leds.h"
41# include "xlat/evdev_misc.h"
42# include "xlat/evdev_mtslots.h"
43# include "xlat/evdev_prop.h"
44# include "xlat/evdev_relative_axes.h"
45# include "xlat/evdev_snd.h"
46# include "xlat/evdev_switch.h"
47# include "xlat/evdev_sync.h"
48
49# ifndef SYN_MAX
50# define SYN_MAX 0xf
51# endif
Dmitry V. Levin19dadf92015-02-22 02:50:33 +030052
Etienne Gemsa4f750b92015-02-20 17:14:10 +010053static void
Dmitry V. Levinc758ed02016-05-27 00:40:53 +000054decode_envelope(const struct ff_envelope *envelope)
Etienne Gemsa4f750b92015-02-20 17:14:10 +010055{
Dmitry V. Levinc758ed02016-05-27 00:40:53 +000056 tprintf(", envelope={attack_length=%" PRIu16
57 ", attack_level=%" PRIu16
58 ", fade_length=%" PRIu16
59 ", fade_level=%#x}",
Etienne Gemsa4f750b92015-02-20 17:14:10 +010060 envelope->attack_length,
61 envelope->attack_level,
62 envelope->fade_length,
63 envelope->fade_level);
64}
65
66static int
67ff_effect_ioctl(struct tcb *tcp, long arg)
68{
Dmitry V. Levin3a45eb32016-05-27 00:41:02 +000069 tprints(", ");
70
Etienne Gemsa4f750b92015-02-20 17:14:10 +010071 struct ff_effect ffe;
72
Dmitry V. Levin3a45eb32016-05-27 00:41:02 +000073 if (umove_or_printaddr(tcp, arg, &ffe))
74 return 1;
Etienne Gemsa4f750b92015-02-20 17:14:10 +010075
Dmitry V. Levin3a45eb32016-05-27 00:41:02 +000076 tprints("{type=");
Etienne Gemsa4f750b92015-02-20 17:14:10 +010077 printxval(evdev_ff_types, ffe.type, "FF_???");
Dmitry V. Levin3a45eb32016-05-27 00:41:02 +000078 tprintf(", id=%" PRIu16
79 ", direction=%" PRIu16 ", ",
80 ffe.id,
81 ffe.direction);
Etienne Gemsa4f750b92015-02-20 17:14:10 +010082
Dmitry V. Levin3a45eb32016-05-27 00:41:02 +000083 if (abbrev(tcp)) {
84 tprints("...}");
85 return 1;
Etienne Gemsa4f750b92015-02-20 17:14:10 +010086 }
87
Dmitry V. Levin3a45eb32016-05-27 00:41:02 +000088 tprintf("trigger={button=%" PRIu16
89 ", interval=%" PRIu16 "}"
90 ", replay={length=%" PRIu16
91 ", delay=%" PRIu16 "}",
92 ffe.trigger.button,
93 ffe.trigger.interval,
94 ffe.replay.length,
95 ffe.replay.delay);
96
97 switch (ffe.type) {
98 case FF_CONSTANT:
99 tprintf(", constant={level=%" PRId16,
100 ffe.u.constant.level);
101 decode_envelope(&ffe.u.constant.envelope);
102 tprints("}");
103 break;
104 case FF_RAMP:
105 tprintf(", ramp={start_level=%" PRId16
106 ", end_level=%" PRId16,
107 ffe.u.ramp.start_level,
108 ffe.u.ramp.end_level);
109 decode_envelope(&ffe.u.ramp.envelope);
110 tprints("}");
111 break;
112 case FF_PERIODIC:
113 tprintf(", periodic={waveform=%" PRIu16
114 ", period=%" PRIu16
115 ", magnitude=%" PRId16
116 ", offset=%" PRId16
117 ", phase=%" PRIu16,
118 ffe.u.periodic.waveform,
119 ffe.u.periodic.period,
120 ffe.u.periodic.magnitude,
121 ffe.u.periodic.offset,
122 ffe.u.periodic.phase);
123 decode_envelope(&ffe.u.periodic.envelope);
124 tprintf(", custom_len=%u"
125 ", custom_data=%#lx}",
126 ffe.u.periodic.custom_len,
127 (unsigned long) ffe.u.periodic.custom_data);
128 break;
129 case FF_RUMBLE:
130 tprintf(", rumble={strong_magnitude=%" PRIu16
131 ", weak_magnitude=%" PRIu16 "}",
132 ffe.u.rumble.strong_magnitude,
133 ffe.u.rumble.weak_magnitude);
134 break;
135 default:
136 break;
137 }
138
139 tprints("}");
140
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100141 return 1;
142}
143
144static int
145abs_ioctl(struct tcb *tcp, long arg)
146{
Dmitry V. Levine1670062016-05-27 00:41:14 +0000147 tprints(", ");
148
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100149 struct input_absinfo absinfo;
150
Dmitry V. Levine1670062016-05-27 00:41:14 +0000151 if (!umove_or_printaddr(tcp, arg, &absinfo)) {
152 tprintf("{value=%u"
153 ", minimum=%u, ",
154 absinfo.value,
155 absinfo.minimum);
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100156
Dmitry V. Levine1670062016-05-27 00:41:14 +0000157 if (!abbrev(tcp)) {
158 tprintf("maximum=%u"
159 ", fuzz=%u"
160 ", flat=%u",
161 absinfo.maximum,
162 absinfo.fuzz,
163 absinfo.flat);
Dmitry V. Levin8d85c232016-05-27 00:39:33 +0000164# ifdef HAVE_STRUCT_INPUT_ABSINFO_RESOLUTION
Dmitry V. Levine1670062016-05-27 00:41:14 +0000165 tprintf(", resolution=%u",
166 absinfo.resolution);
Dmitry V. Levin8d85c232016-05-27 00:39:33 +0000167# endif
Dmitry V. Levine1670062016-05-27 00:41:14 +0000168 } else {
169 tprints("...");
170 }
171
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100172 tprints("}");
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100173 }
Dmitry V. Levine1670062016-05-27 00:41:14 +0000174
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100175 return 1;
176}
177
178static int
179keycode_ioctl(struct tcb *tcp, long arg)
180{
Dmitry V. Levin7954e2a2016-05-27 00:41:25 +0000181 tprints(", ");
182
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100183 unsigned int keycode[2];
184
Dmitry V. Levin7954e2a2016-05-27 00:41:25 +0000185 if (!umove_or_printaddr(tcp, arg, &keycode)) {
186 tprintf("[%u, ", keycode[0]);
187 printxval(evdev_keycode, keycode[1], "KEY_???");
188 tprints("]");
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100189 }
190
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100191 return 1;
192}
193
Dmitry V. Levin8d85c232016-05-27 00:39:33 +0000194# ifdef EVIOCGKEYCODE_V2
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100195static int
196keycode_V2_ioctl(struct tcb *tcp, long arg)
197{
Dmitry V. Levin13f8e8f2016-05-27 00:41:34 +0000198 tprints(", ");
199
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100200 struct input_keymap_entry ike;
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100201
Dmitry V. Levin13f8e8f2016-05-27 00:41:34 +0000202 if (umove_or_printaddr(tcp, arg, &ike))
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100203 return 1;
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100204
Dmitry V. Levin13f8e8f2016-05-27 00:41:34 +0000205 tprintf("{flags=%" PRIu8
206 ", len=%" PRIu8 ", ",
207 ike.flags,
208 ike.len);
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100209
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100210 if (!abbrev(tcp)) {
Dmitry V. Levin7d8b41a2015-02-21 23:05:26 +0000211 unsigned int i;
212
Dmitry V. Levin13f8e8f2016-05-27 00:41:34 +0000213 tprintf("index=%" PRIu16 ", keycode=", ike.index);
Dmitry V. Levin7d8b41a2015-02-21 23:05:26 +0000214 printxval(evdev_keycode, ike.keycode, "KEY_???");
215 tprints(", scancode=[");
216 for (i = 0; i < ARRAY_SIZE(ike.scancode); i++) {
217 if (i > 0)
218 tprints(", ");
219 tprintf("%" PRIx8, ike.scancode[i]);
220 }
Dmitry V. Levin13f8e8f2016-05-27 00:41:34 +0000221 tprints("]");
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100222 } else {
Dmitry V. Levin13f8e8f2016-05-27 00:41:34 +0000223 tprints("...");
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100224 }
Dmitry V. Levin13f8e8f2016-05-27 00:41:34 +0000225
226 tprints("}");
227
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100228 return 1;
229}
Dmitry V. Levin8d85c232016-05-27 00:39:33 +0000230# endif /* EVIOCGKEYCODE_V2 */
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100231
232static int
233getid_ioctl(struct tcb *tcp, long arg)
234{
Dmitry V. Levine54f98a2016-05-27 00:41:43 +0000235 tprints(", ");
236
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100237 struct input_id id;
238
Dmitry V. Levine54f98a2016-05-27 00:41:43 +0000239 if (!umove_or_printaddr(tcp, arg, &id))
240 tprintf("{ID_BUS=%" PRIu16
241 ", ID_VENDOR=%" PRIu16
242 ", ID_PRODUCT=%" PRIu16
243 ", ID_VERSION=%" PRIu16 "}",
244 id.bustype,
245 id.vendor,
246 id.product,
247 id.version);
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100248
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100249 return 1;
250}
251
252static int
253decode_bitset(struct tcb *tcp, long arg, const struct xlat decode_nr[],
254 const unsigned int max_nr, const char *dflt)
255{
Dmitry V. Levin14a810e2016-05-27 00:41:51 +0000256 tprints(", ");
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100257
258 unsigned int size;
259 if ((unsigned long) tcp->u_rval > max_nr)
260 size = max_nr;
261 else
262 size = tcp->u_rval;
263 char decoded_arg[size];
264
Dmitry V. Levin14a810e2016-05-27 00:41:51 +0000265 if (umove_or_printaddr(tcp, arg, &decoded_arg))
266 return 1;
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100267
Dmitry V. Levin14a810e2016-05-27 00:41:51 +0000268 tprints("[");
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100269
270 int bit_displayed = 0;
271 int i = next_set_bit(decoded_arg, 0, size);
272 if (i < 0) {
273 tprints(" 0 ");
274 } else {
275 printxval(decode_nr, i, dflt);
276
277 while ((i = next_set_bit(decoded_arg, i + 1, size)) > 0) {
278 if (abbrev(tcp) && bit_displayed >= 3) {
279 tprints(", ...");
280 break;
281 }
282 tprints(", ");
283 printxval(decode_nr, i, dflt);
284 bit_displayed++;
285 }
286 }
287
288 tprints("]");
289
290 return 1;
291}
292
Dmitry V. Levin8d85c232016-05-27 00:39:33 +0000293# ifdef EVIOCGMTSLOTS
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100294static int
295mtslots_ioctl(struct tcb *tcp, const unsigned int code, long arg)
296{
297 const size_t size = _IOC_SIZE(code) / sizeof(int32_t);
298 if (!size)
299 return 0;
300
301 int32_t buffer[size];
302
303 if (!verbose(tcp) || umove(tcp, arg, &buffer) < 0)
304 return 0;
305
306 tprints(", {code=");
307 printxval(evdev_mtslots, buffer[0], "ABS_MT_???");
308
309 unsigned int i;
310 tprints(", values=[");
311
312 for (i = 1; i < ARRAY_SIZE(buffer); i++)
313 tprintf("%s%d", i > 1 ? ", " : "", buffer[i]);
314
315 tprints("]}");
316 return 1;
317}
Dmitry V. Levin8d85c232016-05-27 00:39:33 +0000318# endif /* EVIOCGMTSLOTS */
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100319
Dmitry V. Levin8d85c232016-05-27 00:39:33 +0000320# if defined EVIOCGREP || defined EVIOCSREP
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100321static int
322repeat_ioctl(struct tcb *tcp, long arg)
323{
Dmitry V. Levinb6795082015-07-06 22:33:39 +0000324 tprints(", ");
325 printpair_int(tcp, arg, "%u");
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100326 return 1;
327}
Dmitry V. Levin8d85c232016-05-27 00:39:33 +0000328# endif /* EVIOCGREP || EVIOCSREP */
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100329
330static int
Dmitry V. Levin53767d82016-05-27 00:40:18 +0000331bit_ioctl(struct tcb *tcp, const unsigned int ev_nr, const long arg)
332{
333 switch (ev_nr) {
334 case EV_SYN:
335 return decode_bitset(tcp, arg, evdev_sync,
336 SYN_MAX, "SYN_???");
337 case EV_KEY:
338 return decode_bitset(tcp, arg, evdev_keycode,
339 KEY_MAX, "KEY_???");
340 case EV_REL:
341 return decode_bitset(tcp, arg, evdev_relative_axes,
342 REL_MAX, "REL_???");
343 case EV_ABS:
344 return decode_bitset(tcp, arg,
345 evdev_abs, ABS_MAX, "ABS_???");
346 case EV_MSC:
347 return decode_bitset(tcp, arg,
348 evdev_misc, MSC_MAX, "MSC_???");
349# ifdef EV_SW
350 case EV_SW:
351 return decode_bitset(tcp, arg,
352 evdev_switch, SW_MAX, "SW_???");
353# endif
354 case EV_LED:
355 return decode_bitset(tcp, arg,
356 evdev_leds, LED_MAX, "LED_???");
357 case EV_SND:
358 return decode_bitset(tcp, arg,
359 evdev_snd, SND_MAX, "SND_???");
360 case EV_REP:
361 return decode_bitset(tcp, arg, evdev_autorepeat,
362 REP_MAX, "REP_???");
363 case EV_FF:
364 return decode_bitset(tcp, arg, evdev_ff_types,
365 FF_MAX, "FF_???");
366 case EV_PWR:
367 printnum_int(tcp, arg, "%d");
368 return 1;
369 case EV_FF_STATUS:
370 return decode_bitset(tcp, arg, evdev_ff_status,
371 FF_STATUS_MAX, "FF_STATUS_???");
372 default:
373 return 0;
374 }
375}
376
377static int
Dmitry V. Levin8a18f802016-05-27 00:40:10 +0000378evdev_read_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100379{
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100380 if (syserror(tcp))
381 return 0;
382
Dmitry V. Levin8a18f802016-05-27 00:40:10 +0000383 /* fixed-number fixed-length commands */
384 switch (code) {
385 case EVIOCGVERSION:
386 tprints(", ");
387 printnum_int(tcp, arg, "%" PRIx32);
388 return 1;
389 case EVIOCGEFFECTS:
390 tprints(", ");
391 printnum_int(tcp, arg, "%" PRIu32);
392 return 1;
393 case EVIOCGID:
394 return getid_ioctl(tcp, arg);
395# ifdef EVIOCGREP
396 case EVIOCGREP:
397 return repeat_ioctl(tcp, arg);;
398# endif
399 case EVIOCGKEYCODE:
400 return keycode_ioctl(tcp, arg);
401# ifdef EVIOCGKEYCODE_V2
402 case EVIOCGKEYCODE_V2:
403 return keycode_V2_ioctl(tcp, arg);
404# endif
405 }
406
407 /* fixed-number variable-length commands */
408 switch (_IOC_NR(code)) {
409# ifdef EVIOCGMTSLOTS
410 case _IOC_NR(EVIOCGMTSLOTS(0)):
411 return mtslots_ioctl(tcp, code, arg);
412# endif
413 case _IOC_NR(EVIOCGNAME(0)):
414 case _IOC_NR(EVIOCGPHYS(0)):
415 case _IOC_NR(EVIOCGUNIQ(0)):
416 tprints(", ");
417 printstr(tcp, arg, tcp->u_rval - 1);
418 return 1;
419# ifdef EVIOCGPROP
420 case _IOC_NR(EVIOCGPROP(0)):
421 return decode_bitset(tcp, arg,
422 evdev_prop, INPUT_PROP_MAX, "PROP_???");
423# endif
424 case _IOC_NR(EVIOCGSND(0)):
425 return decode_bitset(tcp, arg,
426 evdev_snd, SND_MAX, "SND_???");
427# ifdef EVIOCGSW
428 case _IOC_NR(EVIOCGSW(0)):
429 return decode_bitset(tcp, arg,
430 evdev_switch, SW_MAX, "SW_???");
431# endif
432 case _IOC_NR(EVIOCGKEY(0)):
433 return decode_bitset(tcp, arg,
434 evdev_keycode, KEY_MAX, "KEY_???");
435 case _IOC_NR(EVIOCGLED(0)):
436 return decode_bitset(tcp, arg,
437 evdev_leds, LED_MAX, "LED_???");
438 }
439
440 /* multi-number fixed-length commands */
441 if ((_IOC_NR(code) & ~ABS_MAX) == _IOC_NR(EVIOCGABS(0)))
442 return abs_ioctl(tcp, arg);
443
444 /* multi-number variable-length commands */
Dmitry V. Levin53767d82016-05-27 00:40:18 +0000445 if ((_IOC_NR(code) & ~EV_MAX) == _IOC_NR(EVIOCGBIT(0, 0)))
446 return bit_ioctl(tcp, _IOC_NR(code) & EV_MAX, arg);
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100447
Dmitry V. Levin8a18f802016-05-27 00:40:10 +0000448 return 0;
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100449}
450
451static int
Dmitry V. Levin8a18f802016-05-27 00:40:10 +0000452evdev_write_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100453{
Dmitry V. Levin8a18f802016-05-27 00:40:10 +0000454 /* fixed-number fixed-length commands */
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100455 switch (code) {
Dmitry V. Levin8d85c232016-05-27 00:39:33 +0000456# ifdef EVIOCSREP
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100457 case EVIOCSREP:
458 return repeat_ioctl(tcp, arg);
Dmitry V. Levin8d85c232016-05-27 00:39:33 +0000459# endif
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100460 case EVIOCSKEYCODE:
461 return keycode_ioctl(tcp, arg);
Dmitry V. Levin8d85c232016-05-27 00:39:33 +0000462# ifdef EVIOCSKEYCODE_V2
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100463 case EVIOCSKEYCODE_V2:
464 return keycode_V2_ioctl(tcp, arg);
Dmitry V. Levin8d85c232016-05-27 00:39:33 +0000465# endif
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100466 case EVIOCSFF:
467 return ff_effect_ioctl(tcp, arg);
468 case EVIOCRMFF:
Dmitry V. Levin00394242016-05-27 00:40:27 +0000469 tprintf(", %d", (int) arg);
470 return 1;
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100471 case EVIOCGRAB:
Dmitry V. Levin8d85c232016-05-27 00:39:33 +0000472# ifdef EVIOCREVOKE
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100473 case EVIOCREVOKE:
Dmitry V. Levin8d85c232016-05-27 00:39:33 +0000474# endif
Dmitry V. Levin9635df42016-05-27 00:40:45 +0000475 tprintf(", %lu", arg);
476 return 1;
477# ifdef EVIOCSCLOCKID
478 case EVIOCSCLOCKID:
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100479 tprints(", ");
480 printnum_int(tcp, arg, "%u");
481 return 1;
Dmitry V. Levin9635df42016-05-27 00:40:45 +0000482# endif
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100483 }
Dmitry V. Levin8a18f802016-05-27 00:40:10 +0000484
485 /* multi-number fixed-length commands */
486 if ((_IOC_NR(code) & ~ABS_MAX) == _IOC_NR(EVIOCSABS(0)))
487 return abs_ioctl(tcp, arg);
488
489 return 0;
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100490}
491
492int
493evdev_ioctl(struct tcb *tcp, const unsigned int code, long arg)
494{
495 switch(_IOC_DIR(code)) {
496 case _IOC_READ:
Dmitry V. Levin2114e082016-05-27 00:40:02 +0000497 if (entering(tcp))
498 return 0;
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100499 return evdev_read_ioctl(tcp, code, arg);
500 case _IOC_WRITE:
Dmitry V. Levin2114e082016-05-27 00:40:02 +0000501 return evdev_write_ioctl(tcp, code, arg) | RVAL_DECODED;
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100502 default:
Dmitry V. Levin2114e082016-05-27 00:40:02 +0000503 return RVAL_DECODED;
Etienne Gemsa4f750b92015-02-20 17:14:10 +0100504 }
505}
506
507#endif /* HAVE_LINUX_INPUT_H */