Skip to content

Commit 64cbfa9

Browse files
committed
compat_ioctl: move cdrom commands into cdrom.c
There is no need for the special cases for the cdrom ioctls any more now, so make sure that each cdrom driver has a .compat_ioctl() callback and calls cdrom_compat_ioctl() directly there. Reviewed-by: Ben Hutchings <ben.hutchings@codethink.co.uk> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent 77b9040 commit 64cbfa9

5 files changed

Lines changed: 45 additions & 51 deletions

File tree

‎block/compat_ioctl.c‎

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -160,42 +160,6 @@ static int compat_blkdev_driver_ioctl(struct block_device *bdev, fmode_t mode,
160160
case HDIO_DRIVE_CMD:
161161
/* 0x330 is reserved -- it used to be HDIO_GETGEO_BIG */
162162
case 0x330:
163-
/* CDROM stuff */
164-
case CDROMPAUSE:
165-
case CDROMRESUME:
166-
case CDROMPLAYMSF:
167-
case CDROMPLAYTRKIND:
168-
case CDROMREADTOCHDR:
169-
case CDROMREADTOCENTRY:
170-
case CDROMSTOP:
171-
case CDROMSTART:
172-
case CDROMEJECT:
173-
case CDROMVOLCTRL:
174-
case CDROMSUBCHNL:
175-
case CDROMMULTISESSION:
176-
case CDROM_GET_MCN:
177-
case CDROMRESET:
178-
case CDROMVOLREAD:
179-
case CDROMSEEK:
180-
case CDROMPLAYBLK:
181-
case CDROMCLOSETRAY:
182-
case CDROM_DISC_STATUS:
183-
case CDROM_CHANGER_NSLOTS:
184-
case CDROM_GET_CAPABILITY:
185-
case CDROM_SEND_PACKET:
186-
/* Ignore cdrom.h about these next 5 ioctls, they absolutely do
187-
* not take a struct cdrom_read, instead they take a struct cdrom_msf
188-
* which is compatible.
189-
*/
190-
case CDROMREADMODE2:
191-
case CDROMREADMODE1:
192-
case CDROMREADRAW:
193-
case CDROMREADCOOKED:
194-
case CDROMREADALL:
195-
/* DVD ioctls */
196-
case DVD_READ_STRUCT:
197-
case DVD_WRITE_STRUCT:
198-
case DVD_AUTH:
199163
arg = (unsigned long)compat_ptr(arg);
200164
/* These intepret arg as an unsigned long, not as a pointer,
201165
* so we must not do compat_ptr() conversion. */
@@ -211,15 +175,6 @@ static int compat_blkdev_driver_ioctl(struct block_device *bdev, fmode_t mode,
211175
case HDIO_SET_ACOUSTIC:
212176
case HDIO_SET_BUSSTATE:
213177
case HDIO_SET_ADDRESS:
214-
case CDROMEJECT_SW:
215-
case CDROM_SET_OPTIONS:
216-
case CDROM_CLEAR_OPTIONS:
217-
case CDROM_SELECT_SPEED:
218-
case CDROM_SELECT_DISC:
219-
case CDROM_MEDIA_CHANGED:
220-
case CDROM_DRIVE_STATUS:
221-
case CDROM_LOCKDOOR:
222-
case CDROM_DEBUG:
223178
break;
224179
default:
225180
/* unknown ioctl number */

‎drivers/block/paride/pcd.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ static const struct block_device_operations pcd_bdops = {
275275
.open = pcd_block_open,
276276
.release = pcd_block_release,
277277
.ioctl = pcd_block_ioctl,
278+
#ifdef CONFIG_COMPAT
279+
.ioctl = blkdev_compat_ptr_ioctl,
280+
#endif
278281
.check_events = pcd_block_check_events,
279282
};
280283

‎drivers/cdrom/gdrom.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,9 @@ static const struct block_device_operations gdrom_bdops = {
518518
.release = gdrom_bdops_release,
519519
.check_events = gdrom_bdops_check_events,
520520
.ioctl = gdrom_bdops_ioctl,
521+
#ifdef CONFIG_COMPAT
522+
.ioctl = blkdev_compat_ptr_ioctl,
523+
#endif
521524
};
522525

523526
static irqreturn_t gdrom_command_interrupt(int irq, void *dev_id)

‎drivers/ide/ide-cd.c‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#define IDECD_VERSION "5.00"
2727

28+
#include <linux/compat.h>
2829
#include <linux/module.h>
2930
#include <linux/types.h>
3031
#include <linux/kernel.h>
@@ -1710,6 +1711,39 @@ static int idecd_ioctl(struct block_device *bdev, fmode_t mode,
17101711
return ret;
17111712
}
17121713

1714+
#ifdef CONFIG_COMPAT
1715+
static int idecd_locked_compat_ioctl(struct block_device *bdev, fmode_t mode,
1716+
unsigned int cmd, unsigned long arg)
1717+
{
1718+
struct cdrom_info *info = ide_drv_g(bdev->bd_disk, cdrom_info);
1719+
void __user *argp = compat_ptr(arg);
1720+
int err;
1721+
1722+
switch (cmd) {
1723+
case CDROMSETSPINDOWN:
1724+
return idecd_set_spindown(&info->devinfo, (unsigned long)argp);
1725+
case CDROMGETSPINDOWN:
1726+
return idecd_get_spindown(&info->devinfo, (unsigned long)argp);
1727+
default:
1728+
break;
1729+
}
1730+
1731+
return cdrom_ioctl(&info->devinfo, bdev, mode, cmd,
1732+
(unsigned long)argp);
1733+
}
1734+
1735+
static int idecd_compat_ioctl(struct block_device *bdev, fmode_t mode,
1736+
unsigned int cmd, unsigned long arg)
1737+
{
1738+
int ret;
1739+
1740+
mutex_lock(&ide_cd_mutex);
1741+
ret = idecd_locked_compat_ioctl(bdev, mode, cmd, arg);
1742+
mutex_unlock(&ide_cd_mutex);
1743+
1744+
return ret;
1745+
}
1746+
#endif
17131747

17141748
static unsigned int idecd_check_events(struct gendisk *disk,
17151749
unsigned int clearing)
@@ -1732,6 +1766,9 @@ static const struct block_device_operations idecd_ops = {
17321766
.open = idecd_open,
17331767
.release = idecd_release,
17341768
.ioctl = idecd_ioctl,
1769+
#ifdef CONFIG_COMPAT
1770+
.compat_ioctl = idecd_compat_ioctl,
1771+
#endif
17351772
.check_events = idecd_check_events,
17361773
.revalidate_disk = idecd_revalidate_disk
17371774
};

‎drivers/scsi/sr.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -628,12 +628,8 @@ static int sr_block_compat_ioctl(struct block_device *bdev, fmode_t mode, unsign
628628
goto put;
629629
}
630630

631-
/*
632-
* CDROM ioctls are handled in the block layer, but
633-
* do the scsi blk ioctls here.
634-
*/
635-
ret = scsi_cmd_blk_ioctl(bdev, mode, cmd, argp);
636-
if (ret != -ENOTTY)
631+
ret = cdrom_ioctl(&cd->cdi, bdev, mode, cmd, (unsigned long)argp);
632+
if (ret != -ENOSYS)
637633
goto put;
638634

639635
ret = scsi_compat_ioctl(sdev, cmd, argp);

0 commit comments

Comments
 (0)