mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
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: Christoph Hellwig <hch@lst.de> Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
4c3cfcce45
commit
eaf8e3e4b5
@ -2295,37 +2295,46 @@ retry:
|
||||
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);
|
||||
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);
|
||||
|
||||
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_from_user(&info, argp, sizeof(info)))
|
||||
return -EFAULT;
|
||||
ret = cdrom_multisession(cdi, &info);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
sanitize_format(&ms_info.addr, &ms_info.addr_format, requested_format);
|
||||
|
||||
if (copy_to_user(argp, &ms_info, sizeof(ms_info)))
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user