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>
This commit is contained in:
Arnd Bergmann 2019-03-15 17:26:56 +01:00
parent fe0da4e5e8
commit c103d6ee69
5 changed files with 61 additions and 0 deletions

View file

@ -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