Commit 4c3cfcce authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

cdrom: factor out a cdrom_read_tocentry helper

Factor out a version of the CDROMREADTOCENTRY ioctl handler that can
be called directly from kernel space.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 068f8d9b
...@@ -2666,32 +2666,37 @@ static int cdrom_ioctl_read_tochdr(struct cdrom_device_info *cdi, ...@@ -2666,32 +2666,37 @@ static int cdrom_ioctl_read_tochdr(struct cdrom_device_info *cdi,
return 0; return 0;
} }
static int cdrom_ioctl_read_tocentry(struct cdrom_device_info *cdi, int cdrom_read_tocentry(struct cdrom_device_info *cdi,
void __user *argp) struct cdrom_tocentry *entry)
{ {
struct cdrom_tocentry entry; u8 requested_format = entry->cdte_format;
u8 requested_format;
int ret; int ret;
/* cd_dbg(CD_DO_IOCTL, "entering CDROMREADTOCENTRY\n"); */
if (copy_from_user(&entry, argp, sizeof(entry)))
return -EFAULT;
requested_format = entry.cdte_format;
if (requested_format != CDROM_MSF && requested_format != CDROM_LBA) if (requested_format != CDROM_MSF && requested_format != CDROM_LBA)
return -EINVAL; return -EINVAL;
/* make interface to low-level uniform */ /* make interface to low-level uniform */
entry.cdte_format = CDROM_MSF; entry->cdte_format = CDROM_MSF;
ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCENTRY, &entry); ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCENTRY, entry);
if (ret) if (!ret)
sanitize_format(&entry->cdte_addr, &entry->cdte_format,
requested_format);
return ret; return ret;
sanitize_format(&entry.cdte_addr, &entry.cdte_format, requested_format); }
EXPORT_SYMBOL_GPL(cdrom_read_tocentry);
if (copy_to_user(argp, &entry, sizeof(entry))) static int cdrom_ioctl_read_tocentry(struct cdrom_device_info *cdi,
void __user *argp)
{
struct cdrom_tocentry entry;
int ret;
if (copy_from_user(&entry, argp, sizeof(entry)))
return -EFAULT; return -EFAULT;
/* cd_dbg(CD_DO_IOCTL, "CDROMREADTOCENTRY successful\n"); */ ret = cdrom_read_tocentry(cdi, &entry);
return 0; if (!ret && copy_to_user(argp, &entry, sizeof(entry)))
return -EFAULT;
return ret;
} }
static int cdrom_ioctl_play_msf(struct cdrom_device_info *cdi, static int cdrom_ioctl_play_msf(struct cdrom_device_info *cdi,
......
...@@ -94,6 +94,9 @@ struct cdrom_device_ops { ...@@ -94,6 +94,9 @@ struct cdrom_device_ops {
struct packet_command *); struct packet_command *);
}; };
int cdrom_read_tocentry(struct cdrom_device_info *cdi,
struct cdrom_tocentry *entry);
/* the general block_device operations structure: */ /* the general block_device operations structure: */
extern int cdrom_open(struct cdrom_device_info *cdi, struct block_device *bdev, extern int cdrom_open(struct cdrom_device_info *cdi, struct block_device *bdev,
fmode_t mode); fmode_t mode);
......
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