Commit ab8bc541 authored by Arnd Bergmann's avatar Arnd Bergmann

compat_ioctl: cdrom: handle CDROM_LAST_WRITTEN

This is the only ioctl command that does not have a proper
compat handler. Making the normal implementation do the
right thing is actually very simply, so just do that by
using an in_compat_syscall() check to avoid the special
case in the pkcdvd driver.
Reviewed-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parent 8f8f5620
...@@ -2663,26 +2663,6 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, ...@@ -2663,26 +2663,6 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
return ret; return ret;
} }
#ifdef CONFIG_COMPAT
static int pkt_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg)
{
switch (cmd) {
/* compatible */
case CDROMEJECT:
case CDROMMULTISESSION:
case CDROMREADTOCENTRY:
case CDROM_SEND_PACKET: /* compat mode handled in scsi_cmd_ioctl */
case SCSI_IOCTL_SEND_COMMAND:
return pkt_ioctl(bdev, mode, cmd, (unsigned long)compat_ptr(arg));
/* FIXME: no handler so far */
default:
case CDROM_LAST_WRITTEN:
return -ENOIOCTLCMD;
}
}
#endif
static unsigned int pkt_check_events(struct gendisk *disk, static unsigned int pkt_check_events(struct gendisk *disk,
unsigned int clearing) unsigned int clearing)
{ {
...@@ -2704,9 +2684,7 @@ static const struct block_device_operations pktcdvd_ops = { ...@@ -2704,9 +2684,7 @@ static const struct block_device_operations pktcdvd_ops = {
.open = pkt_open, .open = pkt_open,
.release = pkt_close, .release = pkt_close,
.ioctl = pkt_ioctl, .ioctl = pkt_ioctl,
#ifdef CONFIG_COMPAT .compat_ioctl = blkdev_compat_ptr_ioctl,
.compat_ioctl = pkt_compat_ioctl,
#endif
.check_events = pkt_check_events, .check_events = pkt_check_events,
}; };
......
...@@ -3293,9 +3293,10 @@ static noinline int mmc_ioctl_cdrom_last_written(struct cdrom_device_info *cdi, ...@@ -3293,9 +3293,10 @@ static noinline int mmc_ioctl_cdrom_last_written(struct cdrom_device_info *cdi,
ret = cdrom_get_last_written(cdi, &last); ret = cdrom_get_last_written(cdi, &last);
if (ret) if (ret)
return ret; return ret;
if (copy_to_user((long __user *)arg, &last, sizeof(last))) if (in_compat_syscall())
return -EFAULT; return put_user(last, (__s32 __user *)arg);
return 0;
return put_user(last, (long __user *)arg);
} }
static int mmc_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, static int mmc_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment