Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl> |
| 3 | * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl> |
| 4 | * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com> |
Wichert Akkerman | c6c1ea5 | 2001-08-03 21:52:13 +0000 | [diff] [blame] | 5 | * Copyright (c) 1996-2001 Wichert Akkerman <wichert@cistron.nl> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 6 | * All rights reserved. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * 3. The name of the author may not be used to endorse or promote products |
| 17 | * derived from this software without specific prior written permission. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 29 | */ |
| 30 | |
| 31 | #include "defs.h" |
Felix Janda | 3460dc4 | 2015-03-28 18:40:13 +0100 | [diff] [blame] | 32 | #include <linux/ioctl.h> |
Dmitry V. Levin | 924996a | 2015-01-20 00:24:36 +0000 | [diff] [blame] | 33 | #include "xlat/ioctl_dirs.h" |
Wichert Akkerman | a966785 | 2001-03-17 17:26:34 +0000 | [diff] [blame] | 34 | |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 35 | #ifdef HAVE_LINUX_INPUT_H |
| 36 | # include <linux/input.h> |
| 37 | #endif |
| 38 | |
| 39 | #include "xlat/evdev_abs.h" |
| 40 | #include "xlat/evdev_ev.h" |
| 41 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 42 | static int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 43 | compare(const void *a, const void *b) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 44 | { |
Dmitry V. Levin | c7afb48 | 2015-01-19 18:44:21 +0000 | [diff] [blame] | 45 | const unsigned int code1 = (const unsigned long) a; |
| 46 | const unsigned int code2 = ((struct_ioctlent *) b)->code; |
Denys Vlasenko | feb40c4 | 2012-03-20 13:11:51 +0100 | [diff] [blame] | 47 | return (code1 > code2) ? 1 : (code1 < code2) ? -1 : 0; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 48 | } |
| 49 | |
Dmitry V. Levin | 044eef2 | 2015-07-02 21:37:23 +0000 | [diff] [blame] | 50 | static const struct_ioctlent * |
Dmitry V. Levin | df7aa2b | 2015-01-19 17:02:16 +0000 | [diff] [blame] | 51 | ioctl_lookup(const unsigned int code) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 52 | { |
Denys Vlasenko | a9fe13c | 2013-02-22 13:26:10 +0100 | [diff] [blame] | 53 | struct_ioctlent *iop; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 54 | |
Dmitry V. Levin | c7afb48 | 2015-01-19 18:44:21 +0000 | [diff] [blame] | 55 | iop = bsearch((const void *) (const unsigned long) code, ioctlent, |
Denys Vlasenko | 1c2e912 | 2012-03-20 10:57:41 +0100 | [diff] [blame] | 56 | nioctlents, sizeof(ioctlent[0]), compare); |
| 57 | while (iop > ioctlent) { |
| 58 | iop--; |
| 59 | if (iop->code != code) { |
Roland McGrath | 2843a4e | 2003-11-14 02:54:03 +0000 | [diff] [blame] | 60 | iop++; |
| 61 | break; |
| 62 | } |
Denys Vlasenko | 1c2e912 | 2012-03-20 10:57:41 +0100 | [diff] [blame] | 63 | } |
Roland McGrath | 2843a4e | 2003-11-14 02:54:03 +0000 | [diff] [blame] | 64 | return iop; |
| 65 | } |
| 66 | |
Dmitry V. Levin | 044eef2 | 2015-07-02 21:37:23 +0000 | [diff] [blame] | 67 | static const struct_ioctlent * |
Denys Vlasenko | a9fe13c | 2013-02-22 13:26:10 +0100 | [diff] [blame] | 68 | ioctl_next_match(const struct_ioctlent *iop) |
Roland McGrath | 2843a4e | 2003-11-14 02:54:03 +0000 | [diff] [blame] | 69 | { |
Dmitry V. Levin | c7afb48 | 2015-01-19 18:44:21 +0000 | [diff] [blame] | 70 | const unsigned int code = iop->code; |
Denys Vlasenko | 1c2e912 | 2012-03-20 10:57:41 +0100 | [diff] [blame] | 71 | iop++; |
Roland McGrath | 2843a4e | 2003-11-14 02:54:03 +0000 | [diff] [blame] | 72 | if (iop < ioctlent + nioctlents && iop->code == code) |
| 73 | return iop; |
| 74 | return NULL; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 75 | } |
| 76 | |
Dmitry V. Levin | 044eef2 | 2015-07-02 21:37:23 +0000 | [diff] [blame] | 77 | static void |
Dmitry V. Levin | 924996a | 2015-01-20 00:24:36 +0000 | [diff] [blame] | 78 | ioctl_print_code(const unsigned int code) |
| 79 | { |
| 80 | tprints("_IOC("); |
| 81 | printflags(ioctl_dirs, _IOC_DIR(code), "_IOC_???"); |
| 82 | tprintf(", 0x%02x, 0x%02x, 0x%02x)", |
| 83 | _IOC_TYPE(code), _IOC_NR(code), _IOC_SIZE(code)); |
| 84 | } |
| 85 | |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 86 | static int |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 87 | evdev_decode_number(const unsigned int code) |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 88 | { |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 89 | const unsigned int nr = _IOC_NR(code); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 90 | |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 91 | if (_IOC_DIR(code) == _IOC_WRITE) { |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 92 | if (nr >= 0xc0 && nr <= 0xc0 + 0x3f) { |
| 93 | tprints("EVIOCSABS("); |
| 94 | printxval(evdev_abs, nr - 0xc0, "EV_???"); |
| 95 | tprints(")"); |
| 96 | return 1; |
| 97 | } |
| 98 | } |
| 99 | |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 100 | if (_IOC_DIR(code) != _IOC_READ) |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 101 | return 0; |
| 102 | |
| 103 | if (nr >= 0x20 && nr <= 0x20 + 0x1f) { |
| 104 | tprints("EVIOCGBIT("); |
| 105 | printxval(evdev_ev, nr - 0x20, "EV_???"); |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 106 | tprintf(", %u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 107 | return 1; |
| 108 | } else if (nr >= 0x40 && nr <= 0x40 + 0x3f) { |
| 109 | tprints("EVIOCGABS("); |
| 110 | printxval(evdev_abs, nr - 0x40, "ABS_???"); |
| 111 | tprints(")"); |
| 112 | return 1; |
| 113 | } |
| 114 | |
| 115 | switch (_IOC_NR(nr)) { |
| 116 | case 0x06: |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 117 | tprintf("EVIOCGNAME(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 118 | return 1; |
| 119 | case 0x07: |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 120 | tprintf("EVIOCGPHYS(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 121 | return 1; |
| 122 | case 0x08: |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 123 | tprintf("EVIOCGUNIQ(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 124 | return 1; |
| 125 | case 0x09: |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 126 | tprintf("EVIOCGPROP(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 127 | return 1; |
| 128 | case 0x0a: |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 129 | tprintf("EVIOCGMTSLOTS(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 130 | return 1; |
| 131 | case 0x18: |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 132 | tprintf("EVIOCGKEY(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 133 | return 1; |
| 134 | case 0x19: |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 135 | tprintf("EVIOCGLED(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 136 | return 1; |
| 137 | case 0x1a: |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 138 | tprintf("EVIOCGSND(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 139 | return 1; |
| 140 | case 0x1b: |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 141 | tprintf("EVIOCGSW(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 142 | return 1; |
| 143 | default: |
| 144 | return 0; |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | static int |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 149 | hiddev_decode_number(const unsigned int code) |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 150 | { |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 151 | if (_IOC_DIR(code) == _IOC_READ) { |
| 152 | switch (_IOC_NR(code)) { |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 153 | case 0x04: |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 154 | tprintf("HIDIOCGRAWNAME(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 155 | return 1; |
| 156 | case 0x05: |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 157 | tprintf("HIDIOCGRAWPHYS(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 158 | return 1; |
| 159 | case 0x06: |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 160 | tprintf("HIDIOCSFEATURE(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 161 | return 1; |
| 162 | case 0x12: |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 163 | tprintf("HIDIOCGPHYS(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 164 | return 1; |
| 165 | default: |
| 166 | return 0; |
| 167 | } |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 168 | } else if (_IOC_DIR(code) == (_IOC_READ | _IOC_WRITE)) { |
| 169 | switch (_IOC_NR(code)) { |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 170 | case 0x06: |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 171 | tprintf("HIDIOCSFEATURE(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 172 | return 1; |
| 173 | case 0x07: |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 174 | tprintf("HIDIOCGFEATURE(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 175 | return 1; |
| 176 | default: |
| 177 | return 0; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | return 0; |
| 182 | } |
| 183 | |
Dmitry V. Levin | 044eef2 | 2015-07-02 21:37:23 +0000 | [diff] [blame] | 184 | static int |
Dmitry V. Levin | 4f63c11 | 2015-07-02 22:31:11 +0000 | [diff] [blame] | 185 | ioctl_decode_command_number(struct tcb *tcp) |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 186 | { |
Dmitry V. Levin | 4f63c11 | 2015-07-02 22:31:11 +0000 | [diff] [blame] | 187 | const unsigned int code = tcp->u_arg[1]; |
| 188 | |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 189 | switch (_IOC_TYPE(code)) { |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 190 | case 'E': |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 191 | return evdev_decode_number(code); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 192 | case 'H': |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 193 | return hiddev_decode_number(code); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 194 | case 'M': |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 195 | if (_IOC_DIR(code) == _IOC_WRITE) { |
| 196 | tprintf("MIXER_WRITE(%u)", _IOC_NR(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 197 | return 1; |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 198 | } else if (_IOC_DIR(code) == _IOC_READ) { |
| 199 | tprintf("MIXER_READ(%u)", _IOC_NR(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 200 | return 1; |
| 201 | } |
| 202 | return 0; |
| 203 | case 'U': |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 204 | if (_IOC_DIR(code) == _IOC_READ && _IOC_NR(code) == 0x2c) { |
| 205 | tprintf("UI_GET_SYSNAME(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 206 | return 1; |
| 207 | } |
| 208 | return 0; |
| 209 | case 'j': |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 210 | if (_IOC_DIR(code) == _IOC_READ && _IOC_NR(code) == 0x13) { |
| 211 | tprintf("JSIOCGNAME(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 212 | return 1; |
| 213 | } |
| 214 | return 0; |
| 215 | case 'k': |
Dmitry V. Levin | 2803e75 | 2015-07-02 22:23:53 +0000 | [diff] [blame] | 216 | if (_IOC_DIR(code) == _IOC_WRITE && _IOC_NR(code) == 0) { |
| 217 | tprintf("SPI_IOC_MESSAGE(%u)", _IOC_SIZE(code)); |
Gabriel Laskar | 6f9a01c | 2015-01-21 23:35:27 +0100 | [diff] [blame] | 218 | return 1; |
| 219 | } |
| 220 | return 0; |
| 221 | default: |
| 222 | return 0; |
| 223 | } |
| 224 | } |
| 225 | |
Dmitry V. Levin | 044eef2 | 2015-07-02 21:37:23 +0000 | [diff] [blame] | 226 | static int |
Dmitry V. Levin | 802c942 | 2015-07-02 22:27:51 +0000 | [diff] [blame] | 227 | ioctl_decode(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 228 | { |
Dmitry V. Levin | 802c942 | 2015-07-02 22:27:51 +0000 | [diff] [blame] | 229 | const unsigned int code = tcp->u_arg[1]; |
| 230 | const long arg = tcp->u_arg[2]; |
| 231 | |
Dmitry V. Levin | c7afb48 | 2015-01-19 18:44:21 +0000 | [diff] [blame] | 232 | switch (_IOC_TYPE(code)) { |
Roland McGrath | bb3af52 | 2003-01-14 07:53:34 +0000 | [diff] [blame] | 233 | #if defined(ALPHA) || defined(POWERPC) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 234 | case 'f': case 't': case 'T': |
| 235 | #else /* !ALPHA */ |
| 236 | case 0x54: |
| 237 | #endif /* !ALPHA */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 238 | return term_ioctl(tcp, code, arg); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 239 | case 0x89: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 240 | return sock_ioctl(tcp, code, arg); |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 241 | case 'p': |
| 242 | return rtc_ioctl(tcp, code, arg); |
Dmitry V. Levin | 4ef6db4 | 2011-01-15 20:15:31 +0000 | [diff] [blame] | 243 | case 0x03: |
| 244 | case 0x12: |
Mike Frysinger | 5b88608 | 2014-11-21 16:13:16 -0500 | [diff] [blame] | 245 | case 'X': |
Dmitry V. Levin | 4ef6db4 | 2011-01-15 20:15:31 +0000 | [diff] [blame] | 246 | return block_ioctl(tcp, code, arg); |
Dmitry V. Levin | fdb896e | 2014-02-25 23:04:55 +0000 | [diff] [blame] | 247 | #ifdef HAVE_SCSI_SG_H |
Dmitry V. Levin | b011af5 | 2007-06-30 11:37:09 +0000 | [diff] [blame] | 248 | case 0x22: |
| 249 | return scsi_ioctl(tcp, code, arg); |
Dmitry V. Levin | fdb896e | 2014-02-25 23:04:55 +0000 | [diff] [blame] | 250 | #endif |
Mike Frysinger | ebee04c | 2012-04-17 22:19:31 -0400 | [diff] [blame] | 251 | case 'L': |
| 252 | return loop_ioctl(tcp, code, arg); |
Mike Frysinger | 0cbed35 | 2012-04-04 22:22:01 -0400 | [diff] [blame] | 253 | case 'M': |
| 254 | return mtd_ioctl(tcp, code, arg); |
Mike Frysinger | d648f29 | 2013-05-01 23:35:30 -0400 | [diff] [blame] | 255 | case 'o': |
| 256 | case 'O': |
| 257 | return ubi_ioctl(tcp, code, arg); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 258 | case 'V': |
| 259 | return v4l2_ioctl(tcp, code, arg); |
Stefan Sørensen | b88a6f8 | 2014-01-31 12:01:01 +0100 | [diff] [blame] | 260 | case '=': |
| 261 | return ptp_ioctl(tcp, code, arg); |
Etienne Gemsa | 4f750b9 | 2015-02-20 17:14:10 +0100 | [diff] [blame] | 262 | #ifdef HAVE_LINUX_INPUT_H |
| 263 | case 'E': |
| 264 | return evdev_ioctl(tcp, code, arg); |
| 265 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 266 | default: |
| 267 | break; |
| 268 | } |
| 269 | return 0; |
| 270 | } |
Dmitry V. Levin | 044eef2 | 2015-07-02 21:37:23 +0000 | [diff] [blame] | 271 | |
| 272 | SYS_FUNC(ioctl) |
| 273 | { |
| 274 | const struct_ioctlent *iop; |
Dmitry V. Levin | 204c2bc | 2015-07-08 14:10:56 +0000 | [diff] [blame] | 275 | int ret; |
Dmitry V. Levin | 044eef2 | 2015-07-02 21:37:23 +0000 | [diff] [blame] | 276 | |
| 277 | if (entering(tcp)) { |
| 278 | printfd(tcp, tcp->u_arg[0]); |
| 279 | tprints(", "); |
Gabriel Laskar | 9c4fc34 | 2015-09-23 10:11:55 +0200 | [diff] [blame] | 280 | ret = ioctl_decode_command_number(tcp); |
| 281 | iop = ioctl_lookup(tcp->u_arg[1]); |
| 282 | if (iop) { |
| 283 | if (ret) |
| 284 | tprints(" or "); |
| 285 | tprints(iop->symbol); |
| 286 | while ((iop = ioctl_next_match(iop))) |
| 287 | tprintf(" or %s", iop->symbol); |
| 288 | } else if (!ret) { |
| 289 | ioctl_print_code(tcp->u_arg[1]); |
Dmitry V. Levin | 044eef2 | 2015-07-02 21:37:23 +0000 | [diff] [blame] | 290 | } |
Dmitry V. Levin | 204c2bc | 2015-07-08 14:10:56 +0000 | [diff] [blame] | 291 | ret = ioctl_decode(tcp); |
| 292 | } else { |
| 293 | ret = ioctl_decode(tcp) | RVAL_DECODED; |
Dmitry V. Levin | 044eef2 | 2015-07-02 21:37:23 +0000 | [diff] [blame] | 294 | } |
Dmitry V. Levin | 204c2bc | 2015-07-08 14:10:56 +0000 | [diff] [blame] | 295 | |
| 296 | if (ret & RVAL_DECODED) { |
| 297 | ret &= ~RVAL_DECODED; |
| 298 | if (ret) |
| 299 | --ret; |
Dmitry V. Levin | 044eef2 | 2015-07-02 21:37:23 +0000 | [diff] [blame] | 300 | else |
Dmitry V. Levin | 204c2bc | 2015-07-08 14:10:56 +0000 | [diff] [blame] | 301 | tprintf(", %#lx", tcp->u_arg[2]); |
| 302 | ret |= RVAL_DECODED; |
| 303 | } else { |
| 304 | if (ret) |
| 305 | --ret; |
Dmitry V. Levin | 044eef2 | 2015-07-02 21:37:23 +0000 | [diff] [blame] | 306 | } |
Dmitry V. Levin | 204c2bc | 2015-07-08 14:10:56 +0000 | [diff] [blame] | 307 | |
| 308 | return ret; |
Dmitry V. Levin | 044eef2 | 2015-07-02 21:37:23 +0000 | [diff] [blame] | 309 | } |