aboutsummaryrefslogtreecommitdiffstats
path: root/block/compat_ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/compat_ioctl.c')
-rw-r--r--block/compat_ioctl.c73
1 files changed, 26 insertions, 47 deletions
diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
index fd537fdb25a3..504344d29022 100644
--- a/block/compat_ioctl.c
+++ b/block/compat_ioctl.c
@@ -71,8 +71,8 @@ static int compat_hdio_getgeo(struct gendisk *disk, struct block_device *bdev,
71 return ret; 71 return ret;
72} 72}
73 73
74static int compat_hdio_ioctl(struct inode *inode, struct file *file, 74static int compat_hdio_ioctl(struct block_device *bdev, fmode_t mode,
75 struct gendisk *disk, unsigned int cmd, unsigned long arg) 75 unsigned int cmd, unsigned long arg)
76{ 76{
77 mm_segment_t old_fs = get_fs(); 77 mm_segment_t old_fs = get_fs();
78 unsigned long kval; 78 unsigned long kval;
@@ -80,7 +80,7 @@ static int compat_hdio_ioctl(struct inode *inode, struct file *file,
80 int error; 80 int error;
81 81
82 set_fs(KERNEL_DS); 82 set_fs(KERNEL_DS);
83 error = blkdev_driver_ioctl(inode, file, disk, 83 error = __blkdev_driver_ioctl(bdev, mode,
84 cmd, (unsigned long)(&kval)); 84 cmd, (unsigned long)(&kval));
85 set_fs(old_fs); 85 set_fs(old_fs);
86 86
@@ -111,8 +111,8 @@ struct compat_cdrom_generic_command {
111 compat_caddr_t reserved[1]; 111 compat_caddr_t reserved[1];
112}; 112};
113 113
114static int compat_cdrom_read_audio(struct inode *inode, struct file *file, 114static int compat_cdrom_read_audio(struct block_device *bdev, fmode_t mode,
115 struct gendisk *disk, unsigned int cmd, unsigned long arg) 115 unsigned int cmd, unsigned long arg)
116{ 116{
117 struct cdrom_read_audio __user *cdread_audio; 117 struct cdrom_read_audio __user *cdread_audio;
118 struct compat_cdrom_read_audio __user *cdread_audio32; 118 struct compat_cdrom_read_audio __user *cdread_audio32;
@@ -134,12 +134,12 @@ static int compat_cdrom_read_audio(struct inode *inode, struct file *file,
134 if (put_user(datap, &cdread_audio->buf)) 134 if (put_user(datap, &cdread_audio->buf))
135 return -EFAULT; 135 return -EFAULT;
136 136
137 return blkdev_driver_ioctl(inode, file, disk, cmd, 137 return __blkdev_driver_ioctl(bdev, mode, cmd,
138 (unsigned long)cdread_audio); 138 (unsigned long)cdread_audio);
139} 139}
140 140
141static int compat_cdrom_generic_command(struct inode *inode, struct file *file, 141static int compat_cdrom_generic_command(struct block_device *bdev, fmode_t mode,
142 struct gendisk *disk, unsigned int cmd, unsigned long arg) 142 unsigned int cmd, unsigned long arg)
143{ 143{
144 struct cdrom_generic_command __user *cgc; 144 struct cdrom_generic_command __user *cgc;
145 struct compat_cdrom_generic_command __user *cgc32; 145 struct compat_cdrom_generic_command __user *cgc32;
@@ -167,7 +167,7 @@ static int compat_cdrom_generic_command(struct inode *inode, struct file *file,
167 put_user(compat_ptr(data), &cgc->reserved[0])) 167 put_user(compat_ptr(data), &cgc->reserved[0]))
168 return -EFAULT; 168 return -EFAULT;
169 169
170 return blkdev_driver_ioctl(inode, file, disk, cmd, (unsigned long)cgc); 170 return __blkdev_driver_ioctl(bdev, mode, cmd, (unsigned long)cgc);
171} 171}
172 172
173struct compat_blkpg_ioctl_arg { 173struct compat_blkpg_ioctl_arg {
@@ -308,8 +308,8 @@ static struct {
308 308
309#define NR_FD_IOCTL_TRANS ARRAY_SIZE(fd_ioctl_trans_table) 309#define NR_FD_IOCTL_TRANS ARRAY_SIZE(fd_ioctl_trans_table)
310 310
311static int compat_fd_ioctl(struct inode *inode, struct file *file, 311static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
312 struct gendisk *disk, unsigned int cmd, unsigned long arg) 312 unsigned int cmd, unsigned long arg)
313{ 313{
314 mm_segment_t old_fs = get_fs(); 314 mm_segment_t old_fs = get_fs();
315 void *karg = NULL; 315 void *karg = NULL;
@@ -413,7 +413,7 @@ static int compat_fd_ioctl(struct inode *inode, struct file *file,
413 return -EINVAL; 413 return -EINVAL;
414 } 414 }
415 set_fs(KERNEL_DS); 415 set_fs(KERNEL_DS);
416 err = blkdev_driver_ioctl(inode, file, disk, kcmd, (unsigned long)karg); 416 err = __blkdev_driver_ioctl(bdev, mode, kcmd, (unsigned long)karg);
417 set_fs(old_fs); 417 set_fs(old_fs);
418 if (err) 418 if (err)
419 goto out; 419 goto out;
@@ -579,8 +579,8 @@ static int compat_blk_trace_setup(struct block_device *bdev, char __user *arg)
579 return 0; 579 return 0;
580} 580}
581 581
582static int compat_blkdev_driver_ioctl(struct inode *inode, struct file *file, 582static int compat_blkdev_driver_ioctl(struct block_device *bdev, fmode_t mode,
583 struct gendisk *disk, unsigned cmd, unsigned long arg) 583 unsigned cmd, unsigned long arg)
584{ 584{
585 int ret; 585 int ret;
586 586
@@ -596,7 +596,7 @@ static int compat_blkdev_driver_ioctl(struct inode *inode, struct file *file,
596 case HDIO_GET_ACOUSTIC: 596 case HDIO_GET_ACOUSTIC:
597 case HDIO_GET_ADDRESS: 597 case HDIO_GET_ADDRESS:
598 case HDIO_GET_BUSSTATE: 598 case HDIO_GET_BUSSTATE:
599 return compat_hdio_ioctl(inode, file, disk, cmd, arg); 599 return compat_hdio_ioctl(bdev, mode, cmd, arg);
600 case FDSETPRM32: 600 case FDSETPRM32:
601 case FDDEFPRM32: 601 case FDDEFPRM32:
602 case FDGETPRM32: 602 case FDGETPRM32:
@@ -606,11 +606,11 @@ static int compat_blkdev_driver_ioctl(struct inode *inode, struct file *file,
606 case FDPOLLDRVSTAT32: 606 case FDPOLLDRVSTAT32:
607 case FDGETFDCSTAT32: 607 case FDGETFDCSTAT32:
608 case FDWERRORGET32: 608 case FDWERRORGET32:
609 return compat_fd_ioctl(inode, file, disk, cmd, arg); 609 return compat_fd_ioctl(bdev, mode, cmd, arg);
610 case CDROMREADAUDIO: 610 case CDROMREADAUDIO:
611 return compat_cdrom_read_audio(inode, file, disk, cmd, arg); 611 return compat_cdrom_read_audio(bdev, mode, cmd, arg);
612 case CDROM_SEND_PACKET: 612 case CDROM_SEND_PACKET:
613 return compat_cdrom_generic_command(inode, file, disk, cmd, arg); 613 return compat_cdrom_generic_command(bdev, mode, cmd, arg);
614 614
615 /* 615 /*
616 * No handler required for the ones below, we just need to 616 * No handler required for the ones below, we just need to
@@ -679,40 +679,16 @@ static int compat_blkdev_driver_ioctl(struct inode *inode, struct file *file,
679 case DVD_WRITE_STRUCT: 679 case DVD_WRITE_STRUCT:
680 case DVD_AUTH: 680 case DVD_AUTH:
681 arg = (unsigned long)compat_ptr(arg); 681 arg = (unsigned long)compat_ptr(arg);
682 /* These intepret arg as an unsigned long, not as a pointer,
683 * so we must not do compat_ptr() conversion. */
684 case HDIO_SET_MULTCOUNT:
685 case HDIO_SET_UNMASKINTR:
686 case HDIO_SET_KEEPSETTINGS:
687 case HDIO_SET_32BIT:
688 case HDIO_SET_NOWERR:
689 case HDIO_SET_DMA:
690 case HDIO_SET_PIO_MODE:
691 case HDIO_SET_NICE:
692 case HDIO_SET_WCACHE:
693 case HDIO_SET_ACOUSTIC:
694 case HDIO_SET_BUSSTATE:
695 case HDIO_SET_ADDRESS:
696 case CDROMEJECT_SW:
697 case CDROM_SET_OPTIONS:
698 case CDROM_CLEAR_OPTIONS:
699 case CDROM_SELECT_SPEED:
700 case CDROM_SELECT_DISC:
701 case CDROM_MEDIA_CHANGED:
702 case CDROM_DRIVE_STATUS:
703 case CDROM_LOCKDOOR:
704 case CDROM_DEBUG:
705 break; 682 break;
706 default: 683 default:
707 /* unknown ioctl number */ 684 /* unknown ioctl number */
708 return -ENOIOCTLCMD; 685 return -ENOIOCTLCMD;
709 } 686 }
710 687
711 return __blkdev_driver_ioctl(inode->i_bdev, file->f_mode, cmd, arg); 688 return __blkdev_driver_ioctl(bdev, mode, cmd, arg);
712} 689}
713 690
714static int compat_blkdev_locked_ioctl(struct inode *inode, struct file *file, 691static int compat_blkdev_locked_ioctl(struct block_device *bdev,
715 struct block_device *bdev,
716 unsigned cmd, unsigned long arg) 692 unsigned cmd, unsigned long arg)
717{ 693{
718 struct backing_dev_info *bdi; 694 struct backing_dev_info *bdi;
@@ -772,6 +748,9 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
772 struct inode *inode = file->f_mapping->host; 748 struct inode *inode = file->f_mapping->host;
773 struct block_device *bdev = inode->i_bdev; 749 struct block_device *bdev = inode->i_bdev;
774 struct gendisk *disk = bdev->bd_disk; 750 struct gendisk *disk = bdev->bd_disk;
751 fmode_t mode = file->f_mode;
752 if (file->f_flags & O_NDELAY)
753 mode |= FMODE_NDELAY_NOW;
775 754
776 switch (cmd) { 755 switch (cmd) {
777 case HDIO_GETGEO: 756 case HDIO_GETGEO:
@@ -794,13 +773,13 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
794 } 773 }
795 774
796 lock_kernel(); 775 lock_kernel();
797 ret = compat_blkdev_locked_ioctl(inode, file, bdev, cmd, arg); 776 ret = compat_blkdev_locked_ioctl(bdev, cmd, arg);
798 unlock_kernel(); 777 unlock_kernel();
799 if (ret == -ENOIOCTLCMD && disk->fops->compat_ioctl) 778 if (ret == -ENOIOCTLCMD && disk->fops->compat_ioctl)
800 ret = disk->fops->compat_ioctl(bdev, file->f_mode, cmd, arg); 779 ret = disk->fops->compat_ioctl(bdev, mode, cmd, arg);
801 780
802 if (ret != -ENOIOCTLCMD) 781 if (ret != -ENOIOCTLCMD)
803 return ret; 782 return ret;
804 783
805 return compat_blkdev_driver_ioctl(inode, file, disk, cmd, arg); 784 return compat_blkdev_driver_ioctl(bdev, mode, cmd, arg);
806} 785}