1ttcompat(7M)                    STREAMS Modules                   ttcompat(7M)
2
3
4

NAME

6       ttcompat - V7, 4BSD and XENIX STREAMS compatibility module
7

SYNOPSIS

9       #define BSD_COMP
10       #include <sys/stropts.h>
11       #include <sys/ioctl.h>
12       ioctl(fd, I_PUSH, "ttcompat");
13
14

DESCRIPTION

16       ttcompat  is a STREAMS module that translates the ioctl calls supported
17       by the older Version 7, 4BSD, and XENIX terminal drivers into the ioctl
18       calls  supported  by  the  termio interface (see termio(7I)). All other
19       messages pass through this module unchanged; the behavior of  read  and
20       write  calls is unchanged, as is the behavior of ioctl calls other than
21       the ones supported by ttcompat.
22
23
24       This module can be automatically pushed onto a stream using  the  auto‐
25       push   mechanism  when a terminal device is opened; it does not have to
26       be explicitly  pushed onto a stream.  This  module  requires  that  the
27       termios  interface  be supported by the modules and the application can
28       push the driver downstream. The TCGETS, TCSETS, and TCSETSF ioctl calls
29       must  be  supported.  If  any information set or fetched by those ioctl
30       calls is not supported by the modules and driver  downstream,  some  of
31       the  V7/4BSD/XENIX  functions may not be supported. For example, if the
32       CBAUD bits in the  c_cflag field are not supported, the functions  pro‐
33       vided  by  the  sg_ispeed  and sg_ospeed fields of the sgttyb structure
34       (see below) will not be supported. If the  TCFLSH  ioctl  is  not  sup‐
35       ported,  the  function provided by the TIOCFLUSH ioctl will not be sup‐
36       ported. If the TCXONC ioctl is not supported, the functions provided by
37       the  TIOCSTOP  and  TIOCSTART ioctl calls will not be supported. If the
38       TIOCMBIS and TIOCMBIC ioctl calls are not supported, the functions pro‐
39       vided by the TIOCSDTR and TIOCCDTR ioctl calls will not be supported.
40
41
42       The basic ioctl calls use the sgttyb structure defined by <sys/ttold.h>
43       (included by <sys/ioctl.h>):
44
45         struct   sgttyb   {
46              char sg_ispeed;
47              char sg_ospeed;
48              char sg_erase;
49              char sg_kill;
50              int  sg_flags;
51         };
52
53
54
55       The sg_ispeed and sg_ospeed  fields  describe  the   input  and  output
56       speeds  of the device.  If the speed set on the device is  over B38400,
57       then it is reported as B38400 for compatibility reasons. If it  is  set
58       to B38400 and  the current speed is over B38400, the change is ignored.
59       See TIOCGETP and TIOCSETP below. The sg_erase and sg_kill fields of the
60       argument  structure specify the erase and kill characters respectively,
61       and reflect the values in the VERASE and  VKILL  members  of  the  c_cc
62       field of the termios structure.
63
64
65       The  sg_flags  field  of  the argument structure contains several flags
66       that determine the system's treatment of the terminal. They are  mapped
67       into  flags in fields of the terminal state, represented by the termios
68       structure.
69
70
71       Delay type 0 (NL0,  TAB0, CR0, FF0,  BS0) is  always  mapped  into  the
72       equivalent  delay type 0 in the c_oflag field of the termios structure.
73       Other delay  mappings are  performed as follows:
74
75
76
77
78       ┌─────────┬─────────────────────────────────────────────────────────┐
79       │sg_flags │                         c_oflag                         │
80       ├─────────┼─────────────────────────────────────────────────────────┤
81       │BS1      │ BS1                                                     │
82       ├─────────┼─────────────────────────────────────────────────────────┤
83       │FF1      │ VT1                                                     │
84       ├─────────┼─────────────────────────────────────────────────────────┤
85       │CR1      │ CR2                                                     │
86       ├─────────┼─────────────────────────────────────────────────────────┤
87       │CR2      │ CR3                                                     │
88       ├─────────┼─────────────────────────────────────────────────────────┤
89       │CR3      │ CR0 (not supported)                                     │
90       ├─────────┼─────────────────────────────────────────────────────────┤
91       │TAB1     │ TAB1                                                    │
92       ├─────────┼─────────────────────────────────────────────────────────┤
93       │TAB2     │ TAB2                                                    │
94       ├─────────┼─────────────────────────────────────────────────────────┤
95       │XTABS    │ TAB3                                                    │
96       ├─────────┼─────────────────────────────────────────────────────────┤
97       │NL1      │ ONLRET|CR1                                              │
98       ├─────────┼─────────────────────────────────────────────────────────┤
99       │NL2      │ NL1                                                     │
100       ├─────────┼─────────────────────────────────────────────────────────┤
101       │NL3      │ NL0 (not supported)                                     │
102       └─────────┴─────────────────────────────────────────────────────────┘
103
104
105       If previous TIOCLSET or TIOCLBIS ioctl calls have not  selected  LITOUT
106       or  PASS8 mode, and if RAW mode is not selected, the ISTRIP flag is set
107       in the c_iflag field of the termios structure, and the EVENP  and  ODDP
108       flags  control  the  parity  of  characters  sent  to  the terminal and
109       accepted from the terminal, as follows:
110
111       0 (neither EVENP nor ODDP)    Parity is not to be generated  on  output
112                                     or  checked on input. The  character size
113                                     is set to CS8  and  the  PARENB  flag  is
114                                     cleared  in  the  c_cflag  field  of  the
115                                     termios structure.
116
117
118       EVENP                         Even parity characters are to  be  gener‐
119                                     ated on output and accepted on input. The
120                                     INPCK  flag is set in the  c_iflag  field
121                                     of  the  termios structure, the character
122                                     size is set to CS7 and the PARENB flag is
123                                     set  in  the c_iflag field of the termios
124                                     structure.
125
126
127       ODDP                          Odd parity characters are to be generated
128                                     on  output  and  accepted  on  input. The
129                                     INPCK flag is set  in  the  c_iflag,  the
130                                     character  size  is  set  to  CS7 and the
131                                     PARENB and PARODD flags are  set  in  the
132                                     c_iflag field  of the termios structure.
133
134
135       EVENP|ODDP or ANYP            Even  parity  characters are to be gener‐
136                                     ated  on output and characters of  either
137                                     parity  are to be  accepted on input. The
138                                     INPCK flag  is  cleared  in  the  c_iflag
139                                     field,  the  character size is set to CS7
140                                     and the PARENB flag is set in the c_iflag
141                                     field of the termios structure.
142
143
144
145       The  RAW  flag  disables  all  output processing (the OPOST flag in the
146       c_oflag field, and the XCASE and IEXTEN flags in the c_iflag field  are
147       cleared  in  the termios structure) and input processing (all flags  in
148       the c_iflag field other than the IXOFF and IXANY flags  are cleared  in
149       the  termios  structure).   Eight  bits of data, with no parity bit are
150       accepted on input and generated on output; the character size is set to
151       CS8 and the PARENB and PARODD flags are cleared in the c_cflag field of
152       the termios structure. The signal-generating and  line-editing  control
153       characters  are  disabled  by clearing the ISIG and ICANON flags in the
154       c_iflag field of the termios structure.
155
156
157       The CRMOD flag turns input carriage  return  characters  into  linefeed
158       characters,  and  output  linefeed  characters to be sent as a carriage
159       return followed by a linefeed. The ICRNL flag in the c_iflag field, and
160       the  OPOST and ONLCR flags in the c_oflag field, are set in the termios
161       structure.
162
163
164       The LCASE flag maps upper-case letters in the ASCII  character  set  to
165       their  lower-case  equivalents  on  input (the IUCLC flag is set in the
166       c_iflag field), and maps lower-case letters in the ASCII character  set
167       to their upper-case equivalents on output (the OLCUC flag is set in the
168       c_oflag field). Escape sequences are accepted on input,  and  generated
169       on  output,  to  handle certain ASCII characters not supported by older
170       terminals (the XCASE flag is set in the c_lflag field).
171
172
173       Other flags are directly mapped to flags in the termios structure:
174
175
176
177
178       ┌─────────┬─────────────────────────────────────────────────────────┐
179       │sg_flags │               Flags in termios structure                │
180       ├─────────┼─────────────────────────────────────────────────────────┤
181       │CBREAK   │ Complement of ICANON in c_lflag field                   │
182       ├─────────┼─────────────────────────────────────────────────────────┤
183       │ECHO     │ ECHO in c_lflag field                                   │
184       ├─────────┼─────────────────────────────────────────────────────────┤
185       │TANDEM   │ IXOFF in c_iflag field                                  │
186       └─────────┴─────────────────────────────────────────────────────────┘
187
188
189       Another structure associated with each  terminal  specifies  characters
190       that  are special in both the old Version 7 and the newer 4BSD terminal
191       interfaces. The following structure is defined by <sys/ttold.h>:
192
193         struct   tchars   {
194                   char t_intrc;     /* interrupt */
195                   char t_quitc;     /* quit */
196                   char t_startc; /* start output */
197                   char t_stopc;     /* stop output */
198                   char t_eofc;        /* end-of-file */
199                   char t_brkc;        /* input delimiter (like nl) */
200              };
201
202
203
204       XENIX defines the  tchar structure as  tc. The characters are mapped to
205       members of the c_cc field of the termios structure as follows:
206
207                tchars                c_cc index
208                t_intrc               VINTR
209                t_quitc               VQUIT
210                t_startc              VSTART
211                t_stopc               VSTOP
212                t_eofc                VEOF
213                t_brkc                VEOL
214
215
216
217       Also  associated  with each terminal is a local flag word (TIOCLSET and
218       TIOCLGET), specifying flags  supported by the new 4BSD terminal  inter‐
219       face.  Most  of these flags are directly mapped to flags in the termios
220       structure:
221
222
223
224
225       ┌────────────┬─────────────────────────────────────────────────────────┐
226       │Local flags │               Flags in termios structure                │
227       ├────────────┼─────────────────────────────────────────────────────────┤
228       │LCRTBS      │ Not supported                                           │
229       ├────────────┼─────────────────────────────────────────────────────────┤
230       │LPRTERA     │ ECHOPRT in the c_lflag field                            │
231       ├────────────┼─────────────────────────────────────────────────────────┤
232       │LCRTERA     │ ECHOE in the c_lflag field                              │
233       ├────────────┼─────────────────────────────────────────────────────────┤
234       │LTILDE      │ Not supported                                           │
235       ├────────────┼─────────────────────────────────────────────────────────┤
236       │LMDMBUF     │ Not supported                                           │
237       ├────────────┼─────────────────────────────────────────────────────────┤
238       │LTOSTOP     │ TOSTOP in the c_lflag field                             │
239       ├────────────┼─────────────────────────────────────────────────────────┤
240       │LFLUSHO     │ FLUSHO in the c_lflag field                             │
241       ├────────────┼─────────────────────────────────────────────────────────┤
242       │LNOHANG     │ CLOCAL in the c_cflag field                             │
243       ├────────────┼─────────────────────────────────────────────────────────┤
244       │LCRTKIL     │ ECHOKE in the c_lflag field                             │
245       ├────────────┼─────────────────────────────────────────────────────────┤
246       │LPASS8      │ CS8 in the c_cflag field                                │
247       ├────────────┼─────────────────────────────────────────────────────────┤
248       │LCTLECH     │ CTLECH in the c_lflag field                             │
249       ├────────────┼─────────────────────────────────────────────────────────┤
250       │LPENDIN     │ PENDIN in the c_lflag field                             │
251       ├────────────┼─────────────────────────────────────────────────────────┤
252       │LDECCTQ     │ Complement of IXANY in the c_iflag field                │
253       ├────────────┼─────────────────────────────────────────────────────────┤
254       │LNOFLSH     │ NOFLSH in the c_lflag field                             │
255       └────────────┴─────────────────────────────────────────────────────────┘
256
257
258       Each flag has a corresponding equivalent sg_flags value.  The  sg_flags
259       definitions  omit  the leading "L"; for example, TIOCSETP with sg_flags
260       set to TOSTOP is equivalent to TIOCLSET with LTOSTOP.
261
262
263       Another structure associated with each terminal is the  ltchars  struc‐
264       ture  which defines control characters for the new 4BSD terminal inter‐
265       face. Its structure is:
266
267         struct ltchars {
268            char t_suspc;  /* stop process signal */
269            char t_dsuspc; /* delayed stop process signal */
270            char t_rprntc; /* reprint line */
271            char t_flushc; /*flush output (toggles) */
272            char t_werasc; /* word erase */
273            char t_lnextc; /* literal next character */
274         };
275
276
277
278       The characters are mapped to members of the c_cc field of  the  termios
279       structure as follows:
280
281
282
283
284       ┌─────────┬─────────────────────────────────────────────────────────┐
285       │ltchars  │                       c_cc index                        │
286       ├─────────┼─────────────────────────────────────────────────────────┤
287       │t_suspc  │ VSUS                                                    │
288       ├─────────┼─────────────────────────────────────────────────────────┤
289       │t_dsuspc │ VDSUSP                                                  │
290       ├─────────┼─────────────────────────────────────────────────────────┤
291       │t_rprntc │ VREPRINT                                                │
292       ├─────────┼─────────────────────────────────────────────────────────┤
293       │t_flushc │ VDISCARD                                                │
294       ├─────────┼─────────────────────────────────────────────────────────┤
295       │t_werasc │ VWERASE                                                 │
296       ├─────────┼─────────────────────────────────────────────────────────┤
297       │t_lnextc │ VLNEXT                                                  │
298       └─────────┴─────────────────────────────────────────────────────────┘
299

