diff options
author | Dmitry V. Levin <ldv@strace.io> | 2022-11-13 08:00:00 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2022-11-13 08:00:00 +0000 |
commit | e56a444deed7b3c5186503e0c19ffe065a103412 (patch) | |
tree | fcdcc8a4ceeb0a8d857289df0e743a1c16ba9f0a | |
parent | 4d35972818c75df5cbea347fa14a447ec22d8ca4 (diff) | |
download | strace-e56a444deed7b3c5186503e0c19ffe065a103412.tar.gz |
term: modernize
* src/term.c: Do not include xlat/termio_cc.h unless _VMIN is defined.
Use macros from print_fields.h.
(decode_termios2, decode_termios): Do not print c_cc[VMIN]
and c_cc[VTIME] twice.
(decode_termio): Do not print c_cc[_VMIN] and c_cc[_VTIME] twice.
* tests/ioctl_termios.c: Update expected output.
* NEWS: Mention this change.
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/term.c | 203 | ||||
-rw-r--r-- | src/xlat/termios_cc.in | 4 | ||||
-rw-r--r-- | tests/ioctl_termios.c | 343 |
4 files changed, 266 insertions, 285 deletions
@@ -2,6 +2,7 @@ Noteworthy changes in release ?.? (????-??-??) ============================================== * Improvements + * Enhanced decoding of terminal ioctl commands. Noteworthy changes in release 6.0 (2022-10-29) ============================================== diff --git a/src/term.c b/src/term.c index 7b6dfe7a5..323395d56 100644 --- a/src/term.c +++ b/src/term.c @@ -32,9 +32,14 @@ #include "xlat/term_line_discs.h" -#include "xlat/termio_cc.h" #include "xlat/termios_cc.h" +#ifdef _VMIN /* thanks, alpha and powerpc */ +# include "xlat/termio_cc.h" +#else +# define termio_cc termios_cc +#endif + static void decode_oflag(uint64_t val) { @@ -51,11 +56,9 @@ decode_oflag(uint64_t val) { term_oflags_ffdly, FFDLY, "FF?" }, }; - unsigned i; - - for (i = 0; i < ARRAY_SIZE(xlats); i++) { + for (unsigned int i = 0; i < ARRAY_SIZE(xlats); i++) { printxval64(xlats[i].xl, val & xlats[i].mask, xlats[i].dfl); - tprints("|"); + tprint_or(); val &= ~xlats[i].mask; } @@ -67,13 +70,17 @@ static void decode_cflag(uint64_t val) { printxval64(baud_options, val & CBAUD, "B???"); - tprints("|"); + tprint_or(); + if (val & CIBAUD) { printxval64(baud_options, (val & CIBAUD) >> IBSHIFT, "B???"); - tprintf("<<IBSHIFT|"); + tprint_shift(); + print_xlat(IBSHIFT); + tprint_or(); } + printxval64(term_cflags_csize, val & CSIZE, "CS?"); - tprints("|"); + tprint_or(); val &= ~(CBAUD | CIBAUD | CSIZE); printflags64(term_cflags, val, NULL); @@ -82,52 +89,50 @@ decode_cflag(uint64_t val) static void decode_flags(uint64_t iflag, uint64_t oflag, uint64_t cflag, uint64_t lflag) { - tprints("c_iflag="); + tprints_field_name("c_iflag"); printflags64(term_iflags, iflag, NULL); - tprints(", c_oflag="); + + tprint_struct_next(); + tprints_field_name("c_oflag"); decode_oflag(oflag); - tprints(", c_cflag="); + + tprint_struct_next(); + tprints_field_name("c_cflag"); decode_cflag(cflag); - tprints(", c_lflag="); - printflags64(term_lflags, lflag, NULL); -} -static void -decode_line_disc(uint64_t line) -{ - tprints("c_line="); - printxval(term_line_discs, line, "N_???"); + tprint_struct_next(); + tprints_field_name("c_lflag"); + printflags64(term_lflags, lflag, NULL); } static void print_cc_char(bool *first, const unsigned char *data, const char *s, - unsigned idx) + unsigned int idx) { if (*first) *first = false; else - tprints(", "); + tprint_array_next(); + tprint_array_index_begin(); if (s) - tprintf("[%s] = ", s); + tprints(s); else - tprintf("[%u] = ", idx); + PRINT_VAL_U(idx); + tprint_array_index_end(); - tprintf("%#hhx", data[idx]); + PRINT_VAL_X(data[idx]); } static void decode_term_cc(const struct xlat *xl, const unsigned char *data, unsigned size) { - unsigned i = 0; + tprints_field_name("c_cc"); + tprint_array_begin(); bool first = true; - - tprints("["); - - for (i = 0; i < size; i++) + for (unsigned int i = 0; i < size; i++) print_cc_char(&first, data, xlookup(xl, i), i); - - tprints("]"); + tprint_array_end(); } #ifdef HAVE_STRUCT_TERMIOS2 @@ -135,31 +140,29 @@ static void decode_termios2(struct tcb *const tcp, const kernel_ulong_t addr) { struct termios2 tios; - - tprints(", "); if (umove_or_printaddr(tcp, addr, &tios)) return; - tprints("{"); + tprint_struct_begin(); decode_flags(tios.c_iflag, tios.c_oflag, tios.c_cflag, tios.c_lflag); - tprints(", "); + tprint_struct_next(); if (abbrev(tcp)) { - tprints("..."); + tprint_more_data_follows(); } else { - decode_line_disc(tios.c_line); + PRINT_FIELD_XVAL(tios, c_line, term_line_discs, "N_???"); - if (!(tios.c_lflag & ICANON)) - tprintf(", c_cc[VMIN]=%u, c_cc[VTIME]=%u", - tios.c_cc[VMIN], tios.c_cc[VTIME]); - tprints(", c_cc="); + tprint_struct_next(); /* SPARC has two additional bytes in c_cc. */ decode_term_cc(termios_cc, tios.c_cc, sizeof(tios.c_cc)); - tprintf(", c_ispeed=%u", tios.c_ispeed); - tprintf(", c_ospeed=%u", tios.c_ospeed); + tprint_struct_next(); + PRINT_FIELD_U(tios, c_ispeed); + + tprint_struct_next(); + PRINT_FIELD_U(tios, c_ospeed); } - tprints("}"); + tprint_struct_end(); } #endif /* HAVE_STRUCT_TERMIOS2 */ @@ -167,24 +170,19 @@ static void decode_termios(struct tcb *const tcp, const kernel_ulong_t addr) { struct termios tios; - - tprints(", "); if (umove_or_printaddr(tcp, addr, &tios)) return; - tprints("{"); + tprint_struct_begin(); decode_flags(tios.c_iflag, tios.c_oflag, tios.c_cflag, tios.c_lflag); - tprints(", "); + tprint_struct_next(); if (abbrev(tcp)) { - tprints("..."); + tprint_more_data_follows(); } else { - decode_line_disc(tios.c_line); + PRINT_FIELD_XVAL(tios, c_line, term_line_discs, "N_???"); - if (!(tios.c_lflag & ICANON)) - tprintf(", c_cc[VMIN]=%u, c_cc[VTIME]=%u", - tios.c_cc[VMIN], tios.c_cc[VTIME]); - tprints(", c_cc="); + tprint_struct_next(); /* * Fun fact: MIPS has NCCS defined to 23, SPARC to 17 and * everything else to 19. @@ -197,63 +195,60 @@ decode_termios(struct tcb *const tcp, const kernel_ulong_t addr) * having a separate struct termios2. */ #ifdef HAVE_STRUCT_TERMIOS_C_ISPEED - tprintf(", c_ispeed=%u", tios.c_ispeed); + tprint_struct_next(); + PRINT_FIELD_U(tios, c_ispeed); #endif #ifdef HAVE_STRUCT_TERMIOS_C_OSPEED - tprintf(", c_ospeed=%u", tios.c_ospeed); + tprint_struct_next(); + PRINT_FIELD_U(tios, c_ospeed); #endif } - tprints("}"); + tprint_struct_end(); } static void decode_termio(struct tcb *const tcp, const kernel_ulong_t addr) { struct termio tio; - - tprints(", "); if (umove_or_printaddr(tcp, addr, &tio)) return; - tprints("{"); + tprint_struct_begin(); decode_flags(tio.c_iflag, tio.c_oflag, tio.c_cflag, tio.c_lflag); - tprints(", "); + tprint_struct_next(); if (abbrev(tcp)) { - tprints("..."); + tprint_more_data_follows(); } else { - decode_line_disc(tio.c_line); + PRINT_FIELD_XVAL(tio, c_line, term_line_discs, "N_???"); -#ifdef _VMIN /* thanks, alpha and powerpc */ - if (!(tio.c_lflag & ICANON)) - tprintf(", c_cc[_VMIN]=%d, c_cc[_VTIME]=%d", - tio.c_cc[_VMIN], tio.c_cc[_VTIME]); - - tprints(", c_cc="); - decode_term_cc(termio_cc, tio.c_cc, sizeof(tio.c_cc)); -#else /* !_VMIN */ - if (!(tio.c_lflag & ICANON)) - tprintf(", c_cc[VMIN]=%d, c_cc[VTIME]=%d", - tio.c_cc[VMIN], tio.c_cc[VTIME]); - - tprints(", c_cc="); - decode_term_cc(termio_cc, tio.c_cc, sizeof(tio.c_cc)); -#endif /* !_VMIN */ + tprint_struct_next(); + decode_term_cc(termio_cc, tio.c_cc, + MIN(NCC, sizeof(tio.c_cc))); } - - tprints("}"); + tprint_struct_end(); } static void decode_winsize(struct tcb *const tcp, const kernel_ulong_t addr) { struct winsize ws; - - tprints(", "); if (umove_or_printaddr(tcp, addr, &ws)) return; - tprintf("{ws_row=%d, ws_col=%d, ws_xpixel=%d, ws_ypixel=%d}", - ws.ws_row, ws.ws_col, ws.ws_xpixel, ws.ws_ypixel); + + tprint_struct_begin(); + PRINT_FIELD_U(ws, ws_row); + + tprint_struct_next(); + PRINT_FIELD_U(ws, ws_col); + + tprint_struct_next(); + PRINT_FIELD_U(ws, ws_xpixel); + + tprint_struct_next(); + PRINT_FIELD_U(ws, ws_ypixel); + + tprint_struct_end(); } #ifdef TIOCGSIZE @@ -261,26 +256,27 @@ static void decode_ttysize(struct tcb *const tcp, const kernel_ulong_t addr) { struct ttysize ts; - - tprints(", "); if (umove_or_printaddr(tcp, addr, &ts)) return; - tprintf("{ts_lines=%d, ts_cols=%d}", - ts.ts_lines, ts.ts_cols); + + tprint_struct_begin(); + PRINT_FIELD_U(ts, ts_lines); + tprint_struct_next(); + PRINT_FIELD_U(ts, ts_cols); + tprint_struct_end(); } #endif static void decode_modem_flags(struct tcb *const tcp, const kernel_ulong_t addr) { - int i; - - tprints(", "); - if (umove_or_printaddr(tcp, addr, &i)) + unsigned int flags; + if (umove_or_printaddr(tcp, addr, &flags)) return; - tprints("["); - printflags(modem_flags, i, "TIOCM_???"); - tprints("]"); + + tprint_indirect_begin(); + printflags(modem_flags, flags, "TIOCM_???"); + tprint_indirect_end(); } int @@ -305,6 +301,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code, # ifdef TCSETSF2 case TCSETSF2: # endif + tprint_arg_next(); decode_termios2(tcp, arg); break; #endif /* HAVE_STRUCT_TERMIOS2 */ @@ -319,6 +316,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code, case TCSETSW: case TCSETSF: case TIOCSLCKTRMIOS: + tprint_arg_next(); decode_termios(tcp, arg); break; @@ -330,6 +328,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code, case TCSETA: case TCSETAW: case TCSETAF: + tprint_arg_next(); decode_termio(tcp, arg); break; @@ -339,6 +338,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code, return 0; ATTRIBUTE_FALLTHROUGH; case TIOCSWINSZ: + tprint_arg_next(); decode_winsize(tcp, arg); break; @@ -349,23 +349,25 @@ term_ioctl(struct tcb *const tcp, const unsigned int code, return 0; ATTRIBUTE_FALLTHROUGH; case TIOCSSIZE: + tprint_arg_next(); decode_ttysize(tcp, arg); break; #endif /* ioctls with a direct decodable arg */ case TCXONC: - tprints(", "); + tprint_arg_next(); printxval64(tcxonc_options, arg, "TC???"); break; case TCFLSH: - tprints(", "); + tprint_arg_next(); printxval64(tcflsh_options, arg, "TC???"); break; case TCSBRK: case TCSBRKP: case TIOCSCTTY: - tprintf(", %d", (int) arg); + tprint_arg_next(); + PRINT_VAL_D((int) arg); break; /* ioctls with an indirect parameter displayed as modem flags */ @@ -376,6 +378,7 @@ term_ioctl(struct tcb *const tcp, const unsigned int code, case TIOCMBIS: case TIOCMBIC: case TIOCMSET: + tprint_arg_next(); decode_modem_flags(tcp, arg); break; @@ -403,13 +406,13 @@ term_ioctl(struct tcb *const tcp, const unsigned int code, case TIOCPKT: case TIOCSSOFTCAR: case TIOCSPTLCK: - tprints(", "); + tprint_arg_next(); printnum_int(tcp, arg, "%d"); break; /* ioctls with an indirect parameter displayed as a char */ case TIOCSTI: - tprints(", "); + tprint_arg_next(); printstrn(tcp, arg, 1); break; diff --git a/src/xlat/termios_cc.in b/src/xlat/termios_cc.in index fba9d9836..7f4e7f75f 100644 --- a/src/xlat/termios_cc.in +++ b/src/xlat/termios_cc.in @@ -12,7 +12,7 @@ VREPRINT /* Reprint-line character [ICANON]. */ VDISCARD /* Discard character [IEXTEN]. */ VWERASE /* Word-erase character [ICANON]. */ VLNEXT /* Literal-next character [IEXTEN]. */ -VEOF /* End-of-file character [ICANON]. */ -VEOL /* End-of-line character [ICANON]. */ VMIN /* Minimum number of bytes read at once [!ICANON]. */ VTIME /* Time-out value (tenths of a second) [!ICANON]. */ +VEOF /* End-of-file character [ICANON]. */ +VEOL /* End-of-line character [ICANON]. */ diff --git a/tests/ioctl_termios.c b/tests/ioctl_termios.c index 847842238..412ae5b4c 100644 --- a/tests/ioctl_termios.c +++ b/tests/ioctl_termios.c @@ -234,7 +234,7 @@ static void print_termios_cc(const cc_t *ccs, size_t size, bool tios) { static const char * const cc_tio_names[] = { -#if defined __alpha__ || defined __powerpc__ || defined __powerpc64__ +# if defined __alpha__ || defined __powerpc__ || defined __powerpc64__ cc_def_(_VMIN), cc_def_(_VTIME), cc_def_(_VINTR), @@ -245,7 +245,7 @@ print_termios_cc(const cc_t *ccs, size_t size, bool tios) cc_def_(_VEOL), cc_def_(_VEOL2), cc_def_(_VSWTC), -#endif +# endif }; static const char * const cc_tios_names[] = { @@ -265,13 +265,13 @@ print_termios_cc(const cc_t *ccs, size_t size, bool tios) cc_def_(VDISCARD), cc_def_(VWERASE), cc_def_(VLNEXT), -#ifndef __sparc__ /* on sparc VMIN == VEOF and VTIME == VEOL */ +# ifndef __sparc__ /* on sparc VMIN == VEOF and VTIME == VEOL */ cc_def_(VEOF), cc_def_(VEOL), -#endif -#ifdef VDSUSP +# endif +# ifdef VDSUSP cc_def_(VDSUSP), -#endif +# endif }; printf("c_cc=["); @@ -279,18 +279,18 @@ print_termios_cc(const cc_t *ccs, size_t size, bool tios) for (size_t i = 0; i < size; i++) { bool has_name = tios ? (i < ARRAY_SIZE(cc_tios_names)) && cc_tios_names[i] : -#if defined __alpha__ || defined __powerpc__ || defined __powerpc64__ +# if defined __alpha__ || defined __powerpc__ || defined __powerpc64__ (i < ARRAY_SIZE(cc_tio_names)) && cc_tio_names[i]; -#else +# else false; -#endif +# endif const char *name = has_name ? (tios ? cc_tios_names : cc_tio_names)[i] : ""; if (has_name) - printf("%s[%s] = %#hhx", i ? ", " : "", name, ccs[i]); + printf("%s[%s]=%#hhx", i ? ", " : "", name, ccs[i]); else - printf("%s[%zu] = %#hhx", i ? ", " : "", i, ccs[i]); + printf("%s[%zu]=%#hhx", i ? ", " : "", i, ccs[i]); } printf("]"); @@ -307,21 +307,18 @@ print_termios2(void *tios_ptr) print_flags(tios->c_iflag, tios->c_oflag, tios->c_cflag, tios->c_lflag); printf(", "); -#if VERBOSE +# if VERBOSE printf("c_line="); - printxval(term_line_discs, tios->c_line, "N_???"); + printxval(term_line_discs, zero_extend_signed_to_ull(tios->c_line), + "N_???"); printf(", "); - if (!(tios->c_lflag & ICANON)) - printf("c_cc[VMIN]=%hhu, c_cc[VTIME]=%u, ", - tios->c_cc[VMIN], tios->c_cc[VTIME]); - print_termios_cc(tios->c_cc, sizeof(tios->c_cc), true); printf(", c_ispeed=%u, c_ospeed=%u", tios->c_ispeed, tios->c_ospeed); -#else /* !VERBOSE */ +# else /* !VERBOSE */ printf("..."); -#endif /* VERBOSE */ +# endif /* VERBOSE */ printf("}"); } @@ -338,13 +335,10 @@ print_termios(void *tios_ptr) #if VERBOSE printf("c_line="); - printxval(term_line_discs, tios->c_line, "N_???"); + printxval(term_line_discs, zero_extend_signed_to_ull(tios->c_line), + "N_???"); printf(", "); - if (!(tios->c_lflag & ICANON)) - printf("c_cc[VMIN]=%hhu, c_cc[VTIME]=%u, ", - tios->c_cc[VMIN], tios->c_cc[VTIME]); - print_termios_cc(tios->c_cc, sizeof(tios->c_cc), true); # ifdef HAVE_STRUCT_TERMIOS_C_ISPEED @@ -368,12 +362,8 @@ print_termio(void *tios_ptr) #if VERBOSE # if defined __alpha__ || defined __powerpc__ || defined __powerpc64__ const bool alpha = true; - const unsigned vmin = _VMIN; - const unsigned vtime = _VTIME; # else const bool alpha = false; - const unsigned vmin = VMIN; - const unsigned vtime = VTIME; # endif #endif /* VERBOSE */ @@ -384,15 +374,11 @@ print_termio(void *tios_ptr) #if VERBOSE printf("c_line="); - printxval(term_line_discs, tios->c_line, "N_???"); + printxval(term_line_discs, zero_extend_signed_to_ull(tios->c_line), + "N_???"); printf(", "); - if (!(tios->c_lflag & ICANON)) - printf("c_cc[%sVMIN]=%hhu, c_cc[%sVTIME]=%u, ", - alpha ? "_" : "", tios->c_cc[vmin], - alpha ? "_" : "", tios->c_cc[vtime]); - - print_termios_cc(tios->c_cc, sizeof(tios->c_cc), !alpha); + print_termios_cc(tios->c_cc, MIN(NCC, sizeof(tios->c_cc)), !alpha); #else /* !VERBOSE */ printf("..."); #endif /* VERBOSE */ @@ -463,37 +449,37 @@ setup_termios2(void *tios_ptr, int variant) tios->c_iflag = IGNBRK|IUTF8|0xdead0000; tios->c_oflag = NL0|CR2|XTABS|BS0|VT1|FF0|OPOST|ONLCR|OFILL| -#ifdef PAGEOUT +# ifdef PAGEOUT PAGEOUT| -#endif +# endif 0xbad00000; tios->c_cflag = B75 -#if defined IBSHIFT && defined CIBAUD +# if defined IBSHIFT && defined CIBAUD |(B57600<<IBSHIFT) -#endif +# endif |CS6|CSTOPB| -#ifdef CTVB +# ifdef CTVB CTVB| -#endif -#ifdef CMSPAR +# endif +# ifdef CMSPAR CMSPAR| -#endif +# endif 0; tios->c_lflag = ISIG|ECHOE|FLUSHO| -#ifdef DEFECHO +# ifdef DEFECHO DEFECHO| -#endif -#if defined __alpha__ || defined __powerpc__ || defined __powerpc64__ || defined __sparc__ +# endif +# if defined __alpha__ || defined __powerpc__ || defined __powerpc64__ || defined __sparc__ 0xf0f0000 -#else +# else 0xfee00000 -#endif +# endif ; tios->c_line = N_IRDA; - tios->c_cc[VTIME] = 160; - tios->c_cc[VMIN] = 137; + tios->c_cc[VTIME] = 0xa0; + tios->c_cc[VMIN] = 0x89; tios->c_cc[VLNEXT] = 0xff; tios->c_cc[VSWTC] = 0x2a; @@ -502,88 +488,86 @@ setup_termios2(void *tios_ptr, int variant) return "{c_iflag=IGNBRK|IUTF8|0xdead0000, " "c_oflag=NL0|CR2|" -#ifdef __alpha__ -# if TAB3 == XTABS +# ifdef __alpha__ +# if TAB3 == XTABS "TAB3" -# else +# else "TAB0" -# endif -#else /* !__alpha__ */ +# endif +# else /* !__alpha__ */ "XTABS" -#endif +# endif "|BS0|VT1|FF0|OPOST|ONLCR|OFILL|" -#ifdef PAGEOUT +# ifdef PAGEOUT "PAGEOUT|" -#endif -#if defined __alpha__ && XTABS != TAB3 +# endif +# if defined __alpha__ && XTABS != TAB3 "0xbad40000, " -#else +# else "0xbad00000, " -#endif +# endif "c_cflag=B75" -#if defined IBSHIFT && defined CIBAUD +# if defined IBSHIFT && defined CIBAUD "|B57600<<IBSHIFT" -#endif +# endif "|CS6|CSTOPB" -#ifdef CTVB +# ifdef CTVB "|CTVB" -#endif -#ifdef CMSPAR +# endif +# ifdef CMSPAR "|CMSPAR" -#endif +# endif ", " "c_lflag=ISIG|ECHOE|FLUSHO|" -#ifdef __sparc__ +# ifdef __sparc__ "EXTPROC|" -#endif -#ifdef DEFECHO +# endif +# ifdef DEFECHO "DEFECHO|" -#endif -#if defined __alpha__ || defined __powerpc__ || defined __powerpc64__ +# endif +# if defined __alpha__ || defined __powerpc__ || defined __powerpc64__ "0xf0f0000, " -#elif defined __sparc__ +# elif defined __sparc__ "0xf0e0000, " -#else +# else "0xfee00000, " -#endif -#if VERBOSE +# endif +# if VERBOSE "c_line=N_IRDA, " - "c_cc[VMIN]=137, " - "c_cc[VTIME]=160, " -# if defined __alpha__ - "c_cc=[[VEOF] = 0, [VEOL] = 0, [VEOL2] = 0, " - "[VERASE] = 0, [VWERASE] = 0, [VKILL] = 0, " - "[VREPRINT] = 0x89, [VSWTC] = 0x2a, [VINTR] = 0, " - "[VQUIT] = 0, [VSUSP] = 0, [11] = 0, [VSTART] = 0, " - "[VSTOP] = 0, [VLNEXT] = 0xff, [VDISCARD] = 0, " - "[VMIN] = 0x89, [VTIME] = 0xa0, [18] = 0]" -# elif defined __mips__ - "c_cc=[[VINTR] = 0, [VQUIT] = 0, [VERASE] = 0, " - "[VKILL] = 0, [VMIN] = 0, [VTIME] = 0xa0, " - "[VEOL2] = 0x89, [VSWTC] = 0x2a, [VSTART] = 0, " - "[VSTOP] = 0, [VSUSP] = 0, [VDSUSP] = 0, " - "[VREPRINT] = 0, [VDISCARD] = 0, [VWERASE] = 0, " - "[VLNEXT] = 0xff, [VEOF = 0, [VEOL] = 0, [18] = 0, " - "[19] = 0, [20] = 0, [21] = 0, [22] = 0]" -# elif defined __sparc__ - "c_cc=[[VINTR] = 0, [VQUIT] = 0, [VERASE] = 0, " - "[VKILL] = 0, [VEOF] = 0x89, [VEOL] = 0xa0, " - "[VEOL2] = 0, [VSWTC] = 0x2a, [VSTART] = 0, " - "[VSTOP] = 0, [VSUSP] = 0, [VDSUSP] = 0, " - "[VREPRINT] = 0, [VDISCARD] = 0, [VWERASE] = 0, " - "[VLNEXT] = 0xff, [16] = 0, [17] = 0, [18] = 0]" -# else - "c_cc=[[VINTR] = 0, [VQUIT] = 0, [VERASE] = 0, " - "[VKILL] = 0, [VEOF] = 0, [VTIME] = 0xa0, " - "[VMIN] = 0x89, [VSWTC] = 0x2a, [VSTART] = 0, " - "[VSTOP] = 0, [VSUSP] = 0, [VEOL] = 0, [VREPRINT] = 0, " - "[VDISCARD] = 0, [VWERASE] = 0, [VLNEXT] = 0xff, " - "[VEOL2] = 0, [17] = 0, [18] = 0]" -#endif +# if defined __alpha__ + "c_cc=[[VEOF]=0, [VEOL]=0, [VEOL2]=0, " + "[VERASE]=0, [VWERASE]=0, [VKILL]=0, " + "[VREPRINT]=0x89, [VSWTC]=0x2a, [VINTR]=0, " + "[VQUIT]=0, [VSUSP]=0, [11]=0, [VSTART]=0, " + "[VSTOP]=0, [VLNEXT]=0xff, [VDISCARD]=0, " + "[VMIN]=0x89, [VTIME]=0xa0, [18]=0]" +# elif defined __mips__ + "c_cc=[[VINTR]=0, [VQUIT]=0, [VERASE]=0, " + "[VKILL]=0, [VMIN]=0x89, [VTIME]=0xa0, " + "[VEOL2]=0, [VSWTC]=0x2a, [VSTART]=0, " + "[VSTOP]=0, [VSUSP]=0, [11]=0, " + "[VREPRINT]=0, [VDISCARD]=0, [VWERASE]=0, " + "[VLNEXT]=0xff, [VEOF]=0, [VEOL]=0, [18]=0, " + "[19]=0, [20]=0, [21]=0, [22]=0]" +# elif defined __sparc__ + "c_cc=[[VINTR]=0, [VQUIT]=0, [VERASE]=0, " + "[VKILL]=0, [VMIN]=0x89, [VTIME]=0xa0, " + "[VEOL2]=0, [VSWTC]=0x2a, [VSTART]=0, " + "[VSTOP]=0, [VSUSP]=0, [VDSUSP]=0, " + "[VREPRINT]=0, [VDISCARD]=0, [VWERASE]=0, " + "[VLNEXT]=0xff, [16]=0, [17]=0, [18]=0]" +# else + "c_cc=[[VINTR]=0, [VQUIT]=0, [VERASE]=0, " + "[VKILL]=0, [VEOF]=0, [VTIME]=0xa0, " + "[VMIN]=0x89, [VSWTC]=0x2a, [VSTART]=0, " + "[VSTOP]=0, [VSUSP]=0, [VEOL]=0, [VREPRINT]=0, " + "[VDISCARD]=0, [VWERASE]=0, [VLNEXT]=0xff, " + "[VEOL2]=0, [17]=0, [18]=0]" +# endif ", c_ispeed=3141592653, c_ospeed=2718281828" -#else /* !VERBOSE */ +# else /* !VERBOSE */ "..." -#endif /* VERBOSE */ +# endif /* VERBOSE */ "}"; } @@ -639,17 +623,17 @@ setup_termios(void *tios_ptr, int variant) tios->c_line = N_AX25; - tios->c_cc[VTIME] = 160; - tios->c_cc[VMIN] = 137; + tios->c_cc[VTIME] = 0xa0; + tios->c_cc[VMIN] = 0x89; tios->c_cc[VLNEXT] = 0xff; tios->c_cc[VSWTC] = 0x2a; -# ifdef HAVE_STRUCT_TERMIOS_C_ISPEED +#ifdef HAVE_STRUCT_TERMIOS_C_ISPEED tios->c_ispeed = 3141592653U; -# endif -# ifdef HAVE_STRUCT_TERMIOS_C_OSPEED +#endif +#ifdef HAVE_STRUCT_TERMIOS_C_OSPEED tios->c_ospeed = 2718281828U; -# endif +#endif return "{c_iflag=IGNBRK|IUTF8|0xdead0000, " "c_oflag=NL0|CR2|" @@ -699,45 +683,43 @@ setup_termios(void *tios_ptr, int variant) #endif #if VERBOSE "c_line=N_AX25, " - "c_cc[VMIN]=137, " - "c_cc[VTIME]=160, " # if defined __alpha__ - "c_cc=[[VEOF] = 0, [VEOL] = 0, [VEOL2] = 0, " - "[VERASE] = 0, [VWERASE] = 0, [VKILL] = 0, " - "[VREPRINT] = 0x89, [VSWTC] = 0x2a, [VINTR] = 0, " - "[VQUIT] = 0, [VSUSP] = 0, [11] = 0, [VSTART] = 0, " - "[VSTOP] = 0, [VLNEXT] = 0xff, [VDISCARD] = 0, " - "[VMIN] = 0x89, [VTIME] = 0xa0, [18] = 0]" + "c_cc=[[VEOF]=0, [VEOL]=0, [VEOL2]=0, " + "[VERASE]=0, [VWERASE]=0, [VKILL]=0, " + "[VREPRINT]=0x89, [VSWTC]=0x2a, [VINTR]=0, " + "[VQUIT]=0, [VSUSP]=0, [11]=0, [VSTART]=0, " + "[VSTOP]=0, [VLNEXT]=0xff, [VDISCARD]=0, " + "[VMIN]=0x89, [VTIME]=0xa0, [18]=0]" # elif defined __mips__ - "c_cc=[[VINTR] = 0, [VQUIT] = 0, [VERASE] = 0, " - "[VKILL] = 0, [VMIN] = 0, [VTIME] = 0xa0, " - "[VEOL2] = 0x89, [VSWTC] = 0x2a, [VSTART] = 0, " - "[VSTOP] = 0, [VSUSP] = 0, [VDSUSP] = 0, " - "[VREPRINT] = 0, [VDISCARD] = 0, [VWERASE] = 0, " - "[VLNEXT] = 0xff, [VEOF] = 0, [VEOL] = 0, [18] = 0, " - "[19] = 0, [20] = 0, [21] = 0, [22] = 0]" + "c_cc=[[VINTR]=0, [VQUIT]=0, [VERASE]=0, " + "[VKILL]=0, [VMIN]=0x89, [VTIME]=0xa0, " + "[VEOL2]=0, [VSWTC]=0x2a, [VSTART]=0, " + "[VSTOP]=0, [VSUSP]=0, [11]=0, " + "[VREPRINT]=0, [VDISCARD]=0, [VWERASE]=0, " + "[VLNEXT]=0xff, [VEOF]=0, [VEOL]=0, [18]=0, " + "[19]=0, [20]=0, [21]=0, [22]=0]" # elif defined __powerpc__ || defined __powerpc64__ - "c_cc=[[VINTR] = 0, [VQUIT] = 0, [VERASE] = 0, " - "[VKILL] = 0, [VEOF] = 0, [VMIN] = 0x89, " - "[VEOL] = 0, [VTIME] = 0xa0, [VEOL2] = 0, " - "[VSWTC] = 0x2a, [VWERASE] = 0, [VREPRINT] = 0, " - "[VSUSP] = 0, [VSTART] = 0, [VSTOP] = 0, " - "[VLNEXT] = 0xff, [VDISCARD] = 0, [17] = 0, [18] = 0]" + "c_cc=[[VINTR]=0, [VQUIT]=0, [VERASE]=0, " + "[VKILL]=0, [VEOF]=0, [VMIN]=0x89, " + "[VEOL]=0, [VTIME]=0xa0, [VEOL2]=0, " + "[VSWTC]=0x2a, [VWERASE]=0, [VREPRINT]=0, " + "[VSUSP]=0, [VSTART]=0, [VSTOP]=0, " + "[VLNEXT]=0xff, [VDISCARD]=0, [17]=0, [18]=0]" # elif defined __sparc__ - "c_cc=[[VINTR] = 0, [VQUIT] = 0, [VERASE] = 0, " - "[VKILL] = 0, [VEOF] = 0x89, [VEOL] = 0xa0, " - "[VEOL2] = 0, [VSWTC] = 0x2a, [VSTART] = 0, " - "[VSTOP] = 0, [VSUSP] = 0, [VDSUSP] = 0, " - "[VREPRINT] = 0, [VDISCARD] = 0, [VWERASE] = 0, " - "[VLNEXT] = 0xff, [16] = 0]" + "c_cc=[[VINTR]=0, [VQUIT]=0, [VERASE]=0, " + "[VKILL]=0, [VMIN]=0x89, [VTIME]=0xa0, " + "[VEOL2]=0, [VSWTC]=0x2a, [VSTART]=0, " + "[VSTOP]=0, [VSUSP]=0, [VDSUSP]=0, " + "[VREPRINT]=0, [VDISCARD]=0, [VWERASE]=0, " + "[VLNEXT]=0xff, [16]=0]" # else - "c_cc=[[VINTR] = 0, [VQUIT] = 0, [VERASE] = 0, " - "[VKILL] = 0, [VEOF] = 0, [VTIME] = 0xa0, " - "[VMIN] = 0x89, [VSWTC] = 0x2a, [VSTART] = 0, " - "[VSTOP] = 0, [VSUSP] = 0, [VEOL] = 0, [VREPRINT] = 0, " - "[VDISCARD] = 0, [VWERASE] = 0, [VLNEXT] = 0xff, " - "[VEOL2] = 0, [17] = 0, [18] = 0]" -#endif + "c_cc=[[VINTR]=0, [VQUIT]=0, [VERASE]=0, " + "[VKILL]=0, [VEOF]=0, [VTIME]=0xa0, " + "[VMIN]=0x89, [VSWTC]=0x2a, [VSTART]=0, " + "[VSTOP]=0, [VSUSP]=0, [VEOL]=0, [VREPRINT]=0, " + "[VDISCARD]=0, [VWERASE]=0, [VLNEXT]=0xff, " + "[VEOL2]=0, [17]=0, [18]=0]" +# endif # ifdef HAVE_STRUCT_TERMIOS_C_ISPEED ", c_ispeed=3141592653" # endif @@ -787,12 +769,12 @@ setup_termio(void *tios_ptr, int variant) tios->c_line = 234; #if defined __alpha__ || defined __powerpc__ || defined __powerpc64__ - tios->c_cc[_VTIME] = 160; - tios->c_cc[_VMIN] = 137; + tios->c_cc[_VTIME] = 0xa0; + tios->c_cc[_VMIN] = 0x89; tios->c_cc[_VSWTC] = 0x2a; #else - tios->c_cc[VTIME] = 160; - tios->c_cc[VMIN] = 137; + tios->c_cc[VTIME] = 0xa0; + tios->c_cc[VMIN] = 0x89; tios->c_cc[VSWTC] = 0x2a; #endif @@ -831,37 +813,27 @@ setup_termio(void *tios_ptr, int variant) #if VERBOSE "c_line=0xea /* N_??? */, " # if defined __alpha__ - "c_cc[_VMIN]=137, " - "c_cc[_VTIME]=160, " - "c_cc=[[_VEOF] = 0, [_VEOL] = 0, [_VEOL2] = 0, " - "[_VERASE] = 0, [_VWERASE] = 0, [_VKILL] = 0, " - "[_VREPRINT] = 0x89, [_VSWTC] = 0x2a]" + "c_cc=[[_VEOF]=0, [_VEOL]=0, [_VEOL2]=0, " + "[_VERASE]=0, [_VWERASE]=0, [_VKILL]=0, " + "[_VREPRINT]=0x89, [_VSWTC]=0x2a]" # elif defined __mips__ - "c_cc[VMIN]=137, " - "c_cc[VTIME]=160, " - "c_cc=[[VINTR] = 0, [VQUIT] = 0, [VERASE] = 0, " - "[VKILL] = 0, [VMIN] = 0, [VTIME] = 0xa0, " - "[VEOL2] = 0x89, [VSWTC] = 0x2a]" + "c_cc=[[VINTR]=0, [VQUIT]=0, [VERASE]=0, " + "[VKILL]=0, [VMIN]=0x89, [VTIME]=0xa0, " + "[VEOL2]=0, [VSWTC]=0x2a]" # elif defined __powerpc__ || defined __powerpc64__ - "c_cc[_VMIN]=137, " - "c_cc[_VTIME]=160, " - "c_cc=[[_VINTR] = 0, [_VQUIT] = 0, [_VERASE] = 0, " - "[_VKILL] = 0, [_VEOF] = 0, [_VMIN] = 0x89, " - "[_VEOL] = 0, [_VTIME] = 0xa0, [_VEOL2] = 0, " - "[_VSWTC] = 0x2a]" + "c_cc=[[_VINTR]=0, [_VQUIT]=0, [_VERASE]=0, " + "[_VKILL]=0, [_VEOF]=0, [_VMIN]=0x89, " + "[_VEOL]=0, [_VTIME]=0xa0, [_VEOL2]=0, " + "[_VSWTC]=0x2a]" # elif defined __sparc__ - "c_cc[VMIN]=137, " - "c_cc[VTIME]=160, " - "c_cc=[[VINTR] = 0, [VQUIT] = 0, [VERASE] = 0, " - "[VKILL] = 0, [VEOF] = 0x89, [VEOL] = 0xa0, " - "[VEOL2] = 0, [VSWTC] = 0x2a]" + "c_cc=[[VINTR]=0, [VQUIT]=0, [VERASE]=0, " + "[VKILL]=0, [VMIN]=0x89, [VTIME]=0xa0, " + "[VEOL2]=0, [VSWTC]=0x2a]" # else - "c_cc[VMIN]=137, " - "c_cc[VTIME]=160, " - "c_cc=[[VINTR] = 0, [VQUIT] = 0, [VERASE] = 0, " - "[VKILL] = 0, [VEOF] = 0, [VTIME] = 0xa0, " - "[VMIN] = 0x89, [VSWTC] = 0x2a]" -#endif + "c_cc=[[VINTR]=0, [VQUIT]=0, [VERASE]=0, " + "[VKILL]=0, [VEOF]=0, [VTIME]=0xa0, " + "[VMIN]=0x89, [VSWTC]=0x2a]" +# endif #else /* !VERBOSE */ "..." #endif @@ -963,9 +935,14 @@ main(void) }, }; - ret = syscall(__NR_openat, -100, "/dev/ptmx", O_RDWR|O_NOCTTY); + static const char ptmx[] = "/dev/ptmx"; + /* + * The libc function is not available because <linux/fcntl.h> + * is included instead of <fcntl.h>. + */ + ret = syscall(__NR_openat, -100, ptmx, O_RDWR|O_NOCTTY); if (ret < 0) - perror_msg_and_skip("open(\"/dev/ptmx\")"); + perror_msg_and_skip("open: %s", ptmx); for (size_t i = 0; i < ARRAY_SIZE(checks); i++) { const char *last_arg_str = NULL; |