aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2009-11-07 02:10:54 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-07 02:10:54 -0500
commit6b96018b28bd93274b4b2a4c633a5d373fda0441 (patch)
treedd6402a6671f1e4d3ac0b930f410e2f2a59930da /fs
parent206602217747382488fcae68351673cc9103debc (diff)
compat: move sockios handling to net/socket.c
This removes the original socket compat_ioctl code from fs/compat_ioctl.c and converts the code from the copy in net/socket.c into a single function. We add a few cycles of runtime to compat_sock_ioctl() with the long switch() statement, but gain some cycles in return by simplifying the call chain to get there. Due to better inlining, save 1.5kb of object size in the process, and enable further savings: before: text data bss dec hex filename 13540 18008 2080 33628 835c obj/fs/compat_ioctl.o 14565 636 40 15241 3b89 obj/net/socket.o after: text data bss dec hex filename 8916 15176 2080 26172 663c obj/fs/compat_ioctl.o 20725 636 40 21401 5399 obj/net/socket.o Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'fs')
-rw-r--r--fs/compat_ioctl.c722
1 files changed, 0 insertions, 722 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 50d2a5fdc94a..cacf8a83e394 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -246,422 +246,6 @@ static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned
246 return err; 246 return err;
247} 247}
248 248
249#ifdef CONFIG_NET
250static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg)
251{
252 struct compat_timeval __user *up = compat_ptr(arg);
253 struct timeval ktv;
254 mm_segment_t old_fs = get_fs();
255 int err;
256
257 set_fs(KERNEL_DS);
258 err = sys_ioctl(fd, cmd, (unsigned long)&ktv);
259 set_fs(old_fs);
260 if(!err) {
261 err = put_user(ktv.tv_sec, &up->tv_sec);
262 err |= __put_user(ktv.tv_usec, &up->tv_usec);
263 }
264 return err;
265}
266
267static int do_siocgstampns(unsigned int fd, unsigned int cmd, unsigned long arg)
268{
269 struct compat_timespec __user *up = compat_ptr(arg);
270 struct timespec kts;
271 mm_segment_t old_fs = get_fs();
272 int err;
273
274 set_fs(KERNEL_DS);
275 err = sys_ioctl(fd, cmd, (unsigned long)&kts);
276 set_fs(old_fs);
277 if (!err) {
278 err = put_user(kts.tv_sec, &up->tv_sec);
279 err |= __put_user(kts.tv_nsec, &up->tv_nsec);
280 }
281 return err;
282}
283
284struct ifmap32 {
285 compat_ulong_t mem_start;
286 compat_ulong_t mem_end;
287 unsigned short base_addr;
288 unsigned char irq;
289 unsigned char dma;
290 unsigned char port;
291};
292
293struct ifreq32 {
294#define IFHWADDRLEN 6
295#define IFNAMSIZ 16
296 union {
297 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
298 } ifr_ifrn;
299 union {
300 struct sockaddr ifru_addr;
301 struct sockaddr ifru_dstaddr;
302 struct sockaddr ifru_broadaddr;
303 struct sockaddr ifru_netmask;
304 struct sockaddr ifru_hwaddr;
305 short ifru_flags;
306 compat_int_t ifru_ivalue;
307 compat_int_t ifru_mtu;
308 struct ifmap32 ifru_map;
309 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
310 char ifru_newname[IFNAMSIZ];
311 compat_caddr_t ifru_data;
312 /* XXXX? ifru_settings should be here */
313 } ifr_ifru;
314};
315
316struct ifconf32 {
317 compat_int_t ifc_len; /* size of buffer */
318 compat_caddr_t ifcbuf;
319};
320
321static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg)
322{
323 struct ifreq __user *uifr;
324 int err;
325
326 uifr = compat_alloc_user_space(sizeof(struct ifreq));
327 if (copy_in_user(uifr, compat_ptr(arg), sizeof(struct ifreq32)))
328 return -EFAULT;
329
330 err = sys_ioctl(fd, SIOCGIFNAME, (unsigned long)uifr);
331 if (err)
332 return err;
333
334 if (copy_in_user(compat_ptr(arg), uifr, sizeof(struct ifreq32)))
335 return -EFAULT;
336
337 return 0;
338}
339
340static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg)
341{
342 struct ifconf32 ifc32;
343 struct ifconf ifc;
344 struct ifconf __user *uifc;
345 struct ifreq32 __user *ifr32;
346 struct ifreq __user *ifr;
347 unsigned int i, j;
348 int err;
349
350 if (copy_from_user(&ifc32, compat_ptr(arg), sizeof(struct ifconf32)))
351 return -EFAULT;
352
353 if (ifc32.ifcbuf == 0) {
354 ifc32.ifc_len = 0;
355 ifc.ifc_len = 0;
356 ifc.ifc_req = NULL;
357 uifc = compat_alloc_user_space(sizeof(struct ifconf));
358 } else {
359 size_t len =((ifc32.ifc_len / sizeof (struct ifreq32)) + 1) *
360 sizeof (struct ifreq);
361 uifc = compat_alloc_user_space(sizeof(struct ifconf) + len);
362 ifc.ifc_len = len;
363 ifr = ifc.ifc_req = (void __user *)(uifc + 1);
364 ifr32 = compat_ptr(ifc32.ifcbuf);
365 for (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) {
366 if (copy_in_user(ifr, ifr32, sizeof(struct ifreq32)))
367 return -EFAULT;
368 ifr++;
369 ifr32++;
370 }
371 }
372 if (copy_to_user(uifc, &ifc, sizeof(struct ifconf)))
373 return -EFAULT;
374
375 err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)uifc);
376 if (err)
377 return err;
378
379 if (copy_from_user(&ifc, uifc, sizeof(struct ifconf)))
380 return -EFAULT;
381
382 ifr = ifc.ifc_req;
383 ifr32 = compat_ptr(ifc32.ifcbuf);
384 for (i = 0, j = 0;
385 i + sizeof (struct ifreq32) <= ifc32.ifc_len && j < ifc.ifc_len;
386 i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) {
387 if (copy_in_user(ifr32, ifr, sizeof (struct ifreq32)))
388 return -EFAULT;
389 ifr32++;
390 ifr++;
391 }
392
393 if (ifc32.ifcbuf == 0) {
394 /* Translate from 64-bit structure multiple to
395 * a 32-bit one.
396 */
397 i = ifc.ifc_len;
398 i = ((i / sizeof(struct ifreq)) * sizeof(struct ifreq32));
399 ifc32.ifc_len = i;
400 } else {
401 ifc32.ifc_len = i;
402 }
403 if (copy_to_user(compat_ptr(arg), &ifc32, sizeof(struct ifconf32)))
404 return -EFAULT;
405
406 return 0;
407}
408
409static int ethtool_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
410{
411 struct ifreq __user *ifr;
412 struct ifreq32 __user *ifr32;
413 u32 data;
414 void __user *datap;
415
416 ifr = compat_alloc_user_space(sizeof(*ifr));
417 ifr32 = compat_ptr(arg);
418
419 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
420 return -EFAULT;
421
422 if (get_user(data, &ifr32->ifr_ifru.ifru_data))
423 return -EFAULT;
424
425 datap = compat_ptr(data);
426 if (put_user(datap, &ifr->ifr_ifru.ifru_data))
427 return -EFAULT;
428
429 return sys_ioctl(fd, cmd, (unsigned long) ifr);
430}
431
432static int bond_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
433{
434 struct ifreq kifr;
435 struct ifreq __user *uifr;
436 struct ifreq32 __user *ifr32 = compat_ptr(arg);
437 mm_segment_t old_fs;
438 int err;
439 u32 data;
440 void __user *datap;
441
442 switch (cmd) {
443 case SIOCBONDENSLAVE:
444 case SIOCBONDRELEASE:
445 case SIOCBONDSETHWADDR:
446 case SIOCBONDCHANGEACTIVE:
447 if (copy_from_user(&kifr, ifr32, sizeof(struct ifreq32)))
448 return -EFAULT;
449
450 old_fs = get_fs();
451 set_fs (KERNEL_DS);
452 err = sys_ioctl (fd, cmd, (unsigned long)&kifr);
453 set_fs (old_fs);
454
455 return err;
456 case SIOCBONDSLAVEINFOQUERY:
457 case SIOCBONDINFOQUERY:
458 uifr = compat_alloc_user_space(sizeof(*uifr));
459 if (copy_in_user(&uifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
460 return -EFAULT;
461
462 if (get_user(data, &ifr32->ifr_ifru.ifru_data))
463 return -EFAULT;
464
465 datap = compat_ptr(data);
466 if (put_user(datap, &uifr->ifr_ifru.ifru_data))
467 return -EFAULT;
468
469 return sys_ioctl (fd, cmd, (unsigned long)uifr);
470 default:
471 return -EINVAL;
472 };
473}
474
475static int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
476{
477 struct ifreq __user *u_ifreq64;
478 struct ifreq32 __user *u_ifreq32 = compat_ptr(arg);
479 char tmp_buf[IFNAMSIZ];
480 void __user *data64;
481 u32 data32;
482
483 if (copy_from_user(&tmp_buf[0], &(u_ifreq32->ifr_ifrn.ifrn_name[0]),
484 IFNAMSIZ))
485 return -EFAULT;
486 if (__get_user(data32, &u_ifreq32->ifr_ifru.ifru_data))
487 return -EFAULT;
488 data64 = compat_ptr(data32);
489
490 u_ifreq64 = compat_alloc_user_space(sizeof(*u_ifreq64));
491
492 /* Don't check these user accesses, just let that get trapped
493 * in the ioctl handler instead.
494 */
495 if (copy_to_user(&u_ifreq64->ifr_ifrn.ifrn_name[0], &tmp_buf[0],
496 IFNAMSIZ))
497 return -EFAULT;
498 if (__put_user(data64, &u_ifreq64->ifr_ifru.ifru_data))
499 return -EFAULT;
500
501 return sys_ioctl(fd, cmd, (unsigned long) u_ifreq64);
502}
503
504static int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg)
505{
506 struct ifreq ifr;
507 struct ifreq32 __user *uifr32;
508 struct ifmap32 __user *uifmap32;
509 mm_segment_t old_fs;
510 int err;
511
512 uifr32 = compat_ptr(arg);
513 uifmap32 = &uifr32->ifr_ifru.ifru_map;
514 switch (cmd) {
515 case SIOCSIFMAP:
516 err = copy_from_user(&ifr, uifr32, sizeof(ifr.ifr_name));
517 err |= __get_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
518 err |= __get_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
519 err |= __get_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
520 err |= __get_user(ifr.ifr_map.irq, &uifmap32->irq);
521 err |= __get_user(ifr.ifr_map.dma, &uifmap32->dma);
522 err |= __get_user(ifr.ifr_map.port, &uifmap32->port);
523 if (err)
524 return -EFAULT;
525 break;
526 case SIOCSHWTSTAMP:
527 if (copy_from_user(&ifr, uifr32, sizeof(*uifr32)))
528 return -EFAULT;
529 ifr.ifr_data = compat_ptr(uifr32->ifr_ifru.ifru_data);
530 break;
531 default:
532 if (copy_from_user(&ifr, uifr32, sizeof(*uifr32)))
533 return -EFAULT;
534 break;
535 }
536 old_fs = get_fs();
537 set_fs (KERNEL_DS);
538 err = sys_ioctl (fd, cmd, (unsigned long)&ifr);
539 set_fs (old_fs);
540 if (!err) {
541 switch (cmd) {
542 case SIOCGIFFLAGS:
543 case SIOCGIFMETRIC:
544 case SIOCGIFMTU:
545 case SIOCGIFMEM:
546 case SIOCGIFHWADDR:
547 case SIOCGIFINDEX:
548 case SIOCGIFADDR:
549 case SIOCGIFBRDADDR:
550 case SIOCGIFDSTADDR:
551 case SIOCGIFNETMASK:
552 case SIOCGIFTXQLEN:
553 if (copy_to_user(uifr32, &ifr, sizeof(*uifr32)))
554 return -EFAULT;
555 break;
556 case SIOCGIFMAP:
557 err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name));
558 err |= __put_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
559 err |= __put_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
560 err |= __put_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
561 err |= __put_user(ifr.ifr_map.irq, &uifmap32->irq);
562 err |= __put_user(ifr.ifr_map.dma, &uifmap32->dma);
563 err |= __put_user(ifr.ifr_map.port, &uifmap32->port);
564 if (err)
565 err = -EFAULT;
566 break;
567 }
568 }
569 return err;
570}
571
572struct rtentry32 {
573 u32 rt_pad1;
574 struct sockaddr rt_dst; /* target address */
575 struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */
576 struct sockaddr rt_genmask; /* target network mask (IP) */
577 unsigned short rt_flags;
578 short rt_pad2;
579 u32 rt_pad3;
580 unsigned char rt_tos;
581 unsigned char rt_class;
582 short rt_pad4;
583 short rt_metric; /* +1 for binary compatibility! */
584 /* char * */ u32 rt_dev; /* forcing the device at add */
585 u32 rt_mtu; /* per route MTU/Window */
586 u32 rt_window; /* Window clamping */
587 unsigned short rt_irtt; /* Initial RTT */
588
589};
590
591struct in6_rtmsg32 {
592 struct in6_addr rtmsg_dst;
593 struct in6_addr rtmsg_src;
594 struct in6_addr rtmsg_gateway;
595 u32 rtmsg_type;
596 u16 rtmsg_dst_len;
597 u16 rtmsg_src_len;
598 u32 rtmsg_metric;
599 u32 rtmsg_info;
600 u32 rtmsg_flags;
601 s32 rtmsg_ifindex;
602};
603
604static int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
605{
606 int ret;
607 void *r = NULL;
608 struct in6_rtmsg r6;
609 struct rtentry r4;
610 char devname[16];
611 u32 rtdev;
612 mm_segment_t old_fs = get_fs();
613
614 struct socket *mysock = sockfd_lookup(fd, &ret);
615
616 if (mysock && mysock->sk && mysock->sk->sk_family == AF_INET6) { /* ipv6 */
617 struct in6_rtmsg32 __user *ur6 = compat_ptr(arg);
618 ret = copy_from_user (&r6.rtmsg_dst, &(ur6->rtmsg_dst),
619 3 * sizeof(struct in6_addr));
620 ret |= __get_user (r6.rtmsg_type, &(ur6->rtmsg_type));
621 ret |= __get_user (r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len));
622 ret |= __get_user (r6.rtmsg_src_len, &(ur6->rtmsg_src_len));
623 ret |= __get_user (r6.rtmsg_metric, &(ur6->rtmsg_metric));
624 ret |= __get_user (r6.rtmsg_info, &(ur6->rtmsg_info));
625 ret |= __get_user (r6.rtmsg_flags, &(ur6->rtmsg_flags));
626 ret |= __get_user (r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex));
627
628 r = (void *) &r6;
629 } else { /* ipv4 */
630 struct rtentry32 __user *ur4 = compat_ptr(arg);
631 ret = copy_from_user (&r4.rt_dst, &(ur4->rt_dst),
632 3 * sizeof(struct sockaddr));
633 ret |= __get_user (r4.rt_flags, &(ur4->rt_flags));
634 ret |= __get_user (r4.rt_metric, &(ur4->rt_metric));
635 ret |= __get_user (r4.rt_mtu, &(ur4->rt_mtu));
636 ret |= __get_user (r4.rt_window, &(ur4->rt_window));
637 ret |= __get_user (r4.rt_irtt, &(ur4->rt_irtt));
638 ret |= __get_user (rtdev, &(ur4->rt_dev));
639 if (rtdev) {
640 ret |= copy_from_user (devname, compat_ptr(rtdev), 15);
641 r4.rt_dev = devname; devname[15] = 0;
642 } else
643 r4.rt_dev = NULL;
644
645 r = (void *) &r4;
646 }
647
648 if (ret) {
649 ret = -EFAULT;
650 goto out;
651 }
652
653 set_fs (KERNEL_DS);
654 ret = sys_ioctl (fd, cmd, (unsigned long) r);
655 set_fs (old_fs);
656
657out:
658 if (mysock)
659 sockfd_put(mysock);
660
661 return ret;
662}
663#endif
664
665#ifdef CONFIG_BLOCK 249#ifdef CONFIG_BLOCK
666typedef struct sg_io_hdr32 { 250typedef struct sg_io_hdr32 {
667 compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */ 251 compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */
@@ -1206,170 +790,6 @@ static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long a
1206 return err; 790 return err;
1207} 791}
1208 792
1209struct atmif_sioc32 {
1210 compat_int_t number;
1211 compat_int_t length;
1212 compat_caddr_t arg;
1213};
1214
1215struct atm_iobuf32 {
1216 compat_int_t length;
1217 compat_caddr_t buffer;
1218};
1219
1220#define ATM_GETLINKRATE32 _IOW('a', ATMIOC_ITF+1, struct atmif_sioc32)
1221#define ATM_GETNAMES32 _IOW('a', ATMIOC_ITF+3, struct atm_iobuf32)
1222#define ATM_GETTYPE32 _IOW('a', ATMIOC_ITF+4, struct atmif_sioc32)
1223#define ATM_GETESI32 _IOW('a', ATMIOC_ITF+5, struct atmif_sioc32)
1224#define ATM_GETADDR32 _IOW('a', ATMIOC_ITF+6, struct atmif_sioc32)
1225#define ATM_RSTADDR32 _IOW('a', ATMIOC_ITF+7, struct atmif_sioc32)
1226#define ATM_ADDADDR32 _IOW('a', ATMIOC_ITF+8, struct atmif_sioc32)
1227#define ATM_DELADDR32 _IOW('a', ATMIOC_ITF+9, struct atmif_sioc32)
1228#define ATM_GETCIRANGE32 _IOW('a', ATMIOC_ITF+10, struct atmif_sioc32)
1229#define ATM_SETCIRANGE32 _IOW('a', ATMIOC_ITF+11, struct atmif_sioc32)
1230#define ATM_SETESI32 _IOW('a', ATMIOC_ITF+12, struct atmif_sioc32)
1231#define ATM_SETESIF32 _IOW('a', ATMIOC_ITF+13, struct atmif_sioc32)
1232#define ATM_GETSTAT32 _IOW('a', ATMIOC_SARCOM+0, struct atmif_sioc32)
1233#define ATM_GETSTATZ32 _IOW('a', ATMIOC_SARCOM+1, struct atmif_sioc32)
1234#define ATM_GETLOOP32 _IOW('a', ATMIOC_SARCOM+2, struct atmif_sioc32)
1235#define ATM_SETLOOP32 _IOW('a', ATMIOC_SARCOM+3, struct atmif_sioc32)
1236#define ATM_QUERYLOOP32 _IOW('a', ATMIOC_SARCOM+4, struct atmif_sioc32)
1237
1238static struct {
1239 unsigned int cmd32;
1240 unsigned int cmd;
1241} atm_ioctl_map[] = {
1242 { ATM_GETLINKRATE32, ATM_GETLINKRATE },
1243 { ATM_GETNAMES32, ATM_GETNAMES },
1244 { ATM_GETTYPE32, ATM_GETTYPE },
1245 { ATM_GETESI32, ATM_GETESI },
1246 { ATM_GETADDR32, ATM_GETADDR },
1247 { ATM_RSTADDR32, ATM_RSTADDR },
1248 { ATM_ADDADDR32, ATM_ADDADDR },
1249 { ATM_DELADDR32, ATM_DELADDR },
1250 { ATM_GETCIRANGE32, ATM_GETCIRANGE },
1251 { ATM_SETCIRANGE32, ATM_SETCIRANGE },
1252 { ATM_SETESI32, ATM_SETESI },
1253 { ATM_SETESIF32, ATM_SETESIF },
1254 { ATM_GETSTAT32, ATM_GETSTAT },
1255 { ATM_GETSTATZ32, ATM_GETSTATZ },
1256 { ATM_GETLOOP32, ATM_GETLOOP },
1257 { ATM_SETLOOP32, ATM_SETLOOP },
1258 { ATM_QUERYLOOP32, ATM_QUERYLOOP }
1259};
1260
1261#define NR_ATM_IOCTL ARRAY_SIZE(atm_ioctl_map)
1262
1263static int do_atm_iobuf(unsigned int fd, unsigned int cmd, unsigned long arg)
1264{
1265 struct atm_iobuf __user *iobuf;
1266 struct atm_iobuf32 __user *iobuf32;
1267 u32 data;
1268 void __user *datap;
1269 int len, err;
1270
1271 iobuf = compat_alloc_user_space(sizeof(*iobuf));
1272 iobuf32 = compat_ptr(arg);
1273
1274 if (get_user(len, &iobuf32->length) ||
1275 get_user(data, &iobuf32->buffer))
1276 return -EFAULT;
1277 datap = compat_ptr(data);
1278 if (put_user(len, &iobuf->length) ||
1279 put_user(datap, &iobuf->buffer))
1280 return -EFAULT;
1281
1282 err = sys_ioctl(fd, cmd, (unsigned long)iobuf);
1283
1284 if (!err) {
1285 if (copy_in_user(&iobuf32->length, &iobuf->length,
1286 sizeof(int)))
1287 err = -EFAULT;
1288 }
1289
1290 return err;
1291}
1292
1293static int do_atmif_sioc(unsigned int fd, unsigned int cmd, unsigned long arg)
1294{
1295 struct atmif_sioc __user *sioc;
1296 struct atmif_sioc32 __user *sioc32;
1297 u32 data;
1298 void __user *datap;
1299 int err;
1300
1301 sioc = compat_alloc_user_space(sizeof(*sioc));
1302 sioc32 = compat_ptr(arg);
1303
1304 if (copy_in_user(&sioc->number, &sioc32->number, 2 * sizeof(int)) ||
1305 get_user(data, &sioc32->arg))
1306 return -EFAULT;
1307 datap = compat_ptr(data);
1308 if (put_user(datap, &sioc->arg))
1309 return -EFAULT;
1310
1311 err = sys_ioctl(fd, cmd, (unsigned long) sioc);
1312
1313 if (!err) {
1314 if (copy_in_user(&sioc32->length, &sioc->length,
1315 sizeof(int)))
1316 err = -EFAULT;
1317 }
1318 return err;
1319}
1320
1321static int do_atm_ioctl(unsigned int fd, unsigned int cmd32, unsigned long arg)
1322{
1323 int i;
1324 unsigned int cmd = 0;
1325
1326 switch (cmd32) {
1327 case SONET_GETSTAT:
1328 case SONET_GETSTATZ:
1329 case SONET_GETDIAG:
1330 case SONET_SETDIAG:
1331 case SONET_CLRDIAG:
1332 case SONET_SETFRAMING:
1333 case SONET_GETFRAMING:
1334 case SONET_GETFRSENSE:
1335 return do_atmif_sioc(fd, cmd32, arg);
1336 }
1337
1338 for (i = 0; i < NR_ATM_IOCTL; i++) {
1339 if (cmd32 == atm_ioctl_map[i].cmd32) {
1340 cmd = atm_ioctl_map[i].cmd;
1341 break;
1342 }
1343 }
1344 if (i == NR_ATM_IOCTL)
1345 return -EINVAL;
1346
1347 switch (cmd) {
1348 case ATM_GETNAMES:
1349 return do_atm_iobuf(fd, cmd, arg);
1350
1351 case ATM_GETLINKRATE:
1352 case ATM_GETTYPE:
1353 case ATM_GETESI:
1354 case ATM_GETADDR:
1355 case ATM_RSTADDR:
1356 case ATM_ADDADDR:
1357 case ATM_DELADDR:
1358 case ATM_GETCIRANGE:
1359 case ATM_SETCIRANGE:
1360 case ATM_SETESI:
1361 case ATM_SETESIF:
1362 case ATM_GETSTAT:
1363 case ATM_GETSTATZ:
1364 case ATM_GETLOOP:
1365 case ATM_SETLOOP:
1366 case ATM_QUERYLOOP:
1367 return do_atmif_sioc(fd, cmd, arg);
1368 }
1369
1370 return -EINVAL;
1371}
1372
1373static __used int 793static __used int
1374ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg) 794ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg)
1375{ 795{
@@ -1712,21 +1132,6 @@ static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long a
1712 return sys_ioctl(fd, cmd, (unsigned long)tdata); 1132 return sys_ioctl(fd, cmd, (unsigned long)tdata);
1713} 1133}
1714 1134
1715/* Since old style bridge ioctl's endup using SIOCDEVPRIVATE
1716 * for some operations; this forces use of the newer bridge-utils that
1717 * use compatible ioctls
1718 */
1719static int old_bridge_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
1720{
1721 u32 tmp;
1722
1723 if (get_user(tmp, (u32 __user *) arg))
1724 return -EFAULT;
1725 if (tmp == BRCTL_GET_VERSION)
1726 return BRCTL_VERSION + 1;
1727 return -EINVAL;
1728}
1729
1730#define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t) 1135#define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t)
1731#define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t) 1136#define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t)
1732#define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t) 1137#define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t)
@@ -2014,28 +1419,6 @@ COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
2014COMPATIBLE_IOCTL(MTIOCTOP) 1419COMPATIBLE_IOCTL(MTIOCTOP)
2015/* Socket level stuff */ 1420/* Socket level stuff */
2016COMPATIBLE_IOCTL(FIOQSIZE) 1421COMPATIBLE_IOCTL(FIOQSIZE)
2017COMPATIBLE_IOCTL(FIOSETOWN)
2018COMPATIBLE_IOCTL(SIOCSPGRP)
2019COMPATIBLE_IOCTL(FIOGETOWN)
2020COMPATIBLE_IOCTL(SIOCGPGRP)
2021COMPATIBLE_IOCTL(SIOCATMARK)
2022COMPATIBLE_IOCTL(SIOCSIFLINK)
2023COMPATIBLE_IOCTL(SIOCSIFNAME)
2024COMPATIBLE_IOCTL(SIOCSARP)
2025COMPATIBLE_IOCTL(SIOCGARP)
2026COMPATIBLE_IOCTL(SIOCDARP)
2027COMPATIBLE_IOCTL(SIOCSRARP)
2028COMPATIBLE_IOCTL(SIOCGRARP)
2029COMPATIBLE_IOCTL(SIOCDRARP)
2030COMPATIBLE_IOCTL(SIOCADDDLCI)
2031COMPATIBLE_IOCTL(SIOCDELDLCI)
2032COMPATIBLE_IOCTL(SIOCGMIIPHY)
2033COMPATIBLE_IOCTL(SIOCGMIIREG)
2034COMPATIBLE_IOCTL(SIOCSMIIREG)
2035COMPATIBLE_IOCTL(SIOCGIFVLAN)
2036COMPATIBLE_IOCTL(SIOCSIFVLAN)
2037COMPATIBLE_IOCTL(SIOCBRADDBR)
2038COMPATIBLE_IOCTL(SIOCBRDELBR)
2039#ifdef CONFIG_BLOCK 1422#ifdef CONFIG_BLOCK
2040/* SG stuff */ 1423/* SG stuff */
2041COMPATIBLE_IOCTL(SG_SET_TIMEOUT) 1424COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
@@ -2291,22 +1674,6 @@ COMPATIBLE_IOCTL(RAW_SETBIND)
2291COMPATIBLE_IOCTL(RAW_GETBIND) 1674COMPATIBLE_IOCTL(RAW_GETBIND)
2292/* SMB ioctls which do not need any translations */ 1675/* SMB ioctls which do not need any translations */
2293COMPATIBLE_IOCTL(SMB_IOC_NEWCONN) 1676COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
2294/* Little a */
2295COMPATIBLE_IOCTL(ATMSIGD_CTRL)
2296COMPATIBLE_IOCTL(ATMARPD_CTRL)
2297COMPATIBLE_IOCTL(ATMLEC_CTRL)
2298COMPATIBLE_IOCTL(ATMLEC_MCAST)
2299COMPATIBLE_IOCTL(ATMLEC_DATA)
2300COMPATIBLE_IOCTL(ATM_SETSC)
2301COMPATIBLE_IOCTL(SIOCSIFATMTCP)
2302COMPATIBLE_IOCTL(SIOCMKCLIP)
2303COMPATIBLE_IOCTL(ATMARP_MKIP)
2304COMPATIBLE_IOCTL(ATMARP_SETENTRY)
2305COMPATIBLE_IOCTL(ATMARP_ENCAP)
2306COMPATIBLE_IOCTL(ATMTCP_CREATE)
2307COMPATIBLE_IOCTL(ATMTCP_REMOVE)
2308COMPATIBLE_IOCTL(ATMMPC_CTRL)
2309COMPATIBLE_IOCTL(ATMMPC_DATA)
2310/* Watchdog */ 1677/* Watchdog */
2311COMPATIBLE_IOCTL(WDIOC_GETSUPPORT) 1678COMPATIBLE_IOCTL(WDIOC_GETSUPPORT)
2312COMPATIBLE_IOCTL(WDIOC_GETSTATUS) 1679COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
@@ -2512,60 +1879,6 @@ COMPATIBLE_IOCTL(JSIOCGBUTTONS)
2512COMPATIBLE_IOCTL(JSIOCGNAME(0)) 1879COMPATIBLE_IOCTL(JSIOCGNAME(0))
2513 1880
2514/* now things that need handlers */ 1881/* now things that need handlers */
2515#ifdef CONFIG_NET
2516HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32)
2517HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf)
2518HANDLE_IOCTL(SIOCGIFFLAGS, dev_ifsioc)
2519HANDLE_IOCTL(SIOCSIFFLAGS, dev_ifsioc)
2520HANDLE_IOCTL(SIOCGIFMETRIC, dev_ifsioc)
2521HANDLE_IOCTL(SIOCSIFMETRIC, dev_ifsioc)
2522HANDLE_IOCTL(SIOCGIFMTU, dev_ifsioc)
2523HANDLE_IOCTL(SIOCSIFMTU, dev_ifsioc)
2524HANDLE_IOCTL(SIOCGIFMEM, dev_ifsioc)
2525HANDLE_IOCTL(SIOCSIFMEM, dev_ifsioc)
2526HANDLE_IOCTL(SIOCGIFHWADDR, dev_ifsioc)
2527HANDLE_IOCTL(SIOCSIFHWADDR, dev_ifsioc)
2528HANDLE_IOCTL(SIOCADDMULTI, dev_ifsioc)
2529HANDLE_IOCTL(SIOCDELMULTI, dev_ifsioc)
2530HANDLE_IOCTL(SIOCGIFINDEX, dev_ifsioc)
2531HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc)
2532HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc)
2533HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc)
2534HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc)
2535HANDLE_IOCTL(SIOCSIFHWBROADCAST, dev_ifsioc)
2536HANDLE_IOCTL(SIOCSHWTSTAMP, dev_ifsioc)
2537
2538/* ioctls used by appletalk ddp.c */
2539HANDLE_IOCTL(SIOCDIFADDR, dev_ifsioc)
2540HANDLE_IOCTL(SIOCSARP, dev_ifsioc)
2541HANDLE_IOCTL(SIOCDARP, dev_ifsioc)
2542
2543HANDLE_IOCTL(SIOCGIFBRDADDR, dev_ifsioc)
2544HANDLE_IOCTL(SIOCSIFBRDADDR, dev_ifsioc)
2545HANDLE_IOCTL(SIOCGIFDSTADDR, dev_ifsioc)
2546HANDLE_IOCTL(SIOCSIFDSTADDR, dev_ifsioc)
2547HANDLE_IOCTL(SIOCGIFNETMASK, dev_ifsioc)
2548HANDLE_IOCTL(SIOCSIFNETMASK, dev_ifsioc)
2549HANDLE_IOCTL(SIOCSIFPFLAGS, dev_ifsioc)
2550HANDLE_IOCTL(SIOCGIFPFLAGS, dev_ifsioc)
2551HANDLE_IOCTL(SIOCGIFTXQLEN, dev_ifsioc)
2552HANDLE_IOCTL(SIOCSIFTXQLEN, dev_ifsioc)
2553HANDLE_IOCTL(SIOCETHTOOL, ethtool_ioctl)
2554HANDLE_IOCTL(SIOCBONDENSLAVE, bond_ioctl)
2555HANDLE_IOCTL(SIOCBONDRELEASE, bond_ioctl)
2556HANDLE_IOCTL(SIOCBONDSETHWADDR, bond_ioctl)
2557HANDLE_IOCTL(SIOCBONDSLAVEINFOQUERY, bond_ioctl)
2558HANDLE_IOCTL(SIOCBONDINFOQUERY, bond_ioctl)
2559HANDLE_IOCTL(SIOCBONDCHANGEACTIVE, bond_ioctl)
2560HANDLE_IOCTL(SIOCADDRT, routing_ioctl)
2561HANDLE_IOCTL(SIOCDELRT, routing_ioctl)
2562HANDLE_IOCTL(SIOCBRADDIF, dev_ifsioc)
2563HANDLE_IOCTL(SIOCBRDELIF, dev_ifsioc)
2564/* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */
2565HANDLE_IOCTL(SIOCRTMSG, ret_einval)
2566HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp)
2567HANDLE_IOCTL(SIOCGSTAMPNS, do_siocgstampns)
2568#endif
2569#ifdef CONFIG_BLOCK 1882#ifdef CONFIG_BLOCK
2570HANDLE_IOCTL(SG_IO,sg_ioctl_trans) 1883HANDLE_IOCTL(SG_IO,sg_ioctl_trans)
2571HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans) 1884HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans)
@@ -2590,31 +1903,6 @@ HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl)
2590/* One SMB ioctl needs translations. */ 1903/* One SMB ioctl needs translations. */
2591#define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t) 1904#define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
2592HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid) 1905HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)
2593HANDLE_IOCTL(ATM_GETLINKRATE32, do_atm_ioctl)
2594HANDLE_IOCTL(ATM_GETNAMES32, do_atm_ioctl)
2595HANDLE_IOCTL(ATM_GETTYPE32, do_atm_ioctl)
2596HANDLE_IOCTL(ATM_GETESI32, do_atm_ioctl)
2597HANDLE_IOCTL(ATM_GETADDR32, do_atm_ioctl)
2598HANDLE_IOCTL(ATM_RSTADDR32, do_atm_ioctl)
2599HANDLE_IOCTL(ATM_ADDADDR32, do_atm_ioctl)
2600HANDLE_IOCTL(ATM_DELADDR32, do_atm_ioctl)
2601HANDLE_IOCTL(ATM_GETCIRANGE32, do_atm_ioctl)
2602HANDLE_IOCTL(ATM_SETCIRANGE32, do_atm_ioctl)
2603HANDLE_IOCTL(ATM_SETESI32, do_atm_ioctl)
2604HANDLE_IOCTL(ATM_SETESIF32, do_atm_ioctl)
2605HANDLE_IOCTL(ATM_GETSTAT32, do_atm_ioctl)
2606HANDLE_IOCTL(ATM_GETSTATZ32, do_atm_ioctl)
2607HANDLE_IOCTL(ATM_GETLOOP32, do_atm_ioctl)
2608HANDLE_IOCTL(ATM_SETLOOP32, do_atm_ioctl)
2609HANDLE_IOCTL(ATM_QUERYLOOP32, do_atm_ioctl)
2610HANDLE_IOCTL(SONET_GETSTAT, do_atm_ioctl)
2611HANDLE_IOCTL(SONET_GETSTATZ, do_atm_ioctl)
2612HANDLE_IOCTL(SONET_GETDIAG, do_atm_ioctl)
2613HANDLE_IOCTL(SONET_SETDIAG, do_atm_ioctl)
2614HANDLE_IOCTL(SONET_CLRDIAG, do_atm_ioctl)
2615HANDLE_IOCTL(SONET_SETFRAMING, do_atm_ioctl)
2616HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl)
2617HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl)
2618/* block stuff */ 1906/* block stuff */
2619#ifdef CONFIG_BLOCK 1907#ifdef CONFIG_BLOCK
2620/* loop */ 1908/* loop */
@@ -2649,11 +1937,7 @@ COMPATIBLE_IOCTL(USBDEVFS_IOCTL32)
2649HANDLE_IOCTL(I2C_FUNCS, w_long) 1937HANDLE_IOCTL(I2C_FUNCS, w_long)
2650HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl) 1938HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
2651HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl) 1939HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl)
2652/* bridge */
2653HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl)
2654HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl)
2655/* Not implemented in the native kernel */ 1940/* Not implemented in the native kernel */
2656IGNORE_IOCTL(SIOCGIFCOUNT)
2657HANDLE_IOCTL(RTC_IRQP_READ32, rtc_ioctl) 1941HANDLE_IOCTL(RTC_IRQP_READ32, rtc_ioctl)
2658HANDLE_IOCTL(RTC_IRQP_SET32, rtc_ioctl) 1942HANDLE_IOCTL(RTC_IRQP_SET32, rtc_ioctl)
2659HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl) 1943HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl)
@@ -2808,12 +2092,6 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
2808 goto found_handler; 2092 goto found_handler;
2809 } 2093 }
2810 2094
2811#ifdef CONFIG_NET
2812 if (S_ISSOCK(filp->f_path.dentry->d_inode->i_mode) &&
2813 cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) {
2814 error = siocdevprivate_ioctl(fd, cmd, arg);
2815 } else
2816#endif
2817 { 2095 {
2818 static int count; 2096 static int count;
2819 2097