IOCTLS

301       ttcompat  responds  to the following ioctl calls. All others are passed
302       to the module below.
303
304       TIOCGETP      The argument is a pointer to  an  sgttyb  structure.  The
305                     current   terminal  state  is  fetched;  the  appropriate
306                     characters in  the terminal  state are  stored   in  that
307                     structure,  as  are  the  input and output speeds. If the
308                     speed is over B38400,  then B38400 is  returned. The val‐
309                     ues  of  the flags in the sg_flags field are derived from
310                     the flags in the terminal state and stored in the  struc‐
311                     ture.
312
313
314       TIOCEXCL      Set ``exclusive-use'' mode; no further opens are  permit‐
315                     ted until the file has been closed.
316
317
318       TIOCNXCL      Turn off ``exclusive-use'' mode.
319
320
321       TIOCSETP      The argument is a pointer to  an  sgttyb  structure.  The
322                     appropriate characters and input and output speeds in the
323                     terminal state are set from the values in that structure,
324                     and  the flags in the terminal state are set to match the
325                     values of the flags in the sg_flags field of that  struc‐
326                     ture.  The  state is changed with a TCSETSF ioctl so that
327                     the interface delays  until  output  is  quiescent,  then
328                     throws  away  any  unread characters, before changing the
329                     modes. If the current device speed  is  over  B38400  for
330                     either  input  or  output  speed, and B38400 is specified
331                     through this interface for that speed, the actual  device
332                     speed  is  not  changed. If the device speed is B38400 or
333                     lower or if some speed other than  B38400  is  specified,
334                     then the actual speed specified is set.
335
336
337       TIOCSETN      The  argument  is  a  pointer to an sgttyb structure. The
338                     terminal state is changed as  TIOCSETP would  change  it,
339                     but a TCSETS ioctl is used, so that the interface neither
340                     delays nor discards input.
341
342
343       TIOCHPCL      The argument is ignored. The HUPCL flag  is  set  in  the
344                     c_cflag word of the terminal state.
345
346
347       TIOCFLUSH     The  argument  is  a  pointer  to an int variable. If its
348                     value is zero, all characters waiting in input or  output
349                     queues  are  flushed.  Otherwise, the value of the int is
350                     treated as the logical OR of the FREAD and  FWRITE  flags
351                     defined  by  <sys/file.h>.  If  the FREAD bit is set, all
352                     characters waiting in input queues are  flushed,  and  if
353                     the  FWRITE  bit is set, all characters waiting in output
354                     queues are flushed.
355
356
357       TIOCSBRK      The argument is ignored. The break bit  is  set  for  the
358                     device.  (This  is not supported  by ttcompat. The under‐
359                     lying driver must support TIOCSBRK.)
360
361
362       TIOCCBRK      The argument is ignored. The break bit is cleared for the
363                     device.  (This is not supported by ttcompat. The underly‐
364                     ing driver must support TIOCCBRK.)
365
366
367       TIOCSDTR      The argument is ignored. The Data Terminal Ready  bit  is
368                     set for the device.
369
370
371       TIOCCDTR      The  argument  is ignored. The Data Terminal Ready bit is
372                     cleared for the device.
373
374
375       TIOCSTOP      The argument is ignored. Output is stopped as if the STOP
376                     character had been typed.
377
378
379       TIOCSTART     The  argument  is  ignored. Output is restarted as if the
380                     START character had been typed.
381
382
383       TIOCGETC      The argument is a pointer to a tchars structure. The cur‐
384                     rent terminal state is fetched, and the appropriate char‐
385                     acters in the terminal state are stored  in  that  struc‐
386                     ture.
387
388
389       TIOCSETC      The argument is a pointer to a tchars structure. The val‐
390                     ues of the appropriate characters in the  terminal  state
391                     are set from the characters in that structure.
392
393
394       TIOCLGET      The argument is a pointer to an int. The current terminal
395                     state is fetched, and the values of the local  flags  are
396                     derived  from  the flags in the terminal state and stored
397                     in the int pointed to by the argument.
398
399
400       TIOCLBIS      The argument is a pointer to an int whose value is a mask
401                     containing  flags  to be set in the local flags word. The
402                     current terminal state is fetched, and the values of  the
403                     local  flags  are  derived from the flags in the terminal
404                     state; the specified flags are set, and the flags in  the
405                     terminal  state  are  set  to  match the new value of the
406                     local flags word.
407
408
409       TIOCLBIC      The argument is a pointer to an int whose value is a mask
410                     containing  flags  to be cleared in the local flags word.
411                     The current terminal state is fetched, and the values  of
412                     the  local flags are derived from the flags in the termi‐
413                     nal state; the specified flags are cleared, and the flags
414                     in  the  terminal state are set to match the new value of
415                     the local flags word.
416
417
418       TIOCLSET      The argument is a pointer to an int containing a new  set
419                     of  local  flags. The flags in the terminal state are set
420                     to match the  new value of the local flags  word.   (This
421                     ioctl  was  added  because  sg_flags  was  once a 16  bit
422                     value. The local modes controlled by TIOCLSET are equiva‐
423                     lent to the modes controlled by TIOCSETP and sg_flags.)
424
425
426       TIOCGLTC      The  argument  is  a pointer to an ltchars structure. The
427                     values of the  appropriate  characters  in  the  terminal
428                     state are stored in that structure.
429
430
431       TIOCSLTC      The  argument  is  a pointer to an ltchars structure. The
432                     values of the  appropriate  characters  in  the  terminal
433                     state are set from the characters in that structure.
434
435
436       FIORDCHK      Returns  the  number  of immediately readable characters.
437                     The argument is ignored. (This ioctl is  handled  in  the
438                     stream head, not in the ttcompat module.)
439
440
441       FIONREAD      Returns  the number of immediately readable characters in
442                     the int pointed to by the argument. (This ioctl is   han‐
443                     dled in the stream head, not in the ttcompat module.)
444
445
446
447       The following ioctls are returned as successful for the sake of compat‐
448       ibility. However, nothing significant is done (that is,  the  state  of
449       the  terminal  is  not  changed  in  any  way, and no message is passed
450       through to the underlying tty driver).
451
452
453         DIOCSETP
454         DIOCSETP
455         DIOCGETP
456         LDCLOSE
457         LDCHG
458         LDOPEN
459         LDGETT
460         LDSETT
461         TIOCGETD
462         TIOCSETD
463
464
465
466       The following old ioctls are not supported by ttcompat,  but  are  sup‐
467       ported  by  Solaris tty drivers. As with all ioctl not otherwise listed
468       in this documentation, these  are  passed  through  to  the  underlying
469       driver and are handled there.
470
471         TIOCREMOTE
472         TIOCGWINSZ
473         TIOCSWINSZ
474
475
476
477       The  following ioctls are  not supported by ttcompat, and are generally
478       not supported by Solaris tty drivers. They are  passed through, and the
479       tty drivers return EINVAL.
480
481         LDSMAP
482         LDGMAP
483         LDNMAP
484         TIOCNOTTY
485         TIOCOUTQ
486
487
488
489       (Note:     LDSMAP,     LDGMAP,    and     LDNMAP    are   defined    in
490       <sys/termios.h>.)
491

SEE ALSO

493       ioctl(2), termios(3C), ldterm(7M), termio(7I)
494
495
496
497SunOS 5.11                        2 Oct 2001                      ttcompat(7M)
Impressum