blob: 65d3f52714d21a3943475279fd119a51f44892db [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * $Id$
30 */
31
32#include "defs.h"
33
34struct ioctlent ioctlent0[] = {
35/*
36 * `ioctlent.h' may be generated from `ioctlent.raw' by the auxiliary
37 * program `ioctlsort', such that the list is sorted by the `code' field.
38 * This has the side-effect of resolving the _IO.. macros into
39 * plain integers, eliminating the need to include here everything
40 * in "/usr/include" .
41 */
42#include "ioctlent.h"
43};
44
45int nioctlents0 = sizeof ioctlent0 / sizeof ioctlent0[0];
46
47#if SUPPORTED_PERSONALITIES >= 2
48struct ioctlent ioctlent1[] = {
49#include "ioctlent1.h"
50};
51
52int nioctlents1 = sizeof ioctlent1 / sizeof ioctlent1[0];
53#endif /* SUPPORTED_PERSONALITIES >= 2 */
54
55#if SUPPORTED_PERSONALITIES >= 3
56struct ioctlent ioctlent2[] = {
57#include "ioctlent2.h"
58};
59
60int nioctlents1 = sizeof ioctlent2 / sizeof ioctlent2[0];
61#endif /* SUPPORTED_PERSONALITIES >= 3 */
62
63struct ioctlent *ioctlent;
64int nioctlents;
65
66static int
67compare(a, b)
68const void *a;
69const void *b;
70{
71 unsigned long code1 = ((struct ioctlent *) a)->code;
72 unsigned long code2 = ((struct ioctlent *) b)->code;
73 return (code1 > code2) ? 1 : (code1 < code2) ? -1 : 0;
74}
75
76char *
77ioctl_lookup(code)
78long code;
79{
80 struct ioctlent *iop, ioent;
81
82 ioent.code = code;
83 iop = (struct ioctlent *) bsearch((char *) &ioent, (char *) ioctlent,
84 nioctlents, sizeof(struct ioctlent), compare);
85 return iop ? iop->symbol : NULL;
86}
87
88int
89ioctl_decode(tcp, code, arg)
90struct tcb *tcp;
91long code, arg;
92{
93 switch ((code >> 8) & 0xff) {
94#ifdef LINUX
95#ifdef ALPHA
96 case 'f': case 't': case 'T':
97#else /* !ALPHA */
98 case 0x54:
99#endif /* !ALPHA */
100#else /* !LINUX */
101 case 'f': case 't': case 'T':
102#endif /* !LINUX */
103 return term_ioctl(tcp, code, arg);
104#ifdef LINUX
105 case 0x89:
106#else /* !LINUX */
107 case 'r': case 's': case 'i': case 'p':
108#endif /* !LINUX */
109 return sock_ioctl(tcp, code, arg);
110#ifdef SVR4
111 case 'q':
112 return proc_ioctl(tcp, code, arg);
113#endif /* SVR4 */
114#ifdef HAVE_SYS_STREAM_H
115 case 'S':
116 return stream_ioctl(tcp, code, arg);
117#endif /* HAVE_SYS_STREAM_H */
118 default:
119 break;
120 }
121 return 0;
122}
123
124/*
125 * Registry of ioctl characters, culled from
126 * @(#)ioccom.h 1.7 89/06/16 SMI; from UCB ioctl.h 7.1 6/4/86
127 *
128 * char file where defined notes
129 * ---- ------------------ -----
130 * F sun/fbio.h
131 * G sun/gpio.h
132 * H vaxif/if_hy.h
133 * M sundev/mcpcmd.h *overlap*
134 * M sys/modem.h *overlap*
135 * S sys/stropts.h
136 * T sys/termio.h -no overlap-
137 * T sys/termios.h -no overlap-
138 * V sundev/mdreg.h
139 * a vaxuba/adreg.h
140 * d sun/dkio.h -no overlap with sys/des.h-
141 * d sys/des.h (possible overlap)
142 * d vax/dkio.h (possible overlap)
143 * d vaxuba/rxreg.h (possible overlap)
144 * f sys/filio.h
145 * g sunwindow/win_ioctl.h -no overlap-
146 * g sunwindowdev/winioctl.c !no manifest constant! -no overlap-
147 * h sundev/hrc_common.h
148 * i sys/sockio.h *overlap*
149 * i vaxuba/ikreg.h *overlap*
150 * k sundev/kbio.h
151 * m sundev/msio.h (possible overlap)
152 * m sundev/msreg.h (possible overlap)
153 * m sys/mtio.h (possible overlap)
154 * n sun/ndio.h
155 * p net/nit_buf.h (possible overlap)
156 * p net/nit_if.h (possible overlap)
157 * p net/nit_pf.h (possible overlap)
158 * p sundev/fpareg.h (possible overlap)
159 * p sys/sockio.h (possible overlap)
160 * p vaxuba/psreg.h (possible overlap)
161 * q sun/sqz.h
162 * r sys/sockio.h
163 * s sys/sockio.h
164 * t sys/ttold.h (possible overlap)
165 * t sys/ttycom.h (possible overlap)
166 * v sundev/vuid_event.h *overlap*
167 * v sys/vcmd.h *overlap*
168 *
169 * End of Registry
170 */
171