diff options
Diffstat (limited to 'block')
-rw-r--r-- | block/compat_ioctl.c | 17 | ||||
-rw-r--r-- | block/ioctl.c | 35 |
2 files changed, 35 insertions, 17 deletions
diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c index 1e559fba7bdf..576c4fd15463 100644 --- a/block/compat_ioctl.c +++ b/block/compat_ioctl.c | |||
@@ -708,17 +708,17 @@ static int compat_blkdev_driver_ioctl(struct inode *inode, struct file *file, | |||
708 | return -ENOIOCTLCMD; | 708 | return -ENOIOCTLCMD; |
709 | } | 709 | } |
710 | 710 | ||
711 | if (disk->fops->unlocked_ioctl) | 711 | if (disk->fops->__unlocked_ioctl) |
712 | return disk->fops->unlocked_ioctl(file, cmd, arg); | 712 | return disk->fops->__unlocked_ioctl(file, cmd, arg); |
713 | 713 | ||
714 | if (disk->fops->ioctl) { | 714 | if (disk->fops->__ioctl) { |
715 | lock_kernel(); | 715 | lock_kernel(); |
716 | ret = disk->fops->ioctl(inode, file, cmd, arg); | 716 | ret = disk->fops->__ioctl(inode, file, cmd, arg); |
717 | unlock_kernel(); | 717 | unlock_kernel(); |
718 | return ret; | 718 | return ret; |
719 | } | 719 | } |
720 | 720 | ||
721 | return -ENOTTY; | 721 | return __blkdev_driver_ioctl(inode->i_bdev, file->f_mode, cmd, arg); |
722 | } | 722 | } |
723 | 723 | ||
724 | static int compat_blkdev_locked_ioctl(struct inode *inode, struct file *file, | 724 | static int compat_blkdev_locked_ioctl(struct inode *inode, struct file *file, |
@@ -805,10 +805,11 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg) | |||
805 | 805 | ||
806 | lock_kernel(); | 806 | lock_kernel(); |
807 | ret = compat_blkdev_locked_ioctl(inode, file, bdev, cmd, arg); | 807 | ret = compat_blkdev_locked_ioctl(inode, file, bdev, cmd, arg); |
808 | /* FIXME: why do we assume -> compat_ioctl needs the BKL? */ | 808 | if (ret == -ENOIOCTLCMD && disk->fops->__compat_ioctl) |
809 | if (ret == -ENOIOCTLCMD && disk->fops->compat_ioctl) | 809 | ret = disk->fops->__compat_ioctl(file, cmd, arg); |
810 | ret = disk->fops->compat_ioctl(file, cmd, arg); | ||
811 | unlock_kernel(); | 810 | unlock_kernel(); |
811 | if (ret == -ENOIOCTLCMD && disk->fops->compat_ioctl) | ||
812 | ret = disk->fops->compat_ioctl(bdev, file->f_mode, cmd, arg); | ||
812 | 813 | ||
813 | if (ret != -ENOIOCTLCMD) | 814 | if (ret != -ENOIOCTLCMD) |
814 | return ret; | 815 | return ret; |
diff --git a/block/ioctl.c b/block/ioctl.c index 9a26ace6d042..01ff463bc801 100644 --- a/block/ioctl.c +++ b/block/ioctl.c | |||
@@ -269,17 +269,24 @@ int blkdev_driver_ioctl(struct inode *inode, struct file *file, | |||
269 | struct gendisk *disk, unsigned cmd, unsigned long arg) | 269 | struct gendisk *disk, unsigned cmd, unsigned long arg) |
270 | { | 270 | { |
271 | int ret; | 271 | int ret; |
272 | if (disk->fops->unlocked_ioctl) | 272 | fmode_t mode = 0; |
273 | return disk->fops->unlocked_ioctl(file, cmd, arg); | 273 | if (file) { |
274 | mode = file->f_mode; | ||
275 | if (file->f_flags & O_NDELAY) | ||
276 | mode |= FMODE_NDELAY_NOW; | ||
277 | } | ||
278 | |||
279 | if (disk->fops->__unlocked_ioctl) | ||
280 | return disk->fops->__unlocked_ioctl(file, cmd, arg); | ||
274 | 281 | ||
275 | if (disk->fops->ioctl) { | 282 | if (disk->fops->__ioctl) { |
276 | lock_kernel(); | 283 | lock_kernel(); |
277 | ret = disk->fops->ioctl(inode, file, cmd, arg); | 284 | ret = disk->fops->__ioctl(inode, file, cmd, arg); |
278 | unlock_kernel(); | 285 | unlock_kernel(); |
279 | return ret; | 286 | return ret; |
280 | } | 287 | } |
281 | 288 | ||
282 | return -ENOTTY; | 289 | return __blkdev_driver_ioctl(inode->i_bdev, mode, cmd, arg); |
283 | } | 290 | } |
284 | EXPORT_SYMBOL_GPL(blkdev_driver_ioctl); | 291 | EXPORT_SYMBOL_GPL(blkdev_driver_ioctl); |
285 | 292 | ||
@@ -295,12 +302,22 @@ int __blkdev_driver_ioctl(struct block_device *bdev, fmode_t mode, | |||
295 | fake_file.f_path.dentry = &fake_dentry; | 302 | fake_file.f_path.dentry = &fake_dentry; |
296 | fake_dentry.d_inode = bdev->bd_inode; | 303 | fake_dentry.d_inode = bdev->bd_inode; |
297 | 304 | ||
298 | if (disk->fops->unlocked_ioctl) | 305 | if (disk->fops->__unlocked_ioctl) |
299 | return disk->fops->unlocked_ioctl(&fake_file, cmd, arg); | 306 | return disk->fops->__unlocked_ioctl(&fake_file, cmd, arg); |
307 | |||
308 | if (disk->fops->__ioctl) { | ||
309 | lock_kernel(); | ||
310 | ret = disk->fops->__ioctl(bdev->bd_inode, &fake_file, cmd, arg); | ||
311 | unlock_kernel(); | ||
312 | return ret; | ||
313 | } | ||
314 | |||
315 | if (disk->fops->ioctl) | ||
316 | return disk->fops->ioctl(bdev, mode, cmd, arg); | ||
300 | 317 | ||
301 | if (disk->fops->ioctl) { | 318 | if (disk->fops->locked_ioctl) { |
302 | lock_kernel(); | 319 | lock_kernel(); |
303 | ret = disk->fops->ioctl(bdev->bd_inode, &fake_file, cmd, arg); | 320 | ret = disk->fops->locked_ioctl(bdev, mode, cmd, arg); |
304 | unlock_kernel(); | 321 | unlock_kernel(); |
305 | return ret; | 322 | return ret; |
306 | } | 323 | } |