2 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
3 * Copyright (c) 1996-2017 The strace developers.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * The C library's definition of struct termios might differ from
32 * the kernel one, and we need to use the kernel layout.
34 #include <linux/termios.h>
36 #include "xlat/tcxonc_options.h"
37 #include "xlat/tcflsh_options.h"
38 #include "xlat/baud_options.h"
39 #include "xlat/modem_flags.h"
42 decode_termios(struct tcb *const tcp, const kernel_ulong_t addr)
48 if (umove_or_printaddr(tcp, addr, &tios))
52 printxval(baud_options, tios.c_cflag & CBAUD, "B???");
53 tprintf(" %sopost %sisig %sicanon %secho ...}",
54 (tios.c_oflag & OPOST) ? "" : "-",
55 (tios.c_lflag & ISIG) ? "" : "-",
56 (tios.c_lflag & ICANON) ? "" : "-",
57 (tios.c_lflag & ECHO) ? "" : "-");
60 tprintf("{c_iflags=%#lx, c_oflags=%#lx, ",
61 (long) tios.c_iflag, (long) tios.c_oflag);
62 tprintf("c_cflags=%#lx, c_lflags=%#lx, ",
63 (long) tios.c_cflag, (long) tios.c_lflag);
64 tprintf("c_line=%u, ", tios.c_line);
65 if (!(tios.c_lflag & ICANON))
66 tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ",
67 tios.c_cc[VMIN], tios.c_cc[VTIME]);
69 for (i = 0; i < NCCS; i++)
70 tprintf("\\x%02x", tios.c_cc[i]);
75 decode_termio(struct tcb *const tcp, const kernel_ulong_t addr)
81 if (umove_or_printaddr(tcp, addr, &tio))
85 printxval(baud_options, tio.c_cflag & CBAUD, "B???");
86 tprintf(" %sopost %sisig %sicanon %secho ...}",
87 (tio.c_oflag & OPOST) ? "" : "-",
88 (tio.c_lflag & ISIG) ? "" : "-",
89 (tio.c_lflag & ICANON) ? "" : "-",
90 (tio.c_lflag & ECHO) ? "" : "-");
93 tprintf("{c_iflags=%#lx, c_oflags=%#lx, ",
94 (long) tio.c_iflag, (long) tio.c_oflag);
95 tprintf("c_cflags=%#lx, c_lflags=%#lx, ",
96 (long) tio.c_cflag, (long) tio.c_lflag);
97 tprintf("c_line=%u, ", tio.c_line);
99 if (!(tio.c_lflag & ICANON))
100 tprintf("c_cc[_VMIN]=%d, c_cc[_VTIME]=%d, ",
101 tio.c_cc[_VMIN], tio.c_cc[_VTIME]);
103 if (!(tio.c_lflag & ICANON))
104 tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ",
105 tio.c_cc[VMIN], tio.c_cc[VTIME]);
108 for (i = 0; i < NCC; i++)
109 tprintf("\\x%02x", tio.c_cc[i]);
114 decode_winsize(struct tcb *const tcp, const kernel_ulong_t addr)
119 if (umove_or_printaddr(tcp, addr, &ws))
121 tprintf("{ws_row=%d, ws_col=%d, ws_xpixel=%d, ws_ypixel=%d}",
122 ws.ws_row, ws.ws_col, ws.ws_xpixel, ws.ws_ypixel);
127 decode_ttysize(struct tcb *const tcp, const kernel_ulong_t addr)
132 if (umove_or_printaddr(tcp, addr, &ts))
134 tprintf("{ts_lines=%d, ts_cols=%d}",
135 ts.ts_lines, ts.ts_cols);
140 decode_modem_flags(struct tcb *const tcp, const kernel_ulong_t addr)
145 if (umove_or_printaddr(tcp, addr, &i))
148 printflags(modem_flags, i, "TIOCM_???");
153 term_ioctl(struct tcb *const tcp, const unsigned int code,
154 const kernel_ulong_t arg)
178 decode_termios(tcp, arg);
188 decode_termio(tcp, arg);
196 decode_winsize(tcp, arg);
205 decode_ttysize(tcp, arg);
209 /* ioctls with a direct decodable arg */
212 printxval64(tcxonc_options, arg, "TC???");
216 printxval64(tcflsh_options, arg, "TC???");
221 tprintf(", %d", (int) arg);
224 /* ioctls with an indirect parameter displayed as modem flags */
231 decode_modem_flags(tcp, arg);
234 /* ioctls with an indirect parameter displayed in decimal */
258 printnum_int(tcp, arg, "%d");
261 /* ioctls with an indirect parameter displayed as a char */
264 printstrn(tcp, arg, 1);
267 /* ioctls with no parameters */
285 /* ioctls which are unknown */
291 return RVAL_DECODED | 1;