X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fblock%2Fioctl.c;h=6d7bcc9da9e72f806d0c3fe77aacca8c1ec896e3;hb=8e8ece46a861c84343256819eaec77e608ff9217;hp=283a9f2facbada3b18a37fe13c1e142508857b22;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/drivers/block/ioctl.c b/drivers/block/ioctl.c index 283a9f2fa..6d7bcc9da 100644 --- a/drivers/block/ioctl.c +++ b/drivers/block/ioctl.c @@ -3,6 +3,7 @@ #include #include #include +#include #include static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user *arg) @@ -194,7 +195,8 @@ int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd, return -EACCES; if (disk->fops->ioctl) { ret = disk->fops->ioctl(inode, file, cmd, arg); - if (ret != -EINVAL) + /* -EINVAL to handle old uncorrected drivers */ + if (ret != -EINVAL && ret != -ENOTTY) return ret; } fsync_bdev(bdev); @@ -219,3 +221,21 @@ int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd, } return -ENOTTY; } + +/* Most of the generic ioctls are handled in the normal fallback path. + This assumes the blkdev's low level compat_ioctl always returns + ENOIOCTLCMD for unknown ioctls. */ +long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg) +{ + struct block_device *bdev = file->f_dentry->d_inode->i_bdev; + struct gendisk *disk = bdev->bd_disk; + int ret = -ENOIOCTLCMD; + if (disk->fops->compat_ioctl) { + lock_kernel(); + ret = disk->fops->compat_ioctl(file, cmd, arg); + unlock_kernel(); + } + return ret; +} + +EXPORT_SYMBOL_GPL(blkdev_ioctl);