diff options
author | Arnd Bergmann <arnd@arndb.de> | 2010-07-08 08:57:03 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-08-07 12:26:29 -0400 |
commit | 2daa672b1a736d41b3e7a2e3a05f1909a1f96530 (patch) | |
tree | 17a9b1f945307192e6cb9dec78472e39da32e727 /drivers/message | |
parent | 409f3499a2cfcd1e9c2857c53af7fcce069f027f (diff) |
scsi/i2o: restore ioctl changes
This restores the changes from "scsi/i2o_block: cleanup ioctl
handling", which accidentally got reverted.
Origignal changelog:
This fixes the ioctl function of the i2o_block driver, which
has multiple problems:
* The BLKI2OSRSTRAT and BLKI2OSWSTRAT commands always return
-ENOTTY on success, where they should return 0.
* Support for 32 bit compat is missing
* The driver should use the .ioctl function and because
.locked_ioctl is going away.
The use of the big kernel lock remains for now, but gets
made explictit in the ioctl function.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'drivers/message')
-rw-r--r-- | drivers/message/i2o/i2o_block.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c index a5bc3ee0d93e..e6733bc99724 100644 --- a/drivers/message/i2o/i2o_block.c +++ b/drivers/message/i2o/i2o_block.c | |||
@@ -657,30 +657,40 @@ static int i2o_block_ioctl(struct block_device *bdev, fmode_t mode, | |||
657 | { | 657 | { |
658 | struct gendisk *disk = bdev->bd_disk; | 658 | struct gendisk *disk = bdev->bd_disk; |
659 | struct i2o_block_device *dev = disk->private_data; | 659 | struct i2o_block_device *dev = disk->private_data; |
660 | int ret = -ENOTTY; | ||
660 | 661 | ||
661 | /* Anyone capable of this syscall can do *real bad* things */ | 662 | /* Anyone capable of this syscall can do *real bad* things */ |
662 | 663 | ||
663 | if (!capable(CAP_SYS_ADMIN)) | 664 | if (!capable(CAP_SYS_ADMIN)) |
664 | return -EPERM; | 665 | return -EPERM; |
665 | 666 | ||
667 | lock_kernel(); | ||
666 | switch (cmd) { | 668 | switch (cmd) { |
667 | case BLKI2OGRSTRAT: | 669 | case BLKI2OGRSTRAT: |
668 | return put_user(dev->rcache, (int __user *)arg); | 670 | ret = put_user(dev->rcache, (int __user *)arg); |
671 | break; | ||
669 | case BLKI2OGWSTRAT: | 672 | case BLKI2OGWSTRAT: |
670 | return put_user(dev->wcache, (int __user *)arg); | 673 | ret = put_user(dev->wcache, (int __user *)arg); |
674 | break; | ||
671 | case BLKI2OSRSTRAT: | 675 | case BLKI2OSRSTRAT: |
676 | ret = -EINVAL; | ||
672 | if (arg < 0 || arg > CACHE_SMARTFETCH) | 677 | if (arg < 0 || arg > CACHE_SMARTFETCH) |
673 | return -EINVAL; | 678 | break; |
674 | dev->rcache = arg; | 679 | dev->rcache = arg; |
680 | ret = 0; | ||
675 | break; | 681 | break; |
676 | case BLKI2OSWSTRAT: | 682 | case BLKI2OSWSTRAT: |
683 | ret = -EINVAL; | ||
677 | if (arg != 0 | 684 | if (arg != 0 |
678 | && (arg < CACHE_WRITETHROUGH || arg > CACHE_SMARTBACK)) | 685 | && (arg < CACHE_WRITETHROUGH || arg > CACHE_SMARTBACK)) |
679 | return -EINVAL; | 686 | break; |
680 | dev->wcache = arg; | 687 | dev->wcache = arg; |
688 | ret = 0; | ||
681 | break; | 689 | break; |
682 | } | 690 | } |
683 | return -ENOTTY; | 691 | unlock_kernel(); |
692 | |||
693 | return ret; | ||
684 | }; | 694 | }; |
685 | 695 | ||
686 | /** | 696 | /** |
@@ -936,6 +946,7 @@ static const struct block_device_operations i2o_block_fops = { | |||
936 | .open = i2o_block_open, | 946 | .open = i2o_block_open, |
937 | .release = i2o_block_release, | 947 | .release = i2o_block_release, |
938 | .ioctl = i2o_block_ioctl, | 948 | .ioctl = i2o_block_ioctl, |
949 | .compat_ioctl = i2o_block_ioctl, | ||
939 | .getgeo = i2o_block_getgeo, | 950 | .getgeo = i2o_block_getgeo, |
940 | .media_changed = i2o_block_media_changed | 951 | .media_changed = i2o_block_media_changed |
941 | }; | 952 | }; |