blob: 4e6a416be41e2815bce685bec414f797a0bd8bd7 [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
Wichert Akkermanea78f0f1999-11-29 15:34:02 +0000111#ifndef HAVE_MP_PROCFS
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000112 case 'q':
113 return proc_ioctl(tcp, code, arg);
Wichert Akkerman9ce1a631999-08-29 23:15:07 +0000114#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000115#endif /* SVR4 */
116#ifdef HAVE_SYS_STREAM_H
117 case 'S':
118 return stream_ioctl(tcp, code, arg);
119#endif /* HAVE_SYS_STREAM_H */
120 default:
121 break;
122 }
123 return 0;
124}
125
126/*
127 * Registry of ioctl characters, culled from
128 * @(#)ioccom.h 1.7 89/06/16 SMI; from UCB ioctl.h 7.1 6/4/86
129 *
130 * char file where defined notes
131 * ---- ------------------ -----
132 * F sun/fbio.h
133 * G sun/gpio.h
134 * H vaxif/if_hy.h
135 * M sundev/mcpcmd.h *overlap*
136 * M sys/modem.h *overlap*
137 * S sys/stropts.h
138 * T sys/termio.h -no overlap-
139 * T sys/termios.h -no overlap-
140 * V sundev/mdreg.h
141 * a vaxuba/adreg.h
142 * d sun/dkio.h -no overlap with sys/des.h-
143 * d sys/des.h (possible overlap)
144 * d vax/dkio.h (possible overlap)
145 * d vaxuba/rxreg.h (possible overlap)
146 * f sys/filio.h
147 * g sunwindow/win_ioctl.h -no overlap-
148 * g sunwindowdev/winioctl.c !no manifest constant! -no overlap-
149 * h sundev/hrc_common.h
150 * i sys/sockio.h *overlap*
151 * i vaxuba/ikreg.h *overlap*
152 * k sundev/kbio.h
153 * m sundev/msio.h (possible overlap)
154 * m sundev/msreg.h (possible overlap)
155 * m sys/mtio.h (possible overlap)
156 * n sun/ndio.h
157 * p net/nit_buf.h (possible overlap)
158 * p net/nit_if.h (possible overlap)
159 * p net/nit_pf.h (possible overlap)
160 * p sundev/fpareg.h (possible overlap)
161 * p sys/sockio.h (possible overlap)
162 * p vaxuba/psreg.h (possible overlap)
163 * q sun/sqz.h
164 * r sys/sockio.h
165 * s sys/sockio.h
166 * t sys/ttold.h (possible overlap)
167 * t sys/ttycom.h (possible overlap)
168 * v sundev/vuid_event.h *overlap*
169 * v sys/vcmd.h *overlap*
170 *
171 * End of Registry
172 */
173