Home | History | Annotate | Line # | Download | only in common
linux_cdrom.c revision 1.18.4.2
      1  1.18.4.2      yamt /*	$NetBSD: linux_cdrom.c,v 1.18.4.2 2007/02/26 09:09:18 yamt Exp $ */
      2       1.1  christos 
      3       1.1  christos /*
      4       1.1  christos  * Copyright (c) 1997 The NetBSD Foundation, Inc.
      5       1.1  christos  * All rights reserved.
      6       1.1  christos  *
      7       1.1  christos  * Redistribution and use in source and binary forms, with or without
      8       1.1  christos  * modification, are permitted provided that the following conditions
      9       1.1  christos  * are met:
     10       1.1  christos  * 1. Redistributions of source code must retain the above copyright
     11       1.1  christos  *    notice, this list of conditions and the following disclaimer.
     12       1.1  christos  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1  christos  *    notice, this list of conditions and the following disclaimer in the
     14       1.1  christos  *    documentation and/or other materials provided with the distribution.
     15       1.1  christos  * 3. All advertising materials mentioning features or use of this software
     16       1.1  christos  *    must display the following acknowledgement:
     17       1.1  christos  *        This product includes software developed by the NetBSD
     18       1.1  christos  *        Foundation, Inc. and its contributors.
     19       1.1  christos  * 4. Neither the name of The NetBSD Foundation nor the names of its
     20       1.1  christos  *    contributors may be used to endorse or promote products derived
     21       1.1  christos  *    from this software without specific prior written permission.
     22       1.1  christos  *
     23       1.1  christos  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     24       1.1  christos  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     25       1.1  christos  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     26       1.1  christos  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     27       1.1  christos  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     28       1.1  christos  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     29       1.1  christos  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     30       1.1  christos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     31       1.1  christos  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     32       1.1  christos  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     33       1.1  christos  * POSSIBILITY OF SUCH DAMAGE.
     34       1.1  christos  */
     35      1.10     lukem 
     36      1.10     lukem #include <sys/cdefs.h>
     37  1.18.4.2      yamt __KERNEL_RCSID(0, "$NetBSD: linux_cdrom.c,v 1.18.4.2 2007/02/26 09:09:18 yamt Exp $");
     38       1.1  christos 
     39       1.1  christos #include <sys/param.h>
     40       1.1  christos #include <sys/systm.h>
     41       1.1  christos #include <sys/ioctl.h>
     42       1.1  christos #include <sys/file.h>
     43       1.1  christos #include <sys/filedesc.h>
     44       1.1  christos #include <sys/mount.h>
     45       1.1  christos #include <sys/proc.h>
     46       1.1  christos #include <sys/cdio.h>
     47       1.5   mycroft #include <sys/dvdio.h>
     48  1.18.4.1      yamt #include <sys/malloc.h>
     49       1.2       erh 
     50       1.2       erh #include <sys/syscallargs.h>
     51       1.1  christos 
     52       1.3  christos #include <compat/linux/common/linux_types.h>
     53       1.3  christos #include <compat/linux/common/linux_ioctl.h>
     54       1.3  christos #include <compat/linux/common/linux_signal.h>
     55       1.3  christos #include <compat/linux/common/linux_util.h>
     56       1.3  christos #include <compat/linux/common/linux_cdrom.h>
     57       1.3  christos 
     58       1.1  christos #include <compat/linux/linux_syscallargs.h>
     59       1.1  christos 
     60       1.6      fvdl static int bsd_to_linux_msf_lba(unsigned address_format, union msf_lba *bml,
     61       1.6      fvdl 				union linux_cdrom_addr *llml);
     62       1.6      fvdl 
     63      1.13  christos #if DEBUG_LINUX
     64      1.11  christos #define DPRINTF(x) uprintf x
     65       1.1  christos #else
     66       1.1  christos #define DPRINTF(x)
     67       1.1  christos #endif
     68       1.1  christos 
     69       1.6      fvdl /*
     70       1.6      fvdl  * XXX from dev/scsipi/cd.c
     71       1.6      fvdl  */
     72       1.6      fvdl #define MAXTRACK 99
     73       1.6      fvdl 
     74       1.6      fvdl static int
     75       1.6      fvdl bsd_to_linux_msf_lba(unsigned address_format, union msf_lba *bml,
     76       1.6      fvdl 		      union linux_cdrom_addr *llml)
     77       1.6      fvdl {
     78       1.6      fvdl 	switch (address_format) {
     79       1.6      fvdl 	case CD_LBA_FORMAT:
     80       1.6      fvdl 		llml->lba = bml->lba;
     81       1.6      fvdl 		break;
     82       1.6      fvdl 	case CD_MSF_FORMAT:
     83       1.6      fvdl 		llml->msf.minute = bml->msf.minute;
     84       1.6      fvdl 		llml->msf.second = bml->msf.second;
     85       1.6      fvdl 		llml->msf.frame = bml->msf.frame;
     86       1.6      fvdl 		break;
     87       1.6      fvdl 	default:
     88       1.6      fvdl 		return -1;
     89       1.6      fvdl 	}
     90       1.6      fvdl 	return 0;
     91       1.6      fvdl }
     92       1.6      fvdl 
     93       1.1  christos int
     94  1.18.4.1      yamt linux_ioctl_cdrom(l, uap, retval)
     95  1.18.4.1      yamt 	struct lwp *l;
     96       1.1  christos 	struct linux_sys_ioctl_args /* {
     97       1.1  christos 		syscallarg(int) fd;
     98       1.1  christos 		syscallarg(u_long) com;
     99       1.1  christos 		syscallarg(caddr_t) data;
    100       1.1  christos 	} */ *uap;
    101       1.1  christos 	register_t *retval;
    102       1.1  christos {
    103       1.1  christos 	int error, idata;
    104       1.1  christos 	u_long com, ncom;
    105       1.1  christos 	caddr_t sg;
    106       1.1  christos 	struct file *fp;
    107       1.1  christos 	struct filedesc *fdp;
    108  1.18.4.1      yamt 	int (*ioctlf)(struct file *, u_long, void *, struct lwp *);
    109       1.1  christos 
    110  1.18.4.1      yamt 	union {
    111  1.18.4.1      yamt 		struct linux_cdrom_blk ll_blk;
    112  1.18.4.1      yamt 		struct linux_cdrom_msf ll_msf;
    113  1.18.4.1      yamt 		struct linux_cdrom_ti ll_ti;
    114  1.18.4.1      yamt 		struct linux_cdrom_tochdr ll_tochdr;
    115  1.18.4.1      yamt 		struct linux_cdrom_tocentry ll_tocentry;
    116  1.18.4.1      yamt 		struct linux_cdrom_subchnl ll_subchnl;
    117  1.18.4.1      yamt 		struct linux_cdrom_volctrl ll_volctrl;
    118  1.18.4.1      yamt 		struct linux_cdrom_multisession ll_session;
    119  1.18.4.1      yamt 		dvd_struct ll_ds;
    120  1.18.4.1      yamt 		dvd_authinfo ll_dai;
    121  1.18.4.1      yamt 	} *u1;
    122  1.18.4.1      yamt 
    123  1.18.4.1      yamt #define l_blk u1->ll_blk
    124  1.18.4.1      yamt #define l_msf u1->ll_msf
    125  1.18.4.1      yamt #define l_ti u1->ll_ti
    126  1.18.4.1      yamt #define l_tochdr u1->ll_tochdr
    127  1.18.4.1      yamt #define l_tocentry u1->ll_tocentry
    128  1.18.4.1      yamt #define l_subchnl u1->ll_subchnl
    129  1.18.4.1      yamt #define l_volctrl u1->ll_volctrl
    130  1.18.4.1      yamt #define l_session u1->ll_session
    131  1.18.4.1      yamt #define ds u1->ll_ds
    132  1.18.4.1      yamt #define dai u1->ll_dai
    133  1.18.4.1      yamt 
    134  1.18.4.1      yamt 	union {
    135  1.18.4.1      yamt 		struct ioc_play_blocks tt_blocks;
    136  1.18.4.1      yamt 		struct ioc_play_msf tt_msf;
    137  1.18.4.1      yamt 		struct ioc_play_track tt_track;
    138  1.18.4.1      yamt 		struct ioc_toc_header tt_header;
    139  1.18.4.1      yamt 		struct cd_toc_entry tt_entry;
    140  1.18.4.1      yamt 		struct ioc_read_toc_entry tt_toc_entry;
    141  1.18.4.1      yamt 		struct cd_sub_channel_info tt_info;
    142  1.18.4.1      yamt 		struct ioc_read_subchannel tt_subchannel;
    143  1.18.4.1      yamt 		struct ioc_vol tt_vol;
    144  1.18.4.1      yamt 	} *u2;
    145  1.18.4.1      yamt 
    146  1.18.4.1      yamt #define	t_blocks u2->tt_blocks
    147  1.18.4.1      yamt #define	t_msf u2->tt_msf
    148  1.18.4.1      yamt #define	t_track u2->tt_track
    149  1.18.4.1      yamt #define	t_header u2->tt_header
    150  1.18.4.1      yamt #define	t_entry u2->tt_entry
    151  1.18.4.1      yamt #define	t_toc_entry u2->tt_toc_entry
    152  1.18.4.1      yamt #define	t_info u2->tt_info
    153  1.18.4.1      yamt #define	t_subchannel u2->tt_subchannel
    154  1.18.4.1      yamt #define	t_vol u2->tt_vol
    155  1.18.4.1      yamt 
    156  1.18.4.1      yamt 	struct cd_toc_entry *entry;
    157  1.18.4.1      yamt 	struct cd_sub_channel_info *info;
    158  1.18.4.1      yamt 	struct proc *p = l->l_proc;
    159       1.5   mycroft 
    160       1.1  christos 	fdp = p->p_fd;
    161       1.9   thorpej 	if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
    162       1.1  christos 		return (EBADF);
    163       1.1  christos 
    164       1.6      fvdl 	FILE_USE(fp);
    165       1.6      fvdl 
    166       1.1  christos 	com = SCARG(uap, com);
    167       1.1  christos 	ioctlf = fp->f_ops->fo_ioctl;
    168       1.6      fvdl 	retval[0] = error = 0;
    169       1.1  christos 
    170  1.18.4.1      yamt 	u1 = malloc(sizeof(*u1), M_TEMP, M_WAITOK);
    171  1.18.4.1      yamt 	u2 = malloc(sizeof(*u2), M_TEMP, M_WAITOK);
    172  1.18.4.1      yamt 
    173       1.1  christos 	switch(com) {
    174       1.1  christos 	case LINUX_CDROMPLAYMSF:
    175       1.1  christos 		error = copyin(SCARG(uap, data), &l_msf, sizeof l_msf);
    176       1.1  christos 		if (error)
    177       1.6      fvdl 			break;
    178       1.1  christos 
    179       1.1  christos 		t_msf.start_m = l_msf.cdmsf_min0;
    180       1.1  christos 		t_msf.start_s = l_msf.cdmsf_sec0;
    181       1.1  christos 		t_msf.start_f = l_msf.cdmsf_frame0;
    182       1.1  christos 		t_msf.end_m = l_msf.cdmsf_min1;
    183       1.1  christos 		t_msf.end_s = l_msf.cdmsf_sec1;
    184       1.1  christos 		t_msf.end_f = l_msf.cdmsf_frame1;
    185       1.1  christos 
    186  1.18.4.1      yamt 		error = ioctlf(fp, CDIOCPLAYMSF, (caddr_t)&t_msf, l);
    187       1.6      fvdl 		break;
    188       1.1  christos 
    189       1.1  christos 	case LINUX_CDROMPLAYTRKIND:
    190       1.1  christos 		error = copyin(SCARG(uap, data), &l_ti, sizeof l_ti);
    191       1.1  christos 		if (error)
    192       1.6      fvdl 			break;
    193       1.1  christos 
    194       1.1  christos 		t_track.start_track = l_ti.cdti_trk0;
    195       1.1  christos 		t_track.start_index = l_ti.cdti_ind0;
    196       1.1  christos 		t_track.end_track = l_ti.cdti_trk1;
    197       1.1  christos 		t_track.end_index = l_ti.cdti_ind1;
    198       1.1  christos 
    199  1.18.4.1      yamt 		error = ioctlf(fp, CDIOCPLAYTRACKS, (caddr_t)&t_track, l);
    200       1.6      fvdl 		break;
    201       1.1  christos 
    202       1.1  christos 	case LINUX_CDROMREADTOCHDR:
    203  1.18.4.1      yamt 		error = ioctlf(fp, CDIOREADTOCHEADER, (caddr_t)&t_header, l);
    204       1.1  christos 		if (error)
    205       1.6      fvdl 			break;
    206       1.1  christos 
    207       1.1  christos 		l_tochdr.cdth_trk0 = t_header.starting_track;
    208       1.1  christos 		l_tochdr.cdth_trk1 = t_header.ending_track;
    209       1.1  christos 
    210       1.6      fvdl 		error = copyout(&l_tochdr, SCARG(uap, data), sizeof l_tochdr);
    211       1.6      fvdl 		break;
    212       1.1  christos 
    213       1.1  christos 	case LINUX_CDROMREADTOCENTRY:
    214       1.1  christos 		error = copyin(SCARG(uap, data), &l_tocentry,
    215       1.1  christos 			       sizeof l_tocentry);
    216       1.1  christos 		if (error)
    217       1.6      fvdl 			break;
    218      1.18     perry 
    219      1.12  christos 		sg = stackgap_init(p, 0);
    220      1.12  christos 		entry = stackgap_alloc(p, &sg, sizeof *entry);
    221       1.1  christos 		t_toc_entry.address_format = l_tocentry.cdte_format;
    222       1.1  christos 		t_toc_entry.starting_track = l_tocentry.cdte_track;
    223       1.1  christos 		t_toc_entry.data_len = sizeof *entry;
    224       1.1  christos 		t_toc_entry.data = entry;
    225       1.1  christos 
    226       1.6      fvdl 		error = ioctlf(fp, CDIOREADTOCENTRIES, (caddr_t)&t_toc_entry,
    227  1.18.4.1      yamt 			       l);
    228       1.1  christos 		if (error)
    229       1.6      fvdl 			break;
    230       1.1  christos 
    231       1.1  christos 		error = copyin(entry, &t_entry, sizeof t_entry);
    232       1.1  christos 		if (error)
    233       1.6      fvdl 			break;
    234      1.18     perry 
    235       1.1  christos 		l_tocentry.cdte_adr = t_entry.addr_type;
    236       1.1  christos 		l_tocentry.cdte_ctrl = t_entry.control;
    237       1.6      fvdl 		if (bsd_to_linux_msf_lba(t_entry.addr_type, &t_entry.addr,
    238       1.6      fvdl 		    &l_tocentry.cdte_addr) < 0) {
    239      1.13  christos 			DPRINTF(("linux_ioctl: unknown format msf/lba\n"));
    240       1.6      fvdl 			error = EINVAL;
    241       1.1  christos 			break;
    242       1.1  christos 		}
    243      1.18     perry 
    244       1.6      fvdl 		error = copyout(&l_tocentry, SCARG(uap, data),
    245       1.1  christos 			       sizeof l_tocentry);
    246       1.6      fvdl 		break;
    247      1.18     perry 
    248       1.1  christos 	case LINUX_CDROMVOLCTRL:
    249       1.1  christos 		error = copyin(SCARG(uap, data), &l_volctrl, sizeof l_volctrl);
    250       1.1  christos 		if (error)
    251       1.6      fvdl 			break;
    252       1.1  christos 
    253       1.1  christos 		t_vol.vol[0] = l_volctrl.channel0;
    254       1.1  christos 		t_vol.vol[1] = l_volctrl.channel1;
    255       1.1  christos 		t_vol.vol[2] = l_volctrl.channel2;
    256       1.1  christos 		t_vol.vol[3] = l_volctrl.channel3;
    257       1.1  christos 
    258  1.18.4.1      yamt 		error = ioctlf(fp, CDIOCSETVOL, (caddr_t)&t_vol, l);
    259       1.6      fvdl 		break;
    260       1.1  christos 
    261       1.1  christos 	case LINUX_CDROMVOLREAD:
    262  1.18.4.1      yamt 		error = ioctlf(fp, CDIOCGETVOL, (caddr_t)&t_vol, l);
    263       1.1  christos 		if (error)
    264       1.6      fvdl 			break;
    265       1.1  christos 
    266       1.1  christos 		l_volctrl.channel0 = t_vol.vol[0];
    267       1.1  christos 		l_volctrl.channel1 = t_vol.vol[1];
    268       1.1  christos 		l_volctrl.channel2 = t_vol.vol[2];
    269       1.1  christos 		l_volctrl.channel3 = t_vol.vol[3];
    270       1.1  christos 
    271       1.6      fvdl 		error = copyout(&l_volctrl, SCARG(uap, data), sizeof l_volctrl);
    272       1.6      fvdl 		break;
    273       1.1  christos 
    274       1.1  christos 	case LINUX_CDROMSUBCHNL:
    275       1.1  christos 		error = copyin(SCARG(uap, data), &l_subchnl, sizeof l_subchnl);
    276       1.1  christos 		if (error)
    277       1.6      fvdl 			break;
    278       1.7      fvdl 
    279      1.12  christos 		sg = stackgap_init(p, 0);
    280      1.12  christos 		info = stackgap_alloc(p, &sg, sizeof *info);
    281       1.7      fvdl 		t_subchannel.address_format = CD_MSF_FORMAT;
    282       1.7      fvdl 		t_subchannel.track = 0;
    283       1.7      fvdl 		t_subchannel.data_format = l_subchnl.cdsc_format;
    284       1.1  christos 		t_subchannel.data_len = sizeof *info;
    285       1.1  christos 		t_subchannel.data = info;
    286       1.1  christos 		DPRINTF(("linux_ioctl: CDROMSUBCHNL %d %d\n",
    287       1.1  christos 			 l_subchnl.cdsc_format, l_subchnl.cdsc_trk));
    288       1.1  christos 
    289       1.1  christos 		error = ioctlf(fp, CDIOCREADSUBCHANNEL, (caddr_t)&t_subchannel,
    290  1.18.4.1      yamt 			       l);
    291       1.1  christos 		if (error)
    292       1.6      fvdl 			break;
    293       1.1  christos 
    294       1.1  christos 		error = copyin(info, &t_info, sizeof t_info);
    295       1.1  christos 		if (error)
    296       1.6      fvdl 			break;
    297      1.18     perry 
    298       1.6      fvdl 		l_subchnl.cdsc_audiostatus = t_info.header.audio_status;
    299       1.6      fvdl 		l_subchnl.cdsc_adr = t_info.what.position.addr_type;
    300       1.6      fvdl 		l_subchnl.cdsc_ctrl = t_info.what.position.control;
    301       1.6      fvdl 		l_subchnl.cdsc_ind = t_info.what.position.index_number;
    302      1.18     perry 
    303       1.6      fvdl 		DPRINTF(("linux_ioctl: CDIOCREADSUBCHANNEL %d %d %d\n",
    304       1.6      fvdl 			t_info.header.audio_status,
    305       1.6      fvdl 			t_info.header.data_len[0],
    306       1.6      fvdl 			t_info.header.data_len[1]));
    307       1.6      fvdl 		DPRINTF(("(more) %d %d %d %d %d\n",
    308       1.6      fvdl 			t_info.what.position.data_format,
    309       1.6      fvdl 			t_info.what.position.control,
    310       1.6      fvdl 			t_info.what.position.addr_type,
    311       1.6      fvdl 			t_info.what.position.track_number,
    312       1.6      fvdl 			t_info.what.position.index_number));
    313       1.6      fvdl 
    314       1.6      fvdl 		if (bsd_to_linux_msf_lba(t_subchannel.address_format,
    315       1.6      fvdl 					 &t_info.what.position.absaddr,
    316       1.6      fvdl 					 &l_subchnl.cdsc_absaddr) < 0 ||
    317       1.6      fvdl 		    bsd_to_linux_msf_lba(t_subchannel.address_format,
    318       1.6      fvdl 					 &t_info.what.position.reladdr,
    319       1.6      fvdl 					 &l_subchnl.cdsc_reladdr) < 0) {
    320       1.6      fvdl 			DPRINTF(("linux_ioctl: unknown format msf/lba\n"));
    321       1.6      fvdl 			error = EINVAL;
    322       1.6      fvdl 			break;
    323       1.6      fvdl 		}
    324       1.1  christos 
    325       1.6      fvdl 		error = copyout(&l_subchnl, SCARG(uap, data), sizeof l_subchnl);
    326       1.6      fvdl 		break;
    327       1.1  christos 
    328       1.1  christos 	case LINUX_CDROMPLAYBLK:
    329       1.1  christos 		error = copyin(SCARG(uap, data), &l_blk, sizeof l_blk);
    330       1.1  christos 		if (error)
    331       1.6      fvdl 			break;
    332       1.1  christos 
    333       1.1  christos 		t_blocks.blk = l_blk.from;
    334       1.1  christos 		t_blocks.len = l_blk.len;
    335       1.1  christos 
    336  1.18.4.1      yamt 		error = ioctlf(fp, CDIOCPLAYBLOCKS, (caddr_t)&t_blocks, l);
    337       1.6      fvdl 		break;
    338       1.1  christos 
    339       1.1  christos 	case LINUX_CDROMEJECT_SW:
    340       1.1  christos 		error = copyin(SCARG(uap, data), &idata, sizeof idata);
    341       1.1  christos 		if (error)
    342       1.6      fvdl 			break;
    343       1.1  christos 
    344       1.1  christos 		if (idata == 1)
    345       1.1  christos 			ncom = CDIOCALLOW;
    346       1.1  christos 		else
    347       1.1  christos 			ncom = CDIOCPREVENT;
    348  1.18.4.1      yamt 		error = ioctlf(fp, ncom, NULL, l);
    349       1.1  christos 		break;
    350       1.1  christos 
    351       1.1  christos 	case LINUX_CDROMPAUSE:
    352  1.18.4.1      yamt 		error = ioctlf(fp, CDIOCPAUSE, NULL, l);
    353       1.1  christos 		break;
    354       1.1  christos 
    355       1.1  christos 	case LINUX_CDROMRESUME:
    356  1.18.4.1      yamt 		error = ioctlf(fp, CDIOCRESUME, NULL, l);
    357       1.1  christos 		break;
    358       1.1  christos 
    359       1.1  christos 	case LINUX_CDROMSTOP:
    360  1.18.4.1      yamt 		error = ioctlf(fp, CDIOCSTOP, NULL, l);
    361       1.1  christos 		break;
    362       1.1  christos 
    363       1.1  christos 	case LINUX_CDROMSTART:
    364  1.18.4.1      yamt 		error = ioctlf(fp, CDIOCSTART, NULL, l);
    365       1.1  christos 		break;
    366       1.1  christos 
    367       1.1  christos 	case LINUX_CDROMEJECT:
    368  1.18.4.1      yamt 		error = ioctlf(fp, CDIOCEJECT, NULL, l);
    369       1.1  christos 		break;
    370       1.1  christos 
    371       1.1  christos 	case LINUX_CDROMRESET:
    372  1.18.4.1      yamt 		error = ioctlf(fp, CDIOCRESET, NULL, l);
    373       1.6      fvdl 		break;
    374       1.6      fvdl 
    375       1.6      fvdl 	case LINUX_CDROMMULTISESSION:
    376       1.6      fvdl 		error = copyin(SCARG(uap, data), &l_session, sizeof l_session);
    377       1.6      fvdl 		if (error)
    378       1.6      fvdl 			break;
    379       1.6      fvdl 
    380  1.18.4.1      yamt 		error = ioctlf(fp, CDIOREADTOCHEADER, (caddr_t)&t_header, l);
    381       1.6      fvdl 		if (error)
    382       1.6      fvdl 			break;
    383       1.6      fvdl 
    384      1.12  christos 		sg = stackgap_init(p, 0);
    385      1.12  christos 		entry = stackgap_alloc(p, &sg, sizeof *entry);
    386       1.6      fvdl 		t_toc_entry.address_format = l_session.addr_format;
    387       1.6      fvdl 		t_toc_entry.starting_track = 0;
    388       1.6      fvdl 		t_toc_entry.data_len = sizeof *entry;
    389       1.6      fvdl 		t_toc_entry.data = entry;
    390       1.6      fvdl 
    391       1.6      fvdl 		error = ioctlf(fp, CDIOREADTOCENTRIES,
    392  1.18.4.1      yamt 		    (caddr_t)&t_toc_entry, l);
    393       1.6      fvdl 		if (error)
    394       1.6      fvdl 			break;
    395       1.6      fvdl 
    396       1.6      fvdl 		error = copyin(entry, &t_entry, sizeof t_entry);
    397       1.6      fvdl 		if (error)
    398       1.6      fvdl 			break;
    399       1.6      fvdl 
    400       1.6      fvdl 		if (bsd_to_linux_msf_lba(l_session.addr_format,
    401       1.6      fvdl 		    &t_entry.addr, &l_session.addr) < 0) {
    402       1.6      fvdl 			error = EINVAL;
    403       1.6      fvdl 			break;
    404       1.6      fvdl 		}
    405       1.6      fvdl 
    406       1.6      fvdl 		l_session.xa_flag =
    407       1.6      fvdl 		    t_header.starting_track != t_header.ending_track;
    408       1.6      fvdl 
    409       1.6      fvdl 		error = copyout(&l_session, SCARG(uap, data), sizeof l_session);
    410       1.6      fvdl 		break;
    411       1.6      fvdl 
    412       1.6      fvdl 	case LINUX_CDROMCLOSETRAY:
    413  1.18.4.1      yamt 		error = ioctlf(fp, CDIOCCLOSE, NULL, l);
    414       1.6      fvdl 		break;
    415       1.6      fvdl 
    416       1.6      fvdl 	case LINUX_CDROM_LOCKDOOR:
    417       1.6      fvdl 		ncom = SCARG(uap, data) != 0 ? CDIOCPREVENT : CDIOCALLOW;
    418  1.18.4.1      yamt 		error = ioctlf(fp, ncom, NULL, l);
    419       1.6      fvdl 		break;
    420       1.6      fvdl 
    421       1.6      fvdl 	case LINUX_CDROM_SET_OPTIONS:
    422       1.6      fvdl 	case LINUX_CDROM_CLEAR_OPTIONS:
    423       1.6      fvdl 		/* whatever you say */
    424       1.6      fvdl 		break;
    425       1.6      fvdl 
    426       1.6      fvdl 	case LINUX_CDROM_DEBUG:
    427       1.6      fvdl 		ncom = SCARG(uap, data) != 0 ? CDIOCSETDEBUG : CDIOCCLRDEBUG;
    428  1.18.4.1      yamt 		error = ioctlf(fp, ncom, NULL, l);
    429       1.6      fvdl 		break;
    430       1.6      fvdl 
    431       1.6      fvdl 	case LINUX_CDROM_SELECT_SPEED:
    432       1.6      fvdl 	case LINUX_CDROM_SELECT_DISC:
    433       1.6      fvdl 	case LINUX_CDROM_MEDIA_CHANGED:
    434       1.6      fvdl 	case LINUX_CDROM_DRIVE_STATUS:
    435       1.6      fvdl 	case LINUX_CDROM_DISC_STATUS:
    436       1.6      fvdl 	case LINUX_CDROM_CHANGER_NSLOTS:
    437       1.6      fvdl 	case LINUX_CDROM_GET_CAPABILITY:
    438       1.7      fvdl 		error = ENOSYS;
    439       1.1  christos 		break;
    440       1.5   mycroft 
    441       1.5   mycroft 	case LINUX_DVD_READ_STRUCT:
    442       1.5   mycroft 		error = copyin(SCARG(uap, data), &ds, sizeof ds);
    443       1.5   mycroft 		if (error)
    444       1.6      fvdl 			break;
    445  1.18.4.1      yamt 		error = ioctlf(fp, DVD_READ_STRUCT, (caddr_t)&ds, l);
    446       1.5   mycroft 		if (error)
    447       1.6      fvdl 			break;
    448       1.5   mycroft 		error = copyout(&ds, SCARG(uap, data), sizeof ds);
    449       1.6      fvdl 		break;
    450       1.5   mycroft 
    451       1.5   mycroft 	case LINUX_DVD_WRITE_STRUCT:
    452       1.5   mycroft 		error = copyin(SCARG(uap, data), &ds, sizeof ds);
    453       1.5   mycroft 		if (error)
    454       1.6      fvdl 			break;
    455  1.18.4.1      yamt 		error = ioctlf(fp, DVD_WRITE_STRUCT, (caddr_t)&ds, l);
    456       1.5   mycroft 		if (error)
    457       1.6      fvdl 			break;
    458       1.5   mycroft 		error = copyout(&ds, SCARG(uap, data), sizeof ds);
    459       1.6      fvdl 		break;
    460       1.5   mycroft 
    461       1.5   mycroft 	case LINUX_DVD_AUTH:
    462       1.5   mycroft 		error = copyin(SCARG(uap, data), &dai, sizeof dai);
    463       1.5   mycroft 		if (error)
    464       1.6      fvdl 			break;
    465  1.18.4.1      yamt 		error = ioctlf(fp, DVD_AUTH, (caddr_t)&dai, l);
    466       1.5   mycroft 		if (error)
    467       1.6      fvdl 			break;
    468       1.5   mycroft 		error = copyout(&dai, SCARG(uap, data), sizeof dai);
    469       1.6      fvdl 		break;
    470       1.5   mycroft 
    471       1.1  christos 
    472       1.1  christos 	default:
    473       1.4  christos 		DPRINTF(("linux_ioctl: unimplemented ioctl %08lx\n", com));
    474       1.6      fvdl 		error = EINVAL;
    475       1.1  christos 	}
    476       1.1  christos 
    477  1.18.4.1      yamt 	FILE_UNUSE(fp, l);
    478  1.18.4.1      yamt 	free(u1, M_TEMP);
    479  1.18.4.1      yamt 	free(u2, M_TEMP);
    480       1.6      fvdl 	return error;
    481       1.1  christos }
    482