OSDN Git Service

compat_ioctl: block: handle cdrom compat ioctl in non-cdrom drivers
authorArnd Bergmann <arnd@arndb.de>
Thu, 28 Nov 2019 14:48:10 +0000 (15:48 +0100)
committerArnd Bergmann <arnd@arndb.de>
Fri, 3 Jan 2020 08:33:15 +0000 (09:33 +0100)
Various block drivers implement the CDROMMULTISESSION,
CDROM_GET_CAPABILITY, and CDROMEJECT ioctl commands, relying on the
block layer to handle compat_ioctl mode for them.

Move this into the drivers directly as a preparation for simplifying
the block layer later.

When only integer arguments or no arguments are passed, the
same handler can be used for .ioctl and .compat_ioctl, and
when only pointer arguments are passed, the newly added
blkdev_compat_ptr_ioctl can be used.

Reviewed-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
drivers/block/floppy.c
drivers/block/paride/pd.c
drivers/block/paride/pf.c
drivers/block/sunvdc.c
drivers/block/xen-blkfront.c

index 485865f..cd3612e 100644 (file)
@@ -3879,6 +3879,9 @@ static int fd_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
 {
        int drive = (long)bdev->bd_disk->private_data;
        switch (cmd) {
+       case CDROMEJECT: /* CD-ROM eject */
+       case 0x6470:     /* SunOS floppy eject */
+
        case FDMSGON:
        case FDMSGOFF:
        case FDSETEMSGTRESH:
index 6f9ad3f..c096750 100644 (file)
@@ -874,6 +874,7 @@ static const struct block_device_operations pd_fops = {
        .open           = pd_open,
        .release        = pd_release,
        .ioctl          = pd_ioctl,
+       .compat_ioctl   = pd_ioctl,
        .getgeo         = pd_getgeo,
        .check_events   = pd_check_events,
        .revalidate_disk= pd_revalidate
index 6b7d4ca..bb09f21 100644 (file)
@@ -276,6 +276,7 @@ static const struct block_device_operations pf_fops = {
        .open           = pf_open,
        .release        = pf_release,
        .ioctl          = pf_ioctl,
+       .compat_ioctl   = pf_ioctl,
        .getgeo         = pf_getgeo,
        .check_events   = pf_check_events,
 };
index 571612e..39aeebc 100644 (file)
@@ -171,6 +171,7 @@ static const struct block_device_operations vdc_fops = {
        .owner          = THIS_MODULE,
        .getgeo         = vdc_getgeo,
        .ioctl          = vdc_ioctl,
+       .compat_ioctl   = blkdev_compat_ptr_ioctl,
 };
 
 static void vdc_blk_queue_start(struct vdc_port *port)
index c02be06..57d50c5 100644 (file)
@@ -2632,6 +2632,7 @@ static const struct block_device_operations xlvbd_block_fops =
        .release = blkif_release,
        .getgeo = blkif_getgeo,
        .ioctl = blkif_ioctl,
+       .compat_ioctl = blkdev_compat_ptr_ioctl,
 };