diff options
author | Arnd Bergmann <arnd@arndb.de> | 2019-03-15 17:26:56 +0100 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2020-01-03 09:33:24 +0100 |
commit | c103d6ee69f93e123dd05e7d307b099b83c0d82c (patch) | |
tree | 268893eb3bde4dffa21004fa28c51b97545e687f /drivers/ide/ide-floppy_ioctl.c | |
parent | fe0da4e5e8c661663297315da0fa47532ca5f362 (diff) | |
download | linux-c103d6ee69f93e123dd05e7d307b099b83c0d82c.tar.gz linux-c103d6ee69f93e123dd05e7d307b099b83c0d82c.tar.bz2 linux-c103d6ee69f93e123dd05e7d307b099b83c0d82c.zip |
compat_ioctl: ide: floppy: add handler
Rather than relying on fs/compat_ioctl.c, this adds support
for a compat_ioctl() callback in the ide-floppy driver directly,
which lets it translate the scsi commands.
Reviewed-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers/ide/ide-floppy_ioctl.c')
-rw-r--r-- | drivers/ide/ide-floppy_ioctl.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/ide/ide-floppy_ioctl.c b/drivers/ide/ide-floppy_ioctl.c index 40a2ebe34e1d..4fd70f804d6f 100644 --- a/drivers/ide/ide-floppy_ioctl.c +++ b/drivers/ide/ide-floppy_ioctl.c @@ -5,6 +5,7 @@ #include <linux/kernel.h> #include <linux/ide.h> +#include <linux/compat.h> #include <linux/cdrom.h> #include <linux/mutex.h> @@ -302,3 +303,38 @@ out: mutex_unlock(&ide_floppy_ioctl_mutex); return err; } + +#ifdef CONFIG_COMPAT +int ide_floppy_compat_ioctl(ide_drive_t *drive, struct block_device *bdev, + fmode_t mode, unsigned int cmd, unsigned long arg) +{ + struct ide_atapi_pc pc; + void __user *argp = compat_ptr(arg); + int err; + + mutex_lock(&ide_floppy_ioctl_mutex); + if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR) { + err = ide_floppy_lockdoor(drive, &pc, arg, cmd); + goto out; + } + + err = ide_floppy_format_ioctl(drive, &pc, mode, cmd, argp); + if (err != -ENOTTY) + goto out; + + /* + * skip SCSI_IOCTL_SEND_COMMAND (deprecated) + * and CDROM_SEND_PACKET (legacy) ioctls + */ + if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND) + err = scsi_cmd_blk_ioctl(bdev, mode, cmd, argp); + + /* + * there is no generic_ide_compat_ioctl(), that is handled + * through compat_blkdev_ioctl(). + */ +out: + mutex_unlock(&ide_floppy_ioctl_mutex); + return err; +} +#endif |