diff options
| -rw-r--r-- | drivers/ide/ide.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 4d0c661e78a5..12618d2aed2c 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
| @@ -558,6 +558,28 @@ out: | |||
| 558 | return rc; | 558 | return rc; |
| 559 | } | 559 | } |
| 560 | 560 | ||
| 561 | static int ide_get_nice_ioctl(ide_drive_t *drive, unsigned long arg) | ||
| 562 | { | ||
| 563 | return put_user((drive->dsc_overlap << IDE_NICE_DSC_OVERLAP) | | ||
| 564 | (drive->nice1 << IDE_NICE_1), (long __user *)arg); | ||
| 565 | } | ||
| 566 | |||
| 567 | static int ide_set_nice_ioctl(ide_drive_t *drive, unsigned long arg) | ||
| 568 | { | ||
| 569 | if (arg != (arg & ((1 << IDE_NICE_DSC_OVERLAP) | (1 << IDE_NICE_1)))) | ||
| 570 | return -EPERM; | ||
| 571 | |||
| 572 | if (((arg >> IDE_NICE_DSC_OVERLAP) & 1) && | ||
| 573 | (drive->media == ide_disk || drive->media == ide_floppy || | ||
| 574 | drive->scsi)) | ||
| 575 | return -EPERM; | ||
| 576 | |||
| 577 | drive->dsc_overlap = (arg >> IDE_NICE_DSC_OVERLAP) & 1; | ||
| 578 | drive->nice1 = (arg >> IDE_NICE_1) & 1; | ||
| 579 | |||
| 580 | return 0; | ||
| 581 | } | ||
| 582 | |||
| 561 | int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev, | 583 | int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev, |
| 562 | unsigned int cmd, unsigned long arg) | 584 | unsigned int cmd, unsigned long arg) |
| 563 | { | 585 | { |
| @@ -583,9 +605,7 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device | |||
| 583 | return -EINVAL; | 605 | return -EINVAL; |
| 584 | return ide_get_identity_ioctl(drive, cmd, arg); | 606 | return ide_get_identity_ioctl(drive, cmd, arg); |
| 585 | case HDIO_GET_NICE: | 607 | case HDIO_GET_NICE: |
| 586 | return put_user(drive->dsc_overlap << IDE_NICE_DSC_OVERLAP | | 608 | return ide_get_nice_ioctl(drive, arg); |
| 587 | drive->nice1 << IDE_NICE_1, | ||
| 588 | (long __user *) arg); | ||
| 589 | #ifdef CONFIG_IDE_TASK_IOCTL | 609 | #ifdef CONFIG_IDE_TASK_IOCTL |
| 590 | case HDIO_DRIVE_TASKFILE: | 610 | case HDIO_DRIVE_TASKFILE: |
| 591 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) | 611 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) |
| @@ -608,17 +628,9 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device | |||
| 608 | return -EACCES; | 628 | return -EACCES; |
| 609 | return ide_task_ioctl(drive, cmd, arg); | 629 | return ide_task_ioctl(drive, cmd, arg); |
| 610 | case HDIO_SET_NICE: | 630 | case HDIO_SET_NICE: |
| 611 | if (!capable(CAP_SYS_ADMIN)) return -EACCES; | 631 | if (!capable(CAP_SYS_ADMIN)) |
| 612 | if (arg != (arg & ((1 << IDE_NICE_DSC_OVERLAP) | (1 << IDE_NICE_1)))) | 632 | return -EACCES; |
| 613 | return -EPERM; | 633 | return ide_set_nice_ioctl(drive, arg); |
| 614 | if (((arg >> IDE_NICE_DSC_OVERLAP) & 1) && | ||
| 615 | (drive->media == ide_disk || | ||
| 616 | drive->media == ide_floppy || | ||
| 617 | drive->scsi)) | ||
| 618 | return -EPERM; | ||
| 619 | drive->dsc_overlap = (arg >> IDE_NICE_DSC_OVERLAP) & 1; | ||
| 620 | drive->nice1 = (arg >> IDE_NICE_1) & 1; | ||
| 621 | return 0; | ||
| 622 | case HDIO_DRIVE_RESET: | 634 | case HDIO_DRIVE_RESET: |
| 623 | if (!capable(CAP_SYS_ADMIN)) | 635 | if (!capable(CAP_SYS_ADMIN)) |
| 624 | return -EACCES; | 636 | return -EACCES; |
