Skip to content

Commit 89636af

Browse files
committed
ide: add support for SCSI ioctls to ide-floppy
Now that ide-floppy supports SG_IO we can add support for SCSI ioctls (except deprecated SCSI_IOCTL_SEND_COMMAND and legacy CDROM_SEND_PACKET ones - we can add them later iff really needed). While at it remove handling of CDROMEJECT and CDROMCLOSETRAY ioctls from generic_ide_ioctl(): - This prevents ide-{disk,tape,scsi} device drivers from obtaining REQ_TYPE_BLOCK_PC type requests which are currently unsupported by these drivers and which are potentially harmful (as reported by Andrew). - There is no functionality loss since aforementioned ioctls will now be handled by idefloppy_ioctl()->scsi_cmd_ioctl() (for devices using ide-floppy driver) and by idecd_ioctl->cdrom_ioctl()->scsi_cmd_ioctl() (for devices using ide-cd driver). Cc: Jens Axboe <jens.axboe@oracle.com> Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Cc: James Bottomley <James.Bottomley@steeleye.com> Cc: Jeff Garzik <jeff@garzik.org> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1 parent 4bf9fdf commit 89636af

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

‎drivers/ide/ide-floppy.c‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@
9999
#include <linux/bitops.h>
100100
#include <linux/mutex.h>
101101

102+
#include <scsi/scsi_ioctl.h>
103+
102104
#include <asm/byteorder.h>
103105
#include <asm/irq.h>
104106
#include <asm/uaccess.h>
@@ -2099,7 +2101,21 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file,
20992101
case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS:
21002102
return idefloppy_get_format_progress(drive, argp);
21012103
}
2102-
return generic_ide_ioctl(drive, file, bdev, cmd, arg);
2104+
2105+
/*
2106+
* skip SCSI_IOCTL_SEND_COMMAND (deprecated)
2107+
* and CDROM_SEND_PACKET (legacy) ioctls
2108+
*/
2109+
if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND)
2110+
err = scsi_cmd_ioctl(file, bdev->bd_disk->queue,
2111+
bdev->bd_disk, cmd, argp);
2112+
else
2113+
err = -ENOTTY;
2114+
2115+
if (err == -ENOTTY)
2116+
err = generic_ide_ioctl(drive, file, bdev, cmd, arg);
2117+
2118+
return err;
21032119
}
21042120

21052121
static int idefloppy_media_changed(struct gendisk *disk)

‎drivers/ide/ide.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,10 +1097,6 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device
10971097
return 0;
10981098
}
10991099

1100-
case CDROMEJECT:
1101-
case CDROMCLOSETRAY:
1102-
return scsi_cmd_ioctl(file, bdev->bd_disk->queue, bdev->bd_disk, cmd, p);
1103-
11041100
case HDIO_GET_BUSSTATE:
11051101
if (!capable(CAP_SYS_ADMIN))
11061102
return -EACCES;

0 commit comments

Comments
 (0)