linux_ioctl.c revision 1.14 1 1.14 christos /* $NetBSD: linux_ioctl.c,v 1.14 1996/04/05 00:01:28 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.1 fvdl /*
52 1.1 fvdl * Most ioctl command are just converted to their NetBSD values,
53 1.1 fvdl * and passed on. The ones that take structure pointers and (flag)
54 1.1 fvdl * values need some massaging. This is done the usual way by
55 1.1 fvdl * allocating stackgap memory, letting the actual ioctl call do its
56 1.1 fvdl * work their and converting back the data afterwards.
57 1.1 fvdl */
58 1.1 fvdl int
59 1.8 mycroft linux_sys_ioctl(p, v, retval)
60 1.1 fvdl register struct proc *p;
61 1.7 thorpej void *v;
62 1.7 thorpej register_t *retval;
63 1.7 thorpej {
64 1.8 mycroft register struct linux_sys_ioctl_args /* {
65 1.1 fvdl syscallarg(int) fd;
66 1.1 fvdl syscallarg(u_long) com;
67 1.1 fvdl syscallarg(caddr_t) data;
68 1.7 thorpej } */ *uap = v;
69 1.1 fvdl
70 1.13 mycroft switch (LINUX_IOCGROUP(SCARG(uap, com))) {
71 1.13 mycroft case 'P':
72 1.13 mycroft return linux_ioctl_audio(p, uap, retval);
73 1.13 mycroft case 'T':
74 1.13 mycroft return linux_ioctl_termios(p, uap, retval);
75 1.13 mycroft case 0x89:
76 1.13 mycroft return linux_ioctl_socket(p, uap, retval);
77 1.1 fvdl default:
78 1.6 fvdl return linux_machdepioctl(p, uap, retval);
79 1.1 fvdl }
80 1.1 fvdl }
81