summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2016-01-07 09:53:30 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2016-01-08 21:16:50 -0500
commit66cf191f3eae4582a83cb4251b75b43bee95a999 (patch)
tree65447e6f7c6fd824f8735f13ffbd85dc54f0eb66
parentb43417216e9ce55e1f1ab7c834c7ab43db0b53e1 (diff)
compat_ioctl: don't pass fd around when not needed
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/compat_ioctl.c103
-rw-r--r--fs/internal.h7
-rw-r--r--fs/ioctl.c4
-rw-r--r--include/linux/fs.h2
4 files changed, 61 insertions, 55 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 06e60cab0c3b..908837cd2ac7 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -58,6 +58,8 @@
58#include <linux/atalk.h> 58#include <linux/atalk.h>
59#include <linux/gfp.h> 59#include <linux/gfp.h>
60 60
61#include "internal.h"
62
61#include <net/bluetooth/bluetooth.h> 63#include <net/bluetooth/bluetooth.h>
62#include <net/bluetooth/hci_sock.h> 64#include <net/bluetooth/hci_sock.h>
63#include <net/bluetooth/rfcomm.h> 65#include <net/bluetooth/rfcomm.h>
@@ -115,8 +117,7 @@
115#include <asm/fbio.h> 117#include <asm/fbio.h>
116#endif 118#endif
117 119
118static int do_ioctl(struct file *file, unsigned int fd, 120static int do_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
119 unsigned int cmd, unsigned long arg)
120{ 121{
121 int err; 122 int err;
122 123
@@ -124,10 +125,10 @@ static int do_ioctl(struct file *file, unsigned int fd,
124 if (err) 125 if (err)
125 return err; 126 return err;
126 127
127 return do_vfs_ioctl(file, fd, cmd, arg); 128 return vfs_ioctl(file, cmd, arg);
128} 129}
129 130
130static int w_long(struct file *file, unsigned int fd, 131static int w_long(struct file *file,
131 unsigned int cmd, compat_ulong_t __user *argp) 132 unsigned int cmd, compat_ulong_t __user *argp)
132{ 133{
133 mm_segment_t old_fs = get_fs(); 134 mm_segment_t old_fs = get_fs();
@@ -135,7 +136,7 @@ static int w_long(struct file *file, unsigned int fd,
135 unsigned long val; 136 unsigned long val;
136 137
137 set_fs (KERNEL_DS); 138 set_fs (KERNEL_DS);
138 err = do_ioctl(file, fd, cmd, (unsigned long)&val); 139 err = do_ioctl(file, cmd, (unsigned long)&val);
139 set_fs (old_fs); 140 set_fs (old_fs);
140 if (!err && put_user(val, argp)) 141 if (!err && put_user(val, argp))
141 return -EFAULT; 142 return -EFAULT;
@@ -151,7 +152,7 @@ struct compat_video_event {
151 } u; 152 } u;
152}; 153};
153 154
154static int do_video_get_event(struct file *file, unsigned int fd, 155static int do_video_get_event(struct file *file,
155 unsigned int cmd, struct compat_video_event __user *up) 156 unsigned int cmd, struct compat_video_event __user *up)
156{ 157{
157 struct video_event kevent; 158 struct video_event kevent;
@@ -159,7 +160,7 @@ static int do_video_get_event(struct file *file, unsigned int fd,
159 int err; 160 int err;
160 161
161 set_fs(KERNEL_DS); 162 set_fs(KERNEL_DS);
162 err = do_ioctl(file, fd, cmd, (unsigned long) &kevent); 163 err = do_ioctl(file, cmd, (unsigned long) &kevent);
163 set_fs(old_fs); 164 set_fs(old_fs);
164 165
165 if (!err) { 166 if (!err) {
@@ -181,7 +182,7 @@ struct compat_video_still_picture {
181 int32_t size; 182 int32_t size;
182}; 183};
183 184
184static int do_video_stillpicture(struct file *file, unsigned int fd, 185static int do_video_stillpicture(struct file *file,
185 unsigned int cmd, struct compat_video_still_picture __user *up) 186 unsigned int cmd, struct compat_video_still_picture __user *up)
186{ 187{
187 struct video_still_picture __user *up_native; 188 struct video_still_picture __user *up_native;
@@ -202,7 +203,7 @@ static int do_video_stillpicture(struct file *file, unsigned int fd,
202 if (err) 203 if (err)
203 return -EFAULT; 204 return -EFAULT;
204 205
205 err = do_ioctl(file, fd, cmd, (unsigned long) up_native); 206 err = do_ioctl(file, cmd, (unsigned long) up_native);
206 207
207 return err; 208 return err;
208} 209}
@@ -212,7 +213,7 @@ struct compat_video_spu_palette {
212 compat_uptr_t palette; 213 compat_uptr_t palette;
213}; 214};
214 215
215static int do_video_set_spu_palette(struct file *file, unsigned int fd, 216static int do_video_set_spu_palette(struct file *file,
216 unsigned int cmd, struct compat_video_spu_palette __user *up) 217 unsigned int cmd, struct compat_video_spu_palette __user *up)
217{ 218{
218 struct video_spu_palette __user *up_native; 219 struct video_spu_palette __user *up_native;
@@ -230,7 +231,7 @@ static int do_video_set_spu_palette(struct file *file, unsigned int fd,
230 if (err) 231 if (err)
231 return -EFAULT; 232 return -EFAULT;
232 233
233 err = do_ioctl(file, fd, cmd, (unsigned long) up_native); 234 err = do_ioctl(file, cmd, (unsigned long) up_native);
234 235
235 return err; 236 return err;
236} 237}
@@ -288,7 +289,7 @@ static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iov
288 return 0; 289 return 0;
289} 290}
290 291
291static int sg_ioctl_trans(struct file *file, unsigned int fd, unsigned int cmd, 292static int sg_ioctl_trans(struct file *file, unsigned int cmd,
292 sg_io_hdr32_t __user *sgio32) 293 sg_io_hdr32_t __user *sgio32)
293{ 294{
294 sg_io_hdr_t __user *sgio; 295 sg_io_hdr_t __user *sgio;
@@ -301,7 +302,7 @@ static int sg_ioctl_trans(struct file *file, unsigned int fd, unsigned int cmd,
301 if (get_user(interface_id, &sgio32->interface_id)) 302 if (get_user(interface_id, &sgio32->interface_id))
302 return -EFAULT; 303 return -EFAULT;
303 if (interface_id != 'S') 304 if (interface_id != 'S')
304 return do_ioctl(file, fd, cmd, (unsigned long)sgio32); 305 return do_ioctl(file, cmd, (unsigned long)sgio32);
305 306
306 if (get_user(iovec_count, &sgio32->iovec_count)) 307 if (get_user(iovec_count, &sgio32->iovec_count))
307 return -EFAULT; 308 return -EFAULT;
@@ -361,7 +362,7 @@ static int sg_ioctl_trans(struct file *file, unsigned int fd, unsigned int cmd,
361 if (put_user(compat_ptr(data), &sgio->usr_ptr)) 362 if (put_user(compat_ptr(data), &sgio->usr_ptr))
362 return -EFAULT; 363 return -EFAULT;
363 364
364 err = do_ioctl(file, fd, cmd, (unsigned long) sgio); 365 err = do_ioctl(file, cmd, (unsigned long) sgio);
365 366
366 if (err >= 0) { 367 if (err >= 0) {
367 void __user *datap; 368 void __user *datap;
@@ -392,13 +393,13 @@ struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
392 int unused; 393 int unused;
393}; 394};
394 395
395static int sg_grt_trans(struct file *file, unsigned int fd, 396static int sg_grt_trans(struct file *file,
396 unsigned int cmd, struct compat_sg_req_info __user *o) 397 unsigned int cmd, struct compat_sg_req_info __user *o)
397{ 398{
398 int err, i; 399 int err, i;
399 sg_req_info_t __user *r; 400 sg_req_info_t __user *r;
400 r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE); 401 r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE);
401 err = do_ioctl(file, fd, cmd, (unsigned long)r); 402 err = do_ioctl(file, cmd, (unsigned long)r);
402 if (err < 0) 403 if (err < 0)
403 return err; 404 return err;
404 for (i = 0; i < SG_MAX_QUEUE; i++) { 405 for (i = 0; i < SG_MAX_QUEUE; i++) {
@@ -424,7 +425,7 @@ struct sock_fprog32 {
424#define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32) 425#define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32)
425#define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32) 426#define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
426 427
427static int ppp_sock_fprog_ioctl_trans(struct file *file, unsigned int fd, 428static int ppp_sock_fprog_ioctl_trans(struct file *file,
428 unsigned int cmd, struct sock_fprog32 __user *u_fprog32) 429 unsigned int cmd, struct sock_fprog32 __user *u_fprog32)
429{ 430{
430 struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog)); 431 struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog));
@@ -447,7 +448,7 @@ static int ppp_sock_fprog_ioctl_trans(struct file *file, unsigned int fd,
447 else 448 else
448 cmd = PPPIOCSACTIVE; 449 cmd = PPPIOCSACTIVE;
449 450
450 return do_ioctl(file, fd, cmd, (unsigned long) u_fprog64); 451 return do_ioctl(file, cmd, (unsigned long) u_fprog64);
451} 452}
452 453
453struct ppp_option_data32 { 454struct ppp_option_data32 {
@@ -463,7 +464,7 @@ struct ppp_idle32 {
463}; 464};
464#define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32) 465#define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
465 466
466static int ppp_gidle(struct file *file, unsigned int fd, unsigned int cmd, 467static int ppp_gidle(struct file *file, unsigned int cmd,
467 struct ppp_idle32 __user *idle32) 468 struct ppp_idle32 __user *idle32)
468{ 469{
469 struct ppp_idle __user *idle; 470 struct ppp_idle __user *idle;
@@ -472,7 +473,7 @@ static int ppp_gidle(struct file *file, unsigned int fd, unsigned int cmd,
472 473
473 idle = compat_alloc_user_space(sizeof(*idle)); 474 idle = compat_alloc_user_space(sizeof(*idle));
474 475
475 err = do_ioctl(file, fd, PPPIOCGIDLE, (unsigned long) idle); 476 err = do_ioctl(file, PPPIOCGIDLE, (unsigned long) idle);
476 477
477 if (!err) { 478 if (!err) {
478 if (get_user(xmit, &idle->xmit_idle) || 479 if (get_user(xmit, &idle->xmit_idle) ||
@@ -484,7 +485,7 @@ static int ppp_gidle(struct file *file, unsigned int fd, unsigned int cmd,
484 return err; 485 return err;
485} 486}
486 487
487static int ppp_scompress(struct file *file, unsigned int fd, unsigned int cmd, 488static int ppp_scompress(struct file *file, unsigned int cmd,
488 struct ppp_option_data32 __user *odata32) 489 struct ppp_option_data32 __user *odata32)
489{ 490{
490 struct ppp_option_data __user *odata; 491 struct ppp_option_data __user *odata;
@@ -504,7 +505,7 @@ static int ppp_scompress(struct file *file, unsigned int fd, unsigned int cmd,
504 sizeof(__u32) + sizeof(int))) 505 sizeof(__u32) + sizeof(int)))
505 return -EFAULT; 506 return -EFAULT;
506 507
507 return do_ioctl(file, fd, PPPIOCSCOMPRESS, (unsigned long) odata); 508 return do_ioctl(file, PPPIOCSCOMPRESS, (unsigned long) odata);
508} 509}
509 510
510#ifdef CONFIG_BLOCK 511#ifdef CONFIG_BLOCK
@@ -524,7 +525,7 @@ struct mtpos32 {
524}; 525};
525#define MTIOCPOS32 _IOR('m', 3, struct mtpos32) 526#define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
526 527
527static int mt_ioctl_trans(struct file *file, unsigned int fd, 528static int mt_ioctl_trans(struct file *file,
528 unsigned int cmd, void __user *argp) 529 unsigned int cmd, void __user *argp)
529{ 530{
530 mm_segment_t old_fs = get_fs(); 531 mm_segment_t old_fs = get_fs();
@@ -547,7 +548,7 @@ static int mt_ioctl_trans(struct file *file, unsigned int fd,
547 break; 548 break;
548 } 549 }
549 set_fs (KERNEL_DS); 550 set_fs (KERNEL_DS);
550 err = do_ioctl(file, fd, kcmd, (unsigned long)karg); 551 err = do_ioctl(file, kcmd, (unsigned long)karg);
551 set_fs (old_fs); 552 set_fs (old_fs);
552 if (err) 553 if (err)
553 return err; 554 return err;
@@ -618,7 +619,7 @@ struct serial_struct32 {
618 compat_int_t reserved[1]; 619 compat_int_t reserved[1];
619}; 620};
620 621
621static int serial_struct_ioctl(struct file *file, unsigned fd, 622static int serial_struct_ioctl(struct file *file,
622 unsigned cmd, struct serial_struct32 __user *ss32) 623 unsigned cmd, struct serial_struct32 __user *ss32)
623{ 624{
624 typedef struct serial_struct32 SS32; 625 typedef struct serial_struct32 SS32;
@@ -642,7 +643,7 @@ static int serial_struct_ioctl(struct file *file, unsigned fd,
642 ss.iomap_base = 0UL; 643 ss.iomap_base = 0UL;
643 } 644 }
644 set_fs(KERNEL_DS); 645 set_fs(KERNEL_DS);
645 err = do_ioctl(file, fd, cmd, (unsigned long)&ss); 646 err = do_ioctl(file, cmd, (unsigned long)&ss);
646 set_fs(oldseg); 647 set_fs(oldseg);
647 if (cmd == TIOCGSERIAL && err >= 0) { 648 if (cmd == TIOCGSERIAL && err >= 0) {
648 if (!access_ok(VERIFY_WRITE, ss32, sizeof(SS32))) 649 if (!access_ok(VERIFY_WRITE, ss32, sizeof(SS32)))
@@ -687,7 +688,7 @@ struct i2c_rdwr_aligned {
687 struct i2c_msg msgs[0]; 688 struct i2c_msg msgs[0];
688}; 689};
689 690
690static int do_i2c_rdwr_ioctl(struct file *file, unsigned int fd, 691static int do_i2c_rdwr_ioctl(struct file *file,
691 unsigned int cmd, struct i2c_rdwr_ioctl_data32 __user *udata) 692 unsigned int cmd, struct i2c_rdwr_ioctl_data32 __user *udata)
692{ 693{
693 struct i2c_rdwr_aligned __user *tdata; 694 struct i2c_rdwr_aligned __user *tdata;
@@ -721,10 +722,10 @@ static int do_i2c_rdwr_ioctl(struct file *file, unsigned int fd,
721 put_user(compat_ptr(datap), &tmsgs[i].buf)) 722 put_user(compat_ptr(datap), &tmsgs[i].buf))
722 return -EFAULT; 723 return -EFAULT;
723 } 724 }
724 return do_ioctl(file, fd, cmd, (unsigned long)tdata); 725 return do_ioctl(file, cmd, (unsigned long)tdata);
725} 726}
726 727
727static int do_i2c_smbus_ioctl(struct file *file, unsigned int fd, 728static int do_i2c_smbus_ioctl(struct file *file,
728 unsigned int cmd, struct i2c_smbus_ioctl_data32 __user *udata) 729 unsigned int cmd, struct i2c_smbus_ioctl_data32 __user *udata)
729{ 730{
730 struct i2c_smbus_ioctl_data __user *tdata; 731 struct i2c_smbus_ioctl_data __user *tdata;
@@ -747,7 +748,7 @@ static int do_i2c_smbus_ioctl(struct file *file, unsigned int fd,
747 __put_user(compat_ptr(datap), &tdata->data)) 748 __put_user(compat_ptr(datap), &tdata->data))
748 return -EFAULT; 749 return -EFAULT;
749 750
750 return do_ioctl(file, fd, cmd, (unsigned long)tdata); 751 return do_ioctl(file, cmd, (unsigned long)tdata);
751} 752}
752 753
753#define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t) 754#define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t)
@@ -755,7 +756,7 @@ static int do_i2c_smbus_ioctl(struct file *file, unsigned int fd,
755#define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t) 756#define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t)
756#define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t) 757#define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t)
757 758
758static int rtc_ioctl(struct file *file, unsigned fd, 759static int rtc_ioctl(struct file *file,
759 unsigned cmd, void __user *argp) 760 unsigned cmd, void __user *argp)
760{ 761{
761 mm_segment_t oldfs = get_fs(); 762 mm_segment_t oldfs = get_fs();
@@ -767,7 +768,7 @@ static int rtc_ioctl(struct file *file, unsigned fd,
767 case RTC_IRQP_READ32: 768 case RTC_IRQP_READ32:
768 case RTC_EPOCH_READ32: 769 case RTC_EPOCH_READ32:
769 set_fs(KERNEL_DS); 770 set_fs(KERNEL_DS);
770 ret = do_ioctl(file, fd, (cmd == RTC_IRQP_READ32) ? 771 ret = do_ioctl(file, (cmd == RTC_IRQP_READ32) ?
771 RTC_IRQP_READ : RTC_EPOCH_READ, 772 RTC_IRQP_READ : RTC_EPOCH_READ,
772 (unsigned long)&kval); 773 (unsigned long)&kval);
773 set_fs(oldfs); 774 set_fs(oldfs);
@@ -776,9 +777,9 @@ static int rtc_ioctl(struct file *file, unsigned fd,
776 val32 = kval; 777 val32 = kval;
777 return put_user(val32, (unsigned int __user *)argp); 778 return put_user(val32, (unsigned int __user *)argp);
778 case RTC_IRQP_SET32: 779 case RTC_IRQP_SET32:
779 return do_ioctl(file, fd, RTC_IRQP_SET, (unsigned long)argp); 780 return do_ioctl(file, RTC_IRQP_SET, (unsigned long)argp);
780 case RTC_EPOCH_SET32: 781 case RTC_EPOCH_SET32:
781 return do_ioctl(file, fd, RTC_EPOCH_SET, (unsigned long)argp); 782 return do_ioctl(file, RTC_EPOCH_SET, (unsigned long)argp);
782 } 783 }
783 784
784 return -ENOIOCTLCMD; 785 return -ENOIOCTLCMD;
@@ -1450,53 +1451,53 @@ IGNORE_IOCTL(FBIOGCURSOR32)
1450 * a compat_ioctl operation in the place that handleѕ the 1451 * a compat_ioctl operation in the place that handleѕ the
1451 * ioctl for the native case. 1452 * ioctl for the native case.
1452 */ 1453 */
1453static long do_ioctl_trans(int fd, unsigned int cmd, 1454static long do_ioctl_trans(unsigned int cmd,
1454 unsigned long arg, struct file *file) 1455 unsigned long arg, struct file *file)
1455{ 1456{
1456 void __user *argp = compat_ptr(arg); 1457 void __user *argp = compat_ptr(arg);
1457 1458
1458 switch (cmd) { 1459 switch (cmd) {
1459 case PPPIOCGIDLE32: 1460 case PPPIOCGIDLE32:
1460 return ppp_gidle(file, fd, cmd, argp); 1461 return ppp_gidle(file, cmd, argp);
1461 case PPPIOCSCOMPRESS32: 1462 case PPPIOCSCOMPRESS32:
1462 return ppp_scompress(file, fd, cmd, argp); 1463 return ppp_scompress(file, cmd, argp);
1463 case PPPIOCSPASS32: 1464 case PPPIOCSPASS32:
1464 case PPPIOCSACTIVE32: 1465 case PPPIOCSACTIVE32:
1465 return ppp_sock_fprog_ioctl_trans(file, fd, cmd, argp); 1466 return ppp_sock_fprog_ioctl_trans(file, cmd, argp);
1466#ifdef CONFIG_BLOCK 1467#ifdef CONFIG_BLOCK
1467 case SG_IO: 1468 case SG_IO:
1468 return sg_ioctl_trans(file, fd, cmd, argp); 1469 return sg_ioctl_trans(file, cmd, argp);
1469 case SG_GET_REQUEST_TABLE: 1470 case SG_GET_REQUEST_TABLE:
1470 return sg_grt_trans(file, fd, cmd, argp); 1471 return sg_grt_trans(file, cmd, argp);
1471 case MTIOCGET32: 1472 case MTIOCGET32:
1472 case MTIOCPOS32: 1473 case MTIOCPOS32:
1473 return mt_ioctl_trans(file, fd, cmd, argp); 1474 return mt_ioctl_trans(file, cmd, argp);
1474#endif 1475#endif
1475 /* Serial */ 1476 /* Serial */
1476 case TIOCGSERIAL: 1477 case TIOCGSERIAL:
1477 case TIOCSSERIAL: 1478 case TIOCSSERIAL:
1478 return serial_struct_ioctl(file, fd, cmd, argp); 1479 return serial_struct_ioctl(file, cmd, argp);
1479 /* i2c */ 1480 /* i2c */
1480 case I2C_FUNCS: 1481 case I2C_FUNCS:
1481 return w_long(file, fd, cmd, argp); 1482 return w_long(file, cmd, argp);
1482 case I2C_RDWR: 1483 case I2C_RDWR:
1483 return do_i2c_rdwr_ioctl(file, fd, cmd, argp); 1484 return do_i2c_rdwr_ioctl(file, cmd, argp);
1484 case I2C_SMBUS: 1485 case I2C_SMBUS:
1485 return do_i2c_smbus_ioctl(file, fd, cmd, argp); 1486 return do_i2c_smbus_ioctl(file, cmd, argp);
1486 /* Not implemented in the native kernel */ 1487 /* Not implemented in the native kernel */
1487 case RTC_IRQP_READ32: 1488 case RTC_IRQP_READ32:
1488 case RTC_IRQP_SET32: 1489 case RTC_IRQP_SET32:
1489 case RTC_EPOCH_READ32: 1490 case RTC_EPOCH_READ32:
1490 case RTC_EPOCH_SET32: 1491 case RTC_EPOCH_SET32:
1491 return rtc_ioctl(file, fd, cmd, argp); 1492 return rtc_ioctl(file, cmd, argp);
1492 1493
1493 /* dvb */ 1494 /* dvb */
1494 case VIDEO_GET_EVENT: 1495 case VIDEO_GET_EVENT:
1495 return do_video_get_event(file, fd, cmd, argp); 1496 return do_video_get_event(file, cmd, argp);
1496 case VIDEO_STILLPICTURE: 1497 case VIDEO_STILLPICTURE:
1497 return do_video_stillpicture(file, fd, cmd, argp); 1498 return do_video_stillpicture(file, cmd, argp);
1498 case VIDEO_SET_SPU_PALETTE: 1499 case VIDEO_SET_SPU_PALETTE:
1499 return do_video_set_spu_palette(file, fd, cmd, argp); 1500 return do_video_set_spu_palette(file, cmd, argp);
1500 } 1501 }
1501 1502
1502 /* 1503 /*
@@ -1527,7 +1528,7 @@ static long do_ioctl_trans(int fd, unsigned int cmd,
1527 case NBD_SET_BLKSIZE: 1528 case NBD_SET_BLKSIZE:
1528 case NBD_SET_SIZE: 1529 case NBD_SET_SIZE:
1529 case NBD_SET_SIZE_BLOCKS: 1530 case NBD_SET_SIZE_BLOCKS:
1530 return do_vfs_ioctl(file, fd, cmd, arg); 1531 return vfs_ioctl(file, cmd, arg);
1531 } 1532 }
1532 1533
1533 return -ENOIOCTLCMD; 1534 return -ENOIOCTLCMD;
@@ -1616,7 +1617,7 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd,
1616 if (compat_ioctl_check_table(XFORM(cmd))) 1617 if (compat_ioctl_check_table(XFORM(cmd)))
1617 goto found_handler; 1618 goto found_handler;
1618 1619
1619 error = do_ioctl_trans(fd, cmd, arg, f.file); 1620 error = do_ioctl_trans(cmd, arg, f.file);
1620 if (error == -ENOIOCTLCMD) 1621 if (error == -ENOIOCTLCMD)
1621 error = -ENOTTY; 1622 error = -ENOTTY;
1622 1623
diff --git a/fs/internal.h b/fs/internal.h
index 71859c4d0b41..e38c08ca437d 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -151,3 +151,10 @@ extern void mnt_pin_kill(struct mount *m);
151 * fs/nsfs.c 151 * fs/nsfs.c
152 */ 152 */
153extern struct dentry_operations ns_dentry_operations; 153extern struct dentry_operations ns_dentry_operations;
154
155/*
156 * fs/ioctl.c
157 */
158extern int do_vfs_ioctl(struct file *file, unsigned int fd, unsigned int cmd,
159 unsigned long arg);
160extern long vfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 5d01d2638ca5..41c352e81193 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -15,6 +15,7 @@
15#include <linux/writeback.h> 15#include <linux/writeback.h>
16#include <linux/buffer_head.h> 16#include <linux/buffer_head.h>
17#include <linux/falloc.h> 17#include <linux/falloc.h>
18#include "internal.h"
18 19
19#include <asm/ioctls.h> 20#include <asm/ioctls.h>
20 21
@@ -32,8 +33,7 @@
32 * 33 *
33 * Returns 0 on success, -errno on error. 34 * Returns 0 on success, -errno on error.
34 */ 35 */
35static long vfs_ioctl(struct file *filp, unsigned int cmd, 36long vfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36 unsigned long arg)
37{ 37{
38 int error = -ENOTTY; 38 int error = -ENOTTY;
39 39
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 3aa514254161..51f9f8d93d4d 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2764,8 +2764,6 @@ extern int vfs_lstat(const char __user *, struct kstat *);
2764extern int vfs_fstat(unsigned int, struct kstat *); 2764extern int vfs_fstat(unsigned int, struct kstat *);
2765extern int vfs_fstatat(int , const char __user *, struct kstat *, int); 2765extern int vfs_fstatat(int , const char __user *, struct kstat *, int);
2766 2766
2767extern int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
2768 unsigned long arg);
2769extern int __generic_block_fiemap(struct inode *inode, 2767extern int __generic_block_fiemap(struct inode *inode,
2770 struct fiemap_extent_info *fieinfo, 2768 struct fiemap_extent_info *fieinfo,
2771 loff_t start, loff_t len, 2769 loff_t start, loff_t len,