blob: 7882140f8443cb6c8c350e427c11adaffd56bb7b [file] [log] [blame]
Dmitry V. Levindf7aa2b2015-01-19 17:02:16 +00001#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
Dmitry V. Levinfb2a5432015-09-22 21:22:37 +00004
Dmitry V. Levindf7aa2b2015-01-19 17:02:16 +00005#include <fcntl.h>
Dmitry V. Levinfb2a5432015-09-22 21:22:37 +00006#include <stdio.h>
Dmitry V. Levindf7aa2b2015-01-19 17:02:16 +00007#include <stdint.h>
8#include <unistd.h>
9#include <termios.h>
10#include <sys/ioctl.h>
11
12#ifdef HAVE_LINUX_MMTIMER_H
13# include <linux/mmtimer.h>
14#endif
15#ifdef HAVE_LINUX_HIDDEV_H
16# include <linux/hiddev.h>
17#endif
18#ifdef HAVE_LINUX_INPUT_H
19# include <linux/input.h>
20#endif
21
Dmitry V. Levin8c20d892015-05-21 16:19:40 +000022#include <linux/videodev2.h>
23
Dmitry V. Levindf7aa2b2015-01-19 17:02:16 +000024#if defined MMTIMER_GETRES \
Dmitry V. Levin8c20d892015-05-21 16:19:40 +000025 && defined VIDIOC_ENUMINPUT \
Dmitry V. Levindf7aa2b2015-01-19 17:02:16 +000026 && defined HIDIOCGVERSION \
27 && defined HIDIOCGPHYS \
28 && defined EVIOCGBIT \
29 && defined EV_KEY
30
31int
32main(void )
33{
34 struct termios tty;
Dmitry V. Levinfb2a5432015-09-22 21:22:37 +000035 uint64_t data = 0;
Dmitry V. Levindf7aa2b2015-01-19 17:02:16 +000036
Dmitry V. Levinfb2a5432015-09-22 21:22:37 +000037 (void) ioctl(-1, TCGETS, &tty);
38 printf("ioctl(-1, TCGETS, %p)"
39 " = -1 EBADF (Bad file descriptor)\n", &tty);
Dmitry V. Levindf7aa2b2015-01-19 17:02:16 +000040
Dmitry V. Levinfb2a5432015-09-22 21:22:37 +000041 (void) ioctl(-1, MMTIMER_GETRES, &data);
42 printf("ioctl(-1, MMTIMER_GETRES, %p)"
43 " = -1 EBADF (Bad file descriptor)\n", &data);
44
45 (void) ioctl(-1, VIDIOC_ENUMINPUT, 0);
46 printf("ioctl(-1, VIDIOC_ENUMINPUT, 0)"
47 " = -1 EBADF (Bad file descriptor)\n");
48
49 (void) ioctl(-1, HIDIOCGVERSION, &data);
50 printf("ioctl(-1, HIDIOCGRDESCSIZE or HIDIOCGVERSION, %p)"
51 " = -1 EBADF (Bad file descriptor)\n", &data);
52
53 (void) ioctl(-1, HIDIOCGPHYS(8), &data);
54 printf("ioctl(-1, HIDIOCGPHYS(8), %p)"
55 " = -1 EBADF (Bad file descriptor)\n", &data);
56
57 (void) ioctl(-1, EVIOCGBIT(EV_KEY, 8), &data);
58 printf("ioctl(-1, EVIOCGBIT(EV_KEY, 8), %p)"
59 " = -1 EBADF (Bad file descriptor)\n", &data);
60
Gabriel Laskar9c4fc342015-09-23 10:11:55 +020061 (void) ioctl(-1, _IOR('M', 13, int), &data);
62 printf("ioctl(-1, MIXER_READ(13) or OTPSELECT, [MTD_OTP_OFF])"
63 " = -1 EBADF (Bad file descriptor)\n");
64
Dmitry V. Levinfb2a5432015-09-22 21:22:37 +000065 (void) ioctl(-1, _IOR(0xde, 0xad, data), &data);
66 printf("ioctl(-1, _IOC(_IOC_READ, 0xde, 0xad, 0x08), %p)"
67 " = -1 EBADF (Bad file descriptor)\n", &data);
68
69 puts("+++ exited with 0 +++");
Dmitry V. Levindf7aa2b2015-01-19 17:02:16 +000070 return 0;
71}
72
73#else
74
75int
76main(void )
77{
78 return 77;
79}
80
81#endif