1 | *** h/ioctl.h.old Tue May 23 14:50:42 1989 |
---|
2 | --- h/ioctl.h Tue Aug 29 18:24:49 1989 |
---|
3 | *************** |
---|
4 | *** 214,219 **** |
---|
5 | --- 214,220 ---- |
---|
6 | #define TIOCPKT_START 0x08 /* start output */ |
---|
7 | #define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */ |
---|
8 | #define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */ |
---|
9 | + #define TIOCPKT_IOCTL 0x40 /* state change of pty driver */ |
---|
10 | #define TIOCSTOP _IO('t', 111) /* stop output, like ^S */ |
---|
11 | #define TIOCSTART _IO('t', 110) /* start output, like ^Q */ |
---|
12 | #define TIOCMSET _IOW('t', 109, int) /* set all modem bits */ |
---|
13 | *************** |
---|
14 | *** 226,231 **** |
---|
15 | --- 227,235 ---- |
---|
16 | #define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */ |
---|
17 | #define UIOCCMD(n) _IO('u', n) /* usr cntl op "n" */ |
---|
18 | #define TIOCCONS _IO('t', 98) /* become virtual console */ |
---|
19 | + #define TIOCEXT _IOW('t', 97, int) /* pty: external processing */ |
---|
20 | + #define TIOCGSTATE _IOR('t', 96, int) /* pty: get internal state */ |
---|
21 | + #define TIOCSIG _IO('t', 95) /* pty: generate signal */ |
---|
22 | |
---|
23 | #define OTTYDISC 0 /* old, v7 std tty driver */ |
---|
24 | #define NETLDISC 1 /* line discip for berk net */ |
---|
25 | *** h/tty.h.old Tue May 23 14:51:01 1989 |
---|
26 | --- h/tty.h Wed Aug 23 11:30:40 1989 |
---|
27 | *************** |
---|
28 | *** 70,75 **** |
---|
29 | --- 70,76 ---- |
---|
30 | struct ttychars t_chars; /* tty */ |
---|
31 | struct winsize t_winsize; /* window size */ |
---|
32 | /* be careful of tchars & co. */ |
---|
33 | + #ifndef NO_T_CHARS_DEFINES |
---|
34 | #define t_erase t_chars.tc_erase |
---|
35 | #define t_kill t_chars.tc_kill |
---|
36 | #define t_intrc t_chars.tc_intrc |
---|
37 | *************** |
---|
38 | *** 84,89 **** |
---|
39 | --- 85,91 ---- |
---|
40 | #define t_flushc t_chars.tc_flushc |
---|
41 | #define t_werasc t_chars.tc_werasc |
---|
42 | #define t_lnextc t_chars.tc_lnextc |
---|
43 | + #endif |
---|
44 | }; |
---|
45 | |
---|
46 | #define TTIPRI 28 |
---|
47 | *************** |
---|
48 | *** 124,129 **** |
---|
49 | --- 126,132 ---- |
---|
50 | #define TS_LNCH 0x080000 /* next character is literal */ |
---|
51 | #define TS_TYPEN 0x100000 /* retyping suspended input (PENDIN) */ |
---|
52 | #define TS_CNTTB 0x200000 /* counting tab width; leave FLUSHO alone */ |
---|
53 | + #define TS_EXTPROC 0x400000 /* external processing of data */ |
---|
54 | |
---|
55 | #define TS_LOCAL (TS_BKSL|TS_QUOT|TS_ERASE|TS_LNCH|TS_TYPEN|TS_CNTTB) |
---|
56 | |
---|
57 | *** sys/tty.c.old Tue May 23 14:52:28 1989 |
---|
58 | --- sys/tty.c Thu Aug 24 09:31:49 1989 |
---|
59 | *************** |
---|
60 | *** 275,280 **** |
---|
61 | --- 275,285 ---- |
---|
62 | */ |
---|
63 | switch (com) { |
---|
64 | |
---|
65 | + /* get internal state - needed for TS_EXTPROC bit */ |
---|
66 | + case TIOCGSTATE: |
---|
67 | + *(int *)data = tp->t_state; |
---|
68 | + break; |
---|
69 | + |
---|
70 | /* get discipline number */ |
---|
71 | case TIOCGETD: |
---|
72 | *(int *)data = tp->t_line; |
---|
73 | *************** |
---|
74 | *** 752,757 **** |
---|
75 | --- 757,763 ---- |
---|
76 | */ |
---|
77 | if ((tp->t_state&TS_TYPEN) == 0 && (t_flags&PASS8) == 0) |
---|
78 | c &= 0177; |
---|
79 | + if ((tp->t_state&TS_EXTPROC) == 0) { |
---|
80 | /* |
---|
81 | * Check for literal nexting very first |
---|
82 | */ |
---|
83 | *************** |
---|
84 | *** 834,839 **** |
---|
85 | --- 840,846 ---- |
---|
86 | else if (c == '\\') |
---|
87 | tp->t_state |= TS_BKSL; |
---|
88 | } |
---|
89 | + } |
---|
90 | |
---|
91 | /* |
---|
92 | * Cbreak mode, don't process line editing |
---|
93 | *************** |
---|
94 | *** 851,856 **** |
---|
95 | --- 858,864 ---- |
---|
96 | goto endcase; |
---|
97 | } |
---|
98 | |
---|
99 | + if ((tp->t_state&TS_EXTPROC) == 0) { |
---|
100 | /* |
---|
101 | * From here on down cooked mode character |
---|
102 | * processing takes place. |
---|
103 | *************** |
---|
104 | *** 911,916 **** |
---|
105 | --- 919,925 ---- |
---|
106 | goto endcase; |
---|
107 | } |
---|
108 | } |
---|
109 | + } |
---|
110 | |
---|
111 | /* |
---|
112 | * Check for input buffer overflow |
---|
113 | *************** |
---|
114 | *** 933,938 **** |
---|
115 | --- 942,948 ---- |
---|
116 | } else if (tp->t_rocount++ == 0) |
---|
117 | tp->t_rocol = tp->t_col; |
---|
118 | tp->t_state &= ~TS_QUOT; |
---|
119 | + if ((tp->t_state&TS_EXTPROC) == 0) { |
---|
120 | if (c == '\\') |
---|
121 | tp->t_state |= TS_QUOT; |
---|
122 | if (tp->t_state&TS_ERASE) { |
---|
123 | *************** |
---|
124 | *** 948,953 **** |
---|
125 | --- 958,964 ---- |
---|
126 | i--; |
---|
127 | } |
---|
128 | } |
---|
129 | + } |
---|
130 | } |
---|
131 | endcase: |
---|
132 | /* |
---|
133 | *************** |
---|
134 | *** 998,1005 **** |
---|
135 | return (-1); |
---|
136 | /* |
---|
137 | * Turn tabs to spaces as required |
---|
138 | */ |
---|
139 | ! if (c == '\t' && (tp->t_flags&TBDELAY) == XTABS) { |
---|
140 | register int s; |
---|
141 | |
---|
142 | c = 8 - (tp->t_col&7); |
---|
143 | --- 1009,1022 ---- |
---|
144 | return (-1); |
---|
145 | /* |
---|
146 | * Turn tabs to spaces as required |
---|
147 | + * |
---|
148 | + * Special case if we have external processing, we don't |
---|
149 | + * do the tab expansion because we'll probably get it |
---|
150 | + * wrong. If tab expansion needs to be done, let it |
---|
151 | + * happen externally. |
---|
152 | */ |
---|
153 | ! if ((tp->t_state&TS_EXTPROC) == 0 && |
---|
154 | ! c == '\t' && (tp->t_flags&TBDELAY) == XTABS) { |
---|
155 | register int s; |
---|
156 | |
---|
157 | c = 8 - (tp->t_col&7); |
---|
158 | *************** |
---|
159 | *** 1497,1503 **** |
---|
160 | int s; |
---|
161 | char *nextc(); |
---|
162 | |
---|
163 | ! if ((tp->t_flags&ECHO) == 0) |
---|
164 | return; |
---|
165 | tp->t_flags &= ~FLUSHO; |
---|
166 | c &= 0377; |
---|
167 | --- 1514,1520 ---- |
---|
168 | int s; |
---|
169 | char *nextc(); |
---|
170 | |
---|
171 | ! if ((tp->t_flags&ECHO) == 0 || (tp->t_state&TS_EXTPROC)) |
---|
172 | return; |
---|
173 | tp->t_flags &= ~FLUSHO; |
---|
174 | c &= 0377; |
---|
175 | *************** |
---|
176 | *** 1618,1624 **** |
---|
177 | |
---|
178 | if ((tp->t_state&TS_CNTTB) == 0) |
---|
179 | tp->t_flags &= ~FLUSHO; |
---|
180 | ! if ((tp->t_flags&ECHO) == 0) |
---|
181 | return; |
---|
182 | c &= 0377; |
---|
183 | if (tp->t_flags&RAW) { |
---|
184 | --- 1635,1641 ---- |
---|
185 | |
---|
186 | if ((tp->t_state&TS_CNTTB) == 0) |
---|
187 | tp->t_flags &= ~FLUSHO; |
---|
188 | ! if ((tp->t_flags&ECHO) == 0 || (tp->t_state&TS_EXTPROC)) |
---|
189 | return; |
---|
190 | c &= 0377; |
---|
191 | if (tp->t_flags&RAW) { |
---|
192 | *** sys/tty_pty.c.old Tue May 23 14:52:43 1989 |
---|
193 | --- sys/tty_pty.c Tue Aug 29 18:48:36 1989 |
---|
194 | *************** |
---|
195 | *** 208,213 **** |
---|
196 | --- 208,214 ---- |
---|
197 | return (EIO); |
---|
198 | tp->t_oproc = ptsstart; |
---|
199 | (void)(*linesw[tp->t_line].l_modem)(tp, 1); |
---|
200 | + tp->t_state &= ~TS_EXTPROC; |
---|
201 | pti = &pt_ioctl[minor(dev)]; |
---|
202 | pti->pt_flags = 0; |
---|
203 | pti->pt_send = 0; |
---|
204 | *************** |
---|
205 | *** 247,252 **** |
---|
206 | --- 248,275 ---- |
---|
207 | error = ureadc((int)pti->pt_send, uio); |
---|
208 | if (error) |
---|
209 | return (error); |
---|
210 | + if (pti->pt_send & TIOCPKT_IOCTL) { |
---|
211 | + struct xx { |
---|
212 | + struct sgttyb a; |
---|
213 | + struct tchars b; |
---|
214 | + struct ltchars c; |
---|
215 | + int d; |
---|
216 | + int e; |
---|
217 | + } cb; |
---|
218 | + cb.a.sg_ispeed = tp->t_ispeed; |
---|
219 | + cb.a.sg_ospeed = tp->t_ospeed; |
---|
220 | + cb.a.sg_erase = tp->t_erase; |
---|
221 | + cb.a.sg_kill = tp->t_kill; |
---|
222 | + cb.a.sg_flags = tp->t_flags; |
---|
223 | + bcopy((caddr_t)&tp->t_intrc, |
---|
224 | + (caddr_t)&cb.b, sizeof(cb.b)); |
---|
225 | + bcopy((caddr_t)&tp->t_suspc, |
---|
226 | + (caddr_t)&cb.c, sizeof(cb.c)); |
---|
227 | + cb.d = tp->t_state; |
---|
228 | + cb.e = ((unsigned)tp->t_flags)>>16; |
---|
229 | + cc = MIN(uio->uio_resid, sizeof(cb)); |
---|
230 | + uiomove(&cb, cc, UIO_READ, uio); |
---|
231 | + } |
---|
232 | pti->pt_send = 0; |
---|
233 | return (0); |
---|
234 | } |
---|
235 | *************** |
---|
236 | *** 483,488 **** |
---|
237 | --- 506,533 ---- |
---|
238 | * IF CONTROLLER STTY THEN MUST FLUSH TO PREVENT A HANG. |
---|
239 | * ttywflush(tp) will hang if there are characters in the outq. |
---|
240 | */ |
---|
241 | + if (cmd == TIOCEXT) { |
---|
242 | + /* |
---|
243 | + * When the TS_EXTPROC bit is being toggled, we need |
---|
244 | + * to send an TIOCPKT_IOCTL if the packet driver |
---|
245 | + * is turned on. |
---|
246 | + */ |
---|
247 | + if (*(int *)data) { |
---|
248 | + if (pti->pt_flags & PF_PKT) { |
---|
249 | + pti->pt_send |= TIOCPKT_IOCTL; |
---|
250 | + ptcwakeup(tp); |
---|
251 | + } |
---|
252 | + tp->t_state |= TS_EXTPROC; |
---|
253 | + } else { |
---|
254 | + if ((tp->t_state & TS_EXTPROC) && |
---|
255 | + (pti->pt_flags & PF_PKT)) { |
---|
256 | + pti->pt_send |= TIOCPKT_IOCTL; |
---|
257 | + ptcwakeup(tp); |
---|
258 | + } |
---|
259 | + tp->t_state &= ~TS_EXTPROC; |
---|
260 | + } |
---|
261 | + return (0); |
---|
262 | + } else |
---|
263 | if (cdevsw[major(dev)].d_open == ptcopen) |
---|
264 | switch (cmd) { |
---|
265 | |
---|
266 | *************** |
---|
267 | *** 525,530 **** |
---|
268 | --- 570,583 ---- |
---|
269 | while (getc(&tp->t_outq) >= 0) |
---|
270 | ; |
---|
271 | break; |
---|
272 | + |
---|
273 | + case TIOCSIG: |
---|
274 | + if (*(unsigned int *)data >= NSIG) |
---|
275 | + return(EINVAL); |
---|
276 | + if ((tp->t_flags&NOFLSH) == 0) |
---|
277 | + ttyflush(tp, FREAD|FWRITE); |
---|
278 | + gsignal(tp->t_pgrp, *(unsigned int *)data); |
---|
279 | + return(0); |
---|
280 | } |
---|
281 | error = ttioctl(tp, cmd, data, flag); |
---|
282 | /* |
---|
283 | *************** |
---|
284 | *** 549,554 **** |
---|
285 | --- 602,624 ---- |
---|
286 | return (0); |
---|
287 | } |
---|
288 | error = ENOTTY; |
---|
289 | + } |
---|
290 | + /* |
---|
291 | + * If external processing and packet mode send ioctl packet. |
---|
292 | + */ |
---|
293 | + if ((tp->t_state & TS_EXTPROC) && (pti->pt_flags & PF_PKT)) { |
---|
294 | + switch(cmd) { |
---|
295 | + case TIOCSETP: |
---|
296 | + case TIOCSETN: |
---|
297 | + case TIOCSETC: |
---|
298 | + case TIOCSLTC: |
---|
299 | + case TIOCLBIS: |
---|
300 | + case TIOCLBIC: |
---|
301 | + case TIOCLSET: |
---|
302 | + pti->pt_send |= TIOCPKT_IOCTL; |
---|
303 | + default: |
---|
304 | + break; |
---|
305 | + } |
---|
306 | } |
---|
307 | stop = (tp->t_flags & RAW) == 0 && |
---|
308 | tp->t_stopc == CTRL('s') && tp->t_startc == CTRL('q'); |
---|