2 * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
3 * Copyright (c) 2015-2017 The strace developers.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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.
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.
35 #include <sys/ioctl.h>
37 #ifdef HAVE_LINUX_MMTIMER_H
38 # include <linux/mmtimer.h>
40 #ifdef HAVE_LINUX_HIDDEV_H
41 # include <linux/hiddev.h>
43 #ifdef HAVE_LINUX_INPUT_H
44 # include <linux/input.h>
47 #include <linux/videodev2.h>
49 #if defined MMTIMER_GETRES \
50 && defined VIDIOC_ENUMINPUT \
51 && defined HIDIOCGVERSION \
52 && defined HIDIOCGPHYS \
53 && defined EVIOCGBIT \
63 (void) ioctl(-1, TCGETS, &tty);
64 printf("ioctl(-1, TCGETS, %p)"
65 " = -1 EBADF (%m)\n", &tty);
68 (void) ioctl(-1, MMTIMER_GETRES, &data);
69 printf("ioctl(-1, MMTIMER_GETRES, %p)"
70 " = -1 EBADF (%m)\n", &data);
72 (void) ioctl(-1, VIDIOC_ENUMINPUT, 0);
73 printf("ioctl(-1, VIDIOC_ENUMINPUT, NULL)"
74 " = -1 EBADF (%m)\n");
76 (void) ioctl(-1, HIDIOCGVERSION, &data);
77 printf("ioctl(-1, HIDIOCGRDESCSIZE or HIDIOCGVERSION, %p)"
78 " = -1 EBADF (%m)\n", &data);
80 (void) ioctl(-1, HIDIOCGPHYS(8), &data);
81 printf("ioctl(-1, HIDIOCGPHYS(8), %p)"
82 " = -1 EBADF (%m)\n", &data);
84 (void) ioctl(-1, EVIOCGBIT(EV_KEY, 8), &data);
85 printf("ioctl(-1, EVIOCGBIT(EV_KEY, 8), %p)"
86 " = -1 EBADF (%m)\n", &data);
88 (void) ioctl(-1, _IOR('M', 13, int), &data);
89 printf("ioctl(-1, MIXER_READ(13) or OTPSELECT, [MTD_OTP_OFF])"
90 " = -1 EBADF (%m)\n");
92 (void) ioctl(-1, _IOC(_IOC_WRITE, 0xde, 0, 0), (kernel_ulong_t) -1ULL);
93 printf("ioctl(-1, _IOC(_IOC_WRITE, 0xde, 0, 0), %#lx)"
94 " = -1 EBADF (%m)\n", -1UL);
96 (void) ioctl(-1, _IOR(0xde, 0xad, data), &data);
97 printf("ioctl(-1, _IOC(_IOC_READ, 0xde, 0xad, 0x8), %p)"
98 " = -1 EBADF (%m)\n", &data);
100 puts("+++ exited with 0 +++");
106 SKIP_MAIN_UNDEFINED("MMTIMER_GETRES && VIDIOC_ENUMINPUT"
107 " && HIDIOCGVERSION && HIDIOCGPHYS"
108 " && EVIOCGBIT && EV_KEY")