Commit eaf8e3e4 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

cdrom: factor out a cdrom_multisession helper

Factor out a version of the CDROMMULTISESSION 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 4c3cfcce
......@@ -2295,37 +2295,46 @@ static int cdrom_read_cdda(struct cdrom_device_info *cdi, __u8 __user *ubuf,
return cdrom_read_cdda_old(cdi, ubuf, lba, nframes);
}
static int cdrom_ioctl_multisession(struct cdrom_device_info *cdi,
void __user *argp)
int cdrom_multisession(struct cdrom_device_info *cdi,
struct cdrom_multisession *info)
{
struct cdrom_multisession ms_info;
u8 requested_format;
int ret;
cd_dbg(CD_DO_IOCTL, "entering CDROMMULTISESSION\n");
if (!(cdi->ops->capability & CDC_MULTI_SESSION))
return -ENOSYS;
if (copy_from_user(&ms_info, argp, sizeof(ms_info)))
return -EFAULT;
requested_format = ms_info.addr_format;
requested_format = info->addr_format;
if (requested_format != CDROM_MSF && requested_format != CDROM_LBA)
return -EINVAL;
ms_info.addr_format = CDROM_LBA;
info->addr_format = CDROM_LBA;
ret = cdi->ops->get_last_session(cdi, &ms_info);
if (ret)
return ret;
ret = cdi->ops->get_last_session(cdi, info);
if (!ret)
sanitize_format(&info->addr, &info->addr_format,
requested_format);
return ret;
}
EXPORT_SYMBOL_GPL(cdrom_multisession);
sanitize_format(&ms_info.addr, &ms_info.addr_format, requested_format);
static int cdrom_ioctl_multisession(struct cdrom_device_info *cdi,
void __user *argp)
{
struct cdrom_multisession info;
int ret;
cd_dbg(CD_DO_IOCTL, "entering CDROMMULTISESSION\n");
if (copy_to_user(argp, &ms_info, sizeof(ms_info)))
if (copy_from_user(&info, argp, sizeof(info)))
return -EFAULT;
ret = cdrom_multisession(cdi, &info);
if (ret)
return ret;
if (copy_to_user(argp, &info, sizeof(info)))
return -EFAULT;
cd_dbg(CD_DO_IOCTL, "CDROMMULTISESSION successful\n");
return 0;
return ret;
}
static int cdrom_ioctl_eject(struct cdrom_device_info *cdi)
......
......@@ -94,6 +94,8 @@ struct cdrom_device_ops {
struct packet_command *);
};
int cdrom_multisession(struct cdrom_device_info *cdi,
struct cdrom_multisession *info);
int cdrom_read_tocentry(struct cdrom_device_info *cdi,
struct cdrom_tocentry *entry);
......
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