diff options
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/ide-scsi.c | 22 | ||||
-rw-r--r-- | drivers/scsi/scsi_ioctl.c | 6 | ||||
-rw-r--r-- | drivers/scsi/sd.c | 35 | ||||
-rw-r--r-- | drivers/scsi/sg.c | 2 | ||||
-rw-r--r-- | drivers/scsi/sr.c | 40 | ||||
-rw-r--r-- | drivers/scsi/st.c | 7 |
6 files changed, 48 insertions, 64 deletions
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index afc96e844a25..2370fd82ebfe 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
@@ -452,40 +452,34 @@ static ide_driver_t idescsi_driver = { | |||
452 | #endif | 452 | #endif |
453 | }; | 453 | }; |
454 | 454 | ||
455 | static int idescsi_ide_open(struct inode *inode, struct file *filp) | 455 | static int idescsi_ide_open(struct block_device *bdev, fmode_t mode) |
456 | { | 456 | { |
457 | struct gendisk *disk = inode->i_bdev->bd_disk; | 457 | struct ide_scsi_obj *scsi = ide_scsi_get(bdev->bd_disk); |
458 | struct ide_scsi_obj *scsi; | ||
459 | 458 | ||
460 | if (!(scsi = ide_scsi_get(disk))) | 459 | if (!scsi) |
461 | return -ENXIO; | 460 | return -ENXIO; |
462 | 461 | ||
463 | return 0; | 462 | return 0; |
464 | } | 463 | } |
465 | 464 | ||
466 | static int idescsi_ide_release(struct inode *inode, struct file *filp) | 465 | static int idescsi_ide_release(struct gendisk *disk, fmode_t mode) |
467 | { | 466 | { |
468 | struct gendisk *disk = inode->i_bdev->bd_disk; | 467 | ide_scsi_put(ide_scsi_g(disk)); |
469 | struct ide_scsi_obj *scsi = ide_scsi_g(disk); | ||
470 | |||
471 | ide_scsi_put(scsi); | ||
472 | |||
473 | return 0; | 468 | return 0; |
474 | } | 469 | } |
475 | 470 | ||
476 | static int idescsi_ide_ioctl(struct inode *inode, struct file *file, | 471 | static int idescsi_ide_ioctl(struct block_device *bdev, fmode_t mode, |
477 | unsigned int cmd, unsigned long arg) | 472 | unsigned int cmd, unsigned long arg) |
478 | { | 473 | { |
479 | struct block_device *bdev = inode->i_bdev; | ||
480 | struct ide_scsi_obj *scsi = ide_scsi_g(bdev->bd_disk); | 474 | struct ide_scsi_obj *scsi = ide_scsi_g(bdev->bd_disk); |
481 | return generic_ide_ioctl(scsi->drive, file, bdev, cmd, arg); | 475 | return generic_ide_ioctl(scsi->drive, bdev, cmd, arg); |
482 | } | 476 | } |
483 | 477 | ||
484 | static struct block_device_operations idescsi_ops = { | 478 | static struct block_device_operations idescsi_ops = { |
485 | .owner = THIS_MODULE, | 479 | .owner = THIS_MODULE, |
486 | .open = idescsi_ide_open, | 480 | .open = idescsi_ide_open, |
487 | .release = idescsi_ide_release, | 481 | .release = idescsi_ide_release, |
488 | .ioctl = idescsi_ide_ioctl, | 482 | .locked_ioctl = idescsi_ide_ioctl, |
489 | }; | 483 | }; |
490 | 484 | ||
491 | static int idescsi_slave_configure(struct scsi_device * sdp) | 485 | static int idescsi_slave_configure(struct scsi_device * sdp) |
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index 28b19ef26309..dc1cfb2fd76b 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c | |||
@@ -237,7 +237,7 @@ int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) | |||
237 | case SCSI_IOCTL_SEND_COMMAND: | 237 | case SCSI_IOCTL_SEND_COMMAND: |
238 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) | 238 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) |
239 | return -EACCES; | 239 | return -EACCES; |
240 | return sg_scsi_ioctl(NULL, sdev->request_queue, NULL, arg); | 240 | return sg_scsi_ioctl(sdev->request_queue, NULL, 0, arg); |
241 | case SCSI_IOCTL_DOORLOCK: | 241 | case SCSI_IOCTL_DOORLOCK: |
242 | return scsi_set_medium_removal(sdev, SCSI_REMOVAL_PREVENT); | 242 | return scsi_set_medium_removal(sdev, SCSI_REMOVAL_PREVENT); |
243 | case SCSI_IOCTL_DOORUNLOCK: | 243 | case SCSI_IOCTL_DOORUNLOCK: |
@@ -277,14 +277,14 @@ EXPORT_SYMBOL(scsi_ioctl); | |||
277 | * @filp: either NULL or a &struct file which must have the O_NONBLOCK flag. | 277 | * @filp: either NULL or a &struct file which must have the O_NONBLOCK flag. |
278 | */ | 278 | */ |
279 | int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd, | 279 | int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd, |
280 | void __user *arg, struct file *filp) | 280 | void __user *arg, int ndelay) |
281 | { | 281 | { |
282 | int val, result; | 282 | int val, result; |
283 | 283 | ||
284 | /* The first set of iocts may be executed even if we're doing | 284 | /* The first set of iocts may be executed even if we're doing |
285 | * error processing, as long as the device was opened | 285 | * error processing, as long as the device was opened |
286 | * non-blocking */ | 286 | * non-blocking */ |
287 | if (filp && (filp->f_flags & O_NONBLOCK)) { | 287 | if (ndelay) { |
288 | if (scsi_host_in_recovery(sdev->host)) | 288 | if (scsi_host_in_recovery(sdev->host)) |
289 | return -ENODEV; | 289 | return -ENODEV; |
290 | } else if (!scsi_block_when_processing_errors(sdev)) | 290 | } else if (!scsi_block_when_processing_errors(sdev)) |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 7c4d2e68df1c..43f34c73df12 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -609,17 +609,15 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) | |||
609 | * In the latter case @inode and @filp carry an abridged amount | 609 | * In the latter case @inode and @filp carry an abridged amount |
610 | * of information as noted above. | 610 | * of information as noted above. |
611 | **/ | 611 | **/ |
612 | static int sd_open(struct inode *inode, struct file *filp) | 612 | static int sd_open(struct block_device *bdev, fmode_t mode) |
613 | { | 613 | { |
614 | struct gendisk *disk = inode->i_bdev->bd_disk; | 614 | struct scsi_disk *sdkp = scsi_disk_get(bdev->bd_disk); |
615 | struct scsi_disk *sdkp; | ||
616 | struct scsi_device *sdev; | 615 | struct scsi_device *sdev; |
617 | int retval; | 616 | int retval; |
618 | 617 | ||
619 | if (!(sdkp = scsi_disk_get(disk))) | 618 | if (!sdkp) |
620 | return -ENXIO; | 619 | return -ENXIO; |
621 | 620 | ||
622 | |||
623 | SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_open\n")); | 621 | SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_open\n")); |
624 | 622 | ||
625 | sdev = sdkp->device; | 623 | sdev = sdkp->device; |
@@ -633,14 +631,13 @@ static int sd_open(struct inode *inode, struct file *filp) | |||
633 | goto error_out; | 631 | goto error_out; |
634 | 632 | ||
635 | if (sdev->removable || sdkp->write_prot) | 633 | if (sdev->removable || sdkp->write_prot) |
636 | check_disk_change(inode->i_bdev); | 634 | check_disk_change(bdev); |
637 | 635 | ||
638 | /* | 636 | /* |
639 | * If the drive is empty, just let the open fail. | 637 | * If the drive is empty, just let the open fail. |
640 | */ | 638 | */ |
641 | retval = -ENOMEDIUM; | 639 | retval = -ENOMEDIUM; |
642 | if (sdev->removable && !sdkp->media_present && | 640 | if (sdev->removable && !sdkp->media_present && !(mode & FMODE_NDELAY)) |
643 | !(filp->f_flags & O_NDELAY)) | ||
644 | goto error_out; | 641 | goto error_out; |
645 | 642 | ||
646 | /* | 643 | /* |
@@ -648,7 +645,7 @@ static int sd_open(struct inode *inode, struct file *filp) | |||
648 | * if the user expects to be able to write to the thing. | 645 | * if the user expects to be able to write to the thing. |
649 | */ | 646 | */ |
650 | retval = -EROFS; | 647 | retval = -EROFS; |
651 | if (sdkp->write_prot && (filp->f_mode & FMODE_WRITE)) | 648 | if (sdkp->write_prot && (mode & FMODE_WRITE)) |
652 | goto error_out; | 649 | goto error_out; |
653 | 650 | ||
654 | /* | 651 | /* |
@@ -684,9 +681,8 @@ error_out: | |||
684 | * Note: may block (uninterruptible) if error recovery is underway | 681 | * Note: may block (uninterruptible) if error recovery is underway |
685 | * on this disk. | 682 | * on this disk. |
686 | **/ | 683 | **/ |
687 | static int sd_release(struct inode *inode, struct file *filp) | 684 | static int sd_release(struct gendisk *disk, fmode_t mode) |
688 | { | 685 | { |
689 | struct gendisk *disk = inode->i_bdev->bd_disk; | ||
690 | struct scsi_disk *sdkp = scsi_disk(disk); | 686 | struct scsi_disk *sdkp = scsi_disk(disk); |
691 | struct scsi_device *sdev = sdkp->device; | 687 | struct scsi_device *sdev = sdkp->device; |
692 | 688 | ||
@@ -743,10 +739,9 @@ static int sd_getgeo(struct block_device *bdev, struct hd_geometry *geo) | |||
743 | * Note: most ioctls are forward onto the block subsystem or further | 739 | * Note: most ioctls are forward onto the block subsystem or further |
744 | * down in the scsi subsystem. | 740 | * down in the scsi subsystem. |
745 | **/ | 741 | **/ |
746 | static int sd_ioctl(struct inode * inode, struct file * filp, | 742 | static int sd_ioctl(struct block_device *bdev, fmode_t mode, |
747 | unsigned int cmd, unsigned long arg) | 743 | unsigned int cmd, unsigned long arg) |
748 | { | 744 | { |
749 | struct block_device *bdev = inode->i_bdev; | ||
750 | struct gendisk *disk = bdev->bd_disk; | 745 | struct gendisk *disk = bdev->bd_disk; |
751 | struct scsi_device *sdp = scsi_disk(disk)->device; | 746 | struct scsi_device *sdp = scsi_disk(disk)->device; |
752 | void __user *p = (void __user *)arg; | 747 | void __user *p = (void __user *)arg; |
@@ -761,7 +756,8 @@ static int sd_ioctl(struct inode * inode, struct file * filp, | |||
761 | * may try and take the device offline, in which case all further | 756 | * may try and take the device offline, in which case all further |
762 | * access to the device is prohibited. | 757 | * access to the device is prohibited. |
763 | */ | 758 | */ |
764 | error = scsi_nonblockable_ioctl(sdp, cmd, p, filp); | 759 | error = scsi_nonblockable_ioctl(sdp, cmd, p, |
760 | (mode & FMODE_NDELAY_NOW) != 0); | ||
765 | if (!scsi_block_when_processing_errors(sdp) || !error) | 761 | if (!scsi_block_when_processing_errors(sdp) || !error) |
766 | return error; | 762 | return error; |
767 | 763 | ||
@@ -775,7 +771,7 @@ static int sd_ioctl(struct inode * inode, struct file * filp, | |||
775 | case SCSI_IOCTL_GET_BUS_NUMBER: | 771 | case SCSI_IOCTL_GET_BUS_NUMBER: |
776 | return scsi_ioctl(sdp, cmd, p); | 772 | return scsi_ioctl(sdp, cmd, p); |
777 | default: | 773 | default: |
778 | error = scsi_cmd_ioctl(filp, disk->queue, disk, cmd, p); | 774 | error = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, p); |
779 | if (error != -ENOTTY) | 775 | if (error != -ENOTTY) |
780 | return error; | 776 | return error; |
781 | } | 777 | } |
@@ -928,11 +924,10 @@ static void sd_rescan(struct device *dev) | |||
928 | * This gets directly called from VFS. When the ioctl | 924 | * This gets directly called from VFS. When the ioctl |
929 | * is not recognized we go back to the other translation paths. | 925 | * is not recognized we go back to the other translation paths. |
930 | */ | 926 | */ |
931 | static long sd_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 927 | static int sd_compat_ioctl(struct block_device *bdev, fmode_t mode, |
928 | unsigned int cmd, unsigned long arg) | ||
932 | { | 929 | { |
933 | struct block_device *bdev = file->f_path.dentry->d_inode->i_bdev; | 930 | struct scsi_device *sdev = scsi_disk(bdev->bd_disk)->device; |
934 | struct gendisk *disk = bdev->bd_disk; | ||
935 | struct scsi_device *sdev = scsi_disk(disk)->device; | ||
936 | 931 | ||
937 | /* | 932 | /* |
938 | * If we are in the middle of error recovery, don't let anyone | 933 | * If we are in the middle of error recovery, don't let anyone |
@@ -962,7 +957,7 @@ static struct block_device_operations sd_fops = { | |||
962 | .owner = THIS_MODULE, | 957 | .owner = THIS_MODULE, |
963 | .open = sd_open, | 958 | .open = sd_open, |
964 | .release = sd_release, | 959 | .release = sd_release, |
965 | .ioctl = sd_ioctl, | 960 | .locked_ioctl = sd_ioctl, |
966 | .getgeo = sd_getgeo, | 961 | .getgeo = sd_getgeo, |
967 | #ifdef CONFIG_COMPAT | 962 | #ifdef CONFIG_COMPAT |
968 | .compat_ioctl = sd_compat_ioctl, | 963 | .compat_ioctl = sd_compat_ioctl, |
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 93bd59a1ed79..9adf35bd8b56 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -1059,7 +1059,7 @@ sg_ioctl(struct inode *inode, struct file *filp, | |||
1059 | if (sg_allow_access(filp, &opcode)) | 1059 | if (sg_allow_access(filp, &opcode)) |
1060 | return -EPERM; | 1060 | return -EPERM; |
1061 | } | 1061 | } |
1062 | return sg_scsi_ioctl(filp, sdp->device->request_queue, NULL, p); | 1062 | return sg_scsi_ioctl(sdp->device->request_queue, NULL, filp->f_mode, p); |
1063 | case SG_SET_DEBUG: | 1063 | case SG_SET_DEBUG: |
1064 | result = get_user(val, ip); | 1064 | result = get_user(val, ip); |
1065 | if (result) | 1065 | if (result) |
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 0f17009c99d2..62b6633e3a97 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -471,38 +471,31 @@ static int sr_prep_fn(struct request_queue *q, struct request *rq) | |||
471 | return scsi_prep_return(q, rq, ret); | 471 | return scsi_prep_return(q, rq, ret); |
472 | } | 472 | } |
473 | 473 | ||
474 | static int sr_block_open(struct inode *inode, struct file *file) | 474 | static int sr_block_open(struct block_device *bdev, fmode_t mode) |
475 | { | 475 | { |
476 | struct gendisk *disk = inode->i_bdev->bd_disk; | 476 | struct scsi_cd *cd = scsi_cd_get(bdev->bd_disk); |
477 | struct scsi_cd *cd; | 477 | int ret = -ENXIO; |
478 | int ret = 0; | ||
479 | |||
480 | if(!(cd = scsi_cd_get(disk))) | ||
481 | return -ENXIO; | ||
482 | |||
483 | if((ret = cdrom_open(&cd->cdi, inode, file)) != 0) | ||
484 | scsi_cd_put(cd); | ||
485 | 478 | ||
479 | if (cd) { | ||
480 | ret = cdrom_open(&cd->cdi, bdev, mode); | ||
481 | if (ret) | ||
482 | scsi_cd_put(cd); | ||
483 | } | ||
486 | return ret; | 484 | return ret; |
487 | } | 485 | } |
488 | 486 | ||
489 | static int sr_block_release(struct inode *inode, struct file *file) | 487 | static int sr_block_release(struct gendisk *disk, fmode_t mode) |
490 | { | 488 | { |
491 | int ret; | 489 | struct scsi_cd *cd = scsi_cd(disk); |
492 | struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk); | 490 | cdrom_release(&cd->cdi, mode); |
493 | ret = cdrom_release(&cd->cdi, file); | ||
494 | if(ret) | ||
495 | return ret; | ||
496 | |||
497 | scsi_cd_put(cd); | 491 | scsi_cd_put(cd); |
498 | |||
499 | return 0; | 492 | return 0; |
500 | } | 493 | } |
501 | 494 | ||
502 | static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd, | 495 | static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, |
503 | unsigned long arg) | 496 | unsigned long arg) |
504 | { | 497 | { |
505 | struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk); | 498 | struct scsi_cd *cd = scsi_cd(bdev->bd_disk); |
506 | struct scsi_device *sdev = cd->device; | 499 | struct scsi_device *sdev = cd->device; |
507 | void __user *argp = (void __user *)arg; | 500 | void __user *argp = (void __user *)arg; |
508 | int ret; | 501 | int ret; |
@@ -517,7 +510,7 @@ static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd, | |||
517 | return scsi_ioctl(sdev, cmd, argp); | 510 | return scsi_ioctl(sdev, cmd, argp); |
518 | } | 511 | } |
519 | 512 | ||
520 | ret = cdrom_ioctl(file, &cd->cdi, inode, cmd, arg); | 513 | ret = cdrom_ioctl(&cd->cdi, bdev, mode, cmd, arg); |
521 | if (ret != -ENOSYS) | 514 | if (ret != -ENOSYS) |
522 | return ret; | 515 | return ret; |
523 | 516 | ||
@@ -527,7 +520,8 @@ static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd, | |||
527 | * case fall through to scsi_ioctl, which will return ENDOEV again | 520 | * case fall through to scsi_ioctl, which will return ENDOEV again |
528 | * if it doesn't recognise the ioctl | 521 | * if it doesn't recognise the ioctl |
529 | */ | 522 | */ |
530 | ret = scsi_nonblockable_ioctl(sdev, cmd, argp, NULL); | 523 | ret = scsi_nonblockable_ioctl(sdev, cmd, argp, |
524 | (mode & FMODE_NDELAY_NOW) != 0); | ||
531 | if (ret != -ENODEV) | 525 | if (ret != -ENODEV) |
532 | return ret; | 526 | return ret; |
533 | return scsi_ioctl(sdev, cmd, argp); | 527 | return scsi_ioctl(sdev, cmd, argp); |
@@ -544,7 +538,7 @@ static struct block_device_operations sr_bdops = | |||
544 | .owner = THIS_MODULE, | 538 | .owner = THIS_MODULE, |
545 | .open = sr_block_open, | 539 | .open = sr_block_open, |
546 | .release = sr_block_release, | 540 | .release = sr_block_release, |
547 | .ioctl = sr_block_ioctl, | 541 | .locked_ioctl = sr_block_ioctl, |
548 | .media_changed = sr_block_media_changed, | 542 | .media_changed = sr_block_media_changed, |
549 | /* | 543 | /* |
550 | * No compat_ioctl for now because sr_block_ioctl never | 544 | * No compat_ioctl for now because sr_block_ioctl never |
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 5c28d08f18f4..c959bdc55f4f 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -3263,7 +3263,8 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg) | |||
3263 | * may try and take the device offline, in which case all further | 3263 | * may try and take the device offline, in which case all further |
3264 | * access to the device is prohibited. | 3264 | * access to the device is prohibited. |
3265 | */ | 3265 | */ |
3266 | retval = scsi_nonblockable_ioctl(STp->device, cmd_in, p, file); | 3266 | retval = scsi_nonblockable_ioctl(STp->device, cmd_in, p, |
3267 | file->f_flags & O_NDELAY); | ||
3267 | if (!scsi_block_when_processing_errors(STp->device) || retval != -ENODEV) | 3268 | if (!scsi_block_when_processing_errors(STp->device) || retval != -ENODEV) |
3268 | goto out; | 3269 | goto out; |
3269 | retval = 0; | 3270 | retval = 0; |
@@ -3567,8 +3568,8 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg) | |||
3567 | !capable(CAP_SYS_RAWIO)) | 3568 | !capable(CAP_SYS_RAWIO)) |
3568 | i = -EPERM; | 3569 | i = -EPERM; |
3569 | else | 3570 | else |
3570 | i = scsi_cmd_ioctl(file, STp->disk->queue, | 3571 | i = scsi_cmd_ioctl(STp->disk->queue, STp->disk, |
3571 | STp->disk, cmd_in, p); | 3572 | file->f_mode, cmd_in, p); |
3572 | if (i != -ENOTTY) | 3573 | if (i != -ENOTTY) |
3573 | return i; | 3574 | return i; |
3574 | break; | 3575 | break; |