Commit 34484062445fe905bf02c72f87ddda21881acda3
Committed by
Jens Axboe
1 parent
610a63498f
Exists in
master
and in
4 other branches
scsi/i2o_block: cleanup ioctl handling
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 18 additions and 6 deletions Side-by-side Diff
drivers/message/i2o/i2o_block.c
... | ... | @@ -53,6 +53,7 @@ |
53 | 53 | #include <linux/module.h> |
54 | 54 | #include <linux/slab.h> |
55 | 55 | #include <linux/i2o.h> |
56 | +#include <linux/smp_lock.h> | |
56 | 57 | |
57 | 58 | #include <linux/mempool.h> |
58 | 59 | |
59 | 60 | |
60 | 61 | |
61 | 62 | |
62 | 63 | |
63 | 64 | |
64 | 65 | |
65 | 66 | |
66 | 67 | |
67 | 68 | |
68 | 69 | |
... | ... | @@ -652,30 +653,40 @@ |
652 | 653 | { |
653 | 654 | struct gendisk *disk = bdev->bd_disk; |
654 | 655 | struct i2o_block_device *dev = disk->private_data; |
656 | + int ret = -ENOTTY; | |
655 | 657 | |
656 | 658 | /* Anyone capable of this syscall can do *real bad* things */ |
657 | 659 | |
658 | 660 | if (!capable(CAP_SYS_ADMIN)) |
659 | 661 | return -EPERM; |
660 | 662 | |
663 | + lock_kernel(); | |
661 | 664 | switch (cmd) { |
662 | 665 | case BLKI2OGRSTRAT: |
663 | - return put_user(dev->rcache, (int __user *)arg); | |
666 | + ret = put_user(dev->rcache, (int __user *)arg); | |
667 | + break; | |
664 | 668 | case BLKI2OGWSTRAT: |
665 | - return put_user(dev->wcache, (int __user *)arg); | |
669 | + ret = put_user(dev->wcache, (int __user *)arg); | |
670 | + break; | |
666 | 671 | case BLKI2OSRSTRAT: |
672 | + ret = -EINVAL; | |
667 | 673 | if (arg < 0 || arg > CACHE_SMARTFETCH) |
668 | - return -EINVAL; | |
674 | + break; | |
669 | 675 | dev->rcache = arg; |
676 | + ret = 0; | |
670 | 677 | break; |
671 | 678 | case BLKI2OSWSTRAT: |
679 | + ret = -EINVAL; | |
672 | 680 | if (arg != 0 |
673 | 681 | && (arg < CACHE_WRITETHROUGH || arg > CACHE_SMARTBACK)) |
674 | - return -EINVAL; | |
682 | + break; | |
675 | 683 | dev->wcache = arg; |
684 | + ret = 0; | |
676 | 685 | break; |
677 | 686 | } |
678 | - return -ENOTTY; | |
687 | + unlock_kernel(); | |
688 | + | |
689 | + return ret; | |
679 | 690 | }; |
680 | 691 | |
681 | 692 | /** |
... | ... | @@ -930,7 +941,8 @@ |
930 | 941 | .owner = THIS_MODULE, |
931 | 942 | .open = i2o_block_open, |
932 | 943 | .release = i2o_block_release, |
933 | - .locked_ioctl = i2o_block_ioctl, | |
944 | + .ioctl = i2o_block_ioctl, | |
945 | + .compat_ioctl = i2o_block_ioctl, | |
934 | 946 | .getgeo = i2o_block_getgeo, |
935 | 947 | .media_changed = i2o_block_media_changed |
936 | 948 | }; |