Commit 2daa672b1a736d41b3e7a2e3a05f1909a1f96530
Committed by
Jens Axboe
1 parent
409f3499a2
Exists in
master
and in
4 other branches
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>
Showing 1 changed file with 16 additions and 5 deletions Side-by-side Diff
drivers/message/i2o/i2o_block.c
... | ... | @@ -657,30 +657,40 @@ |
657 | 657 | { |
658 | 658 | struct gendisk *disk = bdev->bd_disk; |
659 | 659 | struct i2o_block_device *dev = disk->private_data; |
660 | + int ret = -ENOTTY; | |
660 | 661 | |
661 | 662 | /* Anyone capable of this syscall can do *real bad* things */ |
662 | 663 | |
663 | 664 | if (!capable(CAP_SYS_ADMIN)) |
664 | 665 | return -EPERM; |
665 | 666 | |
667 | + lock_kernel(); | |
666 | 668 | switch (cmd) { |
667 | 669 | case BLKI2OGRSTRAT: |
668 | - return put_user(dev->rcache, (int __user *)arg); | |
670 | + ret = put_user(dev->rcache, (int __user *)arg); | |
671 | + break; | |
669 | 672 | case BLKI2OGWSTRAT: |
670 | - return put_user(dev->wcache, (int __user *)arg); | |
673 | + ret = put_user(dev->wcache, (int __user *)arg); | |
674 | + break; | |
671 | 675 | case BLKI2OSRSTRAT: |
676 | + ret = -EINVAL; | |
672 | 677 | if (arg < 0 || arg > CACHE_SMARTFETCH) |
673 | - return -EINVAL; | |
678 | + break; | |
674 | 679 | dev->rcache = arg; |
680 | + ret = 0; | |
675 | 681 | break; |
676 | 682 | case BLKI2OSWSTRAT: |
683 | + ret = -EINVAL; | |
677 | 684 | if (arg != 0 |
678 | 685 | && (arg < CACHE_WRITETHROUGH || arg > CACHE_SMARTBACK)) |
679 | - return -EINVAL; | |
686 | + break; | |
680 | 687 | dev->wcache = arg; |
688 | + ret = 0; | |
681 | 689 | break; |
682 | 690 | } |
683 | - return -ENOTTY; | |
691 | + unlock_kernel(); | |
692 | + | |
693 | + return ret; | |
684 | 694 | }; |
685 | 695 | |
686 | 696 | /** |
... | ... | @@ -936,6 +946,7 @@ |
936 | 946 | .open = i2o_block_open, |
937 | 947 | .release = i2o_block_release, |
938 | 948 | .ioctl = i2o_block_ioctl, |
949 | + .compat_ioctl = i2o_block_ioctl, | |
939 | 950 | .getgeo = i2o_block_getgeo, |
940 | 951 | .media_changed = i2o_block_media_changed |
941 | 952 | }; |