Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * ioctl32.c: Conversion between 32bit and 64bit native ioctls. |
| 3 | * |
| 4 | * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com) |
| 5 | * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be) |
| 6 | * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs |
| 7 | * Copyright (C) 2003 Pavel Machek (pavel@suse.cz) |
| 8 | * |
| 9 | * These routines maintain argument size conversion between 32bit and 64bit |
| 10 | * ioctls. |
| 11 | */ |
| 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/types.h> |
| 14 | #include <linux/compat.h> |
| 15 | #include <linux/kernel.h> |
Randy Dunlap | 16f7e0f | 2006-01-11 12:17:46 -0800 | [diff] [blame] | 16 | #include <linux/capability.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/compiler.h> |
| 18 | #include <linux/sched.h> |
| 19 | #include <linux/smp.h> |
| 20 | #include <linux/smp_lock.h> |
| 21 | #include <linux/ioctl.h> |
| 22 | #include <linux/if.h> |
| 23 | #include <linux/if_bridge.h> |
| 24 | #include <linux/slab.h> |
| 25 | #include <linux/hdreg.h> |
| 26 | #include <linux/raid/md.h> |
| 27 | #include <linux/kd.h> |
| 28 | #include <linux/dirent.h> |
| 29 | #include <linux/route.h> |
| 30 | #include <linux/in6.h> |
| 31 | #include <linux/ipv6_route.h> |
| 32 | #include <linux/skbuff.h> |
| 33 | #include <linux/netlink.h> |
| 34 | #include <linux/vt.h> |
| 35 | #include <linux/fs.h> |
| 36 | #include <linux/file.h> |
| 37 | #include <linux/fd.h> |
| 38 | #include <linux/ppp_defs.h> |
| 39 | #include <linux/if_ppp.h> |
| 40 | #include <linux/if_pppox.h> |
| 41 | #include <linux/mtio.h> |
| 42 | #include <linux/cdrom.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #include <linux/auto_fs.h> |
| 44 | #include <linux/auto_fs4.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include <linux/tty.h> |
| 46 | #include <linux/vt_kern.h> |
| 47 | #include <linux/fb.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #include <linux/videodev.h> |
| 49 | #include <linux/netdevice.h> |
| 50 | #include <linux/raw.h> |
| 51 | #include <linux/smb_fs.h> |
| 52 | #include <linux/blkpg.h> |
| 53 | #include <linux/blkdev.h> |
| 54 | #include <linux/elevator.h> |
| 55 | #include <linux/rtc.h> |
| 56 | #include <linux/pci.h> |
| 57 | #include <linux/module.h> |
| 58 | #include <linux/serial.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | #include <linux/if_tun.h> |
| 60 | #include <linux/ctype.h> |
| 61 | #include <linux/ioctl32.h> |
| 62 | #include <linux/syscalls.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | #include <linux/i2c.h> |
| 64 | #include <linux/i2c-dev.h> |
| 65 | #include <linux/wireless.h> |
| 66 | #include <linux/atalk.h> |
Jens Axboe | 2056a78 | 2006-03-23 20:00:26 +0100 | [diff] [blame] | 67 | #include <linux/blktrace_api.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
| 69 | #include <net/sock.h> /* siocdevprivate_ioctl */ |
| 70 | #include <net/bluetooth/bluetooth.h> |
| 71 | #include <net/bluetooth/hci.h> |
| 72 | #include <net/bluetooth/rfcomm.h> |
| 73 | |
| 74 | #include <linux/capi.h> |
Hansjoerg Lipp | 5024ad4 | 2006-06-26 00:25:35 -0700 | [diff] [blame] | 75 | #include <linux/gigaset_dev.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
| 77 | #include <scsi/scsi.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | #include <scsi/scsi_ioctl.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | #include <scsi/sg.h> |
| 80 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | #include <asm/uaccess.h> |
| 82 | #include <linux/ethtool.h> |
| 83 | #include <linux/mii.h> |
| 84 | #include <linux/if_bonding.h> |
| 85 | #include <linux/watchdog.h> |
| 86 | #include <linux/dm-ioctl.h> |
| 87 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | #include <linux/soundcard.h> |
| 89 | #include <linux/lp.h> |
| 90 | #include <linux/ppdev.h> |
| 91 | |
| 92 | #include <linux/atm.h> |
| 93 | #include <linux/atmarp.h> |
| 94 | #include <linux/atmclip.h> |
| 95 | #include <linux/atmdev.h> |
| 96 | #include <linux/atmioc.h> |
| 97 | #include <linux/atmlec.h> |
| 98 | #include <linux/atmmpc.h> |
| 99 | #include <linux/atmsvc.h> |
| 100 | #include <linux/atm_tcp.h> |
| 101 | #include <linux/sonet.h> |
| 102 | #include <linux/atm_suni.h> |
| 103 | #include <linux/mtd/mtd.h> |
| 104 | |
| 105 | #include <linux/usb.h> |
| 106 | #include <linux/usbdevice_fs.h> |
| 107 | #include <linux/nbd.h> |
| 108 | #include <linux/random.h> |
| 109 | #include <linux/filter.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | #include <linux/pktcdvd.h> |
| 111 | |
| 112 | #include <linux/hiddev.h> |
| 113 | |
David S. Miller | 6e87abd | 2005-11-16 00:52:57 -0800 | [diff] [blame] | 114 | #include <linux/dvb/audio.h> |
| 115 | #include <linux/dvb/dmx.h> |
| 116 | #include <linux/dvb/frontend.h> |
| 117 | #include <linux/dvb/video.h> |
Andi Kleen | c6b44d1 | 2006-01-12 01:05:26 -0800 | [diff] [blame] | 118 | #include <linux/lp.h> |
David S. Miller | 6e87abd | 2005-11-16 00:52:57 -0800 | [diff] [blame] | 119 | |
Christoph Hellwig | e6a6d2e | 2006-01-09 20:52:14 -0800 | [diff] [blame] | 120 | static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd, |
| 121 | unsigned long arg, struct file *f) |
| 122 | { |
| 123 | return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg)); |
| 124 | } |
| 125 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 127 | { |
| 128 | mm_segment_t old_fs = get_fs(); |
| 129 | int err; |
| 130 | unsigned long val; |
| 131 | |
| 132 | set_fs (KERNEL_DS); |
| 133 | err = sys_ioctl(fd, cmd, (unsigned long)&val); |
| 134 | set_fs (old_fs); |
| 135 | if (!err && put_user(val, (u32 __user *)compat_ptr(arg))) |
| 136 | return -EFAULT; |
| 137 | return err; |
| 138 | } |
| 139 | |
| 140 | static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 141 | { |
| 142 | mm_segment_t old_fs = get_fs(); |
| 143 | u32 __user *argptr = compat_ptr(arg); |
| 144 | int err; |
| 145 | unsigned long val; |
| 146 | |
| 147 | if(get_user(val, argptr)) |
| 148 | return -EFAULT; |
| 149 | set_fs (KERNEL_DS); |
| 150 | err = sys_ioctl(fd, cmd, (unsigned long)&val); |
| 151 | set_fs (old_fs); |
| 152 | if (!err && put_user(val, argptr)) |
| 153 | return -EFAULT; |
| 154 | return err; |
| 155 | } |
| 156 | |
David S. Miller | 6e87abd | 2005-11-16 00:52:57 -0800 | [diff] [blame] | 157 | struct compat_video_event { |
| 158 | int32_t type; |
| 159 | compat_time_t timestamp; |
| 160 | union { |
| 161 | video_size_t size; |
| 162 | unsigned int frame_rate; |
| 163 | } u; |
| 164 | }; |
| 165 | |
| 166 | static int do_video_get_event(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 167 | { |
| 168 | struct video_event kevent; |
| 169 | mm_segment_t old_fs = get_fs(); |
| 170 | int err; |
| 171 | |
| 172 | set_fs(KERNEL_DS); |
| 173 | err = sys_ioctl(fd, cmd, (unsigned long) &kevent); |
| 174 | set_fs(old_fs); |
| 175 | |
| 176 | if (!err) { |
| 177 | struct compat_video_event __user *up = compat_ptr(arg); |
| 178 | |
| 179 | err = put_user(kevent.type, &up->type); |
| 180 | err |= put_user(kevent.timestamp, &up->timestamp); |
| 181 | err |= put_user(kevent.u.size.w, &up->u.size.w); |
| 182 | err |= put_user(kevent.u.size.h, &up->u.size.h); |
| 183 | err |= put_user(kevent.u.size.aspect_ratio, |
| 184 | &up->u.size.aspect_ratio); |
| 185 | if (err) |
| 186 | err = -EFAULT; |
| 187 | } |
| 188 | |
| 189 | return err; |
| 190 | } |
| 191 | |
| 192 | struct compat_video_still_picture { |
| 193 | compat_uptr_t iFrame; |
| 194 | int32_t size; |
| 195 | }; |
| 196 | |
| 197 | static int do_video_stillpicture(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 198 | { |
| 199 | struct compat_video_still_picture __user *up; |
| 200 | struct video_still_picture __user *up_native; |
| 201 | compat_uptr_t fp; |
| 202 | int32_t size; |
| 203 | int err; |
| 204 | |
| 205 | up = (struct compat_video_still_picture __user *) arg; |
| 206 | err = get_user(fp, &up->iFrame); |
| 207 | err |= get_user(size, &up->size); |
| 208 | if (err) |
| 209 | return -EFAULT; |
| 210 | |
| 211 | up_native = |
| 212 | compat_alloc_user_space(sizeof(struct video_still_picture)); |
| 213 | |
| 214 | put_user(compat_ptr(fp), &up_native->iFrame); |
| 215 | put_user(size, &up_native->size); |
| 216 | |
| 217 | err = sys_ioctl(fd, cmd, (unsigned long) up_native); |
| 218 | |
| 219 | return err; |
| 220 | } |
| 221 | |
| 222 | struct compat_video_spu_palette { |
| 223 | int length; |
| 224 | compat_uptr_t palette; |
| 225 | }; |
| 226 | |
| 227 | static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 228 | { |
| 229 | struct compat_video_spu_palette __user *up; |
| 230 | struct video_spu_palette __user *up_native; |
| 231 | compat_uptr_t palp; |
| 232 | int length, err; |
| 233 | |
| 234 | up = (struct compat_video_spu_palette __user *) arg; |
| 235 | err = get_user(palp, &up->palette); |
| 236 | err |= get_user(length, &up->length); |
| 237 | |
| 238 | up_native = compat_alloc_user_space(sizeof(struct video_spu_palette)); |
| 239 | put_user(compat_ptr(palp), &up_native->palette); |
| 240 | put_user(length, &up_native->length); |
| 241 | |
| 242 | err = sys_ioctl(fd, cmd, (unsigned long) up_native); |
| 243 | |
| 244 | return err; |
| 245 | } |
| 246 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | #ifdef CONFIG_NET |
| 248 | static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 249 | { |
| 250 | struct compat_timeval __user *up = compat_ptr(arg); |
| 251 | struct timeval ktv; |
| 252 | mm_segment_t old_fs = get_fs(); |
| 253 | int err; |
| 254 | |
| 255 | set_fs(KERNEL_DS); |
| 256 | err = sys_ioctl(fd, cmd, (unsigned long)&ktv); |
| 257 | set_fs(old_fs); |
| 258 | if(!err) { |
| 259 | err = put_user(ktv.tv_sec, &up->tv_sec); |
| 260 | err |= __put_user(ktv.tv_usec, &up->tv_usec); |
| 261 | } |
| 262 | return err; |
| 263 | } |
| 264 | |
| 265 | struct ifmap32 { |
| 266 | compat_ulong_t mem_start; |
| 267 | compat_ulong_t mem_end; |
| 268 | unsigned short base_addr; |
| 269 | unsigned char irq; |
| 270 | unsigned char dma; |
| 271 | unsigned char port; |
| 272 | }; |
| 273 | |
| 274 | struct ifreq32 { |
| 275 | #define IFHWADDRLEN 6 |
| 276 | #define IFNAMSIZ 16 |
| 277 | union { |
| 278 | char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */ |
| 279 | } ifr_ifrn; |
| 280 | union { |
| 281 | struct sockaddr ifru_addr; |
| 282 | struct sockaddr ifru_dstaddr; |
| 283 | struct sockaddr ifru_broadaddr; |
| 284 | struct sockaddr ifru_netmask; |
| 285 | struct sockaddr ifru_hwaddr; |
| 286 | short ifru_flags; |
| 287 | compat_int_t ifru_ivalue; |
| 288 | compat_int_t ifru_mtu; |
| 289 | struct ifmap32 ifru_map; |
| 290 | char ifru_slave[IFNAMSIZ]; /* Just fits the size */ |
| 291 | char ifru_newname[IFNAMSIZ]; |
| 292 | compat_caddr_t ifru_data; |
| 293 | /* XXXX? ifru_settings should be here */ |
| 294 | } ifr_ifru; |
| 295 | }; |
| 296 | |
| 297 | struct ifconf32 { |
| 298 | compat_int_t ifc_len; /* size of buffer */ |
| 299 | compat_caddr_t ifcbuf; |
| 300 | }; |
| 301 | |
| 302 | static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 303 | { |
| 304 | struct net_device *dev; |
| 305 | struct ifreq32 ifr32; |
| 306 | int err; |
| 307 | |
| 308 | if (copy_from_user(&ifr32, compat_ptr(arg), sizeof(ifr32))) |
| 309 | return -EFAULT; |
| 310 | |
| 311 | dev = dev_get_by_index(ifr32.ifr_ifindex); |
| 312 | if (!dev) |
| 313 | return -ENODEV; |
| 314 | |
| 315 | strlcpy(ifr32.ifr_name, dev->name, sizeof(ifr32.ifr_name)); |
| 316 | dev_put(dev); |
| 317 | |
| 318 | err = copy_to_user(compat_ptr(arg), &ifr32, sizeof(ifr32)); |
| 319 | return (err ? -EFAULT : 0); |
| 320 | } |
| 321 | |
| 322 | static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 323 | { |
| 324 | struct ifconf32 ifc32; |
| 325 | struct ifconf ifc; |
| 326 | struct ifconf __user *uifc; |
| 327 | struct ifreq32 __user *ifr32; |
| 328 | struct ifreq __user *ifr; |
| 329 | unsigned int i, j; |
| 330 | int err; |
| 331 | |
| 332 | if (copy_from_user(&ifc32, compat_ptr(arg), sizeof(struct ifconf32))) |
| 333 | return -EFAULT; |
| 334 | |
| 335 | if (ifc32.ifcbuf == 0) { |
| 336 | ifc32.ifc_len = 0; |
| 337 | ifc.ifc_len = 0; |
| 338 | ifc.ifc_req = NULL; |
| 339 | uifc = compat_alloc_user_space(sizeof(struct ifconf)); |
| 340 | } else { |
| 341 | size_t len =((ifc32.ifc_len / sizeof (struct ifreq32)) + 1) * |
| 342 | sizeof (struct ifreq); |
| 343 | uifc = compat_alloc_user_space(sizeof(struct ifconf) + len); |
| 344 | ifc.ifc_len = len; |
| 345 | ifr = ifc.ifc_req = (void __user *)(uifc + 1); |
| 346 | ifr32 = compat_ptr(ifc32.ifcbuf); |
| 347 | for (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) { |
| 348 | if (copy_in_user(ifr, ifr32, sizeof(struct ifreq32))) |
| 349 | return -EFAULT; |
| 350 | ifr++; |
| 351 | ifr32++; |
| 352 | } |
| 353 | } |
| 354 | if (copy_to_user(uifc, &ifc, sizeof(struct ifconf))) |
| 355 | return -EFAULT; |
| 356 | |
| 357 | err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)uifc); |
| 358 | if (err) |
| 359 | return err; |
| 360 | |
| 361 | if (copy_from_user(&ifc, uifc, sizeof(struct ifconf))) |
| 362 | return -EFAULT; |
| 363 | |
| 364 | ifr = ifc.ifc_req; |
| 365 | ifr32 = compat_ptr(ifc32.ifcbuf); |
Alexandra Kossovsky | 4909724 | 2005-11-20 13:41:59 -0800 | [diff] [blame] | 366 | for (i = 0, j = 0; |
Randy Dunlap | 1efa3c0 | 2006-03-08 16:46:08 -0800 | [diff] [blame] | 367 | i + sizeof (struct ifreq32) <= ifc32.ifc_len && j < ifc.ifc_len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) { |
| 369 | if (copy_in_user(ifr32, ifr, sizeof (struct ifreq32))) |
| 370 | return -EFAULT; |
| 371 | ifr32++; |
| 372 | ifr++; |
| 373 | } |
| 374 | |
| 375 | if (ifc32.ifcbuf == 0) { |
| 376 | /* Translate from 64-bit structure multiple to |
| 377 | * a 32-bit one. |
| 378 | */ |
| 379 | i = ifc.ifc_len; |
| 380 | i = ((i / sizeof(struct ifreq)) * sizeof(struct ifreq32)); |
| 381 | ifc32.ifc_len = i; |
| 382 | } else { |
Alexandra Kossovsky | 4909724 | 2005-11-20 13:41:59 -0800 | [diff] [blame] | 383 | ifc32.ifc_len = i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | } |
| 385 | if (copy_to_user(compat_ptr(arg), &ifc32, sizeof(struct ifconf32))) |
| 386 | return -EFAULT; |
| 387 | |
| 388 | return 0; |
| 389 | } |
| 390 | |
| 391 | static int ethtool_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 392 | { |
| 393 | struct ifreq __user *ifr; |
| 394 | struct ifreq32 __user *ifr32; |
| 395 | u32 data; |
| 396 | void __user *datap; |
| 397 | |
| 398 | ifr = compat_alloc_user_space(sizeof(*ifr)); |
| 399 | ifr32 = compat_ptr(arg); |
| 400 | |
| 401 | if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ)) |
| 402 | return -EFAULT; |
| 403 | |
| 404 | if (get_user(data, &ifr32->ifr_ifru.ifru_data)) |
| 405 | return -EFAULT; |
| 406 | |
| 407 | datap = compat_ptr(data); |
| 408 | if (put_user(datap, &ifr->ifr_ifru.ifru_data)) |
| 409 | return -EFAULT; |
| 410 | |
| 411 | return sys_ioctl(fd, cmd, (unsigned long) ifr); |
| 412 | } |
| 413 | |
| 414 | static int bond_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 415 | { |
| 416 | struct ifreq kifr; |
| 417 | struct ifreq __user *uifr; |
| 418 | struct ifreq32 __user *ifr32 = compat_ptr(arg); |
| 419 | mm_segment_t old_fs; |
| 420 | int err; |
| 421 | u32 data; |
| 422 | void __user *datap; |
| 423 | |
| 424 | switch (cmd) { |
| 425 | case SIOCBONDENSLAVE: |
| 426 | case SIOCBONDRELEASE: |
| 427 | case SIOCBONDSETHWADDR: |
| 428 | case SIOCBONDCHANGEACTIVE: |
| 429 | if (copy_from_user(&kifr, ifr32, sizeof(struct ifreq32))) |
| 430 | return -EFAULT; |
| 431 | |
| 432 | old_fs = get_fs(); |
| 433 | set_fs (KERNEL_DS); |
| 434 | err = sys_ioctl (fd, cmd, (unsigned long)&kifr); |
| 435 | set_fs (old_fs); |
| 436 | |
| 437 | return err; |
| 438 | case SIOCBONDSLAVEINFOQUERY: |
| 439 | case SIOCBONDINFOQUERY: |
| 440 | uifr = compat_alloc_user_space(sizeof(*uifr)); |
| 441 | if (copy_in_user(&uifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ)) |
| 442 | return -EFAULT; |
| 443 | |
| 444 | if (get_user(data, &ifr32->ifr_ifru.ifru_data)) |
| 445 | return -EFAULT; |
| 446 | |
| 447 | datap = compat_ptr(data); |
| 448 | if (put_user(datap, &uifr->ifr_ifru.ifru_data)) |
| 449 | return -EFAULT; |
| 450 | |
| 451 | return sys_ioctl (fd, cmd, (unsigned long)uifr); |
| 452 | default: |
| 453 | return -EINVAL; |
| 454 | }; |
| 455 | } |
| 456 | |
| 457 | int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 458 | { |
| 459 | struct ifreq __user *u_ifreq64; |
| 460 | struct ifreq32 __user *u_ifreq32 = compat_ptr(arg); |
| 461 | char tmp_buf[IFNAMSIZ]; |
| 462 | void __user *data64; |
| 463 | u32 data32; |
| 464 | |
| 465 | if (copy_from_user(&tmp_buf[0], &(u_ifreq32->ifr_ifrn.ifrn_name[0]), |
| 466 | IFNAMSIZ)) |
| 467 | return -EFAULT; |
| 468 | if (__get_user(data32, &u_ifreq32->ifr_ifru.ifru_data)) |
| 469 | return -EFAULT; |
| 470 | data64 = compat_ptr(data32); |
| 471 | |
| 472 | u_ifreq64 = compat_alloc_user_space(sizeof(*u_ifreq64)); |
| 473 | |
| 474 | /* Don't check these user accesses, just let that get trapped |
| 475 | * in the ioctl handler instead. |
| 476 | */ |
| 477 | if (copy_to_user(&u_ifreq64->ifr_ifrn.ifrn_name[0], &tmp_buf[0], |
| 478 | IFNAMSIZ)) |
| 479 | return -EFAULT; |
| 480 | if (__put_user(data64, &u_ifreq64->ifr_ifru.ifru_data)) |
| 481 | return -EFAULT; |
| 482 | |
| 483 | return sys_ioctl(fd, cmd, (unsigned long) u_ifreq64); |
| 484 | } |
| 485 | |
| 486 | static int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 487 | { |
| 488 | struct ifreq ifr; |
| 489 | struct ifreq32 __user *uifr32; |
| 490 | struct ifmap32 __user *uifmap32; |
| 491 | mm_segment_t old_fs; |
| 492 | int err; |
| 493 | |
| 494 | uifr32 = compat_ptr(arg); |
| 495 | uifmap32 = &uifr32->ifr_ifru.ifru_map; |
| 496 | switch (cmd) { |
| 497 | case SIOCSIFMAP: |
| 498 | err = copy_from_user(&ifr, uifr32, sizeof(ifr.ifr_name)); |
| 499 | err |= __get_user(ifr.ifr_map.mem_start, &uifmap32->mem_start); |
| 500 | err |= __get_user(ifr.ifr_map.mem_end, &uifmap32->mem_end); |
| 501 | err |= __get_user(ifr.ifr_map.base_addr, &uifmap32->base_addr); |
| 502 | err |= __get_user(ifr.ifr_map.irq, &uifmap32->irq); |
| 503 | err |= __get_user(ifr.ifr_map.dma, &uifmap32->dma); |
| 504 | err |= __get_user(ifr.ifr_map.port, &uifmap32->port); |
| 505 | if (err) |
| 506 | return -EFAULT; |
| 507 | break; |
| 508 | default: |
| 509 | if (copy_from_user(&ifr, uifr32, sizeof(*uifr32))) |
| 510 | return -EFAULT; |
| 511 | break; |
| 512 | } |
| 513 | old_fs = get_fs(); |
| 514 | set_fs (KERNEL_DS); |
| 515 | err = sys_ioctl (fd, cmd, (unsigned long)&ifr); |
| 516 | set_fs (old_fs); |
| 517 | if (!err) { |
| 518 | switch (cmd) { |
| 519 | /* TUNSETIFF is defined as _IOW, it should be _IORW |
| 520 | * as the data is copied back to user space, but that |
| 521 | * cannot be fixed without breaking all existing apps. |
| 522 | */ |
| 523 | case TUNSETIFF: |
| 524 | case SIOCGIFFLAGS: |
| 525 | case SIOCGIFMETRIC: |
| 526 | case SIOCGIFMTU: |
| 527 | case SIOCGIFMEM: |
| 528 | case SIOCGIFHWADDR: |
| 529 | case SIOCGIFINDEX: |
| 530 | case SIOCGIFADDR: |
| 531 | case SIOCGIFBRDADDR: |
| 532 | case SIOCGIFDSTADDR: |
| 533 | case SIOCGIFNETMASK: |
| 534 | case SIOCGIFTXQLEN: |
| 535 | if (copy_to_user(uifr32, &ifr, sizeof(*uifr32))) |
| 536 | return -EFAULT; |
| 537 | break; |
| 538 | case SIOCGIFMAP: |
| 539 | err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name)); |
| 540 | err |= __put_user(ifr.ifr_map.mem_start, &uifmap32->mem_start); |
| 541 | err |= __put_user(ifr.ifr_map.mem_end, &uifmap32->mem_end); |
| 542 | err |= __put_user(ifr.ifr_map.base_addr, &uifmap32->base_addr); |
| 543 | err |= __put_user(ifr.ifr_map.irq, &uifmap32->irq); |
| 544 | err |= __put_user(ifr.ifr_map.dma, &uifmap32->dma); |
| 545 | err |= __put_user(ifr.ifr_map.port, &uifmap32->port); |
| 546 | if (err) |
| 547 | err = -EFAULT; |
| 548 | break; |
| 549 | } |
| 550 | } |
| 551 | return err; |
| 552 | } |
| 553 | |
| 554 | struct rtentry32 { |
| 555 | u32 rt_pad1; |
| 556 | struct sockaddr rt_dst; /* target address */ |
| 557 | struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */ |
| 558 | struct sockaddr rt_genmask; /* target network mask (IP) */ |
| 559 | unsigned short rt_flags; |
| 560 | short rt_pad2; |
| 561 | u32 rt_pad3; |
| 562 | unsigned char rt_tos; |
| 563 | unsigned char rt_class; |
| 564 | short rt_pad4; |
| 565 | short rt_metric; /* +1 for binary compatibility! */ |
| 566 | /* char * */ u32 rt_dev; /* forcing the device at add */ |
| 567 | u32 rt_mtu; /* per route MTU/Window */ |
| 568 | u32 rt_window; /* Window clamping */ |
| 569 | unsigned short rt_irtt; /* Initial RTT */ |
| 570 | |
| 571 | }; |
| 572 | |
| 573 | struct in6_rtmsg32 { |
| 574 | struct in6_addr rtmsg_dst; |
| 575 | struct in6_addr rtmsg_src; |
| 576 | struct in6_addr rtmsg_gateway; |
| 577 | u32 rtmsg_type; |
| 578 | u16 rtmsg_dst_len; |
| 579 | u16 rtmsg_src_len; |
| 580 | u32 rtmsg_metric; |
| 581 | u32 rtmsg_info; |
| 582 | u32 rtmsg_flags; |
| 583 | s32 rtmsg_ifindex; |
| 584 | }; |
| 585 | |
| 586 | static int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 587 | { |
| 588 | int ret; |
| 589 | void *r = NULL; |
| 590 | struct in6_rtmsg r6; |
| 591 | struct rtentry r4; |
| 592 | char devname[16]; |
| 593 | u32 rtdev; |
| 594 | mm_segment_t old_fs = get_fs(); |
| 595 | |
| 596 | struct socket *mysock = sockfd_lookup(fd, &ret); |
| 597 | |
| 598 | if (mysock && mysock->sk && mysock->sk->sk_family == AF_INET6) { /* ipv6 */ |
| 599 | struct in6_rtmsg32 __user *ur6 = compat_ptr(arg); |
| 600 | ret = copy_from_user (&r6.rtmsg_dst, &(ur6->rtmsg_dst), |
| 601 | 3 * sizeof(struct in6_addr)); |
| 602 | ret |= __get_user (r6.rtmsg_type, &(ur6->rtmsg_type)); |
| 603 | ret |= __get_user (r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len)); |
| 604 | ret |= __get_user (r6.rtmsg_src_len, &(ur6->rtmsg_src_len)); |
| 605 | ret |= __get_user (r6.rtmsg_metric, &(ur6->rtmsg_metric)); |
| 606 | ret |= __get_user (r6.rtmsg_info, &(ur6->rtmsg_info)); |
| 607 | ret |= __get_user (r6.rtmsg_flags, &(ur6->rtmsg_flags)); |
| 608 | ret |= __get_user (r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex)); |
| 609 | |
| 610 | r = (void *) &r6; |
| 611 | } else { /* ipv4 */ |
| 612 | struct rtentry32 __user *ur4 = compat_ptr(arg); |
| 613 | ret = copy_from_user (&r4.rt_dst, &(ur4->rt_dst), |
| 614 | 3 * sizeof(struct sockaddr)); |
| 615 | ret |= __get_user (r4.rt_flags, &(ur4->rt_flags)); |
| 616 | ret |= __get_user (r4.rt_metric, &(ur4->rt_metric)); |
| 617 | ret |= __get_user (r4.rt_mtu, &(ur4->rt_mtu)); |
| 618 | ret |= __get_user (r4.rt_window, &(ur4->rt_window)); |
| 619 | ret |= __get_user (r4.rt_irtt, &(ur4->rt_irtt)); |
| 620 | ret |= __get_user (rtdev, &(ur4->rt_dev)); |
| 621 | if (rtdev) { |
| 622 | ret |= copy_from_user (devname, compat_ptr(rtdev), 15); |
| 623 | r4.rt_dev = devname; devname[15] = 0; |
| 624 | } else |
| 625 | r4.rt_dev = NULL; |
| 626 | |
| 627 | r = (void *) &r4; |
| 628 | } |
| 629 | |
Kirill Korotaev | d99901d | 2005-09-09 13:59:48 +0400 | [diff] [blame] | 630 | if (ret) { |
| 631 | ret = -EFAULT; |
| 632 | goto out; |
| 633 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | |
| 635 | set_fs (KERNEL_DS); |
| 636 | ret = sys_ioctl (fd, cmd, (unsigned long) r); |
| 637 | set_fs (old_fs); |
| 638 | |
Kirill Korotaev | d99901d | 2005-09-09 13:59:48 +0400 | [diff] [blame] | 639 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | if (mysock) |
| 641 | sockfd_put(mysock); |
| 642 | |
| 643 | return ret; |
| 644 | } |
| 645 | #endif |
| 646 | |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 647 | #ifdef CONFIG_BLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | struct hd_geometry32 { |
| 649 | unsigned char heads; |
| 650 | unsigned char sectors; |
| 651 | unsigned short cylinders; |
| 652 | u32 start; |
| 653 | }; |
| 654 | |
| 655 | static int hdio_getgeo(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 656 | { |
| 657 | mm_segment_t old_fs = get_fs(); |
| 658 | struct hd_geometry geo; |
| 659 | struct hd_geometry32 __user *ugeo; |
| 660 | int err; |
| 661 | |
| 662 | set_fs (KERNEL_DS); |
| 663 | err = sys_ioctl(fd, HDIO_GETGEO, (unsigned long)&geo); |
| 664 | set_fs (old_fs); |
| 665 | ugeo = compat_ptr(arg); |
| 666 | if (!err) { |
| 667 | err = copy_to_user (ugeo, &geo, 4); |
| 668 | err |= __put_user (geo.start, &ugeo->start); |
| 669 | } |
| 670 | return err ? -EFAULT : 0; |
| 671 | } |
| 672 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | static int hdio_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 674 | { |
| 675 | mm_segment_t old_fs = get_fs(); |
| 676 | unsigned long kval; |
| 677 | unsigned int __user *uvp; |
| 678 | int error; |
| 679 | |
| 680 | set_fs(KERNEL_DS); |
| 681 | error = sys_ioctl(fd, cmd, (long)&kval); |
| 682 | set_fs(old_fs); |
| 683 | |
| 684 | if(error == 0) { |
| 685 | uvp = compat_ptr(arg); |
| 686 | if(put_user(kval, uvp)) |
| 687 | error = -EFAULT; |
| 688 | } |
| 689 | return error; |
| 690 | } |
| 691 | |
| 692 | |
| 693 | typedef struct sg_io_hdr32 { |
| 694 | compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */ |
| 695 | compat_int_t dxfer_direction; /* [i] data transfer direction */ |
| 696 | unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */ |
| 697 | unsigned char mx_sb_len; /* [i] max length to write to sbp */ |
| 698 | unsigned short iovec_count; /* [i] 0 implies no scatter gather */ |
| 699 | compat_uint_t dxfer_len; /* [i] byte count of data transfer */ |
| 700 | compat_uint_t dxferp; /* [i], [*io] points to data transfer memory |
| 701 | or scatter gather list */ |
| 702 | compat_uptr_t cmdp; /* [i], [*i] points to command to perform */ |
| 703 | compat_uptr_t sbp; /* [i], [*o] points to sense_buffer memory */ |
| 704 | compat_uint_t timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */ |
| 705 | compat_uint_t flags; /* [i] 0 -> default, see SG_FLAG... */ |
| 706 | compat_int_t pack_id; /* [i->o] unused internally (normally) */ |
| 707 | compat_uptr_t usr_ptr; /* [i->o] unused internally */ |
| 708 | unsigned char status; /* [o] scsi status */ |
| 709 | unsigned char masked_status; /* [o] shifted, masked scsi status */ |
| 710 | unsigned char msg_status; /* [o] messaging level data (optional) */ |
| 711 | unsigned char sb_len_wr; /* [o] byte count actually written to sbp */ |
| 712 | unsigned short host_status; /* [o] errors from host adapter */ |
| 713 | unsigned short driver_status; /* [o] errors from software driver */ |
| 714 | compat_int_t resid; /* [o] dxfer_len - actual_transferred */ |
| 715 | compat_uint_t duration; /* [o] time taken by cmd (unit: millisec) */ |
| 716 | compat_uint_t info; /* [o] auxiliary information */ |
| 717 | } sg_io_hdr32_t; /* 64 bytes long (on sparc32) */ |
| 718 | |
| 719 | typedef struct sg_iovec32 { |
| 720 | compat_uint_t iov_base; |
| 721 | compat_uint_t iov_len; |
| 722 | } sg_iovec32_t; |
| 723 | |
| 724 | static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iovec_count) |
| 725 | { |
| 726 | sg_iovec_t __user *iov = (sg_iovec_t __user *) (sgio + 1); |
| 727 | sg_iovec32_t __user *iov32 = dxferp; |
| 728 | int i; |
| 729 | |
| 730 | for (i = 0; i < iovec_count; i++) { |
| 731 | u32 base, len; |
| 732 | |
| 733 | if (get_user(base, &iov32[i].iov_base) || |
| 734 | get_user(len, &iov32[i].iov_len) || |
| 735 | put_user(compat_ptr(base), &iov[i].iov_base) || |
| 736 | put_user(len, &iov[i].iov_len)) |
| 737 | return -EFAULT; |
| 738 | } |
| 739 | |
| 740 | if (put_user(iov, &sgio->dxferp)) |
| 741 | return -EFAULT; |
| 742 | return 0; |
| 743 | } |
| 744 | |
| 745 | static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 746 | { |
| 747 | sg_io_hdr_t __user *sgio; |
| 748 | sg_io_hdr32_t __user *sgio32; |
| 749 | u16 iovec_count; |
| 750 | u32 data; |
| 751 | void __user *dxferp; |
| 752 | int err; |
| 753 | |
| 754 | sgio32 = compat_ptr(arg); |
| 755 | if (get_user(iovec_count, &sgio32->iovec_count)) |
| 756 | return -EFAULT; |
| 757 | |
| 758 | { |
| 759 | void __user *top = compat_alloc_user_space(0); |
| 760 | void __user *new = compat_alloc_user_space(sizeof(sg_io_hdr_t) + |
| 761 | (iovec_count * sizeof(sg_iovec_t))); |
| 762 | if (new > top) |
| 763 | return -EINVAL; |
| 764 | |
| 765 | sgio = new; |
| 766 | } |
| 767 | |
| 768 | /* Ok, now construct. */ |
| 769 | if (copy_in_user(&sgio->interface_id, &sgio32->interface_id, |
| 770 | (2 * sizeof(int)) + |
| 771 | (2 * sizeof(unsigned char)) + |
| 772 | (1 * sizeof(unsigned short)) + |
| 773 | (1 * sizeof(unsigned int)))) |
| 774 | return -EFAULT; |
| 775 | |
| 776 | if (get_user(data, &sgio32->dxferp)) |
| 777 | return -EFAULT; |
| 778 | dxferp = compat_ptr(data); |
| 779 | if (iovec_count) { |
| 780 | if (sg_build_iovec(sgio, dxferp, iovec_count)) |
| 781 | return -EFAULT; |
| 782 | } else { |
| 783 | if (put_user(dxferp, &sgio->dxferp)) |
| 784 | return -EFAULT; |
| 785 | } |
| 786 | |
| 787 | { |
| 788 | unsigned char __user *cmdp; |
| 789 | unsigned char __user *sbp; |
| 790 | |
| 791 | if (get_user(data, &sgio32->cmdp)) |
| 792 | return -EFAULT; |
| 793 | cmdp = compat_ptr(data); |
| 794 | |
| 795 | if (get_user(data, &sgio32->sbp)) |
| 796 | return -EFAULT; |
| 797 | sbp = compat_ptr(data); |
| 798 | |
| 799 | if (put_user(cmdp, &sgio->cmdp) || |
| 800 | put_user(sbp, &sgio->sbp)) |
| 801 | return -EFAULT; |
| 802 | } |
| 803 | |
| 804 | if (copy_in_user(&sgio->timeout, &sgio32->timeout, |
| 805 | 3 * sizeof(int))) |
| 806 | return -EFAULT; |
| 807 | |
| 808 | if (get_user(data, &sgio32->usr_ptr)) |
| 809 | return -EFAULT; |
| 810 | if (put_user(compat_ptr(data), &sgio->usr_ptr)) |
| 811 | return -EFAULT; |
| 812 | |
| 813 | if (copy_in_user(&sgio->status, &sgio32->status, |
| 814 | (4 * sizeof(unsigned char)) + |
| 815 | (2 * sizeof(unsigned (short))) + |
| 816 | (3 * sizeof(int)))) |
| 817 | return -EFAULT; |
| 818 | |
| 819 | err = sys_ioctl(fd, cmd, (unsigned long) sgio); |
| 820 | |
| 821 | if (err >= 0) { |
| 822 | void __user *datap; |
| 823 | |
| 824 | if (copy_in_user(&sgio32->pack_id, &sgio->pack_id, |
| 825 | sizeof(int)) || |
| 826 | get_user(datap, &sgio->usr_ptr) || |
| 827 | put_user((u32)(unsigned long)datap, |
| 828 | &sgio32->usr_ptr) || |
| 829 | copy_in_user(&sgio32->status, &sgio->status, |
| 830 | (4 * sizeof(unsigned char)) + |
| 831 | (2 * sizeof(unsigned short)) + |
| 832 | (3 * sizeof(int)))) |
| 833 | err = -EFAULT; |
| 834 | } |
| 835 | |
| 836 | return err; |
| 837 | } |
| 838 | |
Andi Kleen | 2966387 | 2006-01-11 22:44:03 +0100 | [diff] [blame] | 839 | struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */ |
| 840 | char req_state; |
| 841 | char orphan; |
| 842 | char sg_io_owned; |
| 843 | char problem; |
| 844 | int pack_id; |
| 845 | compat_uptr_t usr_ptr; |
| 846 | unsigned int duration; |
| 847 | int unused; |
| 848 | }; |
| 849 | |
| 850 | static int sg_grt_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 851 | { |
| 852 | int err, i; |
Al Viro | 6b2b4e5 | 2006-02-01 06:33:33 -0500 | [diff] [blame] | 853 | sg_req_info_t __user *r; |
| 854 | struct compat_sg_req_info __user *o = (void __user *)arg; |
Andi Kleen | 2966387 | 2006-01-11 22:44:03 +0100 | [diff] [blame] | 855 | r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE); |
| 856 | err = sys_ioctl(fd,cmd,(unsigned long)r); |
| 857 | if (err < 0) |
| 858 | return err; |
| 859 | for (i = 0; i < SG_MAX_QUEUE; i++) { |
| 860 | void __user *ptr; |
| 861 | int d; |
| 862 | |
| 863 | if (copy_in_user(o + i, r + i, offsetof(sg_req_info_t, usr_ptr)) || |
| 864 | get_user(ptr, &r[i].usr_ptr) || |
| 865 | get_user(d, &r[i].duration) || |
| 866 | put_user((u32)(unsigned long)(ptr), &o[i].usr_ptr) || |
| 867 | put_user(d, &o[i].duration)) |
| 868 | return -EFAULT; |
| 869 | } |
| 870 | return err; |
| 871 | } |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 872 | #endif /* CONFIG_BLOCK */ |
Andi Kleen | 2966387 | 2006-01-11 22:44:03 +0100 | [diff] [blame] | 873 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 874 | struct sock_fprog32 { |
| 875 | unsigned short len; |
| 876 | compat_caddr_t filter; |
| 877 | }; |
| 878 | |
| 879 | #define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32) |
| 880 | #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32) |
| 881 | |
| 882 | static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 883 | { |
| 884 | struct sock_fprog32 __user *u_fprog32 = compat_ptr(arg); |
| 885 | struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog)); |
| 886 | void __user *fptr64; |
| 887 | u32 fptr32; |
| 888 | u16 flen; |
| 889 | |
| 890 | if (get_user(flen, &u_fprog32->len) || |
| 891 | get_user(fptr32, &u_fprog32->filter)) |
| 892 | return -EFAULT; |
| 893 | |
| 894 | fptr64 = compat_ptr(fptr32); |
| 895 | |
| 896 | if (put_user(flen, &u_fprog64->len) || |
| 897 | put_user(fptr64, &u_fprog64->filter)) |
| 898 | return -EFAULT; |
| 899 | |
| 900 | if (cmd == PPPIOCSPASS32) |
| 901 | cmd = PPPIOCSPASS; |
| 902 | else |
| 903 | cmd = PPPIOCSACTIVE; |
| 904 | |
| 905 | return sys_ioctl(fd, cmd, (unsigned long) u_fprog64); |
| 906 | } |
| 907 | |
| 908 | struct ppp_option_data32 { |
| 909 | compat_caddr_t ptr; |
| 910 | u32 length; |
| 911 | compat_int_t transmit; |
| 912 | }; |
| 913 | #define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32) |
| 914 | |
| 915 | struct ppp_idle32 { |
| 916 | compat_time_t xmit_idle; |
| 917 | compat_time_t recv_idle; |
| 918 | }; |
| 919 | #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32) |
| 920 | |
| 921 | static int ppp_gidle(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 922 | { |
| 923 | struct ppp_idle __user *idle; |
| 924 | struct ppp_idle32 __user *idle32; |
| 925 | __kernel_time_t xmit, recv; |
| 926 | int err; |
| 927 | |
| 928 | idle = compat_alloc_user_space(sizeof(*idle)); |
| 929 | idle32 = compat_ptr(arg); |
| 930 | |
| 931 | err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle); |
| 932 | |
| 933 | if (!err) { |
| 934 | if (get_user(xmit, &idle->xmit_idle) || |
| 935 | get_user(recv, &idle->recv_idle) || |
| 936 | put_user(xmit, &idle32->xmit_idle) || |
| 937 | put_user(recv, &idle32->recv_idle)) |
| 938 | err = -EFAULT; |
| 939 | } |
| 940 | return err; |
| 941 | } |
| 942 | |
| 943 | static int ppp_scompress(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 944 | { |
| 945 | struct ppp_option_data __user *odata; |
| 946 | struct ppp_option_data32 __user *odata32; |
| 947 | __u32 data; |
| 948 | void __user *datap; |
| 949 | |
| 950 | odata = compat_alloc_user_space(sizeof(*odata)); |
| 951 | odata32 = compat_ptr(arg); |
| 952 | |
| 953 | if (get_user(data, &odata32->ptr)) |
| 954 | return -EFAULT; |
| 955 | |
| 956 | datap = compat_ptr(data); |
| 957 | if (put_user(datap, &odata->ptr)) |
| 958 | return -EFAULT; |
| 959 | |
| 960 | if (copy_in_user(&odata->length, &odata32->length, |
| 961 | sizeof(__u32) + sizeof(int))) |
| 962 | return -EFAULT; |
| 963 | |
| 964 | return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata); |
| 965 | } |
| 966 | |
| 967 | static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 968 | { |
| 969 | int err; |
| 970 | |
| 971 | switch (cmd) { |
| 972 | case PPPIOCGIDLE32: |
| 973 | err = ppp_gidle(fd, cmd, arg); |
| 974 | break; |
| 975 | |
| 976 | case PPPIOCSCOMPRESS32: |
| 977 | err = ppp_scompress(fd, cmd, arg); |
| 978 | break; |
| 979 | |
| 980 | default: |
| 981 | do { |
| 982 | static int count; |
| 983 | if (++count <= 20) |
| 984 | printk("ppp_ioctl: Unknown cmd fd(%d) " |
| 985 | "cmd(%08x) arg(%08x)\n", |
| 986 | (int)fd, (unsigned int)cmd, (unsigned int)arg); |
| 987 | } while(0); |
| 988 | err = -EINVAL; |
| 989 | break; |
| 990 | }; |
| 991 | |
| 992 | return err; |
| 993 | } |
| 994 | |
| 995 | |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 996 | #ifdef CONFIG_BLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 997 | struct mtget32 { |
| 998 | compat_long_t mt_type; |
| 999 | compat_long_t mt_resid; |
| 1000 | compat_long_t mt_dsreg; |
| 1001 | compat_long_t mt_gstat; |
| 1002 | compat_long_t mt_erreg; |
| 1003 | compat_daddr_t mt_fileno; |
| 1004 | compat_daddr_t mt_blkno; |
| 1005 | }; |
| 1006 | #define MTIOCGET32 _IOR('m', 2, struct mtget32) |
| 1007 | |
| 1008 | struct mtpos32 { |
| 1009 | compat_long_t mt_blkno; |
| 1010 | }; |
| 1011 | #define MTIOCPOS32 _IOR('m', 3, struct mtpos32) |
| 1012 | |
| 1013 | static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 1014 | { |
| 1015 | mm_segment_t old_fs = get_fs(); |
| 1016 | struct mtget get; |
| 1017 | struct mtget32 __user *umget32; |
| 1018 | struct mtpos pos; |
| 1019 | struct mtpos32 __user *upos32; |
| 1020 | unsigned long kcmd; |
| 1021 | void *karg; |
| 1022 | int err = 0; |
| 1023 | |
| 1024 | switch(cmd) { |
| 1025 | case MTIOCPOS32: |
| 1026 | kcmd = MTIOCPOS; |
| 1027 | karg = &pos; |
| 1028 | break; |
| 1029 | case MTIOCGET32: |
| 1030 | kcmd = MTIOCGET; |
| 1031 | karg = &get; |
| 1032 | break; |
| 1033 | default: |
| 1034 | do { |
| 1035 | static int count; |
| 1036 | if (++count <= 20) |
| 1037 | printk("mt_ioctl: Unknown cmd fd(%d) " |
| 1038 | "cmd(%08x) arg(%08x)\n", |
| 1039 | (int)fd, (unsigned int)cmd, (unsigned int)arg); |
| 1040 | } while(0); |
| 1041 | return -EINVAL; |
| 1042 | } |
| 1043 | set_fs (KERNEL_DS); |
| 1044 | err = sys_ioctl (fd, kcmd, (unsigned long)karg); |
| 1045 | set_fs (old_fs); |
| 1046 | if (err) |
| 1047 | return err; |
| 1048 | switch (cmd) { |
| 1049 | case MTIOCPOS32: |
| 1050 | upos32 = compat_ptr(arg); |
| 1051 | err = __put_user(pos.mt_blkno, &upos32->mt_blkno); |
| 1052 | break; |
| 1053 | case MTIOCGET32: |
| 1054 | umget32 = compat_ptr(arg); |
| 1055 | err = __put_user(get.mt_type, &umget32->mt_type); |
| 1056 | err |= __put_user(get.mt_resid, &umget32->mt_resid); |
| 1057 | err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg); |
| 1058 | err |= __put_user(get.mt_gstat, &umget32->mt_gstat); |
| 1059 | err |= __put_user(get.mt_erreg, &umget32->mt_erreg); |
| 1060 | err |= __put_user(get.mt_fileno, &umget32->mt_fileno); |
| 1061 | err |= __put_user(get.mt_blkno, &umget32->mt_blkno); |
| 1062 | break; |
| 1063 | } |
| 1064 | return err ? -EFAULT: 0; |
| 1065 | } |
| 1066 | |
| 1067 | struct cdrom_read_audio32 { |
| 1068 | union cdrom_addr addr; |
| 1069 | u8 addr_format; |
| 1070 | compat_int_t nframes; |
| 1071 | compat_caddr_t buf; |
| 1072 | }; |
| 1073 | |
| 1074 | struct cdrom_generic_command32 { |
| 1075 | unsigned char cmd[CDROM_PACKET_SIZE]; |
| 1076 | compat_caddr_t buffer; |
| 1077 | compat_uint_t buflen; |
| 1078 | compat_int_t stat; |
| 1079 | compat_caddr_t sense; |
| 1080 | unsigned char data_direction; |
| 1081 | compat_int_t quiet; |
| 1082 | compat_int_t timeout; |
| 1083 | compat_caddr_t reserved[1]; |
| 1084 | }; |
| 1085 | |
| 1086 | static int cdrom_do_read_audio(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 1087 | { |
| 1088 | struct cdrom_read_audio __user *cdread_audio; |
| 1089 | struct cdrom_read_audio32 __user *cdread_audio32; |
| 1090 | __u32 data; |
| 1091 | void __user *datap; |
| 1092 | |
| 1093 | cdread_audio = compat_alloc_user_space(sizeof(*cdread_audio)); |
| 1094 | cdread_audio32 = compat_ptr(arg); |
| 1095 | |
| 1096 | if (copy_in_user(&cdread_audio->addr, |
| 1097 | &cdread_audio32->addr, |
| 1098 | (sizeof(*cdread_audio32) - |
| 1099 | sizeof(compat_caddr_t)))) |
| 1100 | return -EFAULT; |
| 1101 | |
| 1102 | if (get_user(data, &cdread_audio32->buf)) |
| 1103 | return -EFAULT; |
| 1104 | datap = compat_ptr(data); |
| 1105 | if (put_user(datap, &cdread_audio->buf)) |
| 1106 | return -EFAULT; |
| 1107 | |
| 1108 | return sys_ioctl(fd, cmd, (unsigned long) cdread_audio); |
| 1109 | } |
| 1110 | |
| 1111 | static int cdrom_do_generic_command(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 1112 | { |
| 1113 | struct cdrom_generic_command __user *cgc; |
| 1114 | struct cdrom_generic_command32 __user *cgc32; |
| 1115 | u32 data; |
| 1116 | unsigned char dir; |
| 1117 | int itmp; |
| 1118 | |
| 1119 | cgc = compat_alloc_user_space(sizeof(*cgc)); |
| 1120 | cgc32 = compat_ptr(arg); |
| 1121 | |
| 1122 | if (copy_in_user(&cgc->cmd, &cgc32->cmd, sizeof(cgc->cmd)) || |
| 1123 | get_user(data, &cgc32->buffer) || |
| 1124 | put_user(compat_ptr(data), &cgc->buffer) || |
| 1125 | copy_in_user(&cgc->buflen, &cgc32->buflen, |
| 1126 | (sizeof(unsigned int) + sizeof(int))) || |
| 1127 | get_user(data, &cgc32->sense) || |
| 1128 | put_user(compat_ptr(data), &cgc->sense) || |
| 1129 | get_user(dir, &cgc32->data_direction) || |
| 1130 | put_user(dir, &cgc->data_direction) || |
| 1131 | get_user(itmp, &cgc32->quiet) || |
| 1132 | put_user(itmp, &cgc->quiet) || |
| 1133 | get_user(itmp, &cgc32->timeout) || |
| 1134 | put_user(itmp, &cgc->timeout) || |
| 1135 | get_user(data, &cgc32->reserved[0]) || |
| 1136 | put_user(compat_ptr(data), &cgc->reserved[0])) |
| 1137 | return -EFAULT; |
| 1138 | |
| 1139 | return sys_ioctl(fd, cmd, (unsigned long) cgc); |
| 1140 | } |
| 1141 | |
| 1142 | static int cdrom_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 1143 | { |
| 1144 | int err; |
| 1145 | |
| 1146 | switch(cmd) { |
| 1147 | case CDROMREADAUDIO: |
| 1148 | err = cdrom_do_read_audio(fd, cmd, arg); |
| 1149 | break; |
| 1150 | |
| 1151 | case CDROM_SEND_PACKET: |
| 1152 | err = cdrom_do_generic_command(fd, cmd, arg); |
| 1153 | break; |
| 1154 | |
| 1155 | default: |
| 1156 | do { |
| 1157 | static int count; |
| 1158 | if (++count <= 20) |
| 1159 | printk("cdrom_ioctl: Unknown cmd fd(%d) " |
| 1160 | "cmd(%08x) arg(%08x)\n", |
| 1161 | (int)fd, (unsigned int)cmd, (unsigned int)arg); |
| 1162 | } while(0); |
| 1163 | err = -EINVAL; |
| 1164 | break; |
| 1165 | }; |
| 1166 | |
| 1167 | return err; |
| 1168 | } |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 1169 | #endif /* CONFIG_BLOCK */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1170 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1171 | #ifdef CONFIG_VT |
| 1172 | |
| 1173 | static int vt_check(struct file *file) |
| 1174 | { |
| 1175 | struct tty_struct *tty; |
| 1176 | struct inode *inode = file->f_dentry->d_inode; |
| 1177 | |
| 1178 | if (file->f_op->ioctl != tty_ioctl) |
| 1179 | return -EINVAL; |
| 1180 | |
| 1181 | tty = (struct tty_struct *)file->private_data; |
| 1182 | if (tty_paranoia_check(tty, inode, "tty_ioctl")) |
| 1183 | return -EINVAL; |
| 1184 | |
| 1185 | if (tty->driver->ioctl != vt_ioctl) |
| 1186 | return -EINVAL; |
| 1187 | |
| 1188 | /* |
| 1189 | * To have permissions to do most of the vt ioctls, we either have |
| 1190 | * to be the owner of the tty, or super-user. |
| 1191 | */ |
| 1192 | if (current->signal->tty == tty || capable(CAP_SYS_ADMIN)) |
| 1193 | return 1; |
| 1194 | return 0; |
| 1195 | } |
| 1196 | |
| 1197 | struct consolefontdesc32 { |
| 1198 | unsigned short charcount; /* characters in font (256 or 512) */ |
| 1199 | unsigned short charheight; /* scan lines per character (1-32) */ |
| 1200 | compat_caddr_t chardata; /* font data in expanded form */ |
| 1201 | }; |
| 1202 | |
| 1203 | static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file) |
| 1204 | { |
| 1205 | struct consolefontdesc32 __user *user_cfd = compat_ptr(arg); |
| 1206 | struct console_font_op op; |
| 1207 | compat_caddr_t data; |
| 1208 | int i, perm; |
| 1209 | |
| 1210 | perm = vt_check(file); |
| 1211 | if (perm < 0) return perm; |
| 1212 | |
| 1213 | switch (cmd) { |
| 1214 | case PIO_FONTX: |
| 1215 | if (!perm) |
| 1216 | return -EPERM; |
| 1217 | op.op = KD_FONT_OP_SET; |
| 1218 | op.flags = 0; |
| 1219 | op.width = 8; |
| 1220 | if (get_user(op.height, &user_cfd->charheight) || |
| 1221 | get_user(op.charcount, &user_cfd->charcount) || |
| 1222 | get_user(data, &user_cfd->chardata)) |
| 1223 | return -EFAULT; |
| 1224 | op.data = compat_ptr(data); |
| 1225 | return con_font_op(vc_cons[fg_console].d, &op); |
| 1226 | case GIO_FONTX: |
| 1227 | op.op = KD_FONT_OP_GET; |
| 1228 | op.flags = 0; |
| 1229 | op.width = 8; |
| 1230 | if (get_user(op.height, &user_cfd->charheight) || |
| 1231 | get_user(op.charcount, &user_cfd->charcount) || |
| 1232 | get_user(data, &user_cfd->chardata)) |
| 1233 | return -EFAULT; |
| 1234 | if (!data) |
| 1235 | return 0; |
| 1236 | op.data = compat_ptr(data); |
| 1237 | i = con_font_op(vc_cons[fg_console].d, &op); |
| 1238 | if (i) |
| 1239 | return i; |
| 1240 | if (put_user(op.height, &user_cfd->charheight) || |
| 1241 | put_user(op.charcount, &user_cfd->charcount) || |
| 1242 | put_user((compat_caddr_t)(unsigned long)op.data, |
| 1243 | &user_cfd->chardata)) |
| 1244 | return -EFAULT; |
| 1245 | return 0; |
| 1246 | } |
| 1247 | return -EINVAL; |
| 1248 | } |
| 1249 | |
| 1250 | struct console_font_op32 { |
| 1251 | compat_uint_t op; /* operation code KD_FONT_OP_* */ |
| 1252 | compat_uint_t flags; /* KD_FONT_FLAG_* */ |
| 1253 | compat_uint_t width, height; /* font size */ |
| 1254 | compat_uint_t charcount; |
| 1255 | compat_caddr_t data; /* font data with height fixed to 32 */ |
| 1256 | }; |
| 1257 | |
| 1258 | static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file) |
| 1259 | { |
| 1260 | struct console_font_op op; |
| 1261 | struct console_font_op32 __user *fontop = compat_ptr(arg); |
| 1262 | int perm = vt_check(file), i; |
| 1263 | struct vc_data *vc; |
| 1264 | |
| 1265 | if (perm < 0) return perm; |
| 1266 | |
| 1267 | if (copy_from_user(&op, fontop, sizeof(struct console_font_op32))) |
| 1268 | return -EFAULT; |
| 1269 | if (!perm && op.op != KD_FONT_OP_GET) |
| 1270 | return -EPERM; |
| 1271 | op.data = compat_ptr(((struct console_font_op32 *)&op)->data); |
| 1272 | op.flags |= KD_FONT_FLAG_OLD; |
| 1273 | vc = ((struct tty_struct *)file->private_data)->driver_data; |
| 1274 | i = con_font_op(vc, &op); |
| 1275 | if (i) |
| 1276 | return i; |
| 1277 | ((struct console_font_op32 *)&op)->data = (unsigned long)op.data; |
| 1278 | if (copy_to_user(fontop, &op, sizeof(struct console_font_op32))) |
| 1279 | return -EFAULT; |
| 1280 | return 0; |
| 1281 | } |
| 1282 | |
| 1283 | struct unimapdesc32 { |
| 1284 | unsigned short entry_ct; |
| 1285 | compat_caddr_t entries; |
| 1286 | }; |
| 1287 | |
| 1288 | static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file) |
| 1289 | { |
| 1290 | struct unimapdesc32 tmp; |
| 1291 | struct unimapdesc32 __user *user_ud = compat_ptr(arg); |
| 1292 | int perm = vt_check(file); |
| 1293 | |
| 1294 | if (perm < 0) return perm; |
| 1295 | if (copy_from_user(&tmp, user_ud, sizeof tmp)) |
| 1296 | return -EFAULT; |
| 1297 | switch (cmd) { |
| 1298 | case PIO_UNIMAP: |
| 1299 | if (!perm) return -EPERM; |
| 1300 | return con_set_unimap(vc_cons[fg_console].d, tmp.entry_ct, compat_ptr(tmp.entries)); |
| 1301 | case GIO_UNIMAP: |
| 1302 | return con_get_unimap(vc_cons[fg_console].d, tmp.entry_ct, &(user_ud->entry_ct), compat_ptr(tmp.entries)); |
| 1303 | } |
| 1304 | return 0; |
| 1305 | } |
| 1306 | |
| 1307 | #endif /* CONFIG_VT */ |
| 1308 | |
| 1309 | static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 1310 | { |
| 1311 | mm_segment_t old_fs = get_fs(); |
| 1312 | __kernel_uid_t kuid; |
| 1313 | int err; |
| 1314 | |
| 1315 | cmd = SMB_IOC_GETMOUNTUID; |
| 1316 | |
| 1317 | set_fs(KERNEL_DS); |
| 1318 | err = sys_ioctl(fd, cmd, (unsigned long)&kuid); |
| 1319 | set_fs(old_fs); |
| 1320 | |
| 1321 | if (err >= 0) |
| 1322 | err = put_user(kuid, (compat_uid_t __user *)compat_ptr(arg)); |
| 1323 | |
| 1324 | return err; |
| 1325 | } |
| 1326 | |
| 1327 | struct atmif_sioc32 { |
| 1328 | compat_int_t number; |
| 1329 | compat_int_t length; |
| 1330 | compat_caddr_t arg; |
| 1331 | }; |
| 1332 | |
| 1333 | struct atm_iobuf32 { |
| 1334 | compat_int_t length; |
| 1335 | compat_caddr_t buffer; |
| 1336 | }; |
| 1337 | |
| 1338 | #define ATM_GETLINKRATE32 _IOW('a', ATMIOC_ITF+1, struct atmif_sioc32) |
| 1339 | #define ATM_GETNAMES32 _IOW('a', ATMIOC_ITF+3, struct atm_iobuf32) |
| 1340 | #define ATM_GETTYPE32 _IOW('a', ATMIOC_ITF+4, struct atmif_sioc32) |
| 1341 | #define ATM_GETESI32 _IOW('a', ATMIOC_ITF+5, struct atmif_sioc32) |
| 1342 | #define ATM_GETADDR32 _IOW('a', ATMIOC_ITF+6, struct atmif_sioc32) |
| 1343 | #define ATM_RSTADDR32 _IOW('a', ATMIOC_ITF+7, struct atmif_sioc32) |
| 1344 | #define ATM_ADDADDR32 _IOW('a', ATMIOC_ITF+8, struct atmif_sioc32) |
| 1345 | #define ATM_DELADDR32 _IOW('a', ATMIOC_ITF+9, struct atmif_sioc32) |
| 1346 | #define ATM_GETCIRANGE32 _IOW('a', ATMIOC_ITF+10, struct atmif_sioc32) |
| 1347 | #define ATM_SETCIRANGE32 _IOW('a', ATMIOC_ITF+11, struct atmif_sioc32) |
| 1348 | #define ATM_SETESI32 _IOW('a', ATMIOC_ITF+12, struct atmif_sioc32) |
| 1349 | #define ATM_SETESIF32 _IOW('a', ATMIOC_ITF+13, struct atmif_sioc32) |
| 1350 | #define ATM_GETSTAT32 _IOW('a', ATMIOC_SARCOM+0, struct atmif_sioc32) |
| 1351 | #define ATM_GETSTATZ32 _IOW('a', ATMIOC_SARCOM+1, struct atmif_sioc32) |
| 1352 | #define ATM_GETLOOP32 _IOW('a', ATMIOC_SARCOM+2, struct atmif_sioc32) |
| 1353 | #define ATM_SETLOOP32 _IOW('a', ATMIOC_SARCOM+3, struct atmif_sioc32) |
| 1354 | #define ATM_QUERYLOOP32 _IOW('a', ATMIOC_SARCOM+4, struct atmif_sioc32) |
| 1355 | |
| 1356 | static struct { |
| 1357 | unsigned int cmd32; |
| 1358 | unsigned int cmd; |
| 1359 | } atm_ioctl_map[] = { |
| 1360 | { ATM_GETLINKRATE32, ATM_GETLINKRATE }, |
| 1361 | { ATM_GETNAMES32, ATM_GETNAMES }, |
| 1362 | { ATM_GETTYPE32, ATM_GETTYPE }, |
| 1363 | { ATM_GETESI32, ATM_GETESI }, |
| 1364 | { ATM_GETADDR32, ATM_GETADDR }, |
| 1365 | { ATM_RSTADDR32, ATM_RSTADDR }, |
| 1366 | { ATM_ADDADDR32, ATM_ADDADDR }, |
| 1367 | { ATM_DELADDR32, ATM_DELADDR }, |
| 1368 | { ATM_GETCIRANGE32, ATM_GETCIRANGE }, |
| 1369 | { ATM_SETCIRANGE32, ATM_SETCIRANGE }, |
| 1370 | { ATM_SETESI32, ATM_SETESI }, |
| 1371 | { ATM_SETESIF32, ATM_SETESIF }, |
| 1372 | { ATM_GETSTAT32, ATM_GETSTAT }, |
| 1373 | { ATM_GETSTATZ32, ATM_GETSTATZ }, |
| 1374 | { ATM_GETLOOP32, ATM_GETLOOP }, |
| 1375 | { ATM_SETLOOP32, ATM_SETLOOP }, |
| 1376 | { ATM_QUERYLOOP32, ATM_QUERYLOOP } |
| 1377 | }; |
| 1378 | |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 1379 | #define NR_ATM_IOCTL ARRAY_SIZE(atm_ioctl_map) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1380 | |
| 1381 | static int do_atm_iobuf(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 1382 | { |
| 1383 | struct atm_iobuf __user *iobuf; |
| 1384 | struct atm_iobuf32 __user *iobuf32; |
| 1385 | u32 data; |
| 1386 | void __user *datap; |
| 1387 | int len, err; |
| 1388 | |
| 1389 | iobuf = compat_alloc_user_space(sizeof(*iobuf)); |
| 1390 | iobuf32 = compat_ptr(arg); |
| 1391 | |
| 1392 | if (get_user(len, &iobuf32->length) || |
| 1393 | get_user(data, &iobuf32->buffer)) |
| 1394 | return -EFAULT; |
| 1395 | datap = compat_ptr(data); |
| 1396 | if (put_user(len, &iobuf->length) || |
| 1397 | put_user(datap, &iobuf->buffer)) |
| 1398 | return -EFAULT; |
| 1399 | |
| 1400 | err = sys_ioctl(fd, cmd, (unsigned long)iobuf); |
| 1401 | |
| 1402 | if (!err) { |
| 1403 | if (copy_in_user(&iobuf32->length, &iobuf->length, |
| 1404 | sizeof(int))) |
| 1405 | err = -EFAULT; |
| 1406 | } |
| 1407 | |
| 1408 | return err; |
| 1409 | } |
| 1410 | |
| 1411 | static int do_atmif_sioc(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 1412 | { |
| 1413 | struct atmif_sioc __user *sioc; |
| 1414 | struct atmif_sioc32 __user *sioc32; |
| 1415 | u32 data; |
| 1416 | void __user *datap; |
| 1417 | int err; |
| 1418 | |
| 1419 | sioc = compat_alloc_user_space(sizeof(*sioc)); |
| 1420 | sioc32 = compat_ptr(arg); |
| 1421 | |
| 1422 | if (copy_in_user(&sioc->number, &sioc32->number, 2 * sizeof(int)) || |
| 1423 | get_user(data, &sioc32->arg)) |
| 1424 | return -EFAULT; |
| 1425 | datap = compat_ptr(data); |
| 1426 | if (put_user(datap, &sioc->arg)) |
| 1427 | return -EFAULT; |
| 1428 | |
| 1429 | err = sys_ioctl(fd, cmd, (unsigned long) sioc); |
| 1430 | |
| 1431 | if (!err) { |
| 1432 | if (copy_in_user(&sioc32->length, &sioc->length, |
| 1433 | sizeof(int))) |
| 1434 | err = -EFAULT; |
| 1435 | } |
| 1436 | return err; |
| 1437 | } |
| 1438 | |
| 1439 | static int do_atm_ioctl(unsigned int fd, unsigned int cmd32, unsigned long arg) |
| 1440 | { |
| 1441 | int i; |
| 1442 | unsigned int cmd = 0; |
| 1443 | |
| 1444 | switch (cmd32) { |
| 1445 | case SONET_GETSTAT: |
| 1446 | case SONET_GETSTATZ: |
| 1447 | case SONET_GETDIAG: |
| 1448 | case SONET_SETDIAG: |
| 1449 | case SONET_CLRDIAG: |
| 1450 | case SONET_SETFRAMING: |
| 1451 | case SONET_GETFRAMING: |
| 1452 | case SONET_GETFRSENSE: |
| 1453 | return do_atmif_sioc(fd, cmd32, arg); |
| 1454 | } |
| 1455 | |
| 1456 | for (i = 0; i < NR_ATM_IOCTL; i++) { |
| 1457 | if (cmd32 == atm_ioctl_map[i].cmd32) { |
| 1458 | cmd = atm_ioctl_map[i].cmd; |
| 1459 | break; |
| 1460 | } |
| 1461 | } |
| 1462 | if (i == NR_ATM_IOCTL) |
| 1463 | return -EINVAL; |
| 1464 | |
| 1465 | switch (cmd) { |
| 1466 | case ATM_GETNAMES: |
| 1467 | return do_atm_iobuf(fd, cmd, arg); |
| 1468 | |
| 1469 | case ATM_GETLINKRATE: |
| 1470 | case ATM_GETTYPE: |
| 1471 | case ATM_GETESI: |
| 1472 | case ATM_GETADDR: |
| 1473 | case ATM_RSTADDR: |
| 1474 | case ATM_ADDADDR: |
| 1475 | case ATM_DELADDR: |
| 1476 | case ATM_GETCIRANGE: |
| 1477 | case ATM_SETCIRANGE: |
| 1478 | case ATM_SETESI: |
| 1479 | case ATM_SETESIF: |
| 1480 | case ATM_GETSTAT: |
| 1481 | case ATM_GETSTATZ: |
| 1482 | case ATM_GETLOOP: |
| 1483 | case ATM_SETLOOP: |
| 1484 | case ATM_QUERYLOOP: |
| 1485 | return do_atmif_sioc(fd, cmd, arg); |
| 1486 | } |
| 1487 | |
| 1488 | return -EINVAL; |
| 1489 | } |
| 1490 | |
| 1491 | static __attribute_used__ int |
| 1492 | ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 1493 | { |
| 1494 | return -EINVAL; |
| 1495 | } |
| 1496 | |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 1497 | #ifdef CONFIG_BLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1498 | static int broken_blkgetsize(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 1499 | { |
| 1500 | /* The mkswap binary hard codes it to Intel value :-((( */ |
| 1501 | return w_long(fd, BLKGETSIZE, arg); |
| 1502 | } |
| 1503 | |
| 1504 | struct blkpg_ioctl_arg32 { |
| 1505 | compat_int_t op; |
| 1506 | compat_int_t flags; |
| 1507 | compat_int_t datalen; |
| 1508 | compat_caddr_t data; |
| 1509 | }; |
| 1510 | |
| 1511 | static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 1512 | { |
| 1513 | struct blkpg_ioctl_arg32 __user *ua32 = compat_ptr(arg); |
| 1514 | struct blkpg_ioctl_arg __user *a = compat_alloc_user_space(sizeof(*a)); |
| 1515 | compat_caddr_t udata; |
| 1516 | compat_int_t n; |
| 1517 | int err; |
| 1518 | |
| 1519 | err = get_user(n, &ua32->op); |
| 1520 | err |= put_user(n, &a->op); |
| 1521 | err |= get_user(n, &ua32->flags); |
| 1522 | err |= put_user(n, &a->flags); |
| 1523 | err |= get_user(n, &ua32->datalen); |
| 1524 | err |= put_user(n, &a->datalen); |
| 1525 | err |= get_user(udata, &ua32->data); |
| 1526 | err |= put_user(compat_ptr(udata), &a->data); |
| 1527 | if (err) |
| 1528 | return err; |
| 1529 | |
| 1530 | return sys_ioctl(fd, cmd, (unsigned long)a); |
| 1531 | } |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 1532 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1533 | |
| 1534 | static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 1535 | { |
| 1536 | return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg); |
| 1537 | } |
| 1538 | |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 1539 | #ifdef CONFIG_BLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1540 | /* Fix sizeof(sizeof()) breakage */ |
| 1541 | #define BLKBSZGET_32 _IOR(0x12,112,int) |
| 1542 | #define BLKBSZSET_32 _IOW(0x12,113,int) |
| 1543 | #define BLKGETSIZE64_32 _IOR(0x12,114,int) |
| 1544 | |
| 1545 | static int do_blkbszget(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 1546 | { |
| 1547 | return sys_ioctl(fd, BLKBSZGET, (unsigned long)compat_ptr(arg)); |
| 1548 | } |
| 1549 | |
| 1550 | static int do_blkbszset(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 1551 | { |
| 1552 | return sys_ioctl(fd, BLKBSZSET, (unsigned long)compat_ptr(arg)); |
| 1553 | } |
| 1554 | |
| 1555 | static int do_blkgetsize64(unsigned int fd, unsigned int cmd, |
| 1556 | unsigned long arg) |
| 1557 | { |
| 1558 | return sys_ioctl(fd, BLKGETSIZE64, (unsigned long)compat_ptr(arg)); |
| 1559 | } |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 1560 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1561 | |
| 1562 | /* Bluetooth ioctls */ |
| 1563 | #define HCIUARTSETPROTO _IOW('U', 200, int) |
| 1564 | #define HCIUARTGETPROTO _IOR('U', 201, int) |
| 1565 | |
| 1566 | #define BNEPCONNADD _IOW('B', 200, int) |
| 1567 | #define BNEPCONNDEL _IOW('B', 201, int) |
| 1568 | #define BNEPGETCONNLIST _IOR('B', 210, int) |
| 1569 | #define BNEPGETCONNINFO _IOR('B', 211, int) |
| 1570 | |
| 1571 | #define CMTPCONNADD _IOW('C', 200, int) |
| 1572 | #define CMTPCONNDEL _IOW('C', 201, int) |
| 1573 | #define CMTPGETCONNLIST _IOR('C', 210, int) |
| 1574 | #define CMTPGETCONNINFO _IOR('C', 211, int) |
| 1575 | |
| 1576 | #define HIDPCONNADD _IOW('H', 200, int) |
| 1577 | #define HIDPCONNDEL _IOW('H', 201, int) |
| 1578 | #define HIDPGETCONNLIST _IOR('H', 210, int) |
| 1579 | #define HIDPGETCONNINFO _IOR('H', 211, int) |
| 1580 | |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 1581 | #ifdef CONFIG_BLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1582 | struct floppy_struct32 { |
| 1583 | compat_uint_t size; |
| 1584 | compat_uint_t sect; |
| 1585 | compat_uint_t head; |
| 1586 | compat_uint_t track; |
| 1587 | compat_uint_t stretch; |
| 1588 | unsigned char gap; |
| 1589 | unsigned char rate; |
| 1590 | unsigned char spec1; |
| 1591 | unsigned char fmt_gap; |
| 1592 | const compat_caddr_t name; |
| 1593 | }; |
| 1594 | |
| 1595 | struct floppy_drive_params32 { |
| 1596 | char cmos; |
| 1597 | compat_ulong_t max_dtr; |
| 1598 | compat_ulong_t hlt; |
| 1599 | compat_ulong_t hut; |
| 1600 | compat_ulong_t srt; |
| 1601 | compat_ulong_t spinup; |
| 1602 | compat_ulong_t spindown; |
| 1603 | unsigned char spindown_offset; |
| 1604 | unsigned char select_delay; |
| 1605 | unsigned char rps; |
| 1606 | unsigned char tracks; |
| 1607 | compat_ulong_t timeout; |
| 1608 | unsigned char interleave_sect; |
| 1609 | struct floppy_max_errors max_errors; |
| 1610 | char flags; |
| 1611 | char read_track; |
| 1612 | short autodetect[8]; |
| 1613 | compat_int_t checkfreq; |
| 1614 | compat_int_t native_format; |
| 1615 | }; |
| 1616 | |
| 1617 | struct floppy_drive_struct32 { |
| 1618 | signed char flags; |
| 1619 | compat_ulong_t spinup_date; |
| 1620 | compat_ulong_t select_date; |
| 1621 | compat_ulong_t first_read_date; |
| 1622 | short probed_format; |
| 1623 | short track; |
| 1624 | short maxblock; |
| 1625 | short maxtrack; |
| 1626 | compat_int_t generation; |
| 1627 | compat_int_t keep_data; |
| 1628 | compat_int_t fd_ref; |
| 1629 | compat_int_t fd_device; |
| 1630 | compat_int_t last_checked; |
| 1631 | compat_caddr_t dmabuf; |
| 1632 | compat_int_t bufblocks; |
| 1633 | }; |
| 1634 | |
| 1635 | struct floppy_fdc_state32 { |
| 1636 | compat_int_t spec1; |
| 1637 | compat_int_t spec2; |
| 1638 | compat_int_t dtr; |
| 1639 | unsigned char version; |
| 1640 | unsigned char dor; |
| 1641 | compat_ulong_t address; |
| 1642 | unsigned int rawcmd:2; |
| 1643 | unsigned int reset:1; |
| 1644 | unsigned int need_configure:1; |
| 1645 | unsigned int perp_mode:2; |
| 1646 | unsigned int has_fifo:1; |
| 1647 | unsigned int driver_version; |
| 1648 | unsigned char track[4]; |
| 1649 | }; |
| 1650 | |
| 1651 | struct floppy_write_errors32 { |
| 1652 | unsigned int write_errors; |
| 1653 | compat_ulong_t first_error_sector; |
| 1654 | compat_int_t first_error_generation; |
| 1655 | compat_ulong_t last_error_sector; |
| 1656 | compat_int_t last_error_generation; |
| 1657 | compat_uint_t badness; |
| 1658 | }; |
| 1659 | |
| 1660 | #define FDSETPRM32 _IOW(2, 0x42, struct floppy_struct32) |
| 1661 | #define FDDEFPRM32 _IOW(2, 0x43, struct floppy_struct32) |
| 1662 | #define FDGETPRM32 _IOR(2, 0x04, struct floppy_struct32) |
| 1663 | #define FDSETDRVPRM32 _IOW(2, 0x90, struct floppy_drive_params32) |
| 1664 | #define FDGETDRVPRM32 _IOR(2, 0x11, struct floppy_drive_params32) |
| 1665 | #define FDGETDRVSTAT32 _IOR(2, 0x12, struct floppy_drive_struct32) |
| 1666 | #define FDPOLLDRVSTAT32 _IOR(2, 0x13, struct floppy_drive_struct32) |
| 1667 | #define FDGETFDCSTAT32 _IOR(2, 0x15, struct floppy_fdc_state32) |
| 1668 | #define FDWERRORGET32 _IOR(2, 0x17, struct floppy_write_errors32) |
| 1669 | |
| 1670 | static struct { |
| 1671 | unsigned int cmd32; |
| 1672 | unsigned int cmd; |
| 1673 | } fd_ioctl_trans_table[] = { |
| 1674 | { FDSETPRM32, FDSETPRM }, |
| 1675 | { FDDEFPRM32, FDDEFPRM }, |
| 1676 | { FDGETPRM32, FDGETPRM }, |
| 1677 | { FDSETDRVPRM32, FDSETDRVPRM }, |
| 1678 | { FDGETDRVPRM32, FDGETDRVPRM }, |
| 1679 | { FDGETDRVSTAT32, FDGETDRVSTAT }, |
| 1680 | { FDPOLLDRVSTAT32, FDPOLLDRVSTAT }, |
| 1681 | { FDGETFDCSTAT32, FDGETFDCSTAT }, |
| 1682 | { FDWERRORGET32, FDWERRORGET } |
| 1683 | }; |
| 1684 | |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 1685 | #define NR_FD_IOCTL_TRANS ARRAY_SIZE(fd_ioctl_trans_table) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1686 | |
| 1687 | static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 1688 | { |
| 1689 | mm_segment_t old_fs = get_fs(); |
| 1690 | void *karg = NULL; |
| 1691 | unsigned int kcmd = 0; |
| 1692 | int i, err; |
| 1693 | |
| 1694 | for (i = 0; i < NR_FD_IOCTL_TRANS; i++) |
| 1695 | if (cmd == fd_ioctl_trans_table[i].cmd32) { |
| 1696 | kcmd = fd_ioctl_trans_table[i].cmd; |
| 1697 | break; |
| 1698 | } |
| 1699 | if (!kcmd) |
| 1700 | return -EINVAL; |
| 1701 | |
| 1702 | switch (cmd) { |
| 1703 | case FDSETPRM32: |
| 1704 | case FDDEFPRM32: |
| 1705 | case FDGETPRM32: |
| 1706 | { |
| 1707 | compat_uptr_t name; |
| 1708 | struct floppy_struct32 __user *uf; |
| 1709 | struct floppy_struct *f; |
| 1710 | |
| 1711 | uf = compat_ptr(arg); |
| 1712 | f = karg = kmalloc(sizeof(struct floppy_struct), GFP_KERNEL); |
| 1713 | if (!karg) |
| 1714 | return -ENOMEM; |
| 1715 | if (cmd == FDGETPRM32) |
| 1716 | break; |
| 1717 | err = __get_user(f->size, &uf->size); |
| 1718 | err |= __get_user(f->sect, &uf->sect); |
| 1719 | err |= __get_user(f->head, &uf->head); |
| 1720 | err |= __get_user(f->track, &uf->track); |
| 1721 | err |= __get_user(f->stretch, &uf->stretch); |
| 1722 | err |= __get_user(f->gap, &uf->gap); |
| 1723 | err |= __get_user(f->rate, &uf->rate); |
| 1724 | err |= __get_user(f->spec1, &uf->spec1); |
| 1725 | err |= __get_user(f->fmt_gap, &uf->fmt_gap); |
| 1726 | err |= __get_user(name, &uf->name); |
| 1727 | f->name = compat_ptr(name); |
| 1728 | if (err) { |
| 1729 | err = -EFAULT; |
| 1730 | goto out; |
| 1731 | } |
| 1732 | break; |
| 1733 | } |
| 1734 | case FDSETDRVPRM32: |
| 1735 | case FDGETDRVPRM32: |
| 1736 | { |
| 1737 | struct floppy_drive_params32 __user *uf; |
| 1738 | struct floppy_drive_params *f; |
| 1739 | |
| 1740 | uf = compat_ptr(arg); |
| 1741 | f = karg = kmalloc(sizeof(struct floppy_drive_params), GFP_KERNEL); |
| 1742 | if (!karg) |
| 1743 | return -ENOMEM; |
| 1744 | if (cmd == FDGETDRVPRM32) |
| 1745 | break; |
| 1746 | err = __get_user(f->cmos, &uf->cmos); |
| 1747 | err |= __get_user(f->max_dtr, &uf->max_dtr); |
| 1748 | err |= __get_user(f->hlt, &uf->hlt); |
| 1749 | err |= __get_user(f->hut, &uf->hut); |
| 1750 | err |= __get_user(f->srt, &uf->srt); |
| 1751 | err |= __get_user(f->spinup, &uf->spinup); |
| 1752 | err |= __get_user(f->spindown, &uf->spindown); |
| 1753 | err |= __get_user(f->spindown_offset, &uf->spindown_offset); |
| 1754 | err |= __get_user(f->select_delay, &uf->select_delay); |
| 1755 | err |= __get_user(f->rps, &uf->rps); |
| 1756 | err |= __get_user(f->tracks, &uf->tracks); |
| 1757 | err |= __get_user(f->timeout, &uf->timeout); |
| 1758 | err |= __get_user(f->interleave_sect, &uf->interleave_sect); |
| 1759 | err |= __copy_from_user(&f->max_errors, &uf->max_errors, sizeof(f->max_errors)); |
| 1760 | err |= __get_user(f->flags, &uf->flags); |
| 1761 | err |= __get_user(f->read_track, &uf->read_track); |
| 1762 | err |= __copy_from_user(f->autodetect, uf->autodetect, sizeof(f->autodetect)); |
| 1763 | err |= __get_user(f->checkfreq, &uf->checkfreq); |
| 1764 | err |= __get_user(f->native_format, &uf->native_format); |
| 1765 | if (err) { |
| 1766 | err = -EFAULT; |
| 1767 | goto out; |
| 1768 | } |
| 1769 | break; |
| 1770 | } |
| 1771 | case FDGETDRVSTAT32: |
| 1772 | case FDPOLLDRVSTAT32: |
| 1773 | karg = kmalloc(sizeof(struct floppy_drive_struct), GFP_KERNEL); |
| 1774 | if (!karg) |
| 1775 | return -ENOMEM; |
| 1776 | break; |
| 1777 | case FDGETFDCSTAT32: |
| 1778 | karg = kmalloc(sizeof(struct floppy_fdc_state), GFP_KERNEL); |
| 1779 | if (!karg) |
| 1780 | return -ENOMEM; |
| 1781 | break; |
| 1782 | case FDWERRORGET32: |
| 1783 | karg = kmalloc(sizeof(struct floppy_write_errors), GFP_KERNEL); |
| 1784 | if (!karg) |
| 1785 | return -ENOMEM; |
| 1786 | break; |
| 1787 | default: |
| 1788 | return -EINVAL; |
| 1789 | } |
| 1790 | set_fs (KERNEL_DS); |
| 1791 | err = sys_ioctl (fd, kcmd, (unsigned long)karg); |
| 1792 | set_fs (old_fs); |
| 1793 | if (err) |
| 1794 | goto out; |
| 1795 | switch (cmd) { |
| 1796 | case FDGETPRM32: |
| 1797 | { |
| 1798 | struct floppy_struct *f = karg; |
| 1799 | struct floppy_struct32 __user *uf = compat_ptr(arg); |
| 1800 | |
| 1801 | err = __put_user(f->size, &uf->size); |
| 1802 | err |= __put_user(f->sect, &uf->sect); |
| 1803 | err |= __put_user(f->head, &uf->head); |
| 1804 | err |= __put_user(f->track, &uf->track); |
| 1805 | err |= __put_user(f->stretch, &uf->stretch); |
| 1806 | err |= __put_user(f->gap, &uf->gap); |
| 1807 | err |= __put_user(f->rate, &uf->rate); |
| 1808 | err |= __put_user(f->spec1, &uf->spec1); |
| 1809 | err |= __put_user(f->fmt_gap, &uf->fmt_gap); |
| 1810 | err |= __put_user((u64)f->name, (compat_caddr_t __user *)&uf->name); |
| 1811 | break; |
| 1812 | } |
| 1813 | case FDGETDRVPRM32: |
| 1814 | { |
| 1815 | struct floppy_drive_params32 __user *uf; |
| 1816 | struct floppy_drive_params *f = karg; |
| 1817 | |
| 1818 | uf = compat_ptr(arg); |
| 1819 | err = __put_user(f->cmos, &uf->cmos); |
| 1820 | err |= __put_user(f->max_dtr, &uf->max_dtr); |
| 1821 | err |= __put_user(f->hlt, &uf->hlt); |
| 1822 | err |= __put_user(f->hut, &uf->hut); |
| 1823 | err |= __put_user(f->srt, &uf->srt); |
| 1824 | err |= __put_user(f->spinup, &uf->spinup); |
| 1825 | err |= __put_user(f->spindown, &uf->spindown); |
| 1826 | err |= __put_user(f->spindown_offset, &uf->spindown_offset); |
| 1827 | err |= __put_user(f->select_delay, &uf->select_delay); |
| 1828 | err |= __put_user(f->rps, &uf->rps); |
| 1829 | err |= __put_user(f->tracks, &uf->tracks); |
| 1830 | err |= __put_user(f->timeout, &uf->timeout); |
| 1831 | err |= __put_user(f->interleave_sect, &uf->interleave_sect); |
| 1832 | err |= __copy_to_user(&uf->max_errors, &f->max_errors, sizeof(f->max_errors)); |
| 1833 | err |= __put_user(f->flags, &uf->flags); |
| 1834 | err |= __put_user(f->read_track, &uf->read_track); |
| 1835 | err |= __copy_to_user(uf->autodetect, f->autodetect, sizeof(f->autodetect)); |
| 1836 | err |= __put_user(f->checkfreq, &uf->checkfreq); |
| 1837 | err |= __put_user(f->native_format, &uf->native_format); |
| 1838 | break; |
| 1839 | } |
| 1840 | case FDGETDRVSTAT32: |
| 1841 | case FDPOLLDRVSTAT32: |
| 1842 | { |
| 1843 | struct floppy_drive_struct32 __user *uf; |
| 1844 | struct floppy_drive_struct *f = karg; |
| 1845 | |
| 1846 | uf = compat_ptr(arg); |
| 1847 | err = __put_user(f->flags, &uf->flags); |
| 1848 | err |= __put_user(f->spinup_date, &uf->spinup_date); |
| 1849 | err |= __put_user(f->select_date, &uf->select_date); |
| 1850 | err |= __put_user(f->first_read_date, &uf->first_read_date); |
| 1851 | err |= __put_user(f->probed_format, &uf->probed_format); |
| 1852 | err |= __put_user(f->track, &uf->track); |
| 1853 | err |= __put_user(f->maxblock, &uf->maxblock); |
| 1854 | err |= __put_user(f->maxtrack, &uf->maxtrack); |
| 1855 | err |= __put_user(f->generation, &uf->generation); |
| 1856 | err |= __put_user(f->keep_data, &uf->keep_data); |
| 1857 | err |= __put_user(f->fd_ref, &uf->fd_ref); |
| 1858 | err |= __put_user(f->fd_device, &uf->fd_device); |
| 1859 | err |= __put_user(f->last_checked, &uf->last_checked); |
| 1860 | err |= __put_user((u64)f->dmabuf, &uf->dmabuf); |
| 1861 | err |= __put_user((u64)f->bufblocks, &uf->bufblocks); |
| 1862 | break; |
| 1863 | } |
| 1864 | case FDGETFDCSTAT32: |
| 1865 | { |
| 1866 | struct floppy_fdc_state32 __user *uf; |
| 1867 | struct floppy_fdc_state *f = karg; |
| 1868 | |
| 1869 | uf = compat_ptr(arg); |
| 1870 | err = __put_user(f->spec1, &uf->spec1); |
| 1871 | err |= __put_user(f->spec2, &uf->spec2); |
| 1872 | err |= __put_user(f->dtr, &uf->dtr); |
| 1873 | err |= __put_user(f->version, &uf->version); |
| 1874 | err |= __put_user(f->dor, &uf->dor); |
| 1875 | err |= __put_user(f->address, &uf->address); |
| 1876 | err |= __copy_to_user((char __user *)&uf->address + sizeof(uf->address), |
| 1877 | (char *)&f->address + sizeof(f->address), sizeof(int)); |
| 1878 | err |= __put_user(f->driver_version, &uf->driver_version); |
| 1879 | err |= __copy_to_user(uf->track, f->track, sizeof(f->track)); |
| 1880 | break; |
| 1881 | } |
| 1882 | case FDWERRORGET32: |
| 1883 | { |
| 1884 | struct floppy_write_errors32 __user *uf; |
| 1885 | struct floppy_write_errors *f = karg; |
| 1886 | |
| 1887 | uf = compat_ptr(arg); |
| 1888 | err = __put_user(f->write_errors, &uf->write_errors); |
| 1889 | err |= __put_user(f->first_error_sector, &uf->first_error_sector); |
| 1890 | err |= __put_user(f->first_error_generation, &uf->first_error_generation); |
| 1891 | err |= __put_user(f->last_error_sector, &uf->last_error_sector); |
| 1892 | err |= __put_user(f->last_error_generation, &uf->last_error_generation); |
| 1893 | err |= __put_user(f->badness, &uf->badness); |
| 1894 | break; |
| 1895 | } |
| 1896 | default: |
| 1897 | break; |
| 1898 | } |
| 1899 | if (err) |
| 1900 | err = -EFAULT; |
| 1901 | |
Jesper Juhl | f99d49a | 2005-11-07 01:01:34 -0800 | [diff] [blame] | 1902 | out: |
| 1903 | kfree(karg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1904 | return err; |
| 1905 | } |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 1906 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1907 | |
| 1908 | struct mtd_oob_buf32 { |
| 1909 | u_int32_t start; |
| 1910 | u_int32_t length; |
| 1911 | compat_caddr_t ptr; /* unsigned char* */ |
| 1912 | }; |
| 1913 | |
| 1914 | #define MEMWRITEOOB32 _IOWR('M',3,struct mtd_oob_buf32) |
| 1915 | #define MEMREADOOB32 _IOWR('M',4,struct mtd_oob_buf32) |
| 1916 | |
| 1917 | static int mtd_rw_oob(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 1918 | { |
| 1919 | struct mtd_oob_buf __user *buf = compat_alloc_user_space(sizeof(*buf)); |
| 1920 | struct mtd_oob_buf32 __user *buf32 = compat_ptr(arg); |
| 1921 | u32 data; |
| 1922 | char __user *datap; |
| 1923 | unsigned int real_cmd; |
| 1924 | int err; |
| 1925 | |
| 1926 | real_cmd = (cmd == MEMREADOOB32) ? |
| 1927 | MEMREADOOB : MEMWRITEOOB; |
| 1928 | |
| 1929 | if (copy_in_user(&buf->start, &buf32->start, |
| 1930 | 2 * sizeof(u32)) || |
| 1931 | get_user(data, &buf32->ptr)) |
| 1932 | return -EFAULT; |
| 1933 | datap = compat_ptr(data); |
| 1934 | if (put_user(datap, &buf->ptr)) |
| 1935 | return -EFAULT; |
| 1936 | |
| 1937 | err = sys_ioctl(fd, real_cmd, (unsigned long) buf); |
| 1938 | |
| 1939 | if (!err) { |
| 1940 | if (copy_in_user(&buf32->start, &buf->start, |
| 1941 | 2 * sizeof(u32))) |
| 1942 | err = -EFAULT; |
| 1943 | } |
| 1944 | |
| 1945 | return err; |
| 1946 | } |
| 1947 | |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 1948 | #ifdef CONFIG_BLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1949 | struct raw32_config_request |
| 1950 | { |
| 1951 | compat_int_t raw_minor; |
| 1952 | __u64 block_major; |
| 1953 | __u64 block_minor; |
| 1954 | } __attribute__((packed)); |
| 1955 | |
| 1956 | static int get_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req) |
| 1957 | { |
| 1958 | int ret; |
| 1959 | |
| 1960 | if (!access_ok(VERIFY_READ, user_req, sizeof(struct raw32_config_request))) |
| 1961 | return -EFAULT; |
| 1962 | |
| 1963 | ret = __get_user(req->raw_minor, &user_req->raw_minor); |
| 1964 | ret |= __get_user(req->block_major, &user_req->block_major); |
| 1965 | ret |= __get_user(req->block_minor, &user_req->block_minor); |
| 1966 | |
| 1967 | return ret ? -EFAULT : 0; |
| 1968 | } |
| 1969 | |
| 1970 | static int set_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req) |
| 1971 | { |
| 1972 | int ret; |
| 1973 | |
| 1974 | if (!access_ok(VERIFY_WRITE, user_req, sizeof(struct raw32_config_request))) |
| 1975 | return -EFAULT; |
| 1976 | |
| 1977 | ret = __put_user(req->raw_minor, &user_req->raw_minor); |
| 1978 | ret |= __put_user(req->block_major, &user_req->block_major); |
| 1979 | ret |= __put_user(req->block_minor, &user_req->block_minor); |
| 1980 | |
| 1981 | return ret ? -EFAULT : 0; |
| 1982 | } |
| 1983 | |
| 1984 | static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg) |
| 1985 | { |
| 1986 | int ret; |
| 1987 | |
| 1988 | switch (cmd) { |
| 1989 | case RAW_SETBIND: |
| 1990 | case RAW_GETBIND: { |
| 1991 | struct raw_config_request req; |
| 1992 | struct raw32_config_request __user *user_req = compat_ptr(arg); |
| 1993 | mm_segment_t oldfs = get_fs(); |
| 1994 | |
| 1995 | if ((ret = get_raw32_request(&req, user_req))) |
| 1996 | return ret; |
| 1997 | |
| 1998 | set_fs(KERNEL_DS); |
| 1999 | ret = sys_ioctl(fd,cmd,(unsigned long)&req); |
| 2000 | set_fs(oldfs); |
| 2001 | |
| 2002 | if ((!ret) && (cmd == RAW_GETBIND)) { |
| 2003 | ret = set_raw32_request(&req, user_req); |
| 2004 | } |
| 2005 | break; |
| 2006 | } |
| 2007 | default: |
| 2008 | ret = sys_ioctl(fd, cmd, arg); |
| 2009 | break; |
| 2010 | } |
| 2011 | return ret; |
| 2012 | } |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 2013 | #endif /* CONFIG_BLOCK */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2014 | |
| 2015 | struct serial_struct32 { |
| 2016 | compat_int_t type; |
| 2017 | compat_int_t line; |
| 2018 | compat_uint_t port; |
| 2019 | compat_int_t irq; |
| 2020 | compat_int_t flags; |
| 2021 | compat_int_t xmit_fifo_size; |
| 2022 | compat_int_t custom_divisor; |
| 2023 | compat_int_t baud_base; |
| 2024 | unsigned short close_delay; |
| 2025 | char io_type; |
| 2026 | char reserved_char[1]; |
| 2027 | compat_int_t hub6; |
| 2028 | unsigned short closing_wait; /* time to wait before closing */ |
| 2029 | unsigned short closing_wait2; /* no longer used... */ |
| 2030 | compat_uint_t iomem_base; |
| 2031 | unsigned short iomem_reg_shift; |
| 2032 | unsigned int port_high; |
| 2033 | /* compat_ulong_t iomap_base FIXME */ |
| 2034 | compat_int_t reserved[1]; |
| 2035 | }; |
| 2036 | |
| 2037 | static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg) |
| 2038 | { |
| 2039 | typedef struct serial_struct SS; |
| 2040 | typedef struct serial_struct32 SS32; |
| 2041 | struct serial_struct32 __user *ss32 = compat_ptr(arg); |
| 2042 | int err; |
| 2043 | struct serial_struct ss; |
| 2044 | mm_segment_t oldseg = get_fs(); |
| 2045 | __u32 udata; |
| 2046 | |
| 2047 | if (cmd == TIOCSSERIAL) { |
| 2048 | if (!access_ok(VERIFY_READ, ss32, sizeof(SS32))) |
| 2049 | return -EFAULT; |
| 2050 | if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base))) |
| 2051 | return -EFAULT; |
| 2052 | __get_user(udata, &ss32->iomem_base); |
| 2053 | ss.iomem_base = compat_ptr(udata); |
| 2054 | __get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift); |
| 2055 | __get_user(ss.port_high, &ss32->port_high); |
| 2056 | ss.iomap_base = 0UL; |
| 2057 | } |
| 2058 | set_fs(KERNEL_DS); |
| 2059 | err = sys_ioctl(fd,cmd,(unsigned long)(&ss)); |
| 2060 | set_fs(oldseg); |
| 2061 | if (cmd == TIOCGSERIAL && err >= 0) { |
| 2062 | if (!access_ok(VERIFY_WRITE, ss32, sizeof(SS32))) |
| 2063 | return -EFAULT; |
| 2064 | if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base))) |
| 2065 | return -EFAULT; |
| 2066 | __put_user((unsigned long)ss.iomem_base >> 32 ? |
| 2067 | 0xffffffff : (unsigned)(unsigned long)ss.iomem_base, |
| 2068 | &ss32->iomem_base); |
| 2069 | __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift); |
| 2070 | __put_user(ss.port_high, &ss32->port_high); |
| 2071 | |
| 2072 | } |
| 2073 | return err; |
| 2074 | } |
| 2075 | |
| 2076 | struct usbdevfs_ctrltransfer32 { |
| 2077 | u8 bRequestType; |
| 2078 | u8 bRequest; |
| 2079 | u16 wValue; |
| 2080 | u16 wIndex; |
| 2081 | u16 wLength; |
| 2082 | u32 timeout; /* in milliseconds */ |
| 2083 | compat_caddr_t data; |
| 2084 | }; |
| 2085 | |
| 2086 | #define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32) |
| 2087 | |
| 2088 | static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 2089 | { |
| 2090 | struct usbdevfs_ctrltransfer32 __user *p32 = compat_ptr(arg); |
| 2091 | struct usbdevfs_ctrltransfer __user *p; |
| 2092 | __u32 udata; |
| 2093 | p = compat_alloc_user_space(sizeof(*p)); |
| 2094 | if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) || |
| 2095 | get_user(udata, &p32->data) || |
| 2096 | put_user(compat_ptr(udata), &p->data)) |
| 2097 | return -EFAULT; |
| 2098 | return sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)p); |
| 2099 | } |
| 2100 | |
| 2101 | |
| 2102 | struct usbdevfs_bulktransfer32 { |
| 2103 | compat_uint_t ep; |
| 2104 | compat_uint_t len; |
| 2105 | compat_uint_t timeout; /* in milliseconds */ |
| 2106 | compat_caddr_t data; |
| 2107 | }; |
| 2108 | |
| 2109 | #define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32) |
| 2110 | |
| 2111 | static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 2112 | { |
| 2113 | struct usbdevfs_bulktransfer32 __user *p32 = compat_ptr(arg); |
| 2114 | struct usbdevfs_bulktransfer __user *p; |
| 2115 | compat_uint_t n; |
| 2116 | compat_caddr_t addr; |
| 2117 | |
| 2118 | p = compat_alloc_user_space(sizeof(*p)); |
| 2119 | |
| 2120 | if (get_user(n, &p32->ep) || put_user(n, &p->ep) || |
| 2121 | get_user(n, &p32->len) || put_user(n, &p->len) || |
| 2122 | get_user(n, &p32->timeout) || put_user(n, &p->timeout) || |
| 2123 | get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data)) |
| 2124 | return -EFAULT; |
| 2125 | |
| 2126 | return sys_ioctl(fd, USBDEVFS_BULK, (unsigned long)p); |
| 2127 | } |
| 2128 | |
| 2129 | |
| 2130 | /* |
| 2131 | * USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY |
| 2132 | * are handled in usbdevfs core. -Christopher Li |
| 2133 | */ |
| 2134 | |
| 2135 | struct usbdevfs_disconnectsignal32 { |
| 2136 | compat_int_t signr; |
| 2137 | compat_caddr_t context; |
| 2138 | }; |
| 2139 | |
| 2140 | #define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32) |
| 2141 | |
| 2142 | static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 2143 | { |
| 2144 | struct usbdevfs_disconnectsignal kdis; |
| 2145 | struct usbdevfs_disconnectsignal32 __user *udis; |
| 2146 | mm_segment_t old_fs; |
| 2147 | u32 uctx; |
| 2148 | int err; |
| 2149 | |
| 2150 | udis = compat_ptr(arg); |
| 2151 | |
| 2152 | if (get_user(kdis.signr, &udis->signr) || |
| 2153 | __get_user(uctx, &udis->context)) |
| 2154 | return -EFAULT; |
| 2155 | |
| 2156 | kdis.context = compat_ptr(uctx); |
| 2157 | |
| 2158 | old_fs = get_fs(); |
| 2159 | set_fs(KERNEL_DS); |
| 2160 | err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis); |
| 2161 | set_fs(old_fs); |
| 2162 | |
| 2163 | return err; |
| 2164 | } |
| 2165 | |
| 2166 | /* |
| 2167 | * I2C layer ioctls |
| 2168 | */ |
| 2169 | |
| 2170 | struct i2c_msg32 { |
| 2171 | u16 addr; |
| 2172 | u16 flags; |
| 2173 | u16 len; |
| 2174 | compat_caddr_t buf; |
| 2175 | }; |
| 2176 | |
| 2177 | struct i2c_rdwr_ioctl_data32 { |
| 2178 | compat_caddr_t msgs; /* struct i2c_msg __user *msgs */ |
| 2179 | u32 nmsgs; |
| 2180 | }; |
| 2181 | |
| 2182 | struct i2c_smbus_ioctl_data32 { |
| 2183 | u8 read_write; |
| 2184 | u8 command; |
| 2185 | u32 size; |
| 2186 | compat_caddr_t data; /* union i2c_smbus_data *data */ |
| 2187 | }; |
| 2188 | |
| 2189 | struct i2c_rdwr_aligned { |
| 2190 | struct i2c_rdwr_ioctl_data cmd; |
| 2191 | struct i2c_msg msgs[0]; |
| 2192 | }; |
| 2193 | |
| 2194 | static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 2195 | { |
| 2196 | struct i2c_rdwr_ioctl_data32 __user *udata = compat_ptr(arg); |
| 2197 | struct i2c_rdwr_aligned __user *tdata; |
| 2198 | struct i2c_msg __user *tmsgs; |
| 2199 | struct i2c_msg32 __user *umsgs; |
| 2200 | compat_caddr_t datap; |
| 2201 | int nmsgs, i; |
| 2202 | |
| 2203 | if (get_user(nmsgs, &udata->nmsgs)) |
| 2204 | return -EFAULT; |
| 2205 | if (nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) |
| 2206 | return -EINVAL; |
| 2207 | |
| 2208 | if (get_user(datap, &udata->msgs)) |
| 2209 | return -EFAULT; |
| 2210 | umsgs = compat_ptr(datap); |
| 2211 | |
| 2212 | tdata = compat_alloc_user_space(sizeof(*tdata) + |
| 2213 | nmsgs * sizeof(struct i2c_msg)); |
| 2214 | tmsgs = &tdata->msgs[0]; |
| 2215 | |
| 2216 | if (put_user(nmsgs, &tdata->cmd.nmsgs) || |
| 2217 | put_user(tmsgs, &tdata->cmd.msgs)) |
| 2218 | return -EFAULT; |
| 2219 | |
| 2220 | for (i = 0; i < nmsgs; i++) { |
| 2221 | if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16))) |
| 2222 | return -EFAULT; |
| 2223 | if (get_user(datap, &umsgs[i].buf) || |
| 2224 | put_user(compat_ptr(datap), &tmsgs[i].buf)) |
| 2225 | return -EFAULT; |
| 2226 | } |
| 2227 | return sys_ioctl(fd, cmd, (unsigned long)tdata); |
| 2228 | } |
| 2229 | |
| 2230 | static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 2231 | { |
| 2232 | struct i2c_smbus_ioctl_data __user *tdata; |
| 2233 | struct i2c_smbus_ioctl_data32 __user *udata; |
| 2234 | compat_caddr_t datap; |
| 2235 | |
| 2236 | tdata = compat_alloc_user_space(sizeof(*tdata)); |
| 2237 | if (tdata == NULL) |
| 2238 | return -ENOMEM; |
| 2239 | if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata))) |
| 2240 | return -EFAULT; |
| 2241 | |
| 2242 | udata = compat_ptr(arg); |
| 2243 | if (!access_ok(VERIFY_READ, udata, sizeof(*udata))) |
| 2244 | return -EFAULT; |
| 2245 | |
| 2246 | if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8))) |
| 2247 | return -EFAULT; |
| 2248 | if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32))) |
| 2249 | return -EFAULT; |
| 2250 | if (__get_user(datap, &udata->data) || |
| 2251 | __put_user(compat_ptr(datap), &tdata->data)) |
| 2252 | return -EFAULT; |
| 2253 | |
| 2254 | return sys_ioctl(fd, cmd, (unsigned long)tdata); |
| 2255 | } |
| 2256 | |
| 2257 | struct compat_iw_point { |
| 2258 | compat_caddr_t pointer; |
| 2259 | __u16 length; |
| 2260 | __u16 flags; |
| 2261 | }; |
| 2262 | |
| 2263 | static int do_wireless_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 2264 | { |
| 2265 | struct iwreq __user *iwr; |
| 2266 | struct iwreq __user *iwr_u; |
| 2267 | struct iw_point __user *iwp; |
| 2268 | struct compat_iw_point __user *iwp_u; |
| 2269 | compat_caddr_t pointer; |
| 2270 | __u16 length, flags; |
| 2271 | |
| 2272 | iwr_u = compat_ptr(arg); |
| 2273 | iwp_u = (struct compat_iw_point __user *) &iwr_u->u.data; |
| 2274 | iwr = compat_alloc_user_space(sizeof(*iwr)); |
| 2275 | if (iwr == NULL) |
| 2276 | return -ENOMEM; |
| 2277 | |
| 2278 | iwp = &iwr->u.data; |
| 2279 | |
| 2280 | if (!access_ok(VERIFY_WRITE, iwr, sizeof(*iwr))) |
| 2281 | return -EFAULT; |
| 2282 | |
| 2283 | if (__copy_in_user(&iwr->ifr_ifrn.ifrn_name[0], |
| 2284 | &iwr_u->ifr_ifrn.ifrn_name[0], |
| 2285 | sizeof(iwr->ifr_ifrn.ifrn_name))) |
| 2286 | return -EFAULT; |
| 2287 | |
| 2288 | if (__get_user(pointer, &iwp_u->pointer) || |
| 2289 | __get_user(length, &iwp_u->length) || |
| 2290 | __get_user(flags, &iwp_u->flags)) |
| 2291 | return -EFAULT; |
| 2292 | |
| 2293 | if (__put_user(compat_ptr(pointer), &iwp->pointer) || |
| 2294 | __put_user(length, &iwp->length) || |
| 2295 | __put_user(flags, &iwp->flags)) |
| 2296 | return -EFAULT; |
| 2297 | |
| 2298 | return sys_ioctl(fd, cmd, (unsigned long) iwr); |
| 2299 | } |
| 2300 | |
| 2301 | /* Since old style bridge ioctl's endup using SIOCDEVPRIVATE |
| 2302 | * for some operations; this forces use of the newer bridge-utils that |
| 2303 | * use compatiable ioctls |
| 2304 | */ |
| 2305 | static int old_bridge_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 2306 | { |
| 2307 | u32 tmp; |
| 2308 | |
| 2309 | if (get_user(tmp, (u32 __user *) arg)) |
| 2310 | return -EFAULT; |
| 2311 | if (tmp == BRCTL_GET_VERSION) |
| 2312 | return BRCTL_VERSION + 1; |
| 2313 | return -EINVAL; |
| 2314 | } |
| 2315 | |
Christoph Hellwig | ec3cad9 | 2006-01-09 20:52:11 -0800 | [diff] [blame] | 2316 | #define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t) |
| 2317 | #define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t) |
| 2318 | #define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t) |
| 2319 | #define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t) |
| 2320 | |
| 2321 | static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg) |
| 2322 | { |
| 2323 | mm_segment_t oldfs = get_fs(); |
| 2324 | compat_ulong_t val32; |
| 2325 | unsigned long kval; |
| 2326 | int ret; |
| 2327 | |
| 2328 | switch (cmd) { |
| 2329 | case RTC_IRQP_READ32: |
| 2330 | case RTC_EPOCH_READ32: |
| 2331 | set_fs(KERNEL_DS); |
| 2332 | ret = sys_ioctl(fd, (cmd == RTC_IRQP_READ32) ? |
| 2333 | RTC_IRQP_READ : RTC_EPOCH_READ, |
| 2334 | (unsigned long)&kval); |
| 2335 | set_fs(oldfs); |
| 2336 | if (ret) |
| 2337 | return ret; |
| 2338 | val32 = kval; |
| 2339 | return put_user(val32, (unsigned int __user *)arg); |
| 2340 | case RTC_IRQP_SET32: |
Andi Kleen | fc5870f | 2006-02-26 04:18:55 +0100 | [diff] [blame] | 2341 | return sys_ioctl(fd, RTC_IRQP_SET, arg); |
Christoph Hellwig | ec3cad9 | 2006-01-09 20:52:11 -0800 | [diff] [blame] | 2342 | case RTC_EPOCH_SET32: |
Andi Kleen | fc5870f | 2006-02-26 04:18:55 +0100 | [diff] [blame] | 2343 | return sys_ioctl(fd, RTC_EPOCH_SET, arg); |
Christoph Hellwig | ec3cad9 | 2006-01-09 20:52:11 -0800 | [diff] [blame] | 2344 | default: |
| 2345 | /* unreached */ |
| 2346 | return -ENOIOCTLCMD; |
| 2347 | } |
| 2348 | } |
| 2349 | |
Andi Kleen | c6b44d1 | 2006-01-12 01:05:26 -0800 | [diff] [blame] | 2350 | static int |
| 2351 | lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
| 2352 | { |
Al Viro | 6b2b4e5 | 2006-02-01 06:33:33 -0500 | [diff] [blame] | 2353 | struct compat_timeval __user *tc = (struct compat_timeval __user *)arg; |
| 2354 | struct timeval __user *tn = compat_alloc_user_space(sizeof(struct timeval)); |
Andi Kleen | c6b44d1 | 2006-01-12 01:05:26 -0800 | [diff] [blame] | 2355 | struct timeval ts; |
| 2356 | if (get_user(ts.tv_sec, &tc->tv_sec) || |
| 2357 | get_user(ts.tv_usec, &tc->tv_usec) || |
| 2358 | put_user(ts.tv_sec, &tn->tv_sec) || |
| 2359 | put_user(ts.tv_usec, &tn->tv_usec)) |
| 2360 | return -EFAULT; |
| 2361 | return sys_ioctl(fd, cmd, (unsigned long)tn); |
| 2362 | } |
| 2363 | |
Christoph Hellwig | e6a6d2e | 2006-01-09 20:52:14 -0800 | [diff] [blame] | 2364 | #define HANDLE_IOCTL(cmd,handler) \ |
| 2365 | { (cmd), (ioctl_trans_handler_t)(handler) }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2366 | |
Christoph Hellwig | e6a6d2e | 2006-01-09 20:52:14 -0800 | [diff] [blame] | 2367 | /* pointer to compatible structure or no argument */ |
| 2368 | #define COMPATIBLE_IOCTL(cmd) \ |
| 2369 | { (cmd), do_ioctl32_pointer }, |
| 2370 | |
| 2371 | /* argument is an unsigned long integer, not a pointer */ |
| 2372 | #define ULONG_IOCTL(cmd) \ |
| 2373 | { (cmd), (ioctl_trans_handler_t)sys_ioctl }, |
| 2374 | |
| 2375 | |
| 2376 | struct ioctl_trans ioctl_start[] = { |
| 2377 | #include <linux/compat_ioctl.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2378 | HANDLE_IOCTL(MEMREADOOB32, mtd_rw_oob) |
| 2379 | HANDLE_IOCTL(MEMWRITEOOB32, mtd_rw_oob) |
| 2380 | #ifdef CONFIG_NET |
| 2381 | HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32) |
| 2382 | HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf) |
| 2383 | HANDLE_IOCTL(SIOCGIFFLAGS, dev_ifsioc) |
| 2384 | HANDLE_IOCTL(SIOCSIFFLAGS, dev_ifsioc) |
| 2385 | HANDLE_IOCTL(SIOCGIFMETRIC, dev_ifsioc) |
| 2386 | HANDLE_IOCTL(SIOCSIFMETRIC, dev_ifsioc) |
| 2387 | HANDLE_IOCTL(SIOCGIFMTU, dev_ifsioc) |
| 2388 | HANDLE_IOCTL(SIOCSIFMTU, dev_ifsioc) |
| 2389 | HANDLE_IOCTL(SIOCGIFMEM, dev_ifsioc) |
| 2390 | HANDLE_IOCTL(SIOCSIFMEM, dev_ifsioc) |
| 2391 | HANDLE_IOCTL(SIOCGIFHWADDR, dev_ifsioc) |
| 2392 | HANDLE_IOCTL(SIOCSIFHWADDR, dev_ifsioc) |
| 2393 | HANDLE_IOCTL(SIOCADDMULTI, dev_ifsioc) |
| 2394 | HANDLE_IOCTL(SIOCDELMULTI, dev_ifsioc) |
| 2395 | HANDLE_IOCTL(SIOCGIFINDEX, dev_ifsioc) |
| 2396 | HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc) |
| 2397 | HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc) |
| 2398 | HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc) |
| 2399 | HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc) |
| 2400 | |
| 2401 | /* ioctls used by appletalk ddp.c */ |
| 2402 | HANDLE_IOCTL(SIOCATALKDIFADDR, dev_ifsioc) |
| 2403 | HANDLE_IOCTL(SIOCDIFADDR, dev_ifsioc) |
| 2404 | HANDLE_IOCTL(SIOCSARP, dev_ifsioc) |
| 2405 | HANDLE_IOCTL(SIOCDARP, dev_ifsioc) |
| 2406 | |
| 2407 | HANDLE_IOCTL(SIOCGIFBRDADDR, dev_ifsioc) |
| 2408 | HANDLE_IOCTL(SIOCSIFBRDADDR, dev_ifsioc) |
| 2409 | HANDLE_IOCTL(SIOCGIFDSTADDR, dev_ifsioc) |
| 2410 | HANDLE_IOCTL(SIOCSIFDSTADDR, dev_ifsioc) |
| 2411 | HANDLE_IOCTL(SIOCGIFNETMASK, dev_ifsioc) |
| 2412 | HANDLE_IOCTL(SIOCSIFNETMASK, dev_ifsioc) |
| 2413 | HANDLE_IOCTL(SIOCSIFPFLAGS, dev_ifsioc) |
| 2414 | HANDLE_IOCTL(SIOCGIFPFLAGS, dev_ifsioc) |
| 2415 | HANDLE_IOCTL(SIOCGIFTXQLEN, dev_ifsioc) |
| 2416 | HANDLE_IOCTL(SIOCSIFTXQLEN, dev_ifsioc) |
| 2417 | HANDLE_IOCTL(TUNSETIFF, dev_ifsioc) |
| 2418 | HANDLE_IOCTL(SIOCETHTOOL, ethtool_ioctl) |
| 2419 | HANDLE_IOCTL(SIOCBONDENSLAVE, bond_ioctl) |
| 2420 | HANDLE_IOCTL(SIOCBONDRELEASE, bond_ioctl) |
| 2421 | HANDLE_IOCTL(SIOCBONDSETHWADDR, bond_ioctl) |
| 2422 | HANDLE_IOCTL(SIOCBONDSLAVEINFOQUERY, bond_ioctl) |
| 2423 | HANDLE_IOCTL(SIOCBONDINFOQUERY, bond_ioctl) |
| 2424 | HANDLE_IOCTL(SIOCBONDCHANGEACTIVE, bond_ioctl) |
| 2425 | HANDLE_IOCTL(SIOCADDRT, routing_ioctl) |
| 2426 | HANDLE_IOCTL(SIOCDELRT, routing_ioctl) |
| 2427 | HANDLE_IOCTL(SIOCBRADDIF, dev_ifsioc) |
| 2428 | HANDLE_IOCTL(SIOCBRDELIF, dev_ifsioc) |
| 2429 | /* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */ |
| 2430 | HANDLE_IOCTL(SIOCRTMSG, ret_einval) |
| 2431 | HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp) |
| 2432 | #endif |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 2433 | #ifdef CONFIG_BLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2434 | HANDLE_IOCTL(HDIO_GETGEO, hdio_getgeo) |
| 2435 | HANDLE_IOCTL(BLKRAGET, w_long) |
| 2436 | HANDLE_IOCTL(BLKGETSIZE, w_long) |
| 2437 | HANDLE_IOCTL(0x1260, broken_blkgetsize) |
| 2438 | HANDLE_IOCTL(BLKFRAGET, w_long) |
| 2439 | HANDLE_IOCTL(BLKSECTGET, w_long) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2440 | HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2441 | HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans) |
| 2442 | HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans) |
| 2443 | HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans) |
| 2444 | HANDLE_IOCTL(HDIO_GET_32BIT, hdio_ioctl_trans) |
| 2445 | HANDLE_IOCTL(HDIO_GET_MULTCOUNT, hdio_ioctl_trans) |
| 2446 | HANDLE_IOCTL(HDIO_GET_NOWERR, hdio_ioctl_trans) |
| 2447 | HANDLE_IOCTL(HDIO_GET_NICE, hdio_ioctl_trans) |
| 2448 | HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans) |
| 2449 | HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans) |
| 2450 | HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans) |
| 2451 | HANDLE_IOCTL(FDSETDRVPRM32, fd_ioctl_trans) |
| 2452 | HANDLE_IOCTL(FDGETDRVPRM32, fd_ioctl_trans) |
| 2453 | HANDLE_IOCTL(FDGETDRVSTAT32, fd_ioctl_trans) |
| 2454 | HANDLE_IOCTL(FDPOLLDRVSTAT32, fd_ioctl_trans) |
| 2455 | HANDLE_IOCTL(FDGETFDCSTAT32, fd_ioctl_trans) |
| 2456 | HANDLE_IOCTL(FDWERRORGET32, fd_ioctl_trans) |
| 2457 | HANDLE_IOCTL(SG_IO,sg_ioctl_trans) |
Andi Kleen | 2966387 | 2006-01-11 22:44:03 +0100 | [diff] [blame] | 2458 | HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans) |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 2459 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2460 | HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans) |
| 2461 | HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans) |
| 2462 | HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans) |
| 2463 | HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans) |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 2464 | #ifdef CONFIG_BLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2465 | HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans) |
| 2466 | HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans) |
| 2467 | HANDLE_IOCTL(CDROMREADAUDIO, cdrom_ioctl_trans) |
| 2468 | HANDLE_IOCTL(CDROM_SEND_PACKET, cdrom_ioctl_trans) |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 2469 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2470 | #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int) |
| 2471 | HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout) |
| 2472 | #ifdef CONFIG_VT |
| 2473 | HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl) |
| 2474 | HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl) |
| 2475 | HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl) |
| 2476 | HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl) |
| 2477 | HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl) |
| 2478 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2479 | /* One SMB ioctl needs translations. */ |
| 2480 | #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t) |
| 2481 | HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid) |
| 2482 | HANDLE_IOCTL(ATM_GETLINKRATE32, do_atm_ioctl) |
| 2483 | HANDLE_IOCTL(ATM_GETNAMES32, do_atm_ioctl) |
| 2484 | HANDLE_IOCTL(ATM_GETTYPE32, do_atm_ioctl) |
| 2485 | HANDLE_IOCTL(ATM_GETESI32, do_atm_ioctl) |
| 2486 | HANDLE_IOCTL(ATM_GETADDR32, do_atm_ioctl) |
| 2487 | HANDLE_IOCTL(ATM_RSTADDR32, do_atm_ioctl) |
| 2488 | HANDLE_IOCTL(ATM_ADDADDR32, do_atm_ioctl) |
| 2489 | HANDLE_IOCTL(ATM_DELADDR32, do_atm_ioctl) |
| 2490 | HANDLE_IOCTL(ATM_GETCIRANGE32, do_atm_ioctl) |
| 2491 | HANDLE_IOCTL(ATM_SETCIRANGE32, do_atm_ioctl) |
| 2492 | HANDLE_IOCTL(ATM_SETESI32, do_atm_ioctl) |
| 2493 | HANDLE_IOCTL(ATM_SETESIF32, do_atm_ioctl) |
| 2494 | HANDLE_IOCTL(ATM_GETSTAT32, do_atm_ioctl) |
| 2495 | HANDLE_IOCTL(ATM_GETSTATZ32, do_atm_ioctl) |
| 2496 | HANDLE_IOCTL(ATM_GETLOOP32, do_atm_ioctl) |
| 2497 | HANDLE_IOCTL(ATM_SETLOOP32, do_atm_ioctl) |
| 2498 | HANDLE_IOCTL(ATM_QUERYLOOP32, do_atm_ioctl) |
| 2499 | HANDLE_IOCTL(SONET_GETSTAT, do_atm_ioctl) |
| 2500 | HANDLE_IOCTL(SONET_GETSTATZ, do_atm_ioctl) |
| 2501 | HANDLE_IOCTL(SONET_GETDIAG, do_atm_ioctl) |
| 2502 | HANDLE_IOCTL(SONET_SETDIAG, do_atm_ioctl) |
| 2503 | HANDLE_IOCTL(SONET_CLRDIAG, do_atm_ioctl) |
| 2504 | HANDLE_IOCTL(SONET_SETFRAMING, do_atm_ioctl) |
| 2505 | HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl) |
| 2506 | HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl) |
| 2507 | /* block stuff */ |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 2508 | #ifdef CONFIG_BLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2509 | HANDLE_IOCTL(BLKBSZGET_32, do_blkbszget) |
| 2510 | HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset) |
| 2511 | HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2512 | /* Raw devices */ |
| 2513 | HANDLE_IOCTL(RAW_SETBIND, raw_ioctl) |
| 2514 | HANDLE_IOCTL(RAW_GETBIND, raw_ioctl) |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 2515 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2516 | /* Serial */ |
| 2517 | HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl) |
| 2518 | HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl) |
Christoph Hellwig | 9c0cbd5 | 2005-10-30 15:01:41 -0800 | [diff] [blame] | 2519 | #ifdef TIOCGLTC |
| 2520 | COMPATIBLE_IOCTL(TIOCGLTC) |
| 2521 | COMPATIBLE_IOCTL(TIOCSLTC) |
| 2522 | #endif |
Christoph Hellwig | 7a81e31 | 2005-11-08 21:35:07 -0800 | [diff] [blame] | 2523 | #ifdef TIOCSTART |
| 2524 | /* |
| 2525 | * For these two we have defintions in ioctls.h and/or termios.h on |
| 2526 | * some architectures but no actual implemention. Some applications |
| 2527 | * like bash call them if they are defined in the headers, so we provide |
| 2528 | * entries here to avoid syslog message spew. |
| 2529 | */ |
| 2530 | COMPATIBLE_IOCTL(TIOCSTART) |
| 2531 | COMPATIBLE_IOCTL(TIOCSTOP) |
| 2532 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2533 | /* Usbdevfs */ |
| 2534 | HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control) |
| 2535 | HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk) |
| 2536 | HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal) |
Pete Zaitcev | c36fc88 | 2005-10-17 18:15:54 -0700 | [diff] [blame] | 2537 | COMPATIBLE_IOCTL(USBDEVFS_IOCTL32) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2538 | /* i2c */ |
| 2539 | HANDLE_IOCTL(I2C_FUNCS, w_long) |
| 2540 | HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl) |
| 2541 | HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl) |
| 2542 | /* wireless */ |
| 2543 | HANDLE_IOCTL(SIOCGIWRANGE, do_wireless_ioctl) |
| 2544 | HANDLE_IOCTL(SIOCSIWSPY, do_wireless_ioctl) |
| 2545 | HANDLE_IOCTL(SIOCGIWSPY, do_wireless_ioctl) |
| 2546 | HANDLE_IOCTL(SIOCSIWTHRSPY, do_wireless_ioctl) |
| 2547 | HANDLE_IOCTL(SIOCGIWTHRSPY, do_wireless_ioctl) |
| 2548 | HANDLE_IOCTL(SIOCGIWAPLIST, do_wireless_ioctl) |
| 2549 | HANDLE_IOCTL(SIOCGIWSCAN, do_wireless_ioctl) |
| 2550 | HANDLE_IOCTL(SIOCSIWESSID, do_wireless_ioctl) |
| 2551 | HANDLE_IOCTL(SIOCGIWESSID, do_wireless_ioctl) |
| 2552 | HANDLE_IOCTL(SIOCSIWNICKN, do_wireless_ioctl) |
| 2553 | HANDLE_IOCTL(SIOCGIWNICKN, do_wireless_ioctl) |
| 2554 | HANDLE_IOCTL(SIOCSIWENCODE, do_wireless_ioctl) |
| 2555 | HANDLE_IOCTL(SIOCGIWENCODE, do_wireless_ioctl) |
| 2556 | HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl) |
| 2557 | HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl) |
Christoph Hellwig | ec3cad9 | 2006-01-09 20:52:11 -0800 | [diff] [blame] | 2558 | HANDLE_IOCTL(RTC_IRQP_READ32, rtc_ioctl) |
| 2559 | HANDLE_IOCTL(RTC_IRQP_SET32, rtc_ioctl) |
| 2560 | HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl) |
| 2561 | HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2562 | |
David S. Miller | 6e87abd | 2005-11-16 00:52:57 -0800 | [diff] [blame] | 2563 | /* dvb */ |
David S. Miller | 6e87abd | 2005-11-16 00:52:57 -0800 | [diff] [blame] | 2564 | HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event) |
| 2565 | HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture) |
| 2566 | HANDLE_IOCTL(VIDEO_SET_SPU_PALETTE, do_video_set_spu_palette) |
Andi Kleen | c6b44d1 | 2006-01-12 01:05:26 -0800 | [diff] [blame] | 2567 | |
| 2568 | /* parport */ |
| 2569 | COMPATIBLE_IOCTL(LPTIME) |
| 2570 | COMPATIBLE_IOCTL(LPCHAR) |
| 2571 | COMPATIBLE_IOCTL(LPABORTOPEN) |
| 2572 | COMPATIBLE_IOCTL(LPCAREFUL) |
| 2573 | COMPATIBLE_IOCTL(LPWAIT) |
| 2574 | COMPATIBLE_IOCTL(LPSETIRQ) |
| 2575 | COMPATIBLE_IOCTL(LPGETSTATUS) |
| 2576 | COMPATIBLE_IOCTL(LPGETSTATUS) |
| 2577 | COMPATIBLE_IOCTL(LPRESET) |
| 2578 | /*LPGETSTATS not implemented, but no kernels seem to compile it in anyways*/ |
| 2579 | COMPATIBLE_IOCTL(LPGETFLAGS) |
| 2580 | HANDLE_IOCTL(LPSETTIMEOUT, lp_timeout_trans) |
Christoph Hellwig | e6a6d2e | 2006-01-09 20:52:14 -0800 | [diff] [blame] | 2581 | }; |
David S. Miller | 6e87abd | 2005-11-16 00:52:57 -0800 | [diff] [blame] | 2582 | |
Christoph Hellwig | e6a6d2e | 2006-01-09 20:52:14 -0800 | [diff] [blame] | 2583 | int ioctl_table_size = ARRAY_SIZE(ioctl_start); |