Skip to content

Commit 1b114b0

Browse files
committed
pktcdvd: add compat_ioctl handler
pkt_ioctl() implements the generic SCSI_IOCTL_SEND_COMMAND and some cdrom ioctls by forwarding to the underlying block device. For compat_ioctl handling, this always takes a roundtrip through fs/compat_ioctl.c that we should try to avoid, at least for the compatible commands. CDROM_SEND_PACKET is an exception here, it requires special translation in compat_blkdev_driver_ioctl(). CDROM_LAST_WRITTEN has no compat handling at the moment. Cc: Jens Axboe <[email protected]> Cc: [email protected] Signed-off-by: Arnd Bergmann <[email protected]>
1 parent fd6c3d5 commit 1b114b0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/block/pktcdvd.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2663,6 +2663,28 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
26632663
return ret;
26642664
}
26652665

2666+
#ifdef CONFIG_COMPAT
2667+
static int pkt_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg)
2668+
{
2669+
switch (cmd) {
2670+
/* compatible */
2671+
case CDROMEJECT:
2672+
case CDROMMULTISESSION:
2673+
case CDROMREADTOCENTRY:
2674+
case SCSI_IOCTL_SEND_COMMAND:
2675+
return pkt_ioctl(bdev, mode, cmd, (unsigned long)compat_ptr(arg));
2676+
2677+
2678+
/* FIXME: no handler so far */
2679+
case CDROM_LAST_WRITTEN:
2680+
/* handled in compat_blkdev_driver_ioctl */
2681+
case CDROM_SEND_PACKET:
2682+
default:
2683+
return -ENOIOCTLCMD;
2684+
}
2685+
}
2686+
#endif
2687+
26662688
static unsigned int pkt_check_events(struct gendisk *disk,
26672689
unsigned int clearing)
26682690
{
@@ -2684,6 +2706,9 @@ static const struct block_device_operations pktcdvd_ops = {
26842706
.open = pkt_open,
26852707
.release = pkt_close,
26862708
.ioctl = pkt_ioctl,
2709+
#ifdef CONFIG_COMPAT
2710+
.ioctl = pkt_compat_ioctl,
2711+
#endif
26872712
.check_events = pkt_check_events,
26882713
};
26892714

0 commit comments

Comments
 (0)