This source file includes following definitions.
- svr4_decode_cmd
- svr4_sys_ioctl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 #include <sys/param.h>
32 #include <sys/proc.h>
33 #include <sys/systm.h>
34 #include <sys/file.h>
35 #include <sys/filedesc.h>
36 #include <sys/ioctl.h>
37 #include <sys/termios.h>
38 #include <sys/tty.h>
39 #include <sys/socket.h>
40 #include <sys/mount.h>
41 #include <net/if.h>
42 #include <sys/malloc.h>
43
44 #include <sys/syscallargs.h>
45
46 #include <compat/svr4/svr4_types.h>
47 #include <compat/svr4/svr4_util.h>
48 #include <compat/svr4/svr4_signal.h>
49 #include <compat/svr4/svr4_syscallargs.h>
50 #include <compat/svr4/svr4_stropts.h>
51 #include <compat/svr4/svr4_ioctl.h>
52 #include <compat/svr4/svr4_jioctl.h>
53 #include <compat/svr4/svr4_termios.h>
54 #include <compat/svr4/svr4_ttold.h>
55 #include <compat/svr4/svr4_filio.h>
56 #include <compat/svr4/svr4_sockio.h>
57
58 #ifdef DEBUG_SVR4
59 static void svr4_decode_cmd(u_long, char *, char *, int *, int *);
60
61
62
63 static void
64 svr4_decode_cmd(cmd, dir, c, num, argsiz)
65 u_long cmd;
66 char *dir, *c;
67 int *num, *argsiz;
68 {
69 if (cmd & SVR4_IOC_VOID)
70 *dir++ = 'V';
71 if (cmd & SVR4_IOC_IN)
72 *dir++ = 'R';
73 if (cmd & SVR4_IOC_OUT)
74 *dir++ = 'W';
75 *dir = '\0';
76 if (cmd & SVR4_IOC_INOUT)
77 *argsiz = (cmd >> 16) & 0xff;
78 else
79 *argsiz = -1;
80
81 *c = (cmd >> 8) & 0xff;
82 *num = cmd & 0xff;
83 }
84 #endif
85
86 int
87 svr4_sys_ioctl(p, v, retval)
88 register struct proc *p;
89 void *v;
90 register_t *retval;
91 {
92 struct svr4_sys_ioctl_args *uap = v;
93 struct file *fp;
94 struct filedesc *fdp;
95 u_long cmd;
96 int (*fun)(struct file *, struct proc *, register_t *,
97 int, u_long, caddr_t);
98 int error = 0;
99 #ifdef DEBUG_SVR4
100 char dir[4];
101 char c;
102 int num;
103 int argsiz;
104
105 svr4_decode_cmd(SCARG(uap, com), dir, &c, &num, &argsiz);
106
107 uprintf("svr4_ioctl(%d, _IO%s(%c, %d, %d), %p);\n", SCARG(uap, fd),
108 dir, c, num, argsiz, SCARG(uap, data));
109 #endif
110 fdp = p->p_fd;
111 cmd = SCARG(uap, com);
112
113 if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
114 return EBADF;
115
116 if ((fp->f_flag & (FREAD | FWRITE)) == 0)
117 return EBADF;
118
119 switch (cmd & 0xff00) {
120 case SVR4_tIOC:
121 fun = svr4_ttold_ioctl;
122 break;
123
124 case SVR4_TIOC:
125 fun = svr4_term_ioctl;
126 break;
127
128 case SVR4_STR:
129 fun = svr4_stream_ioctl;
130 break;
131
132 case SVR4_FIOC:
133 fun = svr4_fil_ioctl;
134 break;
135
136 case SVR4_SIOC:
137 fun = svr4_sock_ioctl;
138 break;
139
140 case SVR4_jIOC:
141 fun = svr4_jerq_ioctl;
142 break;
143
144 case SVR4_XIOC:
145
146 error = EINVAL;
147 goto out;
148
149 default:
150 DPRINTF(("Unimplemented ioctl %lx\n", cmd));
151 error = 0;
152 goto out;
153 }
154 FREF(fp);
155 error = (*fun)(fp, p, retval, SCARG(uap, fd), cmd, SCARG(uap, data));
156 FRELE(fp);
157 out:
158 return (error);
159 }