Home | History | Annotate | Line # | Download | only in common
linux_ioctl.c revision 1.17
      1  1.17  christos /*	$NetBSD: linux_ioctl.c,v 1.17 1998/01/15 14:52:13 christos Exp $	*/
      2   1.1      fvdl 
      3   1.1      fvdl /*
      4   1.1      fvdl  * Copyright (c) 1995 Frank van der Linden
      5   1.1      fvdl  * All rights reserved.
      6   1.1      fvdl  *
      7   1.1      fvdl  * Redistribution and use in source and binary forms, with or without
      8   1.1      fvdl  * modification, are permitted provided that the following conditions
      9   1.1      fvdl  * are met:
     10   1.1      fvdl  * 1. Redistributions of source code must retain the above copyright
     11   1.1      fvdl  *    notice, this list of conditions and the following disclaimer.
     12   1.1      fvdl  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1      fvdl  *    notice, this list of conditions and the following disclaimer in the
     14   1.1      fvdl  *    documentation and/or other materials provided with the distribution.
     15   1.1      fvdl  * 3. All advertising materials mentioning features or use of this software
     16   1.1      fvdl  *    must display the following acknowledgement:
     17   1.1      fvdl  *      This product includes software developed for the NetBSD Project
     18   1.1      fvdl  *      by Frank van der Linden
     19   1.1      fvdl  * 4. The name of the author may not be used to endorse or promote products
     20   1.1      fvdl  *    derived from this software without specific prior written permission
     21   1.1      fvdl  *
     22   1.1      fvdl  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23   1.1      fvdl  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24   1.1      fvdl  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25   1.1      fvdl  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26   1.1      fvdl  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27   1.1      fvdl  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28   1.1      fvdl  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29   1.1      fvdl  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30   1.1      fvdl  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31   1.1      fvdl  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32   1.1      fvdl  */
     33   1.1      fvdl 
     34   1.1      fvdl #include <sys/param.h>
     35   1.1      fvdl #include <sys/proc.h>
     36   1.1      fvdl #include <sys/systm.h>
     37   1.1      fvdl #include <sys/ioctl.h>
     38  1.13   mycroft #include <sys/mount.h>
     39  1.13   mycroft 
     40   1.1      fvdl #include <sys/socket.h>
     41   1.2      fvdl #include <net/if.h>
     42   1.2      fvdl #include <sys/sockio.h>
     43   1.1      fvdl 
     44   1.1      fvdl #include <sys/syscallargs.h>
     45   1.4   mycroft 
     46   1.1      fvdl #include <compat/linux/linux_types.h>
     47   1.4   mycroft #include <compat/linux/linux_signal.h>
     48   1.1      fvdl #include <compat/linux/linux_syscallargs.h>
     49  1.14  christos #include <compat/linux/linux_ioctl.h>
     50   1.1      fvdl 
     51  1.16  augustss #include <compat/ossaudio/ossaudio.h>
     52  1.16  augustss #define LINUX_TO_OSS(v) (v)	/* do nothing, same ioctl() encoding */
     53  1.16  augustss 
     54   1.1      fvdl /*
     55   1.1      fvdl  * Most ioctl command are just converted to their NetBSD values,
     56   1.1      fvdl  * and passed on. The ones that take structure pointers and (flag)
     57   1.1      fvdl  * values need some massaging. This is done the usual way by
     58   1.1      fvdl  * allocating stackgap memory, letting the actual ioctl call do its
     59  1.16  augustss  * work there and converting back the data afterwards.
     60   1.1      fvdl  */
     61   1.1      fvdl int
     62   1.8   mycroft linux_sys_ioctl(p, v, retval)
     63   1.1      fvdl 	register struct proc *p;
     64   1.7   thorpej 	void *v;
     65   1.7   thorpej 	register_t *retval;
     66   1.7   thorpej {
     67   1.8   mycroft 	register struct linux_sys_ioctl_args /* {
     68   1.1      fvdl 		syscallarg(int) fd;
     69   1.1      fvdl 		syscallarg(u_long) com;
     70   1.1      fvdl 		syscallarg(caddr_t) data;
     71   1.7   thorpej 	} */ *uap = v;
     72   1.1      fvdl 
     73  1.13   mycroft 	switch (LINUX_IOCGROUP(SCARG(uap, com))) {
     74  1.15   mycroft 	case 'M':
     75  1.16  augustss 		return oss_ioctl_mixer(p, LINUX_TO_OSS(v), retval);
     76  1.16  augustss 	case 'Q':
     77  1.16  augustss 		return oss_ioctl_sequencer(p, LINUX_TO_OSS(v), retval);
     78  1.13   mycroft 	case 'P':
     79  1.16  augustss 		return oss_ioctl_audio(p, LINUX_TO_OSS(v), retval);
     80  1.17  christos 	case 'S':
     81  1.17  christos 		return linux_ioctl_cdrom(p, uap, retval);
     82  1.13   mycroft 	case 'T':
     83  1.13   mycroft 		return linux_ioctl_termios(p, uap, retval);
     84  1.13   mycroft 	case 0x89:
     85  1.13   mycroft 		return linux_ioctl_socket(p, uap, retval);
     86   1.1      fvdl 	default:
     87   1.6      fvdl 		return linux_machdepioctl(p, uap, retval);
     88   1.1      fvdl 	}
     89   1.1      fvdl }
     90