From af7e34d5cb7547f2c377442a096254dbda0d6809 Mon Sep 17 00:00:00 2001 From: Jung-uk Kim Date: Mon, 5 Dec 2016 21:23:44 +0000 Subject: [PATCH 001/226] Import byacc 20161202. --- CHANGES | 387 +++++++++++------ MANIFEST | 2 +- VERSION | 2 +- aclocal.m4 | 53 ++- btyaccpar.c | 37 +- btyaccpar.skel | 31 +- config.guess | 119 +++--- config.sub | 28 +- configure | 678 ++++++++++++++++-------------- defs.h | 39 +- error.c | 44 +- main.c | 4 +- mstring.c | 16 +- output.c | 98 +++-- package/byacc.spec | 4 +- package/debian/changelog | 6 + package/mingw-byacc.spec | 4 +- package/pkgsrc/Makefile | 2 +- reader.c | 234 ++++++----- test/btyacc/btyacc_calc1.tab.c | 30 +- test/btyacc/btyacc_demo.tab.c | 148 +++---- test/btyacc/btyacc_demo.tab.h | 14 + test/btyacc/btyacc_destroy1.tab.c | 32 +- test/btyacc/btyacc_destroy2.tab.c | 32 +- test/btyacc/btyacc_destroy3.tab.c | 32 +- test/btyacc/calc.tab.c | 30 +- test/btyacc/calc1.tab.c | 30 +- test/btyacc/calc2.tab.c | 30 +- test/btyacc/calc3.tab.c | 30 +- test/btyacc/code_calc.code.c | 24 +- test/btyacc/code_calc.tab.c | 2 + test/btyacc/code_error.code.c | 24 +- test/btyacc/code_error.tab.c | 2 + test/btyacc/empty.tab.c | 28 +- test/btyacc/err_inherit3.tab.c | 36 +- test/btyacc/err_inherit4.tab.c | 42 +- test/btyacc/err_inherit4.tab.h | 14 + test/btyacc/err_syntax10.tab.c | 28 +- test/btyacc/err_syntax11.tab.c | 28 +- test/btyacc/err_syntax12.tab.c | 28 +- test/btyacc/err_syntax18.tab.c | 30 +- test/btyacc/err_syntax20.tab.c | 30 +- test/btyacc/error.tab.c | 28 +- test/btyacc/grammar.tab.c | 30 +- test/btyacc/inherit0.tab.c | 30 +- test/btyacc/inherit1.tab.c | 30 +- test/btyacc/inherit2.tab.c | 36 +- test/btyacc/ok_syntax1.tab.c | 30 +- test/btyacc/pure_calc.tab.c | 30 +- test/btyacc/pure_error.tab.c | 28 +- test/btyacc/quote_calc-s.tab.c | 30 +- test/btyacc/quote_calc.tab.c | 30 +- test/btyacc/quote_calc2-s.tab.c | 30 +- test/btyacc/quote_calc2.tab.c | 30 +- test/btyacc/quote_calc3-s.tab.c | 30 +- test/btyacc/quote_calc3.tab.c | 30 +- test/btyacc/quote_calc4-s.tab.c | 30 +- test/btyacc/quote_calc4.tab.c | 30 +- test/btyacc/rename_debug.c | 28 +- test/btyacc/varsyntax_calc1.tab.c | 30 +- yaccpar.c | 7 +- yaccpar.skel | 3 +- 62 files changed, 1745 insertions(+), 1317 deletions(-) diff --git a/CHANGES b/CHANGES index 67abb971e2b..cef17ead3c9 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,123 @@ -2016-06-06 Thomas E. Dickey +2016-12-02 Thomas E. Dickey + + * test/btyacc/quote_calc4-s.tab.c, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/error.tab.c, test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.tab.c, test/btyacc/ok_syntax1.tab.c, test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/calc.tab.c, test/btyacc/calc1.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/code_calc.code.c, test/btyacc/code_error.code.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/rename_debug.c, test/btyacc/btyacc_calc1.tab.c, test/btyacc/btyacc_demo.tab.c, test/btyacc/btyacc_destroy1.tab.c, test/btyacc/btyacc_destroy2.tab.c, test/btyacc/btyacc_destroy3.tab.c, btyaccpar.c: + regen + + * btyaccpar.skel: changes from NetBSD + + use YYINT rather than short in btyaccpar.skel + (some of this had already been done by Tom Shields) + + remove some casts of malloc/realloc + + * yaccpar.c, yaccpar.skel, output.c: changes from NetBSD + - Add some more bison stuff to make the mesa/gallium parser work: + %initial-action (add missing source struct member in location) + %debug (unimplemented) + %error-verbose (unimplemented) + + This changes some existing code: + + yylloc is now a pointer, so + + the first parameter to YYERROR_DECL() is a pointer + + struct YYLTYPE now has a "source" field + + * test/btyacc/btyacc_demo.tab.h, test/btyacc/code_calc.tab.c, test/btyacc/code_error.tab.c, test/btyacc/err_inherit4.tab.h: + regen + + * btyaccpar.c, btyaccpar.skel, reader.c: changes from NetBSD + - Add some more bison stuff to make the mesa/gallium parser work: + %initial-action (add missing source struct member in location) + %debug (unimplemented) + %error-verbose (unimplemented) + + This changes some existing code: + + yylloc is now a pointer, so + + the first parameter to YYERROR_DECL() is a pointer + + struct YYLTYPE now has a "source" field + + * reader.c: + fix from NetBSD: correct off-by-one when adding a null in copy_param() + + * reader.c: adapted from NetBSD + - Convert *most* error fingerprints to: + -unterminated_arglist(int a_lineno, char *a_line, char *a_cptr) + +unterminated_arglist(const struct ainfo *a) + - Cast new args to unsigned char + + * defs.h: changes from NetBSD + - Add some more bison stuff to make the mesa/gallium parser work: + %initial-action (add missing source struct member in location) + %debug (unimplemented) + %error-verbose (unimplemented) + + This changes some existing code: + + yylloc is now a pointer, so + + the first parameter to YYERROR_DECL() is a pointer + + struct YYLTYPE now has a "source" field + + * defs.h: adapted from NetBSD + - Convert *most* error fingerprints to: + -unterminated_arglist(int a_lineno, char *a_line, char *a_cptr) + +unterminated_arglist(const struct ainfo *a) + - Cast new args to unsigned char + + * main.c: changes from NetBSD + - Add some more bison stuff to make the mesa/gallium parser work: + %initial-action (add missing source struct member in location) + %debug (unimplemented) + %error-verbose (unimplemented) + + This changes some existing code: + + yylloc is now a pointer, so + + the first parameter to YYERROR_DECL() is a pointer + + struct YYLTYPE now has a "source" field + + * error.c: adapted from NetBSD + - Convert *most* error fingerprints to: + -unterminated_arglist(int a_lineno, char *a_line, char *a_cptr) + +unterminated_arglist(const struct ainfo *a) + - Cast new args to unsigned char + + * mstring.c: adapted change from NetBSD to add casts for ctype macros + + * test/btyacc/btyacc_demo.tab.h, test/btyacc/err_inherit4.tab.h: regen + + * output.c: reorder to eliminate a forward-reference + +2016-12-02 Tom.Shields + + * output.c: + modify output to enable compilation of a lexer generated by flex (using + "%option bison-bridge" and "%option bison-locations") to be used with a parser + generated by b(t)yacc (using directives "%locations" and "%pure-parser"). + +2016-12-02 Thomas E. Dickey + + * configure: regen + + * aclocal.m4: Improved autoconf macros + CF_CC_ENV_FLAGS + + improve split between compiler and options, prompted by report where user + had "ccache" before the compiler + + leave non-preprocessor options in "$CC" (but still copy them to "$CFLAGS" + since that's where they should be) + CF_GNU_SOURCE,v + + recent glibc (Debian 2.23-4 for example) has misordered ifdef/checks for new + symbol _DEFAULT_SOURCE, producing warning messages when only _GNU_SOURCE is + defined. Add a followup check to define _DEFAULT_SOURCE. + CF_XOPEN_SOURCE + + add "uclinux" to list of Linux's (patch by Yann E. Morin) + + use _GNU_SOURCE for cygwin headers + + build-fixes for OS/2 + + * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: + bump + +2016-11-20 Thomas E. Dickey + + * config.sub: 2016-11-19 + + * config.guess: 2016-10-02 + +2016-06-06 Thomas E. Dickey * configure: regen @@ -32,7 +151,7 @@ small fix for an edge case of initialized data in Chris Dodd's btyacc changes: "Avoid crash when input pops up an Action error at the first token" -2016-06-01 Thomas E. Dickey +2016-06-01 Thomas E. Dickey * test/yacc/quote_calc2-s.tab.c, test/yacc/quote_calc3-s.tab.c, test/yacc/quote_calc3.tab.c, test/yacc/quote_calc4-s.tab.c, test/yacc/quote_calc4.tab.c, test/yacc/varsyntax_calc1.tab.c, test/yacc/err_syntax18.tab.c, test/yacc/err_syntax20.tab.c, test/yacc/err_syntax24.error, test/yacc/error.tab.c, test/yacc/grammar.tab.c, test/yacc/ok_syntax1.tab.c, test/yacc/pure_calc.tab.c, test/yacc/pure_error.tab.c, test/yacc/quote_calc-s.tab.c, test/yacc/quote_calc.tab.c, test/yacc/quote_calc2.tab.c, test/yacc/calc.tab.c, test/yacc/calc1.tab.c, test/yacc/calc2.tab.c, test/yacc/calc3.tab.c, test/yacc/code_calc.code.c, test/yacc/code_calc.tab.c, test/yacc/code_calc.tab.h, test/yacc/code_error.code.c, test/yacc/empty.tab.c, test/yacc/err_syntax10.tab.c, test/yacc/err_syntax11.tab.c, test/yacc/err_syntax12.tab.c, test/yacc/rename_debug.c, yaccpar.c, test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc4-s.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/err_syntax13.tab.c, test/btyacc/err_syntax14.tab.c, test/btyacc/err_syntax15.tab.c, test/btyacc/err_syntax16.tab.c, test/btyacc/err_syntax17.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax19.tab.c, test/btyacc/err_syntax2.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/err_syntax21.tab.c, test/btyacc/err_syntax22.tab.c, test/btyacc/err_syntax23.tab.c, test/btyacc/err_syntax24.error, test/btyacc/err_syntax24.tab.c, test/btyacc/err_syntax25.tab.c, test/btyacc/err_syntax26.tab.c, test/btyacc/err_syntax27.tab.c, test/btyacc/err_syntax3.tab.c, test/btyacc/err_syntax4.tab.c, test/btyacc/err_syntax5.tab.c, test/btyacc/err_syntax6.tab.c, test/btyacc/err_syntax7.tab.c, test/btyacc/err_syntax7a.tab.c, test/btyacc/err_syntax7b.tab.c, test/btyacc/err_syntax8.tab.c, test/btyacc/err_syntax8a.tab.c, test/btyacc/err_syntax9.tab.c, test/btyacc/error.tab.c, test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.output, test/btyacc/inherit2.tab.c, test/btyacc/ok_syntax1.tab.c, test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/btyacc_calc1.tab.c, test/btyacc/btyacc_demo.error, test/btyacc/btyacc_demo.output, test/btyacc/btyacc_demo.tab.c, test/btyacc/btyacc_destroy1.tab.c, test/btyacc/btyacc_destroy2.tab.c, test/btyacc/btyacc_destroy3.tab.c, test/btyacc/calc.tab.c, test/btyacc/calc1.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/code_calc.code.c, test/btyacc/code_calc.tab.c, test/btyacc/code_calc.tab.h, test/btyacc/code_error.code.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit1.tab.c, test/btyacc/err_inherit2.tab.c, test/btyacc/err_inherit3.output, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.output, test/btyacc/err_inherit4.tab.c, test/btyacc/err_inherit5.tab.c, test/btyacc/err_syntax1.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/rename_debug.c, btyaccpar.c: regen @@ -72,12 +191,12 @@ + changes to a couple of test cases for coverage of #3, #4 and #5 above -2016-06-01 Thomas E. Dickey +2016-06-01 Thomas E. Dickey * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: bump -2016-03-24 Thomas E. Dickey +2016-03-24 Thomas E. Dickey * reader.c: unused variable @@ -90,7 +209,7 @@ the first occurrence of ".c" in the name in 2005-08-13 changes rather than at the end of the filename (patch by Jung-uk Kim) -2016-03-24 Thomas E. Dickey +2016-03-24 Thomas E. Dickey * aclocal.m4: update CF_WITH_MAN2HTML to use configured shell rather than /bin/sh @@ -98,11 +217,11 @@ * VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile: bump -2016-01-25 Thomas E. Dickey +2016-01-25 Thomas E. Dickey * config.guess, config.sub: 2016-01-01 -2015-07-10 Thomas E. Dickey +2015-07-10 Thomas E. Dickey * lr0.c: fix a duplicate-free in the leak-checking @@ -117,7 +236,7 @@ make relationship with format/size clearer (prompted by discussion with Pedro Giffuni, Oliver Pinter) -2015-07-05 Thomas E. Dickey +2015-07-05 Thomas E. Dickey * configure: regen @@ -131,13 +250,13 @@ * configure.in: add configure option --with-man2html -2015-05-02 Thomas E. Dickey +2015-05-02 Thomas E. Dickey * config.guess: 2015-03-04 * config.sub: 2015-03-08 -2014-11-28 Thomas E. Dickey +2014-11-28 Thomas E. Dickey * lr0.c: coverity #39181: memory leak @@ -159,7 +278,7 @@ Regards Jouk. -2014-10-06 Thomas E. Dickey +2014-10-06 Thomas E. Dickey * package/debian/source/format: change to native format to work around regression in Debian packaging. @@ -179,7 +298,7 @@ better fix for get_line, by ensuring there is enough space to null-terminate its result (prompted by discussion with Craig Rodrigues). -2014-10-05 Thomas E. Dickey +2014-10-05 Thomas E. Dickey * main.c: make change to umask before calling mkstemp, as suggested in Coverity #56902 @@ -250,7 +369,7 @@ modify copy_param() to handle resulting comma-separated list. Before, it only expected a single parameter. -2014-10-04 Thomas E. Dickey +2014-10-04 Thomas E. Dickey * reader.c: split-out save_param() from copy_param() @@ -271,28 +390,28 @@ * test/btyacc/btyacc_destroy3.tab.c, test/btyacc/btyacc_destroy1.tab.c, test/btyacc/btyacc_destroy2.tab.c, test/btyacc/btyacc_destroy3.error, test/btyacc/btyacc_destroy3.output, test/btyacc/btyacc_destroy3.tab.h, test/btyacc/btyacc_destroy2.error, test/btyacc/btyacc_destroy2.output, test/btyacc/btyacc_destroy2.tab.h: RCS_BASE -2014-10-03 Thomas E. Dickey +2014-10-03 Thomas E. Dickey * test/btyacc/btyacc_demo2.error, test/btyacc/btyacc_demo2.output, test/btyacc/btyacc_demo2.tab.c, test/btyacc/btyacc_demo2.tab.h, test/btyacc/btyacc_destroy1.error, test/btyacc/btyacc_destroy1.output, test/btyacc/btyacc_destroy1.tab.h, test/btyacc_destroy3.y, test/btyacc_destroy1.y, test/btyacc_destroy2.y: RCS_BASE -2014-10-02 Thomas E. Dickey +2014-10-02 Thomas E. Dickey * main.c, reader.c, defs.h: use calloc in get_line() when allocating line to ensure it is fully initialized, fixes a later uninitialized value in copy_param() (FreeBSD #193499). -2014-09-17 Thomas E. Dickey +2014-09-17 Thomas E. Dickey * closure.c, lalr.c, output.c, defs.h: rephrase odd addressing to fix Coverity #48848, #38950, #38860, not actually a bug. -2014-09-01 Thomas E. Dickey +2014-09-01 Thomas E. Dickey * config.sub: update to 2014-07-28 -2014-07-27 Thomas E. Dickey +2014-07-27 Thomas E. Dickey * configure: regen @@ -301,7 +420,7 @@ * package/pkgsrc/Makefile, VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec: bump -2014-07-15 Thomas E. Dickey +2014-07-15 Thomas E. Dickey * aclocal.m4: resync with my-autoconf (no change to configure script) @@ -312,7 +431,7 @@ make top-level "make check" work again, by adding another step to filtering the test results. -2014-07-14 Thomas E. Dickey +2014-07-14 Thomas E. Dickey * test/run_test.sh: changes from Garrett Cooper's patch: a) ensure that the script returns an error-code if there are differences @@ -331,12 +450,12 @@ * main.c: remove obsolete -D option from usage message -2014-05-27 Thomas E. Dickey +2014-05-27 Thomas E. Dickey * VERSION, package/byacc.spec, package/debian/changelog, test/yacc/big_b.output, test/yacc/big_l.output, test/yacc/help.output, test/yacc/no_b_opt.output, test/yacc/no_output2.output, test/yacc/no_p_opt.output, test/yacc/nostdin.output: bump -2014-04-22 Thomas E. Dickey +2014-04-22 Thomas E. Dickey * mstring.c: use vsnprintf() to ensure that msprintf's buffer is large enough. @@ -364,12 +483,12 @@ drop "NOTES-btyacc-Changes" and "NOTES-btyacc-Disposition", merging relevant content into README.BTYACC -2014-04-22 Thomas E. Dickey +2014-04-22 Thomas E. Dickey * package/pkgsrc/Makefile, VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec: bump -2014-04-19 Thomas E. Dickey +2014-04-19 Thomas E. Dickey * config.sub: 2014-04-03 @@ -379,7 +498,7 @@ * main.c, defs.h: patch to allow DEBUG build with WIN32 system -2014-04-09 Thomas E. Dickey +2014-04-09 Thomas E. Dickey * output.c, reader.c: gcc warnings @@ -420,7 +539,7 @@ * yacc.1: clarify relationship of btyacc features to default configuration. -2014-04-08 Thomas E. Dickey +2014-04-08 Thomas E. Dickey * test/yacc/ok_syntax1.output, test/yacc/ok_syntax1.tab.c, test/yacc/ok_syntax1.tab.h, test/btyacc/ok_syntax1.output, test/btyacc/ok_syntax1.tab.c, test/btyacc/ok_syntax1.tab.h: reference output for testing @@ -443,7 +562,7 @@ * mstring.c: minor reformatting to make coverage analysis simpler -2014-04-07 Thomas E. Dickey +2014-04-07 Thomas E. Dickey * test/run_test.sh: tidy @@ -478,7 +597,7 @@ YYPATCH #define's to make test-outputs easier to compare #line's (report by Tom Shields) -2014-04-06 Thomas E. Dickey +2014-04-06 Thomas E. Dickey * reader.c: fix for valgrind (the calloc's are intentional - valgrind reported use of uninitialized memory) @@ -582,7 +701,7 @@ * test/run_make.sh: modify to avoid use of VPATH, which has no standard implementation -2014-04-05 Thomas E. Dickey +2014-04-05 Thomas E. Dickey * test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.tab.c, test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc4-s.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/btyacc_calc1.tab.c, test/btyacc/btyacc_demo.tab.c, test/btyacc/calc.tab.c, test/btyacc/calc1.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/code_calc.code.c, test/btyacc/code_error.code.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/error.tab.c: discard a change which merged CountLines() with explicit comparisons against @@ -613,13 +732,13 @@ * test/btyacc_demo.y: fix prototypes -2014-04-04 Thomas E. Dickey +2014-04-04 Thomas E. Dickey * reader.c, defs.h, main.c: more merging of Tom Shield's btyacc changes. In the merge, I moved the symbol_pval inside the btyacc ifdef's and added some more btyacc ifdefs -2014-04-03 Thomas E. Dickey +2014-04-03 Thomas E. Dickey * reader.c: merge-in 3/4 of btyacc's changes, deferring those which change test-outputs. @@ -633,7 +752,7 @@ Some of the merge uses ifdef-changes which I applied to ongoing resync, e.g., the introduction of PER_STATE. -2014-04-02 Thomas E. Dickey +2014-04-02 Thomas E. Dickey * test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c: regen @@ -668,7 +787,7 @@ * main.c: changes for btyacc -2014-04-01 Thomas E. Dickey +2014-04-01 Thomas E. Dickey * reader.c: integrate change by Tom Shields to use bsearch rather than successive @@ -683,7 +802,7 @@ * verbose.c: changes for btyacc, ifdef'd -2014-04-01 Thomas E. Dickey +2014-04-01 Thomas E. Dickey * mkpar.c: eliminate most of the ifdef's using macros @@ -695,7 +814,7 @@ new functions used for reporting errors from the btyacc configuration (I reordered some, and ifdef'd the new ones -TD) -2014-03-31 Thomas E. Dickey +2014-03-31 Thomas E. Dickey * test/btyacc/code_calc.code.c, test/btyacc/code_error.code.c: omit the GCC_UNUSED, as noted by Tom Shields not really essential @@ -703,7 +822,7 @@ * test/btyacc/empty.tab.c, test/btyacc/err_inherit1.tab.c, test/btyacc/err_inherit2.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_inherit5.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax14.tab.c, test/btyacc/err_syntax15.tab.c, test/btyacc/err_syntax16.tab.c, test/btyacc/err_syntax17.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax19.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/err_syntax21.tab.c, test/btyacc/err_syntax22.tab.c, test/btyacc/err_syntax23.tab.c, test/btyacc/err_syntax24.tab.c: regen -2014-03-29 Thomas E. Dickey +2014-03-29 Thomas E. Dickey * test/yacc/err_syntax22.tab.c, test/yacc/err_syntax23.tab.c, test/yacc/err_syntax24.tab.c, test/yacc/err_syntax25.tab.c, test/yacc/err_syntax26.tab.c, test/yacc/err_syntax3.tab.c, test/yacc/err_syntax4.tab.c, test/yacc/err_syntax5.tab.c, test/yacc/err_syntax6.tab.c, test/yacc/err_syntax7.tab.c, test/yacc/err_syntax7a.tab.c, test/yacc/err_syntax7b.tab.c, test/yacc/err_syntax8.tab.c, test/yacc/err_syntax8a.tab.c, test/yacc/err_syntax9.tab.c, test/yacc/error.tab.c, test/yacc/grammar.tab.c, test/yacc/pure_calc.tab.c, test/yacc/pure_error.tab.c, test/yacc/quote_calc-s.tab.c, test/yacc/quote_calc.tab.c, test/yacc/quote_calc2-s.tab.c, test/yacc/quote_calc2.tab.c, test/yacc/quote_calc3-s.tab.c, test/yacc/quote_calc3.tab.c, test/yacc/quote_calc4-s.tab.c, test/yacc/quote_calc4.tab.c, test/yacc/varsyntax_calc1.tab.c, test/yacc/calc.tab.c, test/yacc/calc1.tab.c, test/yacc/calc2.tab.c, test/yacc/calc3.tab.c, test/yacc/code_calc.code.c, test/yacc/code_error.code.c, test/yacc/empty.tab.c, test/yacc/err_syntax1.tab.c, test/yacc/err_syntax10.tab.c, test/yacc/err_syntax11.tab.c, test/yacc/err_syntax12.tab.c, test/yacc/err_syntax13.tab.c, test/yacc/err_syntax14.tab.c, test/yacc/err_syntax15.tab.c, test/yacc/err_syntax16.tab.c, test/yacc/err_syntax17.tab.c, test/yacc/err_syntax18.tab.c, test/yacc/err_syntax19.tab.c, test/yacc/err_syntax2.tab.c, test/yacc/err_syntax20.tab.c, test/yacc/err_syntax21.tab.c, skeleton.c: comment-out yysccsid in the banner because it produces unnecessary compiler @@ -713,7 +832,7 @@ * test/run_test.sh: for yacc, ignore the inherit testcases, since they are btyacc-specific -2014-03-28 Thomas E. Dickey +2014-03-28 Thomas E. Dickey * test/yacc/varsyntax_calc1.error, test/yacc/varsyntax_calc1.output, test/yacc/varsyntax_calc1.tab.c, test/yacc/varsyntax_calc1.tab.h, test/yacc/err_inherit3.error, test/yacc/err_inherit3.output, test/yacc/err_inherit3.tab.c, test/yacc/err_inherit3.tab.h, test/yacc/err_inherit4.error, test/yacc/err_inherit4.output, test/yacc/err_inherit4.tab.c, test/yacc/err_inherit4.tab.h, test/yacc/err_inherit5.error, test/yacc/err_inherit5.output, test/yacc/err_inherit5.tab.c, test/yacc/err_inherit5.tab.h, test/yacc/inherit0.error, test/yacc/inherit0.output, test/yacc/inherit0.tab.c, test/yacc/inherit0.tab.h, test/yacc/inherit1.error, test/yacc/inherit1.output, test/yacc/inherit1.tab.c, test/yacc/inherit1.tab.h, test/yacc/inherit2.error, test/yacc/inherit2.output, test/yacc/inherit2.tab.c, test/yacc/inherit2.tab.h, test/yacc/empty.error, test/yacc/empty.output, test/yacc/empty.tab.c, test/yacc/empty.tab.h, test/yacc/err_inherit1.error, test/yacc/err_inherit1.output, test/yacc/err_inherit1.tab.c, test/yacc/err_inherit1.tab.h, test/yacc/err_inherit2.error, test/yacc/err_inherit2.output, test/yacc/err_inherit2.tab.c, test/yacc/err_inherit2.tab.h: reference output for testing @@ -743,7 +862,7 @@ * yacc.1: document -L/-B features from btyacc -2014-03-25 Thomas E. Dickey +2014-03-25 Thomas E. Dickey * yacc.1: typo @@ -762,7 +881,7 @@ * mstring.c: byacc-btyacc-20140323 -2014-03-25 Thomas E. Dickey +2014-03-25 Thomas E. Dickey * test/btyacc/RCS, test/yacc/RCS: PERMIT FILE @@ -777,7 +896,7 @@ * test/btyacc/err_syntax1.output, test/btyacc/err_syntax1.tab.c, test/btyacc/err_syntax1.tab.h, test/btyacc/err_syntax10.error, test/btyacc/err_syntax10.output, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax10.tab.h, test/btyacc/err_syntax11.error, test/btyacc/err_syntax11.output, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax11.tab.h, test/btyacc/err_syntax12.error, test/btyacc/err_syntax12.output, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax12.tab.h, test/btyacc/err_syntax13.error, test/btyacc/err_syntax13.output, test/btyacc/err_syntax13.tab.c, test/btyacc/err_syntax13.tab.h, test/btyacc/err_syntax14.error, test/btyacc/err_syntax14.output, test/btyacc/err_syntax14.tab.c, test/btyacc/err_syntax14.tab.h, test/btyacc/err_syntax15.error, test/btyacc/err_syntax15.output, test/btyacc/err_syntax15.tab.c, test/btyacc/err_syntax15.tab.h, test/btyacc/err_syntax16.error, test/btyacc/err_syntax16.output, test/btyacc/err_syntax16.tab.c, test/btyacc/err_syntax16.tab.h, test/btyacc/err_syntax17.error, test/btyacc/err_syntax17.output, test/btyacc/err_syntax17.tab.c, test/btyacc/err_syntax17.tab.h, test/btyacc/err_syntax18.error, test/btyacc/err_syntax18.output, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax18.tab.h, test/btyacc/err_syntax19.error, test/btyacc/err_syntax19.output, test/btyacc/err_syntax19.tab.c, test/btyacc/err_syntax19.tab.h, test/btyacc/err_syntax2.output, test/btyacc/err_syntax2.tab.c, test/btyacc/err_syntax2.tab.h, test/btyacc/err_syntax20.error, test/btyacc/err_syntax20.output, test/btyacc/err_syntax20.tab.c, test/btyacc/err_syntax20.tab.h, test/btyacc/err_syntax21.error, test/btyacc/err_syntax21.output, test/btyacc/err_syntax21.tab.c, test/btyacc/err_syntax21.tab.h, test/btyacc/err_syntax22.error, test/btyacc/err_syntax22.output, test/btyacc/err_syntax22.tab.c, test/btyacc/err_syntax22.tab.h, test/btyacc/err_syntax23.error, test/btyacc/err_syntax23.output, test/btyacc/err_syntax23.tab.c, test/btyacc/err_syntax23.tab.h, test/btyacc/err_syntax24.error, test/btyacc/err_syntax24.output, test/btyacc/err_syntax24.tab.c, test/btyacc/err_syntax24.tab.h, test/btyacc/err_syntax25.error, test/btyacc/err_syntax25.output, test/btyacc/err_syntax25.tab.c, test/btyacc/err_syntax25.tab.h, test/btyacc/err_syntax26.error, test/btyacc/err_syntax26.output, test/btyacc/err_syntax26.tab.c, test/btyacc/err_syntax26.tab.h, test/btyacc/err_syntax3.output, test/btyacc/err_syntax3.tab.c, test/btyacc/err_syntax3.tab.h, test/btyacc/err_syntax4.output, test/btyacc/err_syntax4.tab.c, test/btyacc/err_syntax4.tab.h, test/btyacc/err_syntax5.output, test/btyacc/err_syntax5.tab.c, test/btyacc/err_syntax5.tab.h, test/btyacc/err_syntax6.output, test/btyacc/err_syntax6.tab.c, test/btyacc/err_syntax6.tab.h, test/btyacc/err_syntax7.output, test/btyacc/err_syntax7.tab.c, test/btyacc/err_syntax7.tab.h, test/btyacc/err_syntax7a.output, test/btyacc/err_syntax7a.tab.c, test/btyacc/err_syntax7a.tab.h, test/btyacc/err_syntax7b.output, test/btyacc/err_syntax7b.tab.c, test/btyacc/err_syntax7b.tab.h, test/btyacc/err_syntax8.output, test/btyacc/err_syntax8.tab.c, test/btyacc/err_syntax8.tab.h, test/btyacc/err_syntax8a.output, test/btyacc/err_syntax8a.tab.c, test/btyacc/err_syntax8a.tab.h, test/btyacc/err_syntax9.output, test/btyacc/err_syntax9.tab.c, test/btyacc/err_syntax9.tab.h: reference output for testing -2014-03-24 Thomas E. Dickey +2014-03-24 Thomas E. Dickey * defs.h: fix compiler warnings due to mputc() @@ -790,7 +909,7 @@ * test/varsyntax_calc1.y, test/btyacc_calc1.y: testcase for btyacc -2014-03-23 Thomas E. Dickey +2014-03-23 Thomas E. Dickey * test/err_syntax26.error, test/err_syntax26.output, test/err_syntax26.tab.c, test/err_syntax26.tab.h, test/yacc/err_syntax26.error, test/yacc/err_syntax26.output, test/yacc/err_syntax26.tab.c, test/yacc/err_syntax26.tab.h: reference output for testing @@ -812,7 +931,7 @@ * test/btyacc/quote_calc3-s.error, test/btyacc/quote_calc4-s.error, test/btyacc/quote_calc4.error, test/btyacc/grammar.dot, test/btyacc/grammar.error, test/btyacc/pure_calc.error, test/btyacc/pure_error.error, test/btyacc/quote_calc-s.error, test/btyacc/quote_calc.error, test/btyacc/quote_calc2-s.error, test/btyacc/quote_calc2.error, test/btyacc/quote_calc3.error, test/btyacc/err_syntax2.error, test/btyacc/err_syntax3.error, test/btyacc/err_syntax4.error, test/btyacc/err_syntax5.error, test/btyacc/err_syntax6.error, test/btyacc/err_syntax7.error, test/btyacc/err_syntax7a.error, test/btyacc/err_syntax7b.error, test/btyacc/err_syntax8.error, test/btyacc/err_syntax8a.error, test/btyacc/err_syntax9.error, test/btyacc/error.error, test/btyacc/calc1.error, test/btyacc/calc2.error, test/btyacc/calc3.error, test/btyacc/code_calc.error, test/btyacc/code_error.error, test/btyacc/empty.error, test/btyacc/err_syntax1.error, test/btyacc/btyacc_calc1.error, test/btyacc/btyacc_demo.error: reference output for testing -2014-03-23 Thomas E. Dickey +2014-03-23 Thomas E. Dickey * test/err_syntax23.error, test/err_syntax23.output, test/err_syntax23.tab.c, test/err_syntax23.tab.h, test/yacc/err_syntax23.error, test/yacc/err_syntax23.output, test/yacc/err_syntax23.tab.c, test/yacc/err_syntax23.tab.h: reference output for testing @@ -824,7 +943,7 @@ * test/run_test.sh: move test-outputs into subdirectories to keep btyacc/yacc results separate -2014-03-23 Thomas E. Dickey +2014-03-23 Thomas E. Dickey * test/err_syntax22.error, test/err_syntax22.output, test/err_syntax22.tab.c, test/err_syntax22.tab.h, test/yacc/err_syntax22.error, test/yacc/err_syntax22.output, test/yacc/err_syntax22.tab.c, test/yacc/err_syntax22.tab.h: reference output for testing @@ -853,7 +972,7 @@ * test/err_syntax17.y: testcase for unterminated_action() -2014-03-22 Thomas E. Dickey +2014-03-22 Thomas E. Dickey * test/err_syntax16.error, test/err_syntax16.output, test/err_syntax16.tab.c, test/err_syntax16.tab.h, test/yacc/err_syntax16.error, test/yacc/err_syntax16.output, test/yacc/err_syntax16.tab.c, test/yacc/err_syntax16.tab.h: reference output for testing @@ -891,7 +1010,7 @@ * test/err_syntax10.y: testcase for retyped_warning() -2014-03-21 Thomas E. Dickey +2014-03-21 Thomas E. Dickey * test/err_syntax9.error, test/err_syntax9.output, test/err_syntax9.tab.c, test/err_syntax9.tab.h, test/yacc/err_syntax9.error, test/yacc/err_syntax9.output, test/yacc/err_syntax9.tab.c, test/yacc/err_syntax9.tab.h: reference output for testing @@ -1011,7 +1130,7 @@ * lalr.c: rename MAXSHORT to MAXYYINT -2014-01-01 Thomas E. Dickey +2014-01-01 Thomas E. Dickey * yacc.1: document %token-table, improve presentation of double-quotes @@ -1035,7 +1154,7 @@ - add YYTRANSLATE() macro - recognize bison's %token-table declaration -2014-01-01 Thomas E. Dickey +2014-01-01 Thomas E. Dickey * configure: regen @@ -1047,19 +1166,19 @@ * configure.in: use CF_MAKE_DOCS -2013-12-26 Thomas E. Dickey +2013-12-26 Thomas E. Dickey * config.guess: 2013-11-29 -2013-11-19 Thomas E. Dickey +2013-11-19 Thomas E. Dickey * aclocal.m4: resync with my-autoconf (fixes for clang and mingw) -2013-10-25 Thomas E. Dickey +2013-10-25 Thomas E. Dickey * config.sub: 2013-10-01 -2013-09-25 Thomas E. Dickey +2013-09-25 Thomas E. Dickey * reader.c: fix two loop-limits found by clang 3.3 --analyze @@ -1094,13 +1213,13 @@ * package/debian/changelog, VERSION, package/byacc.spec: bump -2013-09-07 Thomas E. Dickey +2013-09-07 Thomas E. Dickey * config.sub: update to 2013-09-15 * config.guess: update to 2013-06-10 -2013-03-04 Thomas E. Dickey +2013-03-04 Thomas E. Dickey * package/debian/changelog, VERSION, package/byacc.spec: bump @@ -1130,11 +1249,11 @@ * aclocal.m4: another fix for CF_GCC_VERSION to handle Debian's modification of gcc message. -2013-02-10 Thomas E. Dickey +2013-02-10 Thomas E. Dickey * config.sub, config.guess: update to 2013-02-04 -2012-10-03 Thomas E. Dickey +2012-10-03 Thomas E. Dickey * package/debian/changelog, package/byacc.spec, VERSION: bump @@ -1156,7 +1275,7 @@ suggested patch: drop CF_ANSI_CC_REQD, CF_ANSI_CC_CHECK, CF_PROG_EXT since they are not needed. -2012-10-03 Thomas E. Dickey +2012-10-03 Thomas E. Dickey * aclocal.m4: split-out CF_CC_ENV_FLAGS from CF_ANSI_CC_CHECK to avoid losing it in @@ -1190,13 +1309,13 @@ CF_MIXEDCASE_FILENAMES CF_NO_LEAKS_OPTION -2012-10-03 Thomas E. Dickey +2012-10-03 Thomas E. Dickey * aclocal.m4: move existence-check for mkstemp out of the AC_TRY_RUN, to help with cross-compiles -2012-10-02 Thomas E. Dickey +2012-10-02 Thomas E. Dickey * config_h.in: Adrian Bunk request - replace this with the output from autoheader @@ -1214,7 +1333,7 @@ * makefile.in: add assignment for datarootdir variable. -2012-05-26 Thomas E. Dickey +2012-05-26 Thomas E. Dickey * package/debian/changelog, package/byacc.spec, VERSION: bump @@ -1242,13 +1361,13 @@ use TMALLOC() and TREALLOC() macros to simplify allocation/reallocation (no object change) -2012-05-25 Thomas E. Dickey +2012-05-25 Thomas E. Dickey * output.c, main.c, verbose.c, mkpar.c, lr0.c: use TMALLOC() and TREALLOC() macros to simplify allocation/reallocation (no object change) -2012-01-15 Thomas E. Dickey +2012-01-15 Thomas E. Dickey * package/debian/copyright: bump @@ -1353,7 +1472,7 @@ * test/quote_calc2-s.tab.c, test/quote_calc3-s.tab.c, test/quote_calc4-s.tab.c, test/quote_calc-s.tab.c, test/quote_calc.tab.c, test/quote_calc2.tab.c, test/quote_calc3.tab.c, test/quote_calc4.tab.c: regen -2012-01-14 Thomas E. Dickey +2012-01-14 Thomas E. Dickey * test/calc2.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c, test/calc1.tab.c: regen @@ -1384,7 +1503,7 @@ * test/run_test.sh: generate/test with "-s" option applied. -2012-01-13 Thomas E. Dickey +2012-01-13 Thomas E. Dickey * package/debian/changelog, package/byacc.spec, VERSION: bump @@ -1416,7 +1535,7 @@ * aclocal.m4: resync with my-autoconf, i.e., fixes for CF_XOPEN_SOURCE -2011-12-19 Thomas E. Dickey +2011-12-19 Thomas E. Dickey * package/debian/changelog, package/byacc.spec, VERSION: bump @@ -1430,7 +1549,7 @@ Simply suppressing the second #define makes the behavior closer to yacc. (report by Paulo Andrade). -2011-09-08 Thomas E. Dickey +2011-09-08 Thomas E. Dickey * package/debian/changelog, package/byacc.spec, VERSION: bump @@ -1438,7 +1557,7 @@ fix some more interaction between -i and -d flags to ensure YYERRCODE and YYSTYPE are declared, tested with cproto. -2011-09-07 Thomas E. Dickey +2011-09-07 Thomas E. Dickey * yacc.1: document "-i" option. @@ -1452,14 +1571,14 @@ * skeleton.c, output.c, defs.h: changes to support "-i" option. -2011-09-06 Thomas E. Dickey +2011-09-06 Thomas E. Dickey * reader.c: pass explicit file-pointer to write_section() * main.c: add "-i" option, to generate interface-file (suggested by Denis M. Wilson) -2011-09-05 Thomas E. Dickey +2011-09-05 Thomas E. Dickey * configure: regen @@ -1470,15 +1589,15 @@ * defs.h, error.c, reader.c: add check for missing "}" on %parse-param and %lex-param lines (report by Denis M Wilson) -2011-04-01 Thomas E. Dickey +2011-04-01 Thomas E. Dickey * config.sub: update to 2011-04-01 -2011-02-02 Thomas E. Dickey +2011-02-02 Thomas E. Dickey * config.guess: update to 2011-01-01 -2010-12-29 Thomas E. Dickey +2010-12-29 Thomas E. Dickey * defs.h, skeleton.c: add const qualifier to skeleton data, per NetBSD changes (report by Christos Zoulas) @@ -1500,7 +1619,7 @@ * test/ftp.y: improve example, which was stuck in 19XX and assumed file sizes were longs. -2010-12-29 Thomas E. Dickey +2010-12-29 Thomas E. Dickey * test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c: regen @@ -1518,11 +1637,11 @@ * output.c: correct definition for YYERROR_DECL() -2010-12-29 Thomas E. Dickey +2010-12-29 Thomas E. Dickey * package/debian/changelog, package/byacc.spec, VERSION: bump -2010-12-26 Thomas E. Dickey +2010-12-26 Thomas E. Dickey * defs.h, main.c: change return-type of allocate() to avoid warnings of alignment problems @@ -1542,7 +1661,7 @@ * aclocal.m4: improve quoting, deprecate ${name-value} in favor of standard ${name:-value} -2010-12-25 Thomas E. Dickey +2010-12-25 Thomas E. Dickey * main.c: start revising use of tmpfile(), to make this work with MinGW. Start by @@ -1551,7 +1670,7 @@ * package/debian/changelog, package/byacc.spec, VERSION: bump -2010-11-27 Thomas E. Dickey +2010-11-27 Thomas E. Dickey * package/byacc.spec, package/debian/changelog, VERSION: bump @@ -1561,7 +1680,7 @@ corrected use of %parse-param value in yyerror(); it doesn't use &yylval (report by Clifford Yapp) -2010-11-26 Thomas E. Dickey +2010-11-26 Thomas E. Dickey * skeleton.c: typo @@ -1612,7 +1731,7 @@ * package/debian/changelog, package/byacc.spec, VERSION: bump -2010-11-24 Thomas E. Dickey +2010-11-24 Thomas E. Dickey * main.c, defs.h, symtab.c, error.c: reduce global variables @@ -1622,7 +1741,7 @@ amend fix for Redhat #112617 to still call default_action_warning() for empty rules (report by Bruce Cran). -2010-11-22 Thomas E. Dickey +2010-11-22 Thomas E. Dickey * output.c: add ifdef to guard against redefinition of YYSTYPE union (request by Clifford Yapp). @@ -1654,20 +1773,20 @@ * package/debian/changelog, package/byacc.spec, VERSION: bump -2010-09-28 Thomas E. Dickey +2010-09-28 Thomas E. Dickey * config.guess: update to 2010-09-24 -2010-09-10 Thomas E. Dickey +2010-09-10 Thomas E. Dickey * config.sub: update to 2010-09-11 -2010-06-10 Thomas E. Dickey +2010-06-10 Thomas E. Dickey * yacc.1, package/debian/changelog, package/byacc.spec, VERSION: bump to 2010/06/10 -2010-06-09 Thomas E. Dickey +2010-06-09 Thomas E. Dickey * reader.c: free declarations in leak-testing code. @@ -1710,7 +1829,7 @@ * test/ftp.tab.c, test/ftp.y, reader.c, symtab.c, verbose.c, lr0.c, main.c, mkpar.c, output.c, defs.h, closure.c: fix warnings from clang --analyze -2010-06-08 Thomas E. Dickey +2010-06-08 Thomas E. Dickey * output.c: fix to build with c89, etc. @@ -1742,7 +1861,7 @@ add check_make and check_lint rules to help validate the generated files in the test-directory -2010-06-07 Thomas E. Dickey +2010-06-07 Thomas E. Dickey * test/pure_calc.tab.c, test/pure_error.tab.c: RCS_BASE @@ -1807,11 +1926,11 @@ anyway. This allows for better compatibility with yacc sources written for bison. -2010-06-07 Thomas E. Dickey +2010-06-07 Thomas E. Dickey * VERSION: bump to 2010/06/07 -2010-06-06 Thomas E. Dickey +2010-06-06 Thomas E. Dickey * test/calc.tab.c, configure: regen @@ -1862,12 +1981,12 @@ c) CF_GCC_VERSION, ignore stderr d) CF_GCC_WARNINGS, adjust options to work with c89 wrapper of gcc -2010-04-20 Thomas E. Dickey +2010-04-20 Thomas E. Dickey * package/debian/changelog, package/debian/compat, package/debian/control, package/debian/copyright, package/debian/docs, package/debian/postinst, package/debian/prerm, package/debian/rules, package/debian/watch: scripts from Debian package -2010-02-16 Thomas E. Dickey +2010-02-16 Thomas E. Dickey * yacc.1: document -P and bison-extensions @@ -1919,24 +2038,24 @@ * skeleton.c: fix a memory leak in the generated skeleton -2010-01-01 Thomas E. Dickey +2010-01-01 Thomas E. Dickey * package/debian/source/format: scripts from Debian package -2009-12-31 Thomas E. Dickey +2009-12-31 Thomas E. Dickey * config.guess: update to 2009-12-30 * config.sub: update to 2009-12-31 -2009-10-27 Thomas E. Dickey +2009-10-27 Thomas E. Dickey * VERSION: 20091027 * output.c, mkpar.c, defs.h, lalr.c, closure.c, graph.c, lr0.c, verbose.c, main.c, reader.c: strict compiler warnings -2009-10-26 Thomas E. Dickey +2009-10-26 Thomas E. Dickey * test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c, test/error.tab.c: resync @@ -1951,44 +2070,44 @@ * aclocal.m4: resync with my-autoconf -2009-08-25 Thomas E. Dickey +2009-08-25 Thomas E. Dickey * config.guess, config.sub: update to 2009-08-19 -2009-02-21 Thomas E. Dickey +2009-02-21 Thomas E. Dickey * VERSION: bump * output.c: restore "yylval" symbol, omitted in cleanup on 2008/8/25 -2008-12-26 Thomas E. Dickey +2008-12-26 Thomas E. Dickey * configure: regen with autoconf-2.52 (patched) -2008-12-25 Thomas E. Dickey +2008-12-25 Thomas E. Dickey * test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c: regenerated -2008-12-24 Thomas E. Dickey +2008-12-24 Thomas E. Dickey * VERSION: bump * skeleton.c: remove ifdef-lint from goto yyerrlab, to quiet gcc warning -2008-11-26 Thomas E. Dickey +2008-11-26 Thomas E. Dickey * verbose.c, main.c, defs.h, mkpar.c, reader.c: completed implementation of "%expect" (report by Perry E. Metzger). add "%expect-rr", which is (unlike bison) allowable in LALR parsers. -2008-11-24 Thomas E. Dickey +2008-11-24 Thomas E. Dickey * closure.c, defs.h, error.c, graph.c, lalr.c, lr0.c, main.c, mkpar.c, output.c, reader.c, skeleton.c, symtab.c, verbose.c, warshall.c: change indent-style (request by Perry E. Metzger) -2008-08-27 Thomas E. Dickey +2008-08-27 Thomas E. Dickey * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c: better implementation of YYPARSE_PARAM, using YYPARSE_DECL() macro @@ -2027,12 +2146,12 @@ * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c: remove 'register' keywords -2008-08-26 Thomas E. Dickey +2008-08-26 Thomas E. Dickey * warshall.c, verbose.c, symtab.c, skeleton.c, reader.c, output.c, mkpar.c, main.c, lr0.c, lalr.c, graph.c, error.c, closure.c: remove 'register' keywords -2008-08-25 Thomas E. Dickey +2008-08-25 Thomas E. Dickey * test/ftp.tab.c: regen'd @@ -2072,7 +2191,7 @@ * makefile.in: add dependency on VERSION file. -2008-08-24 Thomas E. Dickey +2008-08-24 Thomas E. Dickey * VERSION: bump @@ -2090,18 +2209,18 @@ * aclocal.m4: resync with my-autoconf (no major changes) -2008-07-24 Thomas E. Dickey +2008-07-24 Thomas E. Dickey * package/pkgsrc/Makefile, package/pkgsrc/distinfo: scripts from NetBSD pkgsrc, for test-builds -2008-03-14 Thomas E. Dickey +2008-03-14 Thomas E. Dickey * config.sub: update to 2008-03-08 * config.guess: update to 2008-03-12 -2007-05-09 Thomas E. Dickey +2007-05-09 Thomas E. Dickey * main.c: close graph, verbose files if opened, on exit. @@ -2128,19 +2247,19 @@ * main.c: file_prefix did not always have a trailing null. -2007-03-25 Thomas E. Dickey +2007-03-25 Thomas E. Dickey * mkdirs.sh: improved version for "make -j" -2006-12-22 Thomas E. Dickey +2006-12-22 Thomas E. Dickey * config.guess: update to 2006/12/22 -2006-12-08 Thomas E. Dickey +2006-12-08 Thomas E. Dickey * config.sub: update to 2006/12/08 -2005-08-13 Thomas E. Dickey +2005-08-13 Thomas E. Dickey * main.c: add -V to usage message @@ -2159,23 +2278,23 @@ Debian #322858 (don't close union_file, which contained data). This feature is used in groff. -2005-08-13 Thomas E. Dickey +2005-08-13 Thomas E. Dickey * configure: regenerated * aclocal.m4: improve checks for Intel compiler warnings -2005-06-25 Thomas E. Dickey +2005-06-25 Thomas E. Dickey * config.sub: update to 2005/6/2 * config.guess: update to 2005/5/27 -2005-05-05 Thomas E. Dickey +2005-05-05 Thomas E. Dickey * defs.h: add a fallback for GCC_UNUSED -2005-05-04 Thomas E. Dickey +2005-05-04 Thomas E. Dickey * makefile.in: add "." to include-path to pickup config.h @@ -2230,7 +2349,7 @@ add "-o" to usage message. It is too long for a single line; rewrite usage() to show one option per line. -2005-05-03 Thomas E. Dickey +2005-05-03 Thomas E. Dickey * main.c: add -o option, to work with scripts that assume bison. simplify create_file_names() with a macro. @@ -2261,21 +2380,21 @@ add graphical output of the LALR(1) automaton for graphviz, associated with command-line option `-g' -2005-04-16 Thomas E. Dickey +2005-04-16 Thomas E. Dickey * config.sub: update to 2005/2/10 * config.guess: update to 2005/3/24 -2005-04-13 Thomas E. Dickey +2005-04-13 Thomas E. Dickey * package/pkgsrc/PLIST: scripts from NetBSD pkgsrc, for test-builds -2005-03-21 Thomas E. Dickey +2005-03-21 Thomas E. Dickey * package/pkgsrc/DESCR: scripts from NetBSD pkgsrc, for test-builds -2004-03-28 Thomas E. Dickey +2004-03-28 Thomas E. Dickey * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c: updates due to adding yyparse() prototype @@ -2346,32 +2465,32 @@ * README: updated to note that this is not the original -2004-03-24 Thomas E. Dickey +2004-03-24 Thomas E. Dickey * test/grammar.y: RCS_BASE -2004-02-23 Thomas E. Dickey +2004-02-23 Thomas E. Dickey * config.sub: RCS_BASE -2004-02-17 Thomas E. Dickey +2004-02-17 Thomas E. Dickey * config.guess: RCS_BASE -2003-11-29 Thomas E. Dickey +2003-11-29 Thomas E. Dickey * install-sh: improved quoting -2002-06-29 Thomas E. Dickey +2002-06-29 Thomas E. Dickey * mkdirs.sh: don't use character range, since some locales don't work as expected -2001-06-22 Thomas E. Dickey +2001-06-22 Thomas E. Dickey * install-sh: RCS_BASE -2000-11-20 Thomas E. Dickey +2000-11-20 Thomas E. Dickey * test/calc.y: RCS_BASE @@ -2379,26 +2498,26 @@ * vmsbuild.com: original version -2000-02-23 dickey +2000-02-23 dickey@clark.net * test/RCS, RCS: PERMIT FILE -2000-02-14 Thomas E. Dickey +2000-02-14 Thomas E. Dickey * main.c: fix for VMS port - making pathname for temp-file * descrip.mms: original version -2000-02-13 Thomas E. Dickey +2000-02-13 Thomas E. Dickey * defs.h, verbose.c, reader.c, main.c, skeleton.c, warshall.c, symtab.c, closure.c, mkpar.c, lalr.c, lr0.c, output.c, error.c: ansify -1999-11-30 Thomas E. Dickey +1999-11-30 Thomas E. Dickey * mkdirs.sh: RCS_BASE -1995-01-01 Thomas E. Dickey +1995-01-01 Thomas E. Dickey * config_h.in: RCS_BASE @@ -2418,7 +2537,7 @@ * test/ftp.output, test/ftp.tab.c, test/ftp.tab.h: RCS_BASE -1993-02-22 Thomas E. Dickey +1993-02-22 Thomas E. Dickey * test/yacc/error.output, test/yacc/error.tab.h: reference output for testing @@ -2458,7 +2577,7 @@ * symtab.c, lalr.c, error.c: original version -1990-01-16 Thomas E. Dickey +1990-01-16 Thomas E. Dickey * test/code_error.y, test/pure_error.y: RCS_BASE diff --git a/MANIFEST b/MANIFEST index 6df6f292a58..7426e2f18f3 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,4 +1,4 @@ -MANIFEST for byacc-20160606, version t20160606 +MANIFEST for byacc-20161202, version t20161202 -------------------------------------------------------------------------------- MANIFEST this file ACKNOWLEDGEMENTS original version of byacc - 1993 diff --git a/VERSION b/VERSION index 602e5397582..b720a20cb78 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -20160606 +20161202 diff --git a/aclocal.m4 b/aclocal.m4 index 7be01e8e201..917a848a68d 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,4 +1,4 @@ -dnl $Id: aclocal.m4,v 1.40 2016/06/07 00:48:07 tom Exp $ +dnl $Id: aclocal.m4,v 1.41 2016/12/02 13:03:06 tom Exp $ dnl Macros for byacc configure script (Thomas E. Dickey) dnl --------------------------------------------------------------------------- dnl Copyright 2004-2015,2016 Thomas E. Dickey @@ -171,11 +171,14 @@ ifelse([$3],,[ :]dnl ])dnl ])])dnl dnl --------------------------------------------------------------------------- -dnl CF_CC_ENV_FLAGS version: 3 updated: 2016/05/21 18:10:17 +dnl CF_CC_ENV_FLAGS version: 6 updated: 2016/08/29 20:57:00 dnl --------------- dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content -dnl into CC. This will not help with broken scripts that wrap the compiler with -dnl options, but eliminates a more common category of user confusion. +dnl into CC. This will not help with broken scripts that wrap the compiler +dnl with options, but eliminates a more common category of user confusion. +dnl +dnl In particular, it addresses the problem of being able to run the C +dnl preprocessor in a consistent manner. dnl dnl Caveat: this also disallows blanks in the pathname for the compiler, but dnl the nuisance of having inconsistent settings for compiler and preprocessor @@ -191,9 +194,19 @@ case "$CC" in AC_MSG_RESULT(broken) AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options) # humor him... - cf_flags=`echo "$CC" | sed -e 's/^[[^ ]]*[[ ]][[ ]]*//'` - CC=`echo "$CC" | sed -e 's/[[ ]].*//'` - CF_ADD_CFLAGS($cf_flags) + cf_flags=`echo "$CC" | sed -e 's/^.*[[ ]]\(-[[^ ]]\)/\1/'` + CC=`echo "$CC " | sed -e 's/[[ ]]-[[^ ]].*$//' -e 's/[[ ]]*$//'` + for cf_arg in $cf_flags + do + case "x$cf_arg" in + (x-[[IUDfgOW]]*) + CF_ADD_CFLAGS($cf_flags) + ;; + (*) + CC="$CC $cf_arg" + ;; + esac + done CF_VERBOSE(resulting CC: '$CC') CF_VERBOSE(resulting CFLAGS: '$CFLAGS') CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS') @@ -577,7 +590,7 @@ rm -rf conftest* AC_SUBST(EXTRA_CFLAGS) ])dnl dnl --------------------------------------------------------------------------- -dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07 +dnl CF_GNU_SOURCE version: 7 updated: 2016/08/05 05:15:37 dnl ------------- dnl Check if we must define _GNU_SOURCE to get a reasonable value for dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect @@ -604,7 +617,20 @@ make an error CPPFLAGS="$cf_save" ]) ]) -test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" + +if test "$cf_cv_gnu_source" = yes +then +AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[ +CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" + AC_TRY_COMPILE([#include ],[ +#ifdef _DEFAULT_SOURCE +make an error +#endif], + [cf_cv_default_source=no], + [cf_cv_default_source=yes]) + ]) +test "$cf_cv_default_source" = yes && CPPFLAGS="$CPPFLAGS -D_DEFAULT_SOURCE" +fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_INTEL_COMPILER version: 7 updated: 2015/04/12 15:39:00 @@ -1294,7 +1320,7 @@ fi fi ])dnl dnl --------------------------------------------------------------------------- -dnl CF_XOPEN_SOURCE version: 50 updated: 2015/10/17 19:03:33 +dnl CF_XOPEN_SOURCE version: 52 updated: 2016/08/27 12:21:42 dnl --------------- dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions, dnl or adapt to the vendor's definitions to get equivalent functionality, @@ -1314,7 +1340,7 @@ case $host_os in (aix[[4-7]]*) cf_xopen_source="-D_ALL_SOURCE" ;; -(cygwin|msys) +(msys) cf_XOPEN_SOURCE=600 ;; (darwin[[0-8]].*) @@ -1342,7 +1368,7 @@ case $host_os in cf_xopen_source="-D_SGI_SOURCE" cf_XOPEN_SOURCE= ;; -(linux*|gnu*|mint*|k*bsd*-gnu) +(linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin) CF_GNU_SOURCE ;; (minix*) @@ -1364,9 +1390,6 @@ case $host_os in (openbsd*) # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw ;; -(os2*) - cf_XOPEN_SOURCE= - ;; (osf[[45]]*) cf_xopen_source="-D_OSF_SOURCE" ;; diff --git a/btyaccpar.c b/btyaccpar.c index 42070193d96..f8ef414a8e3 100644 --- a/btyaccpar.c +++ b/btyaccpar.c @@ -1,8 +1,8 @@ /* This file generated automatically using - * @Id: skel2c,v 1.3 2014/04/06 19:48:04 tom Exp @ + * @Id: skel2c,v 1.4 2016/06/07 00:26:09 tom Exp @ */ -/* @Id: btyaccpar.skel,v 1.3 2016/06/06 23:35:55 Tom.Shields Exp @ */ +/* @Id: btyaccpar.skel,v 1.5 2016/12/02 22:02:28 tom Exp @ */ #include "defs.h" @@ -218,9 +218,9 @@ const char *const hdr_vars[] = "#endif", "", "/* Current position at lexical token queue */", - "static short *yylexp = 0;", + "static YYINT *yylexp = 0;", "", - "static short *yylexemes = 0;", + "static YYINT *yylexemes = 0;", "#endif /* YYBTYACC */", #endif /* defined(YYBTYACC) */ 0 @@ -275,9 +275,9 @@ const char *const body_vars[] = "#endif", "", " /* Current position at lexical token queue */", - " static short *yylexp = 0;", + " static YYINT *yylexp = 0;", "", - " static short *yylexemes = 0;", + " static YYINT *yylexemes = 0;", "#endif /* YYBTYACC */", #endif /* defined(YYBTYACC) */ 0 @@ -451,6 +451,11 @@ const char *const body_2[] = " fprintf(stderr, \"%sdebug[<# of symbols on state stack>]\\n\", YYPREFIX);", "#endif", "", + 0 +}; + +const char *const body_3[] = +{ #if defined(YYBTYACC) "#if YYBTYACC", " yyps = yyNewState(0); if (yyps == 0) goto yyenomem;", @@ -503,10 +508,10 @@ const char *const body_2[] = " size_t s = (size_t) (yylvlim - yylvals);", "", " s += YYLVQUEUEGROWTH;", - " if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;", - " if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;", + " if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;", + " if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;", "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)", - " if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;", + " if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;", "#endif", " yylvp = yylve = yylvals + p;", " yylvlim = yylvals + s;", @@ -516,7 +521,7 @@ const char *const body_2[] = "#endif", " yylexp = yylexemes + p;", " }", - " *yylexp = (short) YYLEX;", + " *yylexp = (YYINT) YYLEX;", " *yylvp++ = yylval;", " yylve++;", "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)", @@ -623,7 +628,7 @@ const char *const body_2[] = " /* If this is a first conflict in the stack, start saving lexemes */", " if (!yylexemes)", " {", - " yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));", + " yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));", " if (yylexemes == NULL) goto yyenomem;", " yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));", " if (yylvals == NULL) goto yyenomem;", @@ -647,7 +652,7 @@ const char *const body_2[] = "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)", " *yylpe++ = yylloc;", "#endif", - " *yylexp = (short) yychar;", + " *yylexp = (YYINT) yychar;", " yychar = YYEMPTY;", " }", " }", @@ -1046,12 +1051,12 @@ const char *const trailer[] = " size_t s = (size_t) (yylvlim - yylvals);", "", " s += YYLVQUEUEGROWTH;", - " if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL)", + " if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)", " goto yyenomem;", - " if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)", + " if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)", " goto yyenomem;", "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)", - " if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)", + " if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)", " goto yyenomem;", "#endif", " yylvp = yylve = yylvals + p;", @@ -1062,7 +1067,7 @@ const char *const trailer[] = "#endif", " yylexp = yylexemes + p;", " }", - " *yylexp = (short) YYLEX;", + " *yylexp = (YYINT) YYLEX;", " *yylvp++ = yylval;", " yylve++;", "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)", diff --git a/btyaccpar.skel b/btyaccpar.skel index 97fc264255d..6b21254f614 100644 --- a/btyaccpar.skel +++ b/btyaccpar.skel @@ -1,4 +1,4 @@ -/* $Id: btyaccpar.skel,v 1.3 2016/06/06 23:35:55 Tom.Shields Exp $ */ +/* $Id: btyaccpar.skel,v 1.5 2016/12/02 22:02:28 tom Exp $ */ #include "defs.h" @@ -176,9 +176,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; %%endif YYBTYACC %% body_vars int yyerrflag; @@ -227,9 +227,9 @@ static short *yylexemes = 0; #endif /* Current position at lexical token queue */ - static short *yylexp = 0; + static YYINT *yylexp = 0; - static short *yylexemes = 0; + static YYINT *yylexemes = 0; %%endif YYBTYACC %% body_1 @@ -386,6 +386,7 @@ YYPARSE_DECL() fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); #endif +%% body_3 %%ifdef YYBTYACC yyps = yyNewState(0); if (yyps == 0) goto yyenomem; yyps->save = 0; @@ -435,10 +436,10 @@ yyloop: size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -448,7 +449,7 @@ yyloop: #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -549,7 +550,7 @@ yyloop: /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -573,7 +574,7 @@ yyloop: #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -954,12 +955,12 @@ yyreduce: size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -970,7 +971,7 @@ yyreduce: #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/config.guess b/config.guess index dcd5149681d..2e9ad7fe818 100755 --- a/config.guess +++ b/config.guess @@ -2,7 +2,7 @@ # Attempt to guess a canonical system name. # Copyright 1992-2016 Free Software Foundation, Inc. -timestamp='2016-01-01' +timestamp='2016-10-02' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -186,9 +186,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. + # to ELF recently (or will in the future) and ABI. case "${UNAME_MACHINE_ARCH}" in - arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ @@ -237,6 +240,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE} + exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; @@ -268,42 +275,42 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; + UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; + UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; + UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; + UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; + UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; + UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; + UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; + UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; + UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 @@ -376,16 +383,16 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build - SUN_ARCH="i386" + SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then - SUN_ARCH="x86_64" + SUN_ARCH=x86_64 fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` @@ -410,7 +417,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} @@ -635,13 +642,13 @@ EOF sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi @@ -680,11 +687,11 @@ EOF exit (0); } EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = "hppa2.0w" ] + if [ ${HP_ARCH} = hppa2.0w ] then eval $set_cc_for_build @@ -697,12 +704,12 @@ EOF # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then - HP_ARCH="hppa2.0w" + HP_ARCH=hppa2.0w else - HP_ARCH="hppa64" + HP_ARCH=hppa64 fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} @@ -807,14 +814,14 @@ EOF echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) @@ -896,7 +903,7 @@ EOF exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix @@ -919,7 +926,7 @@ EOF EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="gnulibc1" ; fi + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) @@ -993,6 +1000,9 @@ EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; + mips64el:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; @@ -1025,6 +1035,9 @@ EOF ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; @@ -1272,6 +1285,9 @@ EOF SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux${UNAME_RELEASE} + exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; @@ -1285,9 +1301,9 @@ EOF UNAME_PROCESSOR=powerpc fi if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in @@ -1309,7 +1325,7 @@ EOF exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then + if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi @@ -1340,7 +1356,7 @@ EOF # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = "386"; then + if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" @@ -1382,7 +1398,7 @@ EOF echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos @@ -1401,18 +1417,17 @@ esac cat >&2 < in order to provide the needed -information to handle your system. +If $0 has already been updated, send the following data and any +information you think might be pertinent to config-patches@gnu.org to +provide the necessary information to handle your system. config.guess timestamp = $timestamp diff --git a/config.sub b/config.sub index da6d1b6826a..3478c1fd0d3 100755 --- a/config.sub +++ b/config.sub @@ -2,7 +2,7 @@ # Configuration validation subroutine script. # Copyright 1992-2016 Free Software Foundation, Inc. -timestamp='2016-01-01' +timestamp='2016-11-19' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -117,7 +117,7 @@ case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | \ + kopensolaris*-gnu* | cloudabi*-eabi* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` @@ -301,6 +301,7 @@ case $basic_machine in | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ @@ -428,6 +429,7 @@ case $basic_machine in | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ | pyramid-* \ | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ @@ -643,6 +645,14 @@ case $basic_machine in basic_machine=m68k-bull os=-sysv3 ;; + e500v[12]) + basic_machine=powerpc-unknown + os=$os"spe" + ;; + e500v[12]-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + os=$os"spe" + ;; ebmon29k) basic_machine=a29k-amd os=-ebmon @@ -1022,7 +1032,7 @@ case $basic_machine in ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - ppcle | powerpclittle | ppc-le | powerpc-little) + ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) @@ -1032,7 +1042,7 @@ case $basic_machine in ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) + ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) @@ -1382,14 +1392,14 @@ case $os in | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* \ + | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ + | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ @@ -1399,7 +1409,7 @@ case $os in | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ - | -onefs* | -tirtos*) + | -onefs* | -tirtos* | -phoenix* | -fuchsia*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1531,6 +1541,8 @@ case $os in ;; -nacl*) ;; + -ios) + ;; -none) ;; *) diff --git a/configure b/configure index 86f9dce852a..9707e502f43 100755 --- a/configure +++ b/configure @@ -1955,8 +1955,12 @@ echo "${ECHO_T}broken" >&6 { echo "$as_me:1955: WARNING: your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options" >&5 echo "$as_me: WARNING: your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options" >&2;} # humor him... - cf_flags=`echo "$CC" | sed -e 's/^[^ ]*[ ][ ]*//'` - CC=`echo "$CC" | sed -e 's/[ ].*//'` + cf_flags=`echo "$CC" | sed -e 's/^.*[ ]\(-[^ ]\)/\1/'` + CC=`echo "$CC " | sed -e 's/[ ]-[^ ].*$//' -e 's/[ ]*$//'` + for cf_arg in $cf_flags + do + case "x$cf_arg" in + (x-[IUDfgOW]*) cf_fix_cppflags=no cf_new_cflags= @@ -2036,26 +2040,32 @@ if test -n "$cf_new_extra_cppflags" ; then EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" fi + ;; + (*) + CC="$CC $cf_arg" + ;; + esac + done test -n "$verbose" && echo " resulting CC: '$CC'" 1>&6 -echo "${as_me:-configure}:2041: testing resulting CC: '$CC' ..." 1>&5 +echo "${as_me:-configure}:2051: testing resulting CC: '$CC' ..." 1>&5 test -n "$verbose" && echo " resulting CFLAGS: '$CFLAGS'" 1>&6 -echo "${as_me:-configure}:2045: testing resulting CFLAGS: '$CFLAGS' ..." 1>&5 +echo "${as_me:-configure}:2055: testing resulting CFLAGS: '$CFLAGS' ..." 1>&5 test -n "$verbose" && echo " resulting CPPFLAGS: '$CPPFLAGS'" 1>&6 -echo "${as_me:-configure}:2049: testing resulting CPPFLAGS: '$CPPFLAGS' ..." 1>&5 +echo "${as_me:-configure}:2059: testing resulting CPPFLAGS: '$CPPFLAGS' ..." 1>&5 ;; (*) - echo "$as_me:2053: result: ok" >&5 + echo "$as_me:2063: result: ok" >&5 echo "${ECHO_T}ok" >&6 ;; esac -echo "$as_me:2058: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "$as_me:2068: checking whether ${MAKE-make} sets \${MAKE}" >&5 echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'` if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then @@ -2075,11 +2085,11 @@ fi rm -f conftest.make fi if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then - echo "$as_me:2078: result: yes" >&5 + echo "$as_me:2088: result: yes" >&5 echo "${ECHO_T}yes" >&6 SET_MAKE= else - echo "$as_me:2082: result: no" >&5 + echo "$as_me:2092: result: no" >&5 echo "${ECHO_T}no" >&6 SET_MAKE="MAKE=${MAKE-make}" fi @@ -2096,7 +2106,7 @@ fi # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. -echo "$as_me:2099: checking for a BSD compatible install" >&5 +echo "$as_me:2109: checking for a BSD compatible install" >&5 echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6 if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then @@ -2145,7 +2155,7 @@ fi INSTALL=$ac_install_sh fi fi -echo "$as_me:2148: result: $INSTALL" >&5 +echo "$as_me:2158: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. @@ -2156,7 +2166,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' -echo "$as_me:2159: checking if filesystem supports mixed-case filenames" >&5 +echo "$as_me:2169: checking if filesystem supports mixed-case filenames" >&5 echo $ECHO_N "checking if filesystem supports mixed-case filenames... $ECHO_C" >&6 if test "${cf_cv_mixedcase+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -2183,7 +2193,7 @@ else fi fi -echo "$as_me:2186: result: $cf_cv_mixedcase" >&5 +echo "$as_me:2196: result: $cf_cv_mixedcase" >&5 echo "${ECHO_T}$cf_cv_mixedcase" >&6 test "$cf_cv_mixedcase" = yes && cat >>confdefs.h <<\EOF @@ -2194,7 +2204,7 @@ for ac_prog in exctags ctags do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:2197: checking for $ac_word" >&5 +echo "$as_me:2207: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CTAGS+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -2209,7 +2219,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CTAGS="$ac_prog" -echo "$as_me:2212: found $ac_dir/$ac_word" >&5 +echo "$as_me:2222: found $ac_dir/$ac_word" >&5 break done @@ -2217,10 +2227,10 @@ fi fi CTAGS=$ac_cv_prog_CTAGS if test -n "$CTAGS"; then - echo "$as_me:2220: result: $CTAGS" >&5 + echo "$as_me:2230: result: $CTAGS" >&5 echo "${ECHO_T}$CTAGS" >&6 else - echo "$as_me:2223: result: no" >&5 + echo "$as_me:2233: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -2231,7 +2241,7 @@ for ac_prog in exetags etags do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:2234: checking for $ac_word" >&5 +echo "$as_me:2244: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ETAGS+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -2246,7 +2256,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ETAGS="$ac_prog" -echo "$as_me:2249: found $ac_dir/$ac_word" >&5 +echo "$as_me:2259: found $ac_dir/$ac_word" >&5 break done @@ -2254,10 +2264,10 @@ fi fi ETAGS=$ac_cv_prog_ETAGS if test -n "$ETAGS"; then - echo "$as_me:2257: result: $ETAGS" >&5 + echo "$as_me:2267: result: $ETAGS" >&5 echo "${ECHO_T}$ETAGS" >&6 else - echo "$as_me:2260: result: no" >&5 + echo "$as_me:2270: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -2266,7 +2276,7 @@ done # Extract the first word of "${CTAGS:-ctags}", so it can be a program name with args. set dummy ${CTAGS:-ctags}; ac_word=$2 -echo "$as_me:2269: checking for $ac_word" >&5 +echo "$as_me:2279: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_MAKE_LOWER_TAGS+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -2281,7 +2291,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_MAKE_LOWER_TAGS="yes" -echo "$as_me:2284: found $ac_dir/$ac_word" >&5 +echo "$as_me:2294: found $ac_dir/$ac_word" >&5 break done @@ -2290,17 +2300,17 @@ fi fi MAKE_LOWER_TAGS=$ac_cv_prog_MAKE_LOWER_TAGS if test -n "$MAKE_LOWER_TAGS"; then - echo "$as_me:2293: result: $MAKE_LOWER_TAGS" >&5 + echo "$as_me:2303: result: $MAKE_LOWER_TAGS" >&5 echo "${ECHO_T}$MAKE_LOWER_TAGS" >&6 else - echo "$as_me:2296: result: no" >&5 + echo "$as_me:2306: result: no" >&5 echo "${ECHO_T}no" >&6 fi if test "$cf_cv_mixedcase" = yes ; then # Extract the first word of "${ETAGS:-etags}", so it can be a program name with args. set dummy ${ETAGS:-etags}; ac_word=$2 -echo "$as_me:2303: checking for $ac_word" >&5 +echo "$as_me:2313: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_MAKE_UPPER_TAGS+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -2315,7 +2325,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_MAKE_UPPER_TAGS="yes" -echo "$as_me:2318: found $ac_dir/$ac_word" >&5 +echo "$as_me:2328: found $ac_dir/$ac_word" >&5 break done @@ -2324,10 +2334,10 @@ fi fi MAKE_UPPER_TAGS=$ac_cv_prog_MAKE_UPPER_TAGS if test -n "$MAKE_UPPER_TAGS"; then - echo "$as_me:2327: result: $MAKE_UPPER_TAGS" >&5 + echo "$as_me:2337: result: $MAKE_UPPER_TAGS" >&5 echo "${ECHO_T}$MAKE_UPPER_TAGS" >&6 else - echo "$as_me:2330: result: no" >&5 + echo "$as_me:2340: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -2351,7 +2361,7 @@ for ac_prog in mawk gawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:2354: checking for $ac_word" >&5 +echo "$as_me:2364: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_AWK+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -2366,7 +2376,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_AWK="$ac_prog" -echo "$as_me:2369: found $ac_dir/$ac_word" >&5 +echo "$as_me:2379: found $ac_dir/$ac_word" >&5 break done @@ -2374,17 +2384,17 @@ fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then - echo "$as_me:2377: result: $AWK" >&5 + echo "$as_me:2387: result: $AWK" >&5 echo "${ECHO_T}$AWK" >&6 else - echo "$as_me:2380: result: no" >&5 + echo "$as_me:2390: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$AWK" && break done -test -z "$AWK" && { { echo "$as_me:2387: error: No awk program found" >&5 +test -z "$AWK" && { { echo "$as_me:2397: error: No awk program found" >&5 echo "$as_me: error: No awk program found" >&2;} { (exit 1); exit 1; }; } @@ -2392,7 +2402,7 @@ for ac_prog in lint cppcheck splint do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:2395: checking for $ac_word" >&5 +echo "$as_me:2405: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_LINT+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -2407,7 +2417,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_LINT="$ac_prog" -echo "$as_me:2410: found $ac_dir/$ac_word" >&5 +echo "$as_me:2420: found $ac_dir/$ac_word" >&5 break done @@ -2415,10 +2425,10 @@ fi fi LINT=$ac_cv_prog_LINT if test -n "$LINT"; then - echo "$as_me:2418: result: $LINT" >&5 + echo "$as_me:2428: result: $LINT" >&5 echo "${ECHO_T}$LINT" >&6 else - echo "$as_me:2421: result: no" >&5 + echo "$as_me:2431: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -2433,7 +2443,7 @@ case $host_os in (aix[4-7]*) cf_xopen_source="-D_ALL_SOURCE" ;; -(cygwin|msys) +(msys) cf_XOPEN_SOURCE=600 ;; (darwin[0-8].*) @@ -2461,16 +2471,16 @@ case $host_os in cf_xopen_source="-D_SGI_SOURCE" cf_XOPEN_SOURCE= ;; -(linux*|gnu*|mint*|k*bsd*-gnu) +(linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin) -echo "$as_me:2466: checking if we must define _GNU_SOURCE" >&5 +echo "$as_me:2476: checking if we must define _GNU_SOURCE" >&5 echo $ECHO_N "checking if we must define _GNU_SOURCE... $ECHO_C" >&6 if test "${cf_cv_gnu_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 2473 "configure" +#line 2483 "configure" #include "confdefs.h" #include int @@ -2485,16 +2495,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2488: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2498: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2491: \$? = $ac_status" >&5 + echo "$as_me:2501: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2494: \"$ac_try\"") >&5 + { (eval echo "$as_me:2504: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2497: \$? = $ac_status" >&5 + echo "$as_me:2507: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_gnu_source=no else @@ -2503,7 +2513,7 @@ cat conftest.$ac_ext >&5 cf_save="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" cat >conftest.$ac_ext <<_ACEOF -#line 2506 "configure" +#line 2516 "configure" #include "confdefs.h" #include int @@ -2518,16 +2528,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2521: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2531: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2524: \$? = $ac_status" >&5 + echo "$as_me:2534: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2527: \"$ac_try\"") >&5 + { (eval echo "$as_me:2537: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2530: \$? = $ac_status" >&5 + echo "$as_me:2540: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_gnu_source=no else @@ -2542,9 +2552,58 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:2545: result: $cf_cv_gnu_source" >&5 +echo "$as_me:2555: result: $cf_cv_gnu_source" >&5 echo "${ECHO_T}$cf_cv_gnu_source" >&6 -test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" + +if test "$cf_cv_gnu_source" = yes +then +echo "$as_me:2560: checking if we should also define _DEFAULT_SOURCE" >&5 +echo $ECHO_N "checking if we should also define _DEFAULT_SOURCE... $ECHO_C" >&6 +if test "${cf_cv_default_source+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" + cat >conftest.$ac_ext <<_ACEOF +#line 2568 "configure" +#include "confdefs.h" +#include +int +main () +{ + +#ifdef _DEFAULT_SOURCE +make an error +#endif + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2583: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2586: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2589: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2592: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cf_cv_default_source=no +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +cf_cv_default_source=yes +fi +rm -f conftest.$ac_objext conftest.$ac_ext + +fi +echo "$as_me:2603: result: $cf_cv_default_source" >&5 +echo "${ECHO_T}$cf_cv_default_source" >&6 +test "$cf_cv_default_source" = yes && CPPFLAGS="$CPPFLAGS -D_DEFAULT_SOURCE" +fi ;; (minix*) @@ -2567,16 +2626,16 @@ cf_trim_CPPFLAGS=`echo "$cf_save_CPPFLAGS" | \ sed -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?$//g'` -echo "$as_me:2570: checking if we should define _POSIX_C_SOURCE" >&5 +echo "$as_me:2629: checking if we should define _POSIX_C_SOURCE" >&5 echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6 if test "${cf_cv_posix_c_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else -echo "${as_me:-configure}:2576: testing if the symbol is already defined go no further ..." 1>&5 +echo "${as_me:-configure}:2635: testing if the symbol is already defined go no further ..." 1>&5 cat >conftest.$ac_ext <<_ACEOF -#line 2579 "configure" +#line 2638 "configure" #include "confdefs.h" #include int @@ -2591,16 +2650,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2594: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2653: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2597: \$? = $ac_status" >&5 + echo "$as_me:2656: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2600: \"$ac_try\"") >&5 + { (eval echo "$as_me:2659: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2603: \$? = $ac_status" >&5 + echo "$as_me:2662: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_posix_c_source=no else @@ -2621,7 +2680,7 @@ cf_want_posix_source=no esac if test "$cf_want_posix_source" = yes ; then cat >conftest.$ac_ext <<_ACEOF -#line 2624 "configure" +#line 2683 "configure" #include "confdefs.h" #include int @@ -2636,16 +2695,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2639: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2698: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2642: \$? = $ac_status" >&5 + echo "$as_me:2701: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2645: \"$ac_try\"") >&5 + { (eval echo "$as_me:2704: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2648: \$? = $ac_status" >&5 + echo "$as_me:2707: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -2656,15 +2715,15 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "${as_me:-configure}:2659: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 +echo "${as_me:-configure}:2718: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 CFLAGS="$cf_trim_CFLAGS" CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source" -echo "${as_me:-configure}:2664: testing if the second compile does not leave our definition intact error ..." 1>&5 +echo "${as_me:-configure}:2723: testing if the second compile does not leave our definition intact error ..." 1>&5 cat >conftest.$ac_ext <<_ACEOF -#line 2667 "configure" +#line 2726 "configure" #include "confdefs.h" #include int @@ -2679,16 +2738,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2682: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2741: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2685: \$? = $ac_status" >&5 + echo "$as_me:2744: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2688: \"$ac_try\"") >&5 + { (eval echo "$as_me:2747: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2691: \$? = $ac_status" >&5 + echo "$as_me:2750: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -2704,7 +2763,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:2707: result: $cf_cv_posix_c_source" >&5 +echo "$as_me:2766: result: $cf_cv_posix_c_source" >&5 echo "${ECHO_T}$cf_cv_posix_c_source" >&6 if test "$cf_cv_posix_c_source" != no ; then @@ -2803,9 +2862,6 @@ fi (openbsd*) # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw ;; -(os2*) - cf_XOPEN_SOURCE= - ;; (osf[45]*) cf_xopen_source="-D_OSF_SOURCE" ;; @@ -2825,14 +2881,14 @@ fi ;; (*) -echo "$as_me:2828: checking if we should define _XOPEN_SOURCE" >&5 +echo "$as_me:2884: checking if we should define _XOPEN_SOURCE" >&5 echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6 if test "${cf_cv_xopen_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 2835 "configure" +#line 2891 "configure" #include "confdefs.h" #include @@ -2851,16 +2907,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2854: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2910: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2857: \$? = $ac_status" >&5 + echo "$as_me:2913: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2860: \"$ac_try\"") >&5 + { (eval echo "$as_me:2916: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2863: \$? = $ac_status" >&5 + echo "$as_me:2919: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_xopen_source=no else @@ -2869,7 +2925,7 @@ cat conftest.$ac_ext >&5 cf_save="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" cat >conftest.$ac_ext <<_ACEOF -#line 2872 "configure" +#line 2928 "configure" #include "confdefs.h" #include @@ -2888,16 +2944,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:2891: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:2947: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:2894: \$? = $ac_status" >&5 + echo "$as_me:2950: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:2897: \"$ac_try\"") >&5 + { (eval echo "$as_me:2953: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2900: \$? = $ac_status" >&5 + echo "$as_me:2956: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_xopen_source=no else @@ -2912,7 +2968,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:2915: result: $cf_cv_xopen_source" >&5 +echo "$as_me:2971: result: $cf_cv_xopen_source" >&5 echo "${ECHO_T}$cf_cv_xopen_source" >&6 if test "$cf_cv_xopen_source" != no ; then @@ -3020,16 +3076,16 @@ cf_trim_CPPFLAGS=`echo "$cf_save_CPPFLAGS" | \ sed -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?$//g'` -echo "$as_me:3023: checking if we should define _POSIX_C_SOURCE" >&5 +echo "$as_me:3079: checking if we should define _POSIX_C_SOURCE" >&5 echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6 if test "${cf_cv_posix_c_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else -echo "${as_me:-configure}:3029: testing if the symbol is already defined go no further ..." 1>&5 +echo "${as_me:-configure}:3085: testing if the symbol is already defined go no further ..." 1>&5 cat >conftest.$ac_ext <<_ACEOF -#line 3032 "configure" +#line 3088 "configure" #include "confdefs.h" #include int @@ -3044,16 +3100,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3047: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3103: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3050: \$? = $ac_status" >&5 + echo "$as_me:3106: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3053: \"$ac_try\"") >&5 + { (eval echo "$as_me:3109: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3056: \$? = $ac_status" >&5 + echo "$as_me:3112: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_posix_c_source=no else @@ -3074,7 +3130,7 @@ cf_want_posix_source=no esac if test "$cf_want_posix_source" = yes ; then cat >conftest.$ac_ext <<_ACEOF -#line 3077 "configure" +#line 3133 "configure" #include "confdefs.h" #include int @@ -3089,16 +3145,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3092: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3148: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3095: \$? = $ac_status" >&5 + echo "$as_me:3151: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3098: \"$ac_try\"") >&5 + { (eval echo "$as_me:3154: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3101: \$? = $ac_status" >&5 + echo "$as_me:3157: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -3109,15 +3165,15 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "${as_me:-configure}:3112: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 +echo "${as_me:-configure}:3168: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 CFLAGS="$cf_trim_CFLAGS" CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source" -echo "${as_me:-configure}:3117: testing if the second compile does not leave our definition intact error ..." 1>&5 +echo "${as_me:-configure}:3173: testing if the second compile does not leave our definition intact error ..." 1>&5 cat >conftest.$ac_ext <<_ACEOF -#line 3120 "configure" +#line 3176 "configure" #include "confdefs.h" #include int @@ -3132,16 +3188,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3135: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3191: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3138: \$? = $ac_status" >&5 + echo "$as_me:3194: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3141: \"$ac_try\"") >&5 + { (eval echo "$as_me:3197: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3144: \$? = $ac_status" >&5 + echo "$as_me:3200: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -3157,7 +3213,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:3160: result: $cf_cv_posix_c_source" >&5 +echo "$as_me:3216: result: $cf_cv_posix_c_source" >&5 echo "${ECHO_T}$cf_cv_posix_c_source" >&6 if test "$cf_cv_posix_c_source" != no ; then @@ -3315,7 +3371,7 @@ done if test -n "$cf_new_cflags" ; then test -n "$verbose" && echo " add to \$CFLAGS $cf_new_cflags" 1>&6 -echo "${as_me:-configure}:3318: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5 +echo "${as_me:-configure}:3374: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5 CFLAGS="$CFLAGS $cf_new_cflags" fi @@ -3323,7 +3379,7 @@ fi if test -n "$cf_new_cppflags" ; then test -n "$verbose" && echo " add to \$CPPFLAGS $cf_new_cppflags" 1>&6 -echo "${as_me:-configure}:3326: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5 +echo "${as_me:-configure}:3382: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5 CPPFLAGS="$CPPFLAGS $cf_new_cppflags" fi @@ -3331,7 +3387,7 @@ fi if test -n "$cf_new_extra_cppflags" ; then test -n "$verbose" && echo " add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6 -echo "${as_me:-configure}:3334: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5 +echo "${as_me:-configure}:3390: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5 EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" fi @@ -3339,10 +3395,10 @@ fi fi if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then - echo "$as_me:3342: checking if _XOPEN_SOURCE really is set" >&5 + echo "$as_me:3398: checking if _XOPEN_SOURCE really is set" >&5 echo $ECHO_N "checking if _XOPEN_SOURCE really is set... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF -#line 3345 "configure" +#line 3401 "configure" #include "confdefs.h" #include int @@ -3357,16 +3413,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3360: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3416: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3363: \$? = $ac_status" >&5 + echo "$as_me:3419: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3366: \"$ac_try\"") >&5 + { (eval echo "$as_me:3422: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3369: \$? = $ac_status" >&5 + echo "$as_me:3425: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_XOPEN_SOURCE_set=yes else @@ -3375,12 +3431,12 @@ cat conftest.$ac_ext >&5 cf_XOPEN_SOURCE_set=no fi rm -f conftest.$ac_objext conftest.$ac_ext - echo "$as_me:3378: result: $cf_XOPEN_SOURCE_set" >&5 + echo "$as_me:3434: result: $cf_XOPEN_SOURCE_set" >&5 echo "${ECHO_T}$cf_XOPEN_SOURCE_set" >&6 if test $cf_XOPEN_SOURCE_set = yes then cat >conftest.$ac_ext <<_ACEOF -#line 3383 "configure" +#line 3439 "configure" #include "confdefs.h" #include int @@ -3395,16 +3451,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3398: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3454: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3401: \$? = $ac_status" >&5 + echo "$as_me:3457: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3404: \"$ac_try\"") >&5 + { (eval echo "$as_me:3460: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3407: \$? = $ac_status" >&5 + echo "$as_me:3463: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_XOPEN_SOURCE_set_ok=yes else @@ -3415,19 +3471,19 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext if test $cf_XOPEN_SOURCE_set_ok = no then - { echo "$as_me:3418: WARNING: _XOPEN_SOURCE is lower than requested" >&5 + { echo "$as_me:3474: WARNING: _XOPEN_SOURCE is lower than requested" >&5 echo "$as_me: WARNING: _XOPEN_SOURCE is lower than requested" >&2;} fi else -echo "$as_me:3423: checking if we should define _XOPEN_SOURCE" >&5 +echo "$as_me:3479: checking if we should define _XOPEN_SOURCE" >&5 echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6 if test "${cf_cv_xopen_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 3430 "configure" +#line 3486 "configure" #include "confdefs.h" #include @@ -3446,16 +3502,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3449: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3505: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3452: \$? = $ac_status" >&5 + echo "$as_me:3508: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3455: \"$ac_try\"") >&5 + { (eval echo "$as_me:3511: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3458: \$? = $ac_status" >&5 + echo "$as_me:3514: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_xopen_source=no else @@ -3464,7 +3520,7 @@ cat conftest.$ac_ext >&5 cf_save="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" cat >conftest.$ac_ext <<_ACEOF -#line 3467 "configure" +#line 3523 "configure" #include "confdefs.h" #include @@ -3483,16 +3539,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3486: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3542: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3489: \$? = $ac_status" >&5 + echo "$as_me:3545: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3492: \"$ac_try\"") >&5 + { (eval echo "$as_me:3548: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3495: \$? = $ac_status" >&5 + echo "$as_me:3551: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_xopen_source=no else @@ -3507,7 +3563,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:3510: result: $cf_cv_xopen_source" >&5 +echo "$as_me:3566: result: $cf_cv_xopen_source" >&5 echo "${ECHO_T}$cf_cv_xopen_source" >&6 if test "$cf_cv_xopen_source" != no ; then @@ -3611,7 +3667,7 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_main_return=return -echo "$as_me:3614: checking how to run the C preprocessor" >&5 +echo "$as_me:3670: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then @@ -3632,18 +3688,18 @@ do # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF -#line 3635 "configure" +#line 3691 "configure" #include "confdefs.h" #include Syntax error _ACEOF -if { (eval echo "$as_me:3640: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:3696: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:3646: \$? = $ac_status" >&5 + echo "$as_me:3702: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -3666,17 +3722,17 @@ rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF -#line 3669 "configure" +#line 3725 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:3673: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:3729: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:3679: \$? = $ac_status" >&5 + echo "$as_me:3735: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -3713,7 +3769,7 @@ fi else ac_cv_prog_CPP=$CPP fi -echo "$as_me:3716: result: $CPP" >&5 +echo "$as_me:3772: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6 ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes @@ -3723,18 +3779,18 @@ do # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF -#line 3726 "configure" +#line 3782 "configure" #include "confdefs.h" #include Syntax error _ACEOF -if { (eval echo "$as_me:3731: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:3787: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:3737: \$? = $ac_status" >&5 + echo "$as_me:3793: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -3757,17 +3813,17 @@ rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF -#line 3760 "configure" +#line 3816 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:3764: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:3820: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:3770: \$? = $ac_status" >&5 + echo "$as_me:3826: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -3795,7 +3851,7 @@ rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else - { { echo "$as_me:3798: error: C preprocessor \"$CPP\" fails sanity check" >&5 + { { echo "$as_me:3854: error: C preprocessor \"$CPP\" fails sanity check" >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;} { (exit 1); exit 1; }; } fi @@ -3810,23 +3866,23 @@ ac_main_return=return for ac_header in fcntl.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:3813: checking for $ac_header" >&5 +echo "$as_me:3869: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 3819 "configure" +#line 3875 "configure" #include "confdefs.h" #include <$ac_header> _ACEOF -if { (eval echo "$as_me:3823: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:3879: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:3829: \$? = $ac_status" >&5 + echo "$as_me:3885: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -3845,7 +3901,7 @@ else fi rm -f conftest.err conftest.$ac_ext fi -echo "$as_me:3848: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "$as_me:3904: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <&5 +echo "$as_me:3914: checking for working mkstemp" >&5 echo $ECHO_N "checking for working mkstemp... $ECHO_C" >&6 if test "${cf_cv_func_mkstemp+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -3866,7 +3922,7 @@ if test "$cross_compiling" = yes; then cf_cv_func_mkstemp=maybe else cat >conftest.$ac_ext <<_ACEOF -#line 3869 "configure" +#line 3925 "configure" #include "confdefs.h" #include @@ -3904,15 +3960,15 @@ int main() _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:3907: \"$ac_link\"") >&5 +if { (eval echo "$as_me:3963: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:3910: \$? = $ac_status" >&5 + echo "$as_me:3966: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:3912: \"$ac_try\"") >&5 + { (eval echo "$as_me:3968: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3915: \$? = $ac_status" >&5 + echo "$as_me:3971: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cf_cv_func_mkstemp=yes @@ -3927,16 +3983,16 @@ rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi -echo "$as_me:3930: result: $cf_cv_func_mkstemp" >&5 +echo "$as_me:3986: result: $cf_cv_func_mkstemp" >&5 echo "${ECHO_T}$cf_cv_func_mkstemp" >&6 if test "x$cf_cv_func_mkstemp" = xmaybe ; then - echo "$as_me:3933: checking for mkstemp" >&5 + echo "$as_me:3989: checking for mkstemp" >&5 echo $ECHO_N "checking for mkstemp... $ECHO_C" >&6 if test "${ac_cv_func_mkstemp+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 3939 "configure" +#line 3995 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char mkstemp (); below. */ @@ -3967,16 +4023,16 @@ f = mkstemp; /* workaround for ICC 12.0.3 */ if (f == 0) return 1; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:3970: \"$ac_link\"") >&5 +if { (eval echo "$as_me:4026: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:3973: \$? = $ac_status" >&5 + echo "$as_me:4029: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:3976: \"$ac_try\"") >&5 + { (eval echo "$as_me:4032: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3979: \$? = $ac_status" >&5 + echo "$as_me:4035: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_mkstemp=yes else @@ -3986,7 +4042,7 @@ ac_cv_func_mkstemp=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:3989: result: $ac_cv_func_mkstemp" >&5 +echo "$as_me:4045: result: $ac_cv_func_mkstemp" >&5 echo "${ECHO_T}$ac_cv_func_mkstemp" >&6 fi @@ -4001,13 +4057,13 @@ fi for ac_func in vsnprintf do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:4004: checking for $ac_func" >&5 +echo "$as_me:4060: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 4010 "configure" +#line 4066 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. */ @@ -4038,16 +4094,16 @@ f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:4041: \"$ac_link\"") >&5 +if { (eval echo "$as_me:4097: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:4044: \$? = $ac_status" >&5 + echo "$as_me:4100: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:4047: \"$ac_try\"") >&5 + { (eval echo "$as_me:4103: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4050: \$? = $ac_status" >&5 + echo "$as_me:4106: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else @@ -4057,7 +4113,7 @@ eval "$as_ac_var=no" fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:4060: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "$as_me:4116: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <&5 +echo "$as_me:4126: checking for maximum table size" >&5 echo $ECHO_N "checking for maximum table size... $ECHO_C" >&6 # Check whether --with-max-table-size or --without-max-table-size was given. @@ -4077,12 +4133,12 @@ if test "${with_max_table_size+set}" = set; then fi; if test -n "$with_max_table_size" then - echo "$as_me:4080: result: $with_max_table_size" >&5 + echo "$as_me:4136: result: $with_max_table_size" >&5 echo "${ECHO_T}$with_max_table_size" >&6 check=`expr "$with_max_table_size" + 0` if test "x$check" != "x$with_max_table_size" then - { { echo "$as_me:4085: error: invalid value for --with-max-table-size: $with_max_table_size" >&5 + { { echo "$as_me:4141: error: invalid value for --with-max-table-size: $with_max_table_size" >&5 echo "$as_me: error: invalid value for --with-max-table-size: $with_max_table_size" >&2;} { (exit 1); exit 1; }; } fi @@ -4092,11 +4148,11 @@ cat >>confdefs.h <&5 + echo "$as_me:4151: result: default" >&5 echo "${ECHO_T}default" >&6 fi -echo "$as_me:4099: checking if backtracking extension is wanted" >&5 +echo "$as_me:4155: checking if backtracking extension is wanted" >&5 echo $ECHO_N "checking if backtracking extension is wanted... $ECHO_C" >&6 # Check whether --enable-btyacc or --disable-btyacc was given. @@ -4104,7 +4160,7 @@ if test "${enable_btyacc+set}" = set; then enableval="$enable_btyacc" fi; -echo "$as_me:4107: result: $enable_btyacc" >&5 +echo "$as_me:4163: result: $enable_btyacc" >&5 echo "${ECHO_T}$enable_btyacc" >&6 if test "$enable_btyacc" = "yes"; then @@ -4119,7 +4175,7 @@ fi if ( test "$GCC" = yes || test "$GXX" = yes ) then -echo "$as_me:4122: checking if you want to check for gcc warnings" >&5 +echo "$as_me:4178: checking if you want to check for gcc warnings" >&5 echo $ECHO_N "checking if you want to check for gcc warnings... $ECHO_C" >&6 # Check whether --with-warnings or --without-warnings was given. @@ -4129,7 +4185,7 @@ if test "${with_warnings+set}" = set; then else cf_opt_with_warnings=no fi; -echo "$as_me:4132: result: $cf_opt_with_warnings" >&5 +echo "$as_me:4188: result: $cf_opt_with_warnings" >&5 echo "${ECHO_T}$cf_opt_with_warnings" >&6 if test "$cf_opt_with_warnings" != no ; then @@ -4151,10 +4207,10 @@ cat > conftest.i <&5 + { echo "$as_me:4210: checking for $CC __attribute__ directives..." >&5 echo "$as_me: checking for $CC __attribute__ directives..." >&6;} cat > conftest.$ac_ext <&5 + if { (eval echo "$as_me:4262: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4209: \$? = $ac_status" >&5 + echo "$as_me:4265: \$? = $ac_status" >&5 (exit $ac_status); }; then - test -n "$verbose" && echo "$as_me:4211: result: ... $cf_attribute" >&5 + test -n "$verbose" && echo "$as_me:4267: result: ... $cf_attribute" >&5 echo "${ECHO_T}... $cf_attribute" >&6 cat conftest.h >>confdefs.h case $cf_attribute in @@ -4272,12 +4328,12 @@ INTEL_COMPILER=no if test "$GCC" = yes ; then case $host_os in (linux*|gnu*) - echo "$as_me:4275: checking if this is really Intel C compiler" >&5 + echo "$as_me:4331: checking if this is really Intel C compiler" >&5 echo $ECHO_N "checking if this is really Intel C compiler... $ECHO_C" >&6 cf_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -no-gcc" cat >conftest.$ac_ext <<_ACEOF -#line 4280 "configure" +#line 4336 "configure" #include "confdefs.h" int @@ -4294,16 +4350,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:4297: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4353: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4300: \$? = $ac_status" >&5 + echo "$as_me:4356: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:4303: \"$ac_try\"") >&5 + { (eval echo "$as_me:4359: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4306: \$? = $ac_status" >&5 + echo "$as_me:4362: \$? = $ac_status" >&5 (exit $ac_status); }; }; then INTEL_COMPILER=yes cf_save_CFLAGS="$cf_save_CFLAGS -we147" @@ -4314,7 +4370,7 @@ cat conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest.$ac_ext CFLAGS="$cf_save_CFLAGS" - echo "$as_me:4317: result: $INTEL_COMPILER" >&5 + echo "$as_me:4373: result: $INTEL_COMPILER" >&5 echo "${ECHO_T}$INTEL_COMPILER" >&6 ;; esac @@ -4323,12 +4379,12 @@ fi CLANG_COMPILER=no if test "$GCC" = yes ; then - echo "$as_me:4326: checking if this is really Clang C compiler" >&5 + echo "$as_me:4382: checking if this is really Clang C compiler" >&5 echo $ECHO_N "checking if this is really Clang C compiler... $ECHO_C" >&6 cf_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Qunused-arguments" cat >conftest.$ac_ext <<_ACEOF -#line 4331 "configure" +#line 4387 "configure" #include "confdefs.h" int @@ -4345,16 +4401,16 @@ make an error } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:4348: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4404: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4351: \$? = $ac_status" >&5 + echo "$as_me:4407: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:4354: \"$ac_try\"") >&5 + { (eval echo "$as_me:4410: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4357: \$? = $ac_status" >&5 + echo "$as_me:4413: \$? = $ac_status" >&5 (exit $ac_status); }; }; then CLANG_COMPILER=yes cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments" @@ -4365,12 +4421,12 @@ cat conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest.$ac_ext CFLAGS="$cf_save_CFLAGS" - echo "$as_me:4368: result: $CLANG_COMPILER" >&5 + echo "$as_me:4424: result: $CLANG_COMPILER" >&5 echo "${ECHO_T}$CLANG_COMPILER" >&6 fi cat > conftest.$ac_ext <&5 + { echo "$as_me:4446: checking for $CC warning options..." >&5 echo "$as_me: checking for $CC warning options..." >&6;} cf_save_CFLAGS="$CFLAGS" EXTRA_CFLAGS="-Wall" @@ -4403,12 +4459,12 @@ echo "$as_me: checking for $CC warning options..." >&6;} wd981 do CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt" - if { (eval echo "$as_me:4406: \"$ac_compile\"") >&5 + if { (eval echo "$as_me:4462: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4409: \$? = $ac_status" >&5 + echo "$as_me:4465: \$? = $ac_status" >&5 (exit $ac_status); }; then - test -n "$verbose" && echo "$as_me:4411: result: ... -$cf_opt" >&5 + test -n "$verbose" && echo "$as_me:4467: result: ... -$cf_opt" >&5 echo "${ECHO_T}... -$cf_opt" >&6 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt" fi @@ -4417,7 +4473,7 @@ echo "${ECHO_T}... -$cf_opt" >&6 elif test "$GCC" = yes then - { echo "$as_me:4420: checking for $CC warning options..." >&5 + { echo "$as_me:4476: checking for $CC warning options..." >&5 echo "$as_me: checking for $CC warning options..." >&6;} cf_save_CFLAGS="$CFLAGS" EXTRA_CFLAGS= @@ -4441,12 +4497,12 @@ echo "$as_me: checking for $CC warning options..." >&6;} Wundef $cf_gcc_warnings $cf_warn_CONST Wwrite-strings do CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt" - if { (eval echo "$as_me:4444: \"$ac_compile\"") >&5 + if { (eval echo "$as_me:4500: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4447: \$? = $ac_status" >&5 + echo "$as_me:4503: \$? = $ac_status" >&5 (exit $ac_status); }; then - test -n "$verbose" && echo "$as_me:4449: result: ... -$cf_opt" >&5 + test -n "$verbose" && echo "$as_me:4505: result: ... -$cf_opt" >&5 echo "${ECHO_T}... -$cf_opt" >&6 case $cf_opt in (Wcast-qual) @@ -4457,7 +4513,7 @@ echo "${ECHO_T}... -$cf_opt" >&6 ([34].*) test -n "$verbose" && echo " feature is broken in gcc $GCC_VERSION" 1>&6 -echo "${as_me:-configure}:4460: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 +echo "${as_me:-configure}:4516: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 continue;; esac @@ -4467,7 +4523,7 @@ echo "${as_me:-configure}:4460: testing feature is broken in gcc $GCC_VERSION .. ([12].*) test -n "$verbose" && echo " feature is broken in gcc $GCC_VERSION" 1>&6 -echo "${as_me:-configure}:4470: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 +echo "${as_me:-configure}:4526: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 continue;; esac @@ -4483,7 +4539,7 @@ rm -rf conftest* fi fi -echo "$as_me:4486: checking if you want to see long compiling messages" >&5 +echo "$as_me:4542: checking if you want to see long compiling messages" >&5 echo $ECHO_N "checking if you want to see long compiling messages... $ECHO_C" >&6 # Check whether --enable-echo or --disable-echo was given. @@ -4517,10 +4573,10 @@ else ECHO_CC='' fi; -echo "$as_me:4520: result: $enableval" >&5 +echo "$as_me:4576: result: $enableval" >&5 echo "${ECHO_T}$enableval" >&6 -echo "$as_me:4523: checking if you want to use dmalloc for testing" >&5 +echo "$as_me:4579: checking if you want to use dmalloc for testing" >&5 echo $ECHO_N "checking if you want to use dmalloc for testing... $ECHO_C" >&6 # Check whether --with-dmalloc or --without-dmalloc was given. @@ -4537,7 +4593,7 @@ EOF else with_dmalloc= fi; -echo "$as_me:4540: result: ${with_dmalloc:-no}" >&5 +echo "$as_me:4596: result: ${with_dmalloc:-no}" >&5 echo "${ECHO_T}${with_dmalloc:-no}" >&6 case .$with_cflags in @@ -4631,23 +4687,23 @@ fi esac if test "$with_dmalloc" = yes ; then - echo "$as_me:4634: checking for dmalloc.h" >&5 + echo "$as_me:4690: checking for dmalloc.h" >&5 echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6 if test "${ac_cv_header_dmalloc_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 4640 "configure" +#line 4696 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:4644: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4700: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:4650: \$? = $ac_status" >&5 + echo "$as_me:4706: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -4666,11 +4722,11 @@ else fi rm -f conftest.err conftest.$ac_ext fi -echo "$as_me:4669: result: $ac_cv_header_dmalloc_h" >&5 +echo "$as_me:4725: result: $ac_cv_header_dmalloc_h" >&5 echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6 if test $ac_cv_header_dmalloc_h = yes; then -echo "$as_me:4673: checking for dmalloc_debug in -ldmalloc" >&5 +echo "$as_me:4729: checking for dmalloc_debug in -ldmalloc" >&5 echo $ECHO_N "checking for dmalloc_debug in -ldmalloc... $ECHO_C" >&6 if test "${ac_cv_lib_dmalloc_dmalloc_debug+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4678,7 +4734,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ldmalloc $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 4681 "configure" +#line 4737 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -4697,16 +4753,16 @@ dmalloc_debug (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:4700: \"$ac_link\"") >&5 +if { (eval echo "$as_me:4756: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:4703: \$? = $ac_status" >&5 + echo "$as_me:4759: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:4706: \"$ac_try\"") >&5 + { (eval echo "$as_me:4762: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4709: \$? = $ac_status" >&5 + echo "$as_me:4765: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dmalloc_dmalloc_debug=yes else @@ -4717,7 +4773,7 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:4720: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5 +echo "$as_me:4776: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5 echo "${ECHO_T}$ac_cv_lib_dmalloc_dmalloc_debug" >&6 if test $ac_cv_lib_dmalloc_dmalloc_debug = yes; then cat >>confdefs.h <&5 +echo "$as_me:4791: checking if you want to use dbmalloc for testing" >&5 echo $ECHO_N "checking if you want to use dbmalloc for testing... $ECHO_C" >&6 # Check whether --with-dbmalloc or --without-dbmalloc was given. @@ -4749,7 +4805,7 @@ EOF else with_dbmalloc= fi; -echo "$as_me:4752: result: ${with_dbmalloc:-no}" >&5 +echo "$as_me:4808: result: ${with_dbmalloc:-no}" >&5 echo "${ECHO_T}${with_dbmalloc:-no}" >&6 case .$with_cflags in @@ -4843,23 +4899,23 @@ fi esac if test "$with_dbmalloc" = yes ; then - echo "$as_me:4846: checking for dbmalloc.h" >&5 + echo "$as_me:4902: checking for dbmalloc.h" >&5 echo $ECHO_N "checking for dbmalloc.h... $ECHO_C" >&6 if test "${ac_cv_header_dbmalloc_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 4852 "configure" +#line 4908 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:4856: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4912: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:4862: \$? = $ac_status" >&5 + echo "$as_me:4918: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -4878,11 +4934,11 @@ else fi rm -f conftest.err conftest.$ac_ext fi -echo "$as_me:4881: result: $ac_cv_header_dbmalloc_h" >&5 +echo "$as_me:4937: result: $ac_cv_header_dbmalloc_h" >&5 echo "${ECHO_T}$ac_cv_header_dbmalloc_h" >&6 if test $ac_cv_header_dbmalloc_h = yes; then -echo "$as_me:4885: checking for debug_malloc in -ldbmalloc" >&5 +echo "$as_me:4941: checking for debug_malloc in -ldbmalloc" >&5 echo $ECHO_N "checking for debug_malloc in -ldbmalloc... $ECHO_C" >&6 if test "${ac_cv_lib_dbmalloc_debug_malloc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4890,7 +4946,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ldbmalloc $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 4893 "configure" +#line 4949 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -4909,16 +4965,16 @@ debug_malloc (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:4912: \"$ac_link\"") >&5 +if { (eval echo "$as_me:4968: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:4915: \$? = $ac_status" >&5 + echo "$as_me:4971: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:4918: \"$ac_try\"") >&5 + { (eval echo "$as_me:4974: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4921: \$? = $ac_status" >&5 + echo "$as_me:4977: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dbmalloc_debug_malloc=yes else @@ -4929,7 +4985,7 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:4932: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5 +echo "$as_me:4988: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5 echo "${ECHO_T}$ac_cv_lib_dbmalloc_debug_malloc" >&6 if test $ac_cv_lib_dbmalloc_debug_malloc = yes; then cat >>confdefs.h <&5 +echo "$as_me:5003: checking if you want to use valgrind for testing" >&5 echo $ECHO_N "checking if you want to use valgrind for testing... $ECHO_C" >&6 # Check whether --with-valgrind or --without-valgrind was given. @@ -4961,7 +5017,7 @@ EOF else with_valgrind= fi; -echo "$as_me:4964: result: ${with_valgrind:-no}" >&5 +echo "$as_me:5020: result: ${with_valgrind:-no}" >&5 echo "${ECHO_T}${with_valgrind:-no}" >&6 case .$with_cflags in @@ -5054,7 +5110,7 @@ fi ;; esac -echo "$as_me:5057: checking if you want to perform memory-leak testing" >&5 +echo "$as_me:5113: checking if you want to perform memory-leak testing" >&5 echo $ECHO_N "checking if you want to perform memory-leak testing... $ECHO_C" >&6 # Check whether --enable-leaks or --disable-leaks was given. @@ -5064,7 +5120,7 @@ if test "${enable_leaks+set}" = set; then else : ${with_no_leaks:=no} fi; -echo "$as_me:5067: result: $with_no_leaks" >&5 +echo "$as_me:5123: result: $with_no_leaks" >&5 echo "${ECHO_T}$with_no_leaks" >&6 if test "$with_no_leaks" = yes ; then @@ -5081,7 +5137,7 @@ fi # Extract the first word of "groff", so it can be a program name with args. set dummy groff; ac_word=$2 -echo "$as_me:5084: checking for $ac_word" >&5 +echo "$as_me:5140: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_GROFF_PATH+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -5098,7 +5154,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_GROFF_PATH="$ac_dir/$ac_word" - echo "$as_me:5101: found $ac_dir/$ac_word" >&5 + echo "$as_me:5157: found $ac_dir/$ac_word" >&5 break fi done @@ -5110,16 +5166,16 @@ fi GROFF_PATH=$ac_cv_path_GROFF_PATH if test -n "$GROFF_PATH"; then - echo "$as_me:5113: result: $GROFF_PATH" >&5 + echo "$as_me:5169: result: $GROFF_PATH" >&5 echo "${ECHO_T}$GROFF_PATH" >&6 else - echo "$as_me:5116: result: no" >&5 + echo "$as_me:5172: result: no" >&5 echo "${ECHO_T}no" >&6 fi # Extract the first word of "nroff", so it can be a program name with args. set dummy nroff; ac_word=$2 -echo "$as_me:5122: checking for $ac_word" >&5 +echo "$as_me:5178: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_NROFF_PATH+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -5136,7 +5192,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_NROFF_PATH="$ac_dir/$ac_word" - echo "$as_me:5139: found $ac_dir/$ac_word" >&5 + echo "$as_me:5195: found $ac_dir/$ac_word" >&5 break fi done @@ -5148,10 +5204,10 @@ fi NROFF_PATH=$ac_cv_path_NROFF_PATH if test -n "$NROFF_PATH"; then - echo "$as_me:5151: result: $NROFF_PATH" >&5 + echo "$as_me:5207: result: $NROFF_PATH" >&5 echo "${ECHO_T}$NROFF_PATH" >&6 else - echo "$as_me:5154: result: no" >&5 + echo "$as_me:5210: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -5164,7 +5220,7 @@ else GROFF_NOTE= fi -echo "$as_me:5167: checking for program to convert manpage to html" >&5 +echo "$as_me:5223: checking for program to convert manpage to html" >&5 echo $ECHO_N "checking for program to convert manpage to html... $ECHO_C" >&6 # Check whether --with-man2html or --without-man2html was given. @@ -5179,11 +5235,11 @@ cf_with_groff=no case $cf_man2html in (yes) - echo "$as_me:5182: result: man2html" >&5 + echo "$as_me:5238: result: man2html" >&5 echo "${ECHO_T}man2html" >&6 # Extract the first word of "man2html", so it can be a program name with args. set dummy man2html; ac_word=$2 -echo "$as_me:5186: checking for $ac_word" >&5 +echo "$as_me:5242: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_cf_man2html+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -5200,7 +5256,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_cf_man2html="$ac_dir/$ac_word" - echo "$as_me:5203: found $ac_dir/$ac_word" >&5 + echo "$as_me:5259: found $ac_dir/$ac_word" >&5 break fi done @@ -5212,10 +5268,10 @@ fi cf_man2html=$ac_cv_path_cf_man2html if test -n "$cf_man2html"; then - echo "$as_me:5215: result: $cf_man2html" >&5 + echo "$as_me:5271: result: $cf_man2html" >&5 echo "${ECHO_T}$cf_man2html" >&6 else - echo "$as_me:5218: result: no" >&5 + echo "$as_me:5274: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -5223,11 +5279,11 @@ fi (no|groff|*/groff*) cf_with_groff=yes cf_man2html=$GROFF_PATH - echo "$as_me:5226: result: $cf_man2html" >&5 + echo "$as_me:5282: result: $cf_man2html" >&5 echo "${ECHO_T}$cf_man2html" >&6 ;; (*) - echo "$as_me:5230: result: $cf_man2html" >&5 + echo "$as_me:5286: result: $cf_man2html" >&5 echo "${ECHO_T}$cf_man2html" >&6 ;; esac @@ -5291,14 +5347,14 @@ case ".$cf_man2html" in cf_man2html=`echo $cf_man2html | sed -e s%NONE%$cf_path_syntax%` ;; (*) - { { echo "$as_me:5294: error: expected a pathname, not \"$cf_man2html\"" >&5 + { { echo "$as_me:5350: error: expected a pathname, not \"$cf_man2html\"" >&5 echo "$as_me: error: expected a pathname, not \"$cf_man2html\"" >&2;} { (exit 1); exit 1; }; } ;; esac MAN2HTML_PATH="$cf_man2html" - echo "$as_me:5301: checking for $cf_man2html top/bottom margins" >&5 + echo "$as_me:5357: checking for $cf_man2html top/bottom margins" >&5 echo $ECHO_N "checking for $cf_man2html top/bottom margins... $ECHO_C" >&6 # for this example, expect 3 lines of content, the remainder is head/foot @@ -5316,10 +5372,10 @@ CF_EOF cf_man2html_bot=`expr $cf_man2html_bot - 2 - $cf_man2html_top` cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot" - echo "$as_me:5319: result: $cf_man2html_top_bot" >&5 + echo "$as_me:5375: result: $cf_man2html_top_bot" >&5 echo "${ECHO_T}$cf_man2html_top_bot" >&6 - echo "$as_me:5322: checking for pagesize to use" >&5 + echo "$as_me:5378: checking for pagesize to use" >&5 echo $ECHO_N "checking for pagesize to use... $ECHO_C" >&6 for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do @@ -5344,7 +5400,7 @@ CF_EOF test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999 rm -rf conftest* - echo "$as_me:5347: result: $cf_man2html_page" >&5 + echo "$as_me:5403: result: $cf_man2html_page" >&5 echo "${ECHO_T}$cf_man2html_page" >&6 cat >>$MAN2HTML_TEMP <&5 +echo "$as_me:5422: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 5372 "configure" +#line 5428 "configure" #include "confdefs.h" #include #include @@ -5377,13 +5433,13 @@ else #include _ACEOF -if { (eval echo "$as_me:5380: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:5436: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:5386: \$? = $ac_status" >&5 + echo "$as_me:5442: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -5405,7 +5461,7 @@ rm -f conftest.err conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF -#line 5408 "configure" +#line 5464 "configure" #include "confdefs.h" #include @@ -5423,7 +5479,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF -#line 5426 "configure" +#line 5482 "configure" #include "confdefs.h" #include @@ -5444,7 +5500,7 @@ if test $ac_cv_header_stdc = yes; then : else cat >conftest.$ac_ext <<_ACEOF -#line 5447 "configure" +#line 5503 "configure" #include "confdefs.h" #include #if ((' ' & 0x0FF) == 0x020) @@ -5470,15 +5526,15 @@ main () } _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:5473: \"$ac_link\"") >&5 +if { (eval echo "$as_me:5529: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:5476: \$? = $ac_status" >&5 + echo "$as_me:5532: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:5478: \"$ac_try\"") >&5 + { (eval echo "$as_me:5534: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:5481: \$? = $ac_status" >&5 + echo "$as_me:5537: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -5491,7 +5547,7 @@ rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi -echo "$as_me:5494: result: $ac_cv_header_stdc" >&5 +echo "$as_me:5550: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6 if test $ac_cv_header_stdc = yes; then @@ -5507,28 +5563,28 @@ for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:5510: checking for $ac_header" >&5 +echo "$as_me:5566: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 5516 "configure" +#line 5572 "configure" #include "confdefs.h" $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:5522: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:5578: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:5525: \$? = $ac_status" >&5 + echo "$as_me:5581: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:5528: \"$ac_try\"") >&5 + { (eval echo "$as_me:5584: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:5531: \$? = $ac_status" >&5 + echo "$as_me:5587: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_Header=yes" else @@ -5538,7 +5594,7 @@ eval "$as_ac_Header=no" fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:5541: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "$as_me:5597: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <&5 +echo "$as_me:5607: checking for mode_t" >&5 echo $ECHO_N "checking for mode_t... $ECHO_C" >&6 if test "${ac_cv_type_mode_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 5557 "configure" +#line 5613 "configure" #include "confdefs.h" $ac_includes_default int @@ -5569,16 +5625,16 @@ if (sizeof (mode_t)) } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:5572: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:5628: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:5575: \$? = $ac_status" >&5 + echo "$as_me:5631: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:5578: \"$ac_try\"") >&5 + { (eval echo "$as_me:5634: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:5581: \$? = $ac_status" >&5 + echo "$as_me:5637: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_type_mode_t=yes else @@ -5588,7 +5644,7 @@ ac_cv_type_mode_t=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:5591: result: $ac_cv_type_mode_t" >&5 +echo "$as_me:5647: result: $ac_cv_type_mode_t" >&5 echo "${ECHO_T}$ac_cv_type_mode_t" >&6 if test $ac_cv_type_mode_t = yes; then : @@ -5681,7 +5737,7 @@ DEFS=-DHAVE_CONFIG_H : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ echo "$as_me:5684: creating $CONFIG_STATUS" >&5 +{ echo "$as_me:5740: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL @@ -5854,7 +5910,7 @@ cat >>$CONFIG_STATUS <<\EOF echo "$ac_cs_version"; exit 0 ;; --he | --h) # Conflict between --help and --header - { { echo "$as_me:5857: error: ambiguous option: $1 + { { echo "$as_me:5913: error: ambiguous option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2;} @@ -5873,7 +5929,7 @@ Try \`$0 --help' for more information." >&2;} ac_need_defaults=false;; # This is an error. - -*) { { echo "$as_me:5876: error: unrecognized option: $1 + -*) { { echo "$as_me:5932: error: unrecognized option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2;} @@ -5910,7 +5966,7 @@ do # Handling of arguments. "makefile" ) CONFIG_FILES="$CONFIG_FILES makefile" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h:config_h.in" ;; - *) { { echo "$as_me:5913: error: invalid argument: $ac_config_target" >&5 + *) { { echo "$as_me:5969: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac @@ -6171,7 +6227,7 @@ done; } esac if test x"$ac_file" != x-; then - { echo "$as_me:6174: creating $ac_file" >&5 + { echo "$as_me:6230: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} rm -f "$ac_file" fi @@ -6189,7 +6245,7 @@ echo "$as_me: creating $ac_file" >&6;} -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:6192: error: cannot find input file: $f" >&5 + test -f "$f" || { { echo "$as_me:6248: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; @@ -6202,7 +6258,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;} echo $srcdir/$f else # /dev/null tree - { { echo "$as_me:6205: error: cannot find input file: $f" >&5 + { { echo "$as_me:6261: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; @@ -6218,7 +6274,7 @@ cat >>$CONFIG_STATUS <<\EOF if test -n "$ac_seen"; then ac_used=`grep '@datarootdir@' $ac_item` if test -z "$ac_used"; then - { echo "$as_me:6221: WARNING: datarootdir was used implicitly but not set: + { echo "$as_me:6277: WARNING: datarootdir was used implicitly but not set: $ac_seen" >&5 echo "$as_me: WARNING: datarootdir was used implicitly but not set: $ac_seen" >&2;} @@ -6227,7 +6283,7 @@ $ac_seen" >&2;} fi ac_seen=`grep '${datarootdir}' $ac_item` if test -n "$ac_seen"; then - { echo "$as_me:6230: WARNING: datarootdir was used explicitly but not set: + { echo "$as_me:6286: WARNING: datarootdir was used explicitly but not set: $ac_seen" >&5 echo "$as_me: WARNING: datarootdir was used explicitly but not set: $ac_seen" >&2;} @@ -6264,7 +6320,7 @@ s,@INSTALL@,$ac_INSTALL,;t t ac_init=`egrep '[ ]*'$ac_name'[ ]*=' $ac_file` if test -z "$ac_init"; then ac_seen=`echo "$ac_seen" |sed -e 's,^,'$ac_file':,'` - { echo "$as_me:6267: WARNING: Variable $ac_name is used but was not set: + { echo "$as_me:6323: WARNING: Variable $ac_name is used but was not set: $ac_seen" >&5 echo "$as_me: WARNING: Variable $ac_name is used but was not set: $ac_seen" >&2;} @@ -6275,7 +6331,7 @@ $ac_seen" >&2;} egrep -n '@[A-Z_][A-Z_0-9]+@' $ac_file >>$tmp/out if test -s $tmp/out; then ac_seen=`sed -e 's,^,'$ac_file':,' < $tmp/out` - { echo "$as_me:6278: WARNING: Some variables may not be substituted: + { echo "$as_me:6334: WARNING: Some variables may not be substituted: $ac_seen" >&5 echo "$as_me: WARNING: Some variables may not be substituted: $ac_seen" >&2;} @@ -6324,7 +6380,7 @@ for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue * ) ac_file_in=$ac_file.in ;; esac - test x"$ac_file" != x- && { echo "$as_me:6327: creating $ac_file" >&5 + test x"$ac_file" != x- && { echo "$as_me:6383: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} # First look for the input files in the build tree, otherwise in the @@ -6335,7 +6391,7 @@ echo "$as_me: creating $ac_file" >&6;} -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:6338: error: cannot find input file: $f" >&5 + test -f "$f" || { { echo "$as_me:6394: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; @@ -6348,7 +6404,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;} echo $srcdir/$f else # /dev/null tree - { { echo "$as_me:6351: error: cannot find input file: $f" >&5 + { { echo "$as_me:6407: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; @@ -6466,7 +6522,7 @@ cat >>$CONFIG_STATUS <<\EOF rm -f $tmp/in if test x"$ac_file" != x-; then if cmp -s $ac_file $tmp/config.h 2>/dev/null; then - { echo "$as_me:6469: $ac_file is unchanged" >&5 + { echo "$as_me:6525: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ diff --git a/defs.h b/defs.h index aacc954c130..1fbd672688d 100644 --- a/defs.h +++ b/defs.h @@ -1,4 +1,4 @@ -/* $Id: defs.h,v 1.52 2016/06/01 22:56:37 Tom.Shields Exp $ */ +/* $Id: defs.h,v 1.54 2016/12/02 19:27:56 tom Exp $ */ #ifdef HAVE_CONFIG_H #include @@ -118,10 +118,13 @@ #define LEX_PARAM 14 #define POSIX_YACC 15 #define TOKEN_TABLE 16 +#define ERROR_VERBOSE 17 +#define XXXDEBUG 18 #if defined(YYBTYACC) -#define LOCATIONS 17 -#define DESTRUCTOR 18 +#define LOCATIONS 19 +#define DESTRUCTOR 20 +#define INITIAL_ACTION 21 #endif /* symbol classes */ @@ -198,7 +201,7 @@ struct bucket #if defined(YYBTYACC) char **argnames; char **argtags; - int args; + int args; char *destructor; #endif Value_t value; @@ -287,10 +290,12 @@ extern int outline; extern int exit_code; extern int pure_parser; extern int token_table; +extern int error_verbose; #if defined(YYBTYACC) extern int locations; extern int backtrack; extern int destructor; +extern char *initial_action; #endif extern const char *const banner[]; @@ -303,6 +308,7 @@ extern const char *const hdr_vars[]; extern const char *const body_1[]; extern const char *const body_vars[]; extern const char *const body_2[]; +extern const char *const body_3[]; extern const char *const trailer[]; extern char *code_file_name; @@ -412,22 +418,29 @@ extern param *parse_param; #endif #ifndef GCC_PRINTFLIKE -#define GCC_PRINTFLIKE(fmt,var) /*nothing*/ +#define GCC_PRINTFLIKE(fmt,var) /*nothing */ #endif /* closure.c */ -extern void closure(Value_t * nucleus, int n); +extern void closure(Value_t *nucleus, int n); extern void finalize_closure(void); extern void set_first_derives(void); /* error.c */ +struct ainfo +{ + int a_lineno; + char *a_line; + char *a_cptr; +}; + extern void arg_number_disagree_warning(int a_lineno, char *a_name); extern void arg_type_disagree_warning(int a_lineno, int i, char *a_name); extern void at_error(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; extern void at_warning(int a_lineno, int i); extern void bad_formals(void) GCC_NORETURN; extern void default_action_warning(char *s); -extern void destructor_redeclared_warning(int a_lineno, char *a_line, char *a_cptr); +extern void destructor_redeclared_warning(const struct ainfo *); extern void dollar_error(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; extern void dollar_warning(int a_lineno, int i); extern void fatal(const char *msg) GCC_NORETURN; @@ -454,16 +467,16 @@ extern void unexpected_EOF(void) GCC_NORETURN; extern void unknown_arg_warning(int d_lineno, const char *dlr_opt, const char *d_arg, const char *d_line, const char *d_cptr); extern void unknown_rhs(int i) GCC_NORETURN; extern void unsupported_flag_warning(const char *flag, const char *details); -extern void unterminated_action(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; -extern void unterminated_comment(int c_lineno, char *c_line, char *c_cptr) GCC_NORETURN; -extern void unterminated_string(int s_lineno, char *s_line, char *s_cptr) GCC_NORETURN; -extern void unterminated_text(int t_lineno, char *t_line, char *t_cptr) GCC_NORETURN; -extern void unterminated_union(int u_lineno, char *u_line, char *u_cptr) GCC_NORETURN; +extern void unterminated_action(const struct ainfo *) GCC_NORETURN; +extern void unterminated_comment(const struct ainfo *) GCC_NORETURN; +extern void unterminated_string(const struct ainfo *) GCC_NORETURN; +extern void unterminated_text(const struct ainfo *) GCC_NORETURN; +extern void unterminated_union(const struct ainfo *) GCC_NORETURN; extern void untyped_arg_warning(int a_lineno, const char *dlr_opt, const char *a_name); extern void untyped_lhs(void) GCC_NORETURN; extern void untyped_rhs(int i, char *s) GCC_NORETURN; extern void used_reserved(char *s) GCC_NORETURN; -extern void unterminated_arglist(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; +extern void unterminated_arglist(const struct ainfo *) GCC_NORETURN; extern void wrong_number_args_warning(const char *which, const char *a_name); extern void wrong_type_for_arg_warning(int i, char *a_name); diff --git a/error.c b/error.c index dd626353f45..07dc89417cb 100644 --- a/error.c +++ b/error.c @@ -1,4 +1,4 @@ -/* $Id: error.c,v 1.13 2016/06/07 00:15:16 tom Exp $ */ +/* $Id: error.c,v 1.14 2016/12/02 18:35:55 tom Exp $ */ /* routines for printing error messages */ @@ -77,38 +77,38 @@ syntax_error(int st_lineno, char *st_line, char *st_cptr) } void -unterminated_comment(int c_lineno, char *c_line, char *c_cptr) +unterminated_comment(const struct ainfo *a) { fprintf(stderr, "%s: e - line %d of \"%s\", unmatched /*\n", - myname, c_lineno, input_file_name); - print_pos(c_line, c_cptr); + myname, a->a_lineno, input_file_name); + print_pos(a->a_line, a->a_cptr); done(1); } void -unterminated_string(int s_lineno, char *s_line, char *s_cptr) +unterminated_string(const struct ainfo *a) { fprintf(stderr, "%s: e - line %d of \"%s\", unterminated string\n", - myname, s_lineno, input_file_name); - print_pos(s_line, s_cptr); + myname, a->a_lineno, input_file_name); + print_pos(a->a_line, a->a_cptr); done(1); } void -unterminated_text(int t_lineno, char *t_line, char *t_cptr) +unterminated_text(const struct ainfo *a) { fprintf(stderr, "%s: e - line %d of \"%s\", unmatched %%{\n", - myname, t_lineno, input_file_name); - print_pos(t_line, t_cptr); + myname, a->a_lineno, input_file_name); + print_pos(a->a_line, a->a_cptr); done(1); } void -unterminated_union(int u_lineno, char *u_line, char *u_cptr) +unterminated_union(const struct ainfo *a) { fprintf(stderr, "%s: e - line %d of \"%s\", unterminated %%union \ -declaration\n", myname, u_lineno, input_file_name); - print_pos(u_line, u_cptr); +declaration\n", myname, a->a_lineno, input_file_name); + print_pos(a->a_line, a->a_cptr); done(1); } @@ -218,11 +218,11 @@ specifiers\n", myname, lineno, input_file_name); } void -unterminated_action(int a_lineno, char *a_line, char *a_cptr) +unterminated_action(const struct ainfo *a) { fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n", - myname, a_lineno, input_file_name); - print_pos(a_line, a_cptr); + myname, a->a_lineno, input_file_name); + print_pos(a->a_line, a->a_cptr); done(1); } @@ -316,12 +316,12 @@ at_error(int a_lineno, char *a_line, char *a_cptr) } void -unterminated_arglist(int a_lineno, char *a_line, char *a_cptr) +unterminated_arglist(const struct ainfo *a) { fprintf(stderr, "%s: e - line %d of \"%s\", unterminated argument list\n", - myname, a_lineno, input_file_name); - print_pos(a_line, a_cptr); + myname, a->a_lineno, input_file_name); + print_pos(a->a_line, a->a_cptr); done(1); } @@ -394,10 +394,10 @@ start_requires_args(char *a_name) } void -destructor_redeclared_warning(int a_lineno, char *a_line, char *a_cptr) +destructor_redeclared_warning(const struct ainfo *a) { fprintf(stderr, "%s: w - line %d of \"%s\", destructor redeclared\n", - myname, a_lineno, input_file_name); - print_pos(a_line, a_cptr); + myname, a->a_lineno, input_file_name); + print_pos(a->a_line, a->a_cptr); } #endif diff --git a/main.c b/main.c index 37889c3ff8f..137df206811 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.56 2016/03/25 00:16:28 Jung-uk.Kim Exp $ */ +/* $Id: main.c,v 1.57 2016/12/02 18:44:44 tom Exp $ */ #include #ifndef _WIN32 @@ -92,6 +92,7 @@ char *symbol_assoc; int pure_parser; int token_table; +int error_verbose; #if defined(YYBTYACC) Value_t *symbol_pval; @@ -99,6 +100,7 @@ char **symbol_destructor; char **symbol_type_tag; int locations = 0; /* default to no position processing */ int backtrack = 0; /* default is no backtracking */ +char *initial_action = NULL; #endif int exit_code; diff --git a/mstring.c b/mstring.c index dc384e5a385..3bdb122973a 100644 --- a/mstring.c +++ b/mstring.c @@ -1,4 +1,4 @@ -/* $Id: mstring.c,v 1.6 2014/04/22 23:36:31 tom Exp $ */ +/* $Id: mstring.c,v 1.7 2016/12/02 17:57:21 tom Exp $ */ #include #include @@ -157,20 +157,20 @@ strnscmp(const char *a, const char *b) { while (1) { - while (isspace(*a)) + while (isspace(UCH(*a))) a++; - while (isspace(*b)) + while (isspace(UCH(*b))) b++; while (*a && *a == *b) a++, b++; - if (isspace(*a)) + if (isspace(UCH(*a))) { - if (isalnum(a[-1]) && isalnum(*b)) + if (isalnum(UCH(a[-1])) && isalnum(UCH(*b))) break; } - else if (isspace(*b)) + else if (isspace(UCH(*b))) { - if (isalnum(b[-1]) && isalnum(*a)) + if (isalnum(UCH(b[-1])) && isalnum(UCH(*a))) break; } else @@ -186,7 +186,7 @@ strnshash(const char *s) while (*s) { - if (!isspace(*s)) + if (!isspace(UCH(*s))) h = (h << 5) - h + (unsigned char)*s; s++; } diff --git a/output.c b/output.c index 8b6d8b2dd31..0f5194a76bc 100644 --- a/output.c +++ b/output.c @@ -1,4 +1,4 @@ -/* $Id: output.c,v 1.76 2016/06/07 00:14:34 tom Exp $ */ +/* $Id: output.c,v 1.79 2016/12/02 20:42:38 tom Exp $ */ #include "defs.h" @@ -234,6 +234,43 @@ end_table(void) output_line("};"); } +static void +output_stype(FILE * fp) +{ + if (!unionized && ntags == 0) + { + putc_code(fp, '\n'); + putl_code(fp, "#if " + "! defined(YYSTYPE) && " + "! defined(YYSTYPE_IS_DECLARED)\n"); + putl_code(fp, "/* Default: YYSTYPE is the semantic value type. */\n"); + putl_code(fp, "typedef int YYSTYPE;\n"); + putl_code(fp, "# define YYSTYPE_IS_DECLARED 1\n"); + putl_code(fp, "#endif\n"); + } +} + +#if defined(YYBTYACC) +static void +output_ltype(FILE * fp) +{ + putc_code(fp, '\n'); + putl_code(fp, "#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED\n"); + putl_code(fp, "/* Default: YYLTYPE is the text position type. */\n"); + putl_code(fp, "typedef struct YYLTYPE\n"); + putl_code(fp, "{\n"); + putl_code(fp, " int first_line;\n"); + putl_code(fp, " int first_column;\n"); + putl_code(fp, " int last_line;\n"); + putl_code(fp, " int last_column;\n"); + putl_code(fp, " unsigned source;\n"); + putl_code(fp, "} YYLTYPE;\n"); + putl_code(fp, "#define YYLTYPE_IS_DECLARED 1\n"); + putl_code(fp, "#endif\n"); + putl_code(fp, "#define YYRHSLOC(rhs, k) ((rhs)[k])\n"); +} +#endif + static void output_YYINT_typedef(FILE * fp) { @@ -329,6 +366,8 @@ output_accessing_symbols(void) translate[i] = symbol_pval[gsymb]; } + putl_code(output_file, + "#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)\n"); /* yystos[] may be unused, depending on compile-time defines */ start_int_table("stos", translate[0]); @@ -348,6 +387,8 @@ output_accessing_symbols(void) end_table(); FREE(translate); + putl_code(output_file, + "#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */\n"); } } @@ -1220,6 +1261,10 @@ output_defines(FILE * fp) } fprintf(fp, "extern YYSTYPE %slval;\n", symbol_prefix); } +#if defined(YYBTYACC) + if (locations) + output_ltype(fp); +#endif } } @@ -1539,41 +1584,6 @@ output_pure_parser(FILE * fp) putc_code(fp, '\n'); } -static void -output_stype(FILE * fp) -{ - if (!unionized && ntags == 0) - { - putc_code(fp, '\n'); - putl_code(fp, "#if " - "! defined(YYSTYPE) && " - "! defined(YYSTYPE_IS_DECLARED)\n"); - putl_code(fp, "/* Default: YYSTYPE is the semantic value type. */\n"); - putl_code(fp, "typedef int YYSTYPE;\n"); - putl_code(fp, "# define YYSTYPE_IS_DECLARED 1\n"); - putl_code(fp, "#endif\n"); - } -} - -#if defined(YYBTYACC) -static void -output_ltype(FILE * fp) -{ - putc_code(fp, '\n'); - putl_code(fp, "#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED\n"); - putl_code(fp, "/* Default: YYLTYPE is the text position type. */\n"); - putl_code(fp, "typedef struct YYLTYPE\n"); - putl_code(fp, "{\n"); - putl_code(fp, " int first_line;\n"); - putl_code(fp, " int first_column;\n"); - putl_code(fp, " int last_line;\n"); - putl_code(fp, " int last_column;\n"); - putl_code(fp, "} YYLTYPE;\n"); - putl_code(fp, "#define YYLTYPE_IS_DECLARED 1\n"); - putl_code(fp, "#endif\n"); -} -#endif - static void output_trailing_text(void) { @@ -1781,7 +1791,7 @@ output_error_decl(FILE * fp) puts_code(fp, "#define YYERROR_DECL() yyerror("); #if defined(YYBTYACC) if (locations) - puts_code(fp, "YYLTYPE loc, "); + puts_code(fp, "YYLTYPE *loc, "); #endif puts_param_types(fp, parse_param, 1); putl_code(fp, "const char *s)\n"); @@ -1792,7 +1802,7 @@ output_error_decl(FILE * fp) puts_code(fp, "#define YYERROR_CALL(msg) yyerror("); #if defined(YYBTYACC) if (locations) - puts_code(fp, "yylloc, "); + puts_code(fp, "&yylloc, "); #endif puts_param_names(fp, parse_param, 1); putl_code(fp, "msg)\n"); @@ -1845,6 +1855,13 @@ output_yydestruct_decl(FILE * fp) putl_code(fp, "#endif\n"); } +static void +output_initial_action(void) +{ + if (initial_action) + fprintf(code_file, "%s\n", initial_action); +} + static void output_yydestruct_impl(void) { @@ -2051,6 +2068,11 @@ output(void) write_section(code_file, body_vars); } write_section(code_file, body_2); +#if defined(YYBTYACC) + if (initial_action) + output_initial_action(); +#endif + write_section(code_file, body_3); output_semantic_actions(); write_section(code_file, trailer); } diff --git a/package/byacc.spec b/package/byacc.spec index 219bdfca1a4..2106a356a98 100644 --- a/package/byacc.spec +++ b/package/byacc.spec @@ -1,8 +1,8 @@ Summary: byacc - public domain Berkeley LALR Yacc parser generator %define AppProgram byacc -%define AppVersion 20160606 +%define AppVersion 20161202 %define UseProgram yacc -# $XTermId: byacc.spec,v 1.31 2016/06/07 00:44:26 tom Exp $ +# $XTermId: byacc.spec,v 1.32 2016/12/02 12:58:46 tom Exp $ Name: %{AppProgram} Version: %{AppVersion} Release: 1 diff --git a/package/debian/changelog b/package/debian/changelog index 25dde429680..b30984d1a96 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,3 +1,9 @@ +byacc (20161202) unstable; urgency=low + + * maintenance updates + + -- Thomas E. Dickey Fri, 02 Dec 2016 07:58:46 -0500 + byacc (20160606) unstable; urgency=low * maintenance updates diff --git a/package/mingw-byacc.spec b/package/mingw-byacc.spec index 86bbf891932..6ea04c1d1d0 100644 --- a/package/mingw-byacc.spec +++ b/package/mingw-byacc.spec @@ -1,8 +1,8 @@ Summary: byacc - public domain Berkeley LALR Yacc parser generator %define AppProgram byacc -%define AppVersion 20160606 +%define AppVersion 20161202 %define UseProgram yacc -# $XTermId: mingw-byacc.spec,v 1.13 2016/06/07 00:44:26 tom Exp $ +# $XTermId: mingw-byacc.spec,v 1.14 2016/12/02 12:58:46 tom Exp $ Name: %{AppProgram} Version: %{AppVersion} Release: 1 diff --git a/package/pkgsrc/Makefile b/package/pkgsrc/Makefile index bff3d5194e5..877117d710d 100644 --- a/package/pkgsrc/Makefile +++ b/package/pkgsrc/Makefile @@ -1,7 +1,7 @@ # $NetBSD: Makefile,v 1.9 2008/07/24 17:13:00 tonnerre Exp $ # -DISTNAME= byacc-20160606 +DISTNAME= byacc-20161202 PKGREVISION= 1 CATEGORIES= devel MASTER_SITES= ftp://invisible-island.net/byacc/ diff --git a/reader.c b/reader.c index 0f305059c94..333ee0c83dc 100644 --- a/reader.c +++ b/reader.c @@ -1,4 +1,4 @@ -/* $Id: reader.c,v 1.63 2016/06/07 00:17:51 tom Exp $ */ +/* $Id: reader.c,v 1.66 2016/12/02 20:14:34 tom Exp $ */ #include "defs.h" @@ -22,6 +22,7 @@ static void start_rule(bucket *bp, int s_lineno); #if defined(YYBTYACC) +static void copy_initial_action(void); static void copy_destructor(void); static char *process_destructor_XX(char *code, char *tag); #endif @@ -185,10 +186,10 @@ static void skip_comment(void) { char *s; - - int st_lineno = lineno; - char *st_line = dup_line(); - char *st_cptr = st_line + (cptr - line); + struct ainfo a; + a.a_lineno = lineno; + a.a_line = dup_line(); + a.a_cptr = a.a_line + (cptr - line); s = cptr + 2; for (;;) @@ -196,14 +197,14 @@ skip_comment(void) if (*s == '*' && s[1] == '/') { cptr = s + 2; - FREE(st_line); + FREE(a.a_line); return; } if (*s == '\n') { get_line(); if (line == NULL) - unterminated_comment(st_lineno, st_line, st_cptr); + unterminated_comment(&a); s = cptr; } else @@ -290,17 +291,22 @@ nextc(void) /* *INDENT-OFF* */ static struct keyword { - char name[13]; + char name[14]; int token; } keywords[] = { { "binary", NONASSOC }, + { "debug", XXXDEBUG }, #if defined(YYBTYACC) { "destructor", DESTRUCTOR }, #endif + { "error-verbose",ERROR_VERBOSE }, { "expect", EXPECT }, { "expect-rr", EXPECT_RR }, { "ident", IDENT }, +#if defined(YYBTYACC) + { "initial-action", INITIAL_ACTION }, +#endif { "left", LEFT }, { "lex-param", LEX_PARAM }, #if defined(YYBTYACC) @@ -428,9 +434,10 @@ copy_string(int quote) { struct mstring *temp = msnew(); int c; - int s_lineno = lineno; - char *s_line = dup_line(); - char *s_cptr = s_line + (cptr - line - 1); + struct ainfo a; + a.a_lineno = lineno; + a.a_line = dup_line(); + a.a_cptr = a.a_line + (cptr - line - 1); for (;;) { @@ -438,11 +445,11 @@ copy_string(int quote) mputc(temp, c); if (c == quote) { - FREE(s_line); + FREE(a.a_line); return msdone(temp); } if (c == '\n') - unterminated_string(s_lineno, s_line, s_cptr); + unterminated_string(&a); if (c == '\\') { c = *cptr++; @@ -451,7 +458,7 @@ copy_string(int quote) { get_line(); if (line == NULL) - unterminated_string(s_lineno, s_line, s_cptr); + unterminated_string(&a); } } } @@ -478,9 +485,10 @@ copy_comment(void) } else if (c == '*') { - int c_lineno = lineno; - char *c_line = dup_line(); - char *c_cptr = c_line + (cptr - line - 1); + struct ainfo a; + a.a_lineno = lineno; + a.a_line = dup_line(); + a.a_cptr = a.a_line + (cptr - line - 1); mputc(temp, c); ++cptr; @@ -492,14 +500,14 @@ copy_comment(void) { mputc(temp, '/'); ++cptr; - FREE(c_line); + FREE(a.a_line); return msdone(temp); } if (c == '\n') { get_line(); if (line == NULL) - unterminated_comment(c_lineno, c_line, c_cptr); + unterminated_comment(&a); } } } @@ -512,15 +520,16 @@ copy_text(void) int c; FILE *f = text_file; int need_newline = 0; - int t_lineno = lineno; - char *t_line = dup_line(); - char *t_cptr = t_line + (cptr - line - 2); + struct ainfo a; + a.a_lineno = lineno; + a.a_line = dup_line(); + a.a_cptr = a.a_line + (cptr - line - 2); if (*cptr == '\n') { get_line(); if (line == NULL) - unterminated_text(t_lineno, t_line, t_cptr); + unterminated_text(&a); } if (!lflag) fprintf(f, line_format, lineno, input_file_name); @@ -535,7 +544,7 @@ copy_text(void) get_line(); if (line) goto loop; - unterminated_text(t_lineno, t_line, t_cptr); + unterminated_text(&a); case '\'': case '"': @@ -565,7 +574,7 @@ copy_text(void) if (need_newline) putc('\n', f); ++cptr; - FREE(t_line); + FREE(a.a_line); return; } /* FALLTHRU */ @@ -598,9 +607,10 @@ copy_union(void) { int c; int depth; - int u_lineno = lineno; - char *u_line = dup_line(); - char *u_cptr = u_line + (cptr - line - 6); + struct ainfo a; + a.a_lineno = lineno; + a.a_line = dup_line(); + a.a_cptr = a.a_line + (cptr - line - 6); if (unionized) over_unionized(cptr - 6); @@ -626,7 +636,7 @@ copy_union(void) case '\n': get_line(); if (line == NULL) - unterminated_union(u_lineno, u_line, u_cptr); + unterminated_union(&a); goto loop; case L_CURL: @@ -638,7 +648,7 @@ copy_union(void) { puts_both(" YYSTYPE;\n"); puts_both("#endif /* !YYSTYPE_IS_DECLARED */\n"); - FREE(u_line); + FREE(a.a_line); return; } goto loop; @@ -897,7 +907,7 @@ copy_param(int k) goto oops; } - buf[i--] = '\0'; + buf[++i] = '\0'; (void)trim_blanks(buf); comma = buf - 1; @@ -974,9 +984,10 @@ get_literal(void) int n; char *s; bucket *bp; - int s_lineno = lineno; - char *s_line = dup_line(); - char *s_cptr = s_line + (cptr - line); + struct ainfo a; + a.a_lineno = lineno; + a.a_line = dup_line(); + a.a_cptr = a.a_line + (cptr - line); quote = *cptr++; cinc = 0; @@ -986,7 +997,7 @@ get_literal(void) if (c == quote) break; if (c == '\n') - unterminated_string(s_lineno, s_line, s_cptr); + unterminated_string(&a); if (c == '\\') { char *c_cptr = cptr - 1; @@ -997,7 +1008,7 @@ get_literal(void) case '\n': get_line(); if (line == NULL) - unterminated_string(s_lineno, s_line, s_cptr); + unterminated_string(&a); continue; case '0': @@ -1069,7 +1080,7 @@ get_literal(void) } cachec(c); } - FREE(s_line); + FREE(a.a_line); n = cinc; s = TMALLOC(char, n); @@ -1269,7 +1280,7 @@ scan_id(void) { char *b = cptr; - while (isalnum(*cptr) || *cptr == '_' || *cptr == '$') + while (isalnum(UCH(*cptr)) || *cptr == '_' || *cptr == '$') cptr++; return cache_tag(b, (size_t) (cptr - b)); } @@ -1562,6 +1573,10 @@ read_declarations(void) token_table = 1; break; + case ERROR_VERBOSE: + error_verbose = 1; + break; + #if defined(YYBTYACC) case LOCATIONS: locations = 1; @@ -1571,8 +1586,15 @@ read_declarations(void) destructor = 1; copy_destructor(); break; + case INITIAL_ACTION: + copy_initial_action(); + break; #endif + case XXXDEBUG: + /* XXX: FIXME */ + break; + case POSIX_YACC: /* noop for bison compatibility. byacc is already designed to be posix * yacc compatible. */ @@ -1654,9 +1676,11 @@ copy_args(int *alen) struct mstring *s = msnew(); int depth = 0, len = 1; char c, quote = 0; - int a_lineno = lineno; - char *a_line = dup_line(); - char *a_cptr = a_line + (cptr - line - 1); + struct ainfo a; + + a.a_lineno = lineno; + a.a_line = dup_line(); + a.a_cptr = a.a_line + (cptr - line - 1); while ((c = *cptr++) != R_PAREN || depth || quote) { @@ -1673,9 +1697,9 @@ copy_args(int *alen) if (!line) { if (quote) - unterminated_string(a_lineno, a_line, a_cptr); + unterminated_string(&a); else - unterminated_arglist(a_lineno, a_line, a_cptr); + unterminated_arglist(&a); } } else if (quote) @@ -1700,7 +1724,7 @@ copy_args(int *alen) } if (alen) *alen = len; - FREE(a_line); + FREE(a.a_line); return msdone(s); } @@ -1709,13 +1733,13 @@ parse_id(char *p, char **save) { char *b; - while (isspace(*p)) + while (isspace(UCH(*p))) if (*p++ == '\n') rescan_lineno++; - if (!isalpha(*p) && *p != '_') + if (!isalpha(UCH(*p)) && *p != '_') return NULL; b = p; - while (isalnum(*p) || *p == '_' || *p == '$') + while (isalnum(UCH(*p)) || *p == '_' || *p == '$') p++; if (save) { @@ -1729,7 +1753,7 @@ parse_int(char *p, int *save) { int neg = 0, val = 0; - while (isspace(*p)) + while (isspace(UCH(*p))) if (*p++ == '\n') rescan_lineno++; if (*p == '-') @@ -1737,9 +1761,9 @@ parse_int(char *p, int *save) neg = 1; p++; } - if (!isdigit(*p)) + if (!isdigit(UCH(*p))) return NULL; - while (isdigit(*p)) + while (isdigit(UCH(*p))) val = val * 10 + *p++ - '0'; if (neg) val = -val; @@ -1773,12 +1797,12 @@ parse_arginfo(bucket *a, char *args, int argslen) return; for (i = 0; i < argslen; i++) { - while (isspace(*p)) + while (isspace(UCH(*p))) if (*p++ == '\n') rescan_lineno++; if (*p++ != '$') bad_formals(); - while (isspace(*p)) + while (isspace(UCH(*p))) if (*p++ == '\n') rescan_lineno++; if (*p == '<') @@ -1786,7 +1810,7 @@ parse_arginfo(bucket *a, char *args, int argslen) havetags = 1; if (!(p = parse_id(p + 1, &tmp))) bad_formals(); - while (isspace(*p)) + while (isspace(UCH(*p))) if (*p++ == '\n') rescan_lineno++; if (*p++ != '>') @@ -1803,7 +1827,7 @@ parse_arginfo(bucket *a, char *args, int argslen) a->argtags[i] = NULL; if (!(p = parse_id(p, &a->argnames[i]))) bad_formals(); - while (isspace(*p)) + while (isspace(UCH(*p))) if (*p++ == '\n') rescan_lineno++; if (*p++) @@ -1852,7 +1876,7 @@ compile_arg(char **theptr, char *yyvaltag) if (*++p == '<') if (!(p = parse_id(++p, &tag)) || *p++ != '>') illegal_tag(rescan_lineno, NULL, NULL); - if (isdigit(*p) || *p == '-') + if (isdigit(UCH(*p)) || *p == '-') { int val; if (!(p = parse_int(p, &val))) @@ -1876,7 +1900,7 @@ compile_arg(char **theptr, char *yyvaltag) else if (havetags) unknown_rhs(val); } - else if (isalpha(*p) || *p == '_') + else if (isalpha(UCH(*p)) || *p == '_') { char *arg; if (!(p = parse_id(p, &arg))) @@ -1949,7 +1973,7 @@ can_elide_arg(char **theptr, char *yyvaltag) } rhs = pitem + nitems - 1; - if (isdigit(*p) || *p == '-') + if (isdigit(UCH(*p)) || *p == '-') { int val; if (!(p = parse_int(p, &val))) @@ -1969,7 +1993,7 @@ can_elide_arg(char **theptr, char *yyvaltag) } } } - else if (isalpha(*p) || *p == '_') + else if (isalpha(UCH(*p)) || *p == '_') { char *arg; if (!(p = parse_id(p, &arg))) @@ -2337,12 +2361,14 @@ copy_action(void) #endif char *tag; FILE *f = action_file; - int a_lineno = lineno; - char *a_line = dup_line(); - char *a_cptr = a_line + (cptr - line); + struct ainfo a; Value_t *offsets = NULL, maxoffset; bucket **rhs; + a.a_lineno = lineno; + a.a_line = dup_line(); + a.a_cptr = a.a_line + (cptr - line); + if (last_was_action) insert_empty_rule(); last_was_action = 1; @@ -2509,7 +2535,7 @@ copy_action(void) goto loop; } #if defined(YYBTYACC) - else if (isalpha(cptr[1]) || cptr[1] == '_') + else if (isalpha(UCH(cptr[1])) || cptr[1] == '_') { char *arg; ++cptr; @@ -2607,7 +2633,7 @@ copy_action(void) goto loop; } fprintf(f, "\nbreak;\n"); - FREE(a_line); + FREE(a.a_line); if (maxoffset > 0) FREE(offsets); return; @@ -2621,13 +2647,13 @@ copy_action(void) get_line(); if (line) goto loop; - unterminated_action(a_lineno, a_line, a_cptr); + unterminated_action(&a); case ';': if (depth > 0) goto loop; fprintf(f, "\nbreak;\n"); - FREE(a_line); + free(a.a_line); if (maxoffset > 0) FREE(offsets); return; @@ -2670,7 +2696,7 @@ copy_action(void) } #endif fprintf(f, "\nbreak;\n"); - FREE(a_line); + free(a.a_line); if (maxoffset > 0) FREE(offsets); return; @@ -2698,32 +2724,27 @@ copy_action(void) } #if defined(YYBTYACC) -static void -copy_destructor(void) +static char * +get_code(struct ainfo *a, const char *loc) { int c; int depth; char *tag; - bucket *bp; - struct mstring *destructor_text = msnew(); - char *code_text; - int a_lineno; - char *a_line; - char *a_cptr; + struct mstring *code_mstr = msnew(); if (!lflag) - msprintf(destructor_text, line_format, lineno, input_file_name); + msprintf(code_mstr, line_format, lineno, input_file_name); cptr = after_blanks(cptr); if (*cptr == L_CURL) /* avoid putting curly-braces in first column, to ease editing */ - mputc(destructor_text, '\t'); + mputc(code_mstr, '\t'); else syntax_error(lineno, line, cptr); - a_lineno = lineno; - a_line = dup_line(); - a_cptr = a_line + (cptr - line); + a->a_lineno = lineno; + a->a_line = dup_line(); + a->a_cptr = a->a_line + (cptr - line); depth = 0; loop: @@ -2741,7 +2762,7 @@ copy_destructor(void) c = *cptr; if (c == '$') { - msprintf(destructor_text, "(*val).%s", tag); + msprintf(code_mstr, "(*val).%s", tag); ++cptr; FREE(d_line); goto loop; @@ -2752,7 +2773,7 @@ copy_destructor(void) else if (cptr[1] == '$') { /* process '$$' later; replacement is context dependent */ - msprintf(destructor_text, "$$"); + msprintf(code_mstr, "$$"); cptr += 2; goto loop; } @@ -2766,7 +2787,7 @@ copy_destructor(void) char *l_cptr = l_line + (cptr - line); syntax_error(l_lineno, l_line, l_cptr); } - msprintf(destructor_text, "(*loc)"); + msprintf(code_mstr, "%s", loc); cptr += 2; goto loop; } @@ -2774,21 +2795,21 @@ copy_destructor(void) { do { - mputc(destructor_text, c); + mputc(code_mstr, c); c = *++cptr; } while (isalnum(c) || c == '_' || c == '$'); goto loop; } ++cptr; - mputc(destructor_text, c); + mputc(code_mstr, c); switch (c) { case '\n': get_line(); if (line) goto loop; - unterminated_action(a_lineno, a_line, a_cptr); + unterminated_action(a); case L_CURL: ++depth; @@ -2797,13 +2818,13 @@ copy_destructor(void) case R_CURL: if (--depth > 0) goto loop; - goto process_symbols; + goto out; case '\'': case '"': { char *s = copy_string(c); - msprintf(destructor_text, "%s", s); + msprintf(code_mstr, "%s", s); free(s); } goto loop; @@ -2811,7 +2832,7 @@ copy_destructor(void) case '/': { char *s = copy_comment(); - msprintf(destructor_text, "%s", s); + msprintf(code_mstr, "%s", s); free(s); } goto loop; @@ -2819,8 +2840,29 @@ copy_destructor(void) default: goto loop; } - process_symbols: - code_text = msdone(destructor_text); + out: + return msdone(code_mstr); +} + +static void +copy_initial_action(void) +{ + struct ainfo a; + + initial_action = get_code(&a, "yyloc"); + free(a.a_line); +} + +static void +copy_destructor(void) +{ + char *code_text; + int c; + struct ainfo a; + bucket *bp; + + code_text = get_code(&a, "(*loc)"); + for (;;) { c = nextc(); @@ -2839,7 +2881,7 @@ copy_destructor(void) default_destructor[UNTYPED_DEFAULT] = bp; } if (bp->destructor != NULL) - destructor_redeclared_warning(a_lineno, a_line, a_cptr); + destructor_redeclared_warning(&a); else /* replace "$$" with "(*val)" in destructor code */ bp->destructor = process_destructor_XX(code_text, NULL); @@ -2855,7 +2897,7 @@ copy_destructor(void) default_destructor[TYPED_DEFAULT] = bp; } if (bp->destructor != NULL) - destructor_redeclared_warning(a_lineno, a_line, a_cptr); + destructor_redeclared_warning(&a); else { /* postpone re-processing destructor $$s until end of grammar spec */ @@ -2866,10 +2908,10 @@ copy_destructor(void) } else { /* "semantic type" default destructor */ - tag = get_tag(); + char *tag = get_tag(); bp = lookup_type_destructor(tag); if (bp->destructor != NULL) - destructor_redeclared_warning(a_lineno, a_line, a_cptr); + destructor_redeclared_warning(&a); else /* replace "$$" with "(*val).tag" in destructor code */ bp->destructor = process_destructor_XX(code_text, tag); @@ -2879,7 +2921,7 @@ copy_destructor(void) { /* "symbol" destructor */ bp = get_name(); if (bp->destructor != NULL) - destructor_redeclared_warning(a_lineno, a_line, a_cptr); + destructor_redeclared_warning(&a); else { /* postpone re-processing destructor $$s until end of grammar spec */ @@ -2891,7 +2933,7 @@ copy_destructor(void) else break; } - free(a_line); + free(a.a_line); free(code_text); } diff --git a/test/btyacc/btyacc_calc1.tab.c b/test/btyacc/btyacc_calc1.tab.c index 17e7962609d..d6463602908 100644 --- a/test/btyacc/btyacc_calc1.tab.c +++ b/test/btyacc/btyacc_calc1.tab.c @@ -215,6 +215,7 @@ static const YYINT calc1_defred[] = { 1, 0, 24, 0, 26, 0, 0, 23, 25, 14, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 17, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT calc1_stos[] = { 0, 262, 256, 257, 258, 259, 45, 40, 263, 264, 265, 10, 61, 61, 257, 258, 263, 264, 263, 264, 43, @@ -223,6 +224,7 @@ static const YYINT calc1_stos[] = { 0, 263, 264, 263, 264, 264, 264, 264, 264, 263, 263, 43, 45, 42, 47, 263, 263, 263, 263, 263, 41, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT calc1_dgoto[] = { 1, 32, 9, 10, }; @@ -613,7 +615,7 @@ vdiv(double a, double b, INTERVAL v) { return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); } -#line 617 "btyacc_calc1.tab.c" +#line 619 "btyacc_calc1.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -792,9 +794,9 @@ YYPARSE_DECL() #endif /* Current position at lexical token queue */ - static short *yylexp = 0; + static YYINT *yylexp = 0; - static short *yylexemes = 0; + static YYINT *yylexemes = 0; #endif /* YYBTYACC */ int yym, yyn, yystate, yyresult; #if YYBTYACC @@ -866,10 +868,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -879,7 +881,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -980,7 +982,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1004,7 +1006,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1523,7 +1525,7 @@ case 28: yyval.vval = yystack.l_mark[-1].vval; } break; -#line 1527 "btyacc_calc1.tab.c" +#line 1529 "btyacc_calc1.tab.c" default: break; } @@ -1578,12 +1580,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1594,7 +1596,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/btyacc_demo.tab.c b/test/btyacc/btyacc_demo.tab.c index 0954a4039fe..618da35f5b6 100644 --- a/test/btyacc/btyacc_demo.tab.c +++ b/test/btyacc/btyacc_demo.tab.c @@ -173,9 +173,11 @@ typedef struct YYLTYPE int first_column; int last_line; int last_column; + unsigned source; } YYLTYPE; #define YYLTYPE_IS_DECLARED 1 #endif +#define YYRHSLOC(rhs, k) ((rhs)[k]) /* compatibility with bison */ #ifdef YYPARSE_PARAM @@ -200,10 +202,10 @@ typedef struct YYLTYPE /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(YYLTYPE loc, const char *s) +#define YYERROR_DECL() yyerror(YYLTYPE *loc, const char *s) #endif #ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(yylloc, msg) +#define YYERROR_CALL(msg) yyerror(&yylloc, msg) #endif #ifndef YYDESTRUCT_DECL @@ -258,6 +260,7 @@ static const YYINT demo_defred[] = { 5, 45, 44, 0, 0, 49, 58, 0, 30, 50, 56, 0, 0, 0, 51, 0, 0, 52, 0, 53, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT demo_stos[] = { 0, 271, 289, 275, 290, 261, 262, 263, 264, 265, 269, 273, 281, 282, 283, 285, 286, 42, 40, 259, 274, @@ -270,6 +273,7 @@ static const YYINT demo_stos[] = { 0, 272, 272, 266, 272, 273, 276, 298, 40, 59, 278, 294, 272, 41, 267, 296, 276, 268, 297, 276, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT demo_dgoto[] = { 1, 84, 85, 20, 3, 86, 66, 40, 21, 44, 12, 13, 14, 24, 15, 16, 46, 47, 2, 22, 30, @@ -624,9 +628,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 200 "btyacc_demo.y" @@ -656,7 +660,7 @@ extern Expr * var_expr(Scope *scope, char *id); extern Code * build_expr_code(Expr *expr); extern Code * build_if(Expr *cond_expr, Code *then_stmt, Code *else_stmt); extern Code * code_append(Code *stmt_list, Code *stmt); -#line 660 "btyacc_demo.tab.c" +#line 664 "btyacc_demo.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED @@ -673,7 +677,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 677 "btyacc_demo.tab.c" +#line 681 "btyacc_demo.tab.c" case 45: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -682,7 +686,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 686 "btyacc_demo.tab.c" +#line 690 "btyacc_demo.tab.c" case 42: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -691,7 +695,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 695 "btyacc_demo.tab.c" +#line 699 "btyacc_demo.tab.c" case 47: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -700,7 +704,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 704 "btyacc_demo.tab.c" +#line 708 "btyacc_demo.tab.c" case 37: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -709,7 +713,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 713 "btyacc_demo.tab.c" +#line 717 "btyacc_demo.tab.c" case 257: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -718,7 +722,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 722 "btyacc_demo.tab.c" +#line 726 "btyacc_demo.tab.c" case 258: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -727,7 +731,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 731 "btyacc_demo.tab.c" +#line 735 "btyacc_demo.tab.c" case 40: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -736,7 +740,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 740 "btyacc_demo.tab.c" +#line 744 "btyacc_demo.tab.c" case 91: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -745,7 +749,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 749 "btyacc_demo.tab.c" +#line 753 "btyacc_demo.tab.c" case 46: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -754,7 +758,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 758 "btyacc_demo.tab.c" +#line 762 "btyacc_demo.tab.c" case 259: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -763,7 +767,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).id); } break; -#line 767 "btyacc_demo.tab.c" +#line 771 "btyacc_demo.tab.c" case 260: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -772,7 +776,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).expr); } break; -#line 776 "btyacc_demo.tab.c" +#line 780 "btyacc_demo.tab.c" case 261: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -781,7 +785,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 785 "btyacc_demo.tab.c" +#line 789 "btyacc_demo.tab.c" case 262: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -790,7 +794,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 794 "btyacc_demo.tab.c" +#line 798 "btyacc_demo.tab.c" case 263: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -799,7 +803,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 803 "btyacc_demo.tab.c" +#line 807 "btyacc_demo.tab.c" case 264: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -808,7 +812,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 812 "btyacc_demo.tab.c" +#line 816 "btyacc_demo.tab.c" case 265: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -817,7 +821,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 821 "btyacc_demo.tab.c" +#line 825 "btyacc_demo.tab.c" case 266: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -826,7 +830,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 830 "btyacc_demo.tab.c" +#line 834 "btyacc_demo.tab.c" case 267: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -835,7 +839,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 839 "btyacc_demo.tab.c" +#line 843 "btyacc_demo.tab.c" case 268: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -844,7 +848,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 848 "btyacc_demo.tab.c" +#line 852 "btyacc_demo.tab.c" case 269: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -853,7 +857,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 857 "btyacc_demo.tab.c" +#line 861 "btyacc_demo.tab.c" case 59: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -862,7 +866,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 866 "btyacc_demo.tab.c" +#line 870 "btyacc_demo.tab.c" case 44: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -871,7 +875,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 875 "btyacc_demo.tab.c" +#line 879 "btyacc_demo.tab.c" case 41: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -880,7 +884,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 884 "btyacc_demo.tab.c" +#line 888 "btyacc_demo.tab.c" case 93: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -889,7 +893,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 893 "btyacc_demo.tab.c" +#line 897 "btyacc_demo.tab.c" case 123: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -898,7 +902,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 902 "btyacc_demo.tab.c" +#line 906 "btyacc_demo.tab.c" case 125: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -907,7 +911,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 911 "btyacc_demo.tab.c" +#line 915 "btyacc_demo.tab.c" case 270: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -916,7 +920,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 920 "btyacc_demo.tab.c" +#line 924 "btyacc_demo.tab.c" case 271: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -925,7 +929,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 929 "btyacc_demo.tab.c" +#line 933 "btyacc_demo.tab.c" case 272: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -934,7 +938,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).expr); } break; -#line 938 "btyacc_demo.tab.c" +#line 942 "btyacc_demo.tab.c" case 273: #line 67 "btyacc_demo.y" { /* 'msg' is a 'char *' indicating the context of destructor invocation*/ @@ -944,7 +948,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).decl->scope); free((*val).decl->type); } break; -#line 948 "btyacc_demo.tab.c" +#line 952 "btyacc_demo.tab.c" case 274: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -953,7 +957,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 957 "btyacc_demo.tab.c" +#line 961 "btyacc_demo.tab.c" case 275: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", @@ -962,7 +966,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } break; -#line 966 "btyacc_demo.tab.c" +#line 970 "btyacc_demo.tab.c" case 276: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -971,7 +975,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).code); } break; -#line 975 "btyacc_demo.tab.c" +#line 979 "btyacc_demo.tab.c" case 277: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -980,7 +984,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).code); } break; -#line 984 "btyacc_demo.tab.c" +#line 988 "btyacc_demo.tab.c" case 278: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -989,7 +993,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).code); } break; -#line 993 "btyacc_demo.tab.c" +#line 997 "btyacc_demo.tab.c" case 279: #line 73 "btyacc_demo.y" { printf("%s accessed by symbol with type (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n", @@ -998,7 +1002,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).decl); } break; -#line 1002 "btyacc_demo.tab.c" +#line 1006 "btyacc_demo.tab.c" case 280: #line 73 "btyacc_demo.y" { printf("%s accessed by symbol with type (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n", @@ -1007,7 +1011,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).decl); } break; -#line 1011 "btyacc_demo.tab.c" +#line 1015 "btyacc_demo.tab.c" case 281: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1016,7 +1020,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).type); } break; -#line 1020 "btyacc_demo.tab.c" +#line 1024 "btyacc_demo.tab.c" case 282: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1025,7 +1029,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).type); } break; -#line 1029 "btyacc_demo.tab.c" +#line 1033 "btyacc_demo.tab.c" case 283: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1034,7 +1038,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).type); } break; -#line 1038 "btyacc_demo.tab.c" +#line 1042 "btyacc_demo.tab.c" case 284: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1043,7 +1047,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).type); } break; -#line 1047 "btyacc_demo.tab.c" +#line 1051 "btyacc_demo.tab.c" case 285: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1052,7 +1056,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).type); } break; -#line 1056 "btyacc_demo.tab.c" +#line 1060 "btyacc_demo.tab.c" case 286: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1061,7 +1065,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1065 "btyacc_demo.tab.c" +#line 1069 "btyacc_demo.tab.c" case 287: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1070,7 +1074,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).dlist); } break; -#line 1074 "btyacc_demo.tab.c" +#line 1078 "btyacc_demo.tab.c" case 288: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1079,7 +1083,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).dlist); } break; -#line 1083 "btyacc_demo.tab.c" +#line 1087 "btyacc_demo.tab.c" case 289: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1088,7 +1092,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1092 "btyacc_demo.tab.c" +#line 1096 "btyacc_demo.tab.c" case 290: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1097,7 +1101,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1101 "btyacc_demo.tab.c" +#line 1105 "btyacc_demo.tab.c" case 291: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1106,7 +1110,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1110 "btyacc_demo.tab.c" +#line 1114 "btyacc_demo.tab.c" case 292: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1115,7 +1119,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1119 "btyacc_demo.tab.c" +#line 1123 "btyacc_demo.tab.c" case 293: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1124,7 +1128,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).type); } break; -#line 1128 "btyacc_demo.tab.c" +#line 1132 "btyacc_demo.tab.c" case 294: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1133,7 +1137,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1137 "btyacc_demo.tab.c" +#line 1141 "btyacc_demo.tab.c" case 295: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1142,7 +1146,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).type); } break; -#line 1146 "btyacc_demo.tab.c" +#line 1150 "btyacc_demo.tab.c" case 296: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1151,7 +1155,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1155 "btyacc_demo.tab.c" +#line 1159 "btyacc_demo.tab.c" case 297: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1160,7 +1164,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1164 "btyacc_demo.tab.c" +#line 1168 "btyacc_demo.tab.c" case 298: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", @@ -1169,7 +1173,7 @@ YYDESTRUCT_DECL() (*loc).last_line, (*loc).last_column); free((*val).scope); } break; -#line 1173 "btyacc_demo.tab.c" +#line 1177 "btyacc_demo.tab.c" } } #define YYDESTRUCT_IS_DECLARED 1 @@ -1376,10 +1380,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -1389,7 +1393,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -1490,7 +1494,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1514,7 +1518,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -2099,7 +2103,7 @@ case 59: #line 197 "btyacc_demo.y" { yyval.code = yystack.l_mark[-1].code; } break; -#line 2103 "btyacc_demo.tab.c" +#line 2107 "btyacc_demo.tab.c" default: break; } @@ -2154,12 +2158,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -2170,7 +2174,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/btyacc_demo.tab.h b/test/btyacc/btyacc_demo.tab.h index 33139ebebd3..c219fb1fae9 100644 --- a/test/btyacc/btyacc_demo.tab.h +++ b/test/btyacc/btyacc_demo.tab.h @@ -33,4 +33,18 @@ typedef union { #endif /* !YYSTYPE_IS_DECLARED */ extern YYSTYPE demo_lval; +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +/* Default: YYLTYPE is the text position type. */ +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; + unsigned source; +} YYLTYPE; +#define YYLTYPE_IS_DECLARED 1 +#endif +#define YYRHSLOC(rhs, k) ((rhs)[k]) + #endif /* _demo__defines_h_ */ diff --git a/test/btyacc/btyacc_destroy1.tab.c b/test/btyacc/btyacc_destroy1.tab.c index c598913376c..ae87b3b3166 100644 --- a/test/btyacc/btyacc_destroy1.tab.c +++ b/test/btyacc/btyacc_destroy1.tab.c @@ -214,11 +214,13 @@ static const YYINT destroy1_defred[] = { 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 9, 1, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT destroy1_stos[] = { 0, 257, 258, 259, 260, 263, 265, 266, 266, 261, 264, 267, 267, 40, 261, 40, 40, 265, 258, 265, 41, 44, 44, 266, 266, 41, 41, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT destroy1_dgoto[] = { 5, 10, 6, 7, 11, }; @@ -475,15 +477,15 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 89 "btyacc_destroy1.y" extern int YYLEX_DECL(); extern void YYERROR_DECL(); -#line 487 "btyacc_destroy1.tab.c" +#line 489 "btyacc_destroy1.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED @@ -503,7 +505,7 @@ YYDESTRUCT_DECL() } } break; -#line 507 "btyacc_destroy1.tab.c" +#line 509 "btyacc_destroy1.tab.c" } } #define YYDESTRUCT_IS_DECLARED 1 @@ -710,10 +712,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -723,7 +725,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -824,7 +826,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -848,7 +850,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1223,7 +1225,7 @@ case 9: #line 86 "btyacc_destroy1.y" { yyval.nlist = yystack.l_mark[-5].nlist; } break; -#line 1227 "btyacc_destroy1.tab.c" +#line 1229 "btyacc_destroy1.tab.c" default: break; } @@ -1278,12 +1280,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1294,7 +1296,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/btyacc_destroy2.tab.c b/test/btyacc/btyacc_destroy2.tab.c index 04d4d37df09..17621b05375 100644 --- a/test/btyacc/btyacc_destroy2.tab.c +++ b/test/btyacc/btyacc_destroy2.tab.c @@ -214,11 +214,13 @@ static const YYINT destroy2_defred[] = { 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 9, 1, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT destroy2_stos[] = { 0, 257, 258, 259, 260, 263, 265, 266, 266, 261, 264, 267, 267, 40, 261, 40, 40, 265, 258, 265, 41, 44, 44, 266, 266, 41, 41, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT destroy2_dgoto[] = { 5, 10, 6, 7, 11, }; @@ -475,15 +477,15 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 89 "btyacc_destroy2.y" extern int YYLEX_DECL(); extern void YYERROR_DECL(); -#line 487 "btyacc_destroy2.tab.c" +#line 489 "btyacc_destroy2.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED @@ -503,7 +505,7 @@ YYDESTRUCT_DECL() } } break; -#line 507 "btyacc_destroy2.tab.c" +#line 509 "btyacc_destroy2.tab.c" } } #define YYDESTRUCT_IS_DECLARED 1 @@ -710,10 +712,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -723,7 +725,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -824,7 +826,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -848,7 +850,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1223,7 +1225,7 @@ case 9: #line 86 "btyacc_destroy2.y" { yyval.nlist = yystack.l_mark[-5].nlist; } break; -#line 1227 "btyacc_destroy2.tab.c" +#line 1229 "btyacc_destroy2.tab.c" default: break; } @@ -1278,12 +1280,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1294,7 +1296,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/btyacc_destroy3.tab.c b/test/btyacc/btyacc_destroy3.tab.c index fca98b8d847..d16181b765a 100644 --- a/test/btyacc/btyacc_destroy3.tab.c +++ b/test/btyacc/btyacc_destroy3.tab.c @@ -214,11 +214,13 @@ static const YYINT destroy3_defred[] = { 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 9, 1, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT destroy3_stos[] = { 0, 257, 258, 259, 260, 263, 265, 266, 266, 261, 264, 267, 267, 40, 261, 40, 40, 265, 258, 265, 41, 44, 44, 266, 266, 41, 41, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT destroy3_dgoto[] = { 5, 10, 6, 7, 11, }; @@ -475,15 +477,15 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 92 "btyacc_destroy3.y" extern int YYLEX_DECL(); extern void YYERROR_DECL(); -#line 487 "btyacc_destroy3.tab.c" +#line 489 "btyacc_destroy3.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED @@ -503,7 +505,7 @@ YYDESTRUCT_DECL() } } break; -#line 507 "btyacc_destroy3.tab.c" +#line 509 "btyacc_destroy3.tab.c" } } #define YYDESTRUCT_IS_DECLARED 1 @@ -710,10 +712,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -723,7 +725,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -824,7 +826,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -848,7 +850,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1223,7 +1225,7 @@ case 9: #line 89 "btyacc_destroy3.y" { yyval.nlist = yystack.l_mark[-5].nlist; } break; -#line 1227 "btyacc_destroy3.tab.c" +#line 1229 "btyacc_destroy3.tab.c" default: break; } @@ -1278,12 +1280,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1294,7 +1296,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/calc.tab.c b/test/btyacc/calc.tab.c index 03d52366d43..82e1f39a100 100644 --- a/test/btyacc/calc.tab.c +++ b/test/btyacc/calc.tab.c @@ -185,12 +185,14 @@ static const YYINT calc_defred[] = { 1, 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, 10, 11, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT calc_stos[] = { 0, 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, 263, 263, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT calc_dgoto[] = { 1, 7, 8, 9, }; @@ -456,9 +458,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 66 "calc.y" /* start of programs */ @@ -502,7 +504,7 @@ yylex(void) } return( c ); } -#line 506 "calc.tab.c" +#line 508 "calc.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -705,10 +707,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -718,7 +720,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -819,7 +821,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -843,7 +845,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1229,7 +1231,7 @@ case 18: #line 63 "calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1233 "calc.tab.c" +#line 1235 "calc.tab.c" default: break; } @@ -1284,12 +1286,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1300,7 +1302,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/calc1.tab.c b/test/btyacc/calc1.tab.c index 4046fd3c453..48a94a64ae4 100644 --- a/test/btyacc/calc1.tab.c +++ b/test/btyacc/calc1.tab.c @@ -215,6 +215,7 @@ static const YYINT calc1_defred[] = { 0, 0, 0, 0, 0, 5, 6, 0, 0, 0, 12, 13, 17, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT calc1_stos[] = { 0, 256, 257, 258, 259, 45, 40, 262, 263, 264, 10, 61, 61, 257, 258, 263, 264, 263, 264, 43, 45, @@ -224,6 +225,7 @@ static const YYINT calc1_stos[] = { 0, 43, 45, 42, 47, 10, 10, 263, 263, 263, 263, 263, 41, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT calc1_dgoto[] = { 7, 32, 9, 0, }; @@ -511,9 +513,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 176 "calc1.y" /* beginning of subroutines section */ @@ -646,7 +648,7 @@ vdiv(double a, double b, INTERVAL v) { return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); } -#line 650 "calc1.tab.c" +#line 652 "calc1.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -849,10 +851,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -862,7 +864,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -963,7 +965,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -987,7 +989,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1476,7 +1478,7 @@ case 28: yyval.vval = yystack.l_mark[-1].vval; } break; -#line 1480 "calc1.tab.c" +#line 1482 "calc1.tab.c" default: break; } @@ -1531,12 +1533,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1547,7 +1549,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/calc2.tab.c b/test/btyacc/calc2.tab.c index 99c381e9aa2..694e7977122 100644 --- a/test/btyacc/calc2.tab.c +++ b/test/btyacc/calc2.tab.c @@ -187,12 +187,14 @@ static const YYINT calc2_defred[] = { 1, 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, 10, 11, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT calc2_stos[] = { 0, 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, 263, 263, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT calc2_dgoto[] = { 1, 7, 8, 9, }; @@ -458,9 +460,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 73 "calc2.y" /* start of programs */ @@ -515,7 +517,7 @@ YYLEX_DECL() } return( c ); } -#line 519 "calc2.tab.c" +#line 521 "calc2.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -718,10 +720,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -731,7 +733,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -832,7 +834,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -856,7 +858,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1242,7 +1244,7 @@ case 18: #line 70 "calc2.y" { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1246 "calc2.tab.c" +#line 1248 "calc2.tab.c" default: break; } @@ -1297,12 +1299,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1313,7 +1315,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/calc3.tab.c b/test/btyacc/calc3.tab.c index b3ba798b7d8..383d6349d7f 100644 --- a/test/btyacc/calc3.tab.c +++ b/test/btyacc/calc3.tab.c @@ -192,12 +192,14 @@ static const YYINT calc3_defred[] = { 1, 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, 10, 11, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT calc3_stos[] = { 0, 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, 263, 263, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT calc3_dgoto[] = { 1, 7, 8, 9, }; @@ -470,7 +472,7 @@ YYLEX_DECL() } return( c ); } -#line 474 "calc3.tab.c" +#line 476 "calc3.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -649,9 +651,9 @@ YYPARSE_DECL() #endif /* Current position at lexical token queue */ - static short *yylexp = 0; + static YYINT *yylexp = 0; - static short *yylexemes = 0; + static YYINT *yylexemes = 0; #endif /* YYBTYACC */ int yym, yyn, yystate, yyresult; #if YYBTYACC @@ -723,10 +725,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -736,7 +738,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -837,7 +839,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -861,7 +863,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1247,7 +1249,7 @@ case 18: #line 73 "calc3.y" { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1251 "calc3.tab.c" +#line 1253 "calc3.tab.c" default: break; } @@ -1302,12 +1304,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1318,7 +1320,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/code_calc.code.c b/test/btyacc/code_calc.code.c index a7d322a9258..1b5cf0f67fb 100644 --- a/test/btyacc/code_calc.code.c +++ b/test/btyacc/code_calc.code.c @@ -327,9 +327,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 70 "code_calc.y" /* start of programs */ @@ -580,10 +580,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -593,7 +593,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -694,7 +694,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -718,7 +718,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1159,12 +1159,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1175,7 +1175,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/code_calc.tab.c b/test/btyacc/code_calc.tab.c index 0de2897ccdf..6486b83667e 100644 --- a/test/btyacc/code_calc.tab.c +++ b/test/btyacc/code_calc.tab.c @@ -16,12 +16,14 @@ const YYINT calc_defred[] = { 1, 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, 10, 11, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) const YYINT calc_stos[] = { 0, 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, 263, 263, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ const YYINT calc_dgoto[] = { 1, 7, 8, 9, }; diff --git a/test/btyacc/code_error.code.c b/test/btyacc/code_error.code.c index f9ccb5a9324..f1cd1c69109 100644 --- a/test/btyacc/code_error.code.c +++ b/test/btyacc/code_error.code.c @@ -317,9 +317,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 12 "code_error.y" @@ -550,10 +550,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -563,7 +563,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -664,7 +664,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -688,7 +688,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1068,12 +1068,12 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1084,7 +1084,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/code_error.tab.c b/test/btyacc/code_error.tab.c index d5288b20ad3..88cff35909a 100644 --- a/test/btyacc/code_error.tab.c +++ b/test/btyacc/code_error.tab.c @@ -11,9 +11,11 @@ const YYINT error_len[] = { 2, const YYINT error_defred[] = { 0, 1, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) const YYINT error_stos[] = { 0, 256, 258, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ const YYINT error_dgoto[] = { 2, }; const YYINT error_sindex[] = { -256, diff --git a/test/btyacc/empty.tab.c b/test/btyacc/empty.tab.c index da0fbf96b8d..a2935ef07f0 100644 --- a/test/btyacc/empty.tab.c +++ b/test/btyacc/empty.tab.c @@ -174,9 +174,11 @@ static const YYINT empty_len[] = { 2, static const YYINT empty_defred[] = { 1, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT empty_stos[] = { 0, 258, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT empty_dgoto[] = { 1, }; static const YYINT empty_sindex[] = { 0, @@ -347,9 +349,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 13 "empty.y" @@ -364,7 +366,7 @@ static void YYERROR_DECL() { printf("%s\n",s); } -#line 368 "empty.tab.c" +#line 370 "empty.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -567,10 +569,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -580,7 +582,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -681,7 +683,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -705,7 +707,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1085,12 +1087,12 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1101,7 +1103,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/err_inherit3.tab.c b/test/btyacc/err_inherit3.tab.c index 6cb563e56e9..95c1724c1e1 100644 --- a/test/btyacc/err_inherit3.tab.c +++ b/test/btyacc/err_inherit3.tab.c @@ -210,10 +210,12 @@ static const YYINT err_inherit3_defred[] = { 0, 5, 6, 7, 8, 0, 0, 12, 1, 4, 2, 2, 0, 0, 11, 13, 0, 3, 0, 10, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT err_inherit3_stos[] = { 0, 257, 258, 259, 260, 263, 266, 267, 267, 265, 271, 268, 269, 269, 261, 264, 270, 264, 264, 261, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT err_inherit3_dgoto[] = { 5, 15, 9, 6, 7, 11, 12, 16, 10, }; @@ -408,15 +410,15 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 78 "err_inherit3.y" extern int YYLEX_DECL(); extern void YYERROR_DECL(); -#line 420 "err_inherit3.tab.c" +#line 422 "err_inherit3.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED @@ -436,7 +438,7 @@ YYDESTRUCT_DECL() } } break; -#line 440 "err_inherit3.tab.c" +#line 442 "err_inherit3.tab.c" case 264: #line 30 "err_inherit3.y" { @@ -448,7 +450,7 @@ YYDESTRUCT_DECL() } } break; -#line 452 "err_inherit3.tab.c" +#line 454 "err_inherit3.tab.c" case 265: #line 30 "err_inherit3.y" { @@ -460,7 +462,7 @@ YYDESTRUCT_DECL() } } break; -#line 464 "err_inherit3.tab.c" +#line 466 "err_inherit3.tab.c" } } #define YYDESTRUCT_IS_DECLARED 1 @@ -667,10 +669,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -680,7 +682,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -781,7 +783,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -805,7 +807,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1187,7 +1189,7 @@ case 13: #line 75 "err_inherit3.y" { yyval.nlist = yystack.l_mark[0].nlist; } break; -#line 1191 "err_inherit3.tab.c" +#line 1193 "err_inherit3.tab.c" default: break; } @@ -1242,12 +1244,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1258,7 +1260,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/err_inherit4.tab.c b/test/btyacc/err_inherit4.tab.c index daa6881f0f7..25db4552713 100644 --- a/test/btyacc/err_inherit4.tab.c +++ b/test/btyacc/err_inherit4.tab.c @@ -169,9 +169,11 @@ typedef struct YYLTYPE int first_column; int last_line; int last_column; + unsigned source; } YYLTYPE; #define YYLTYPE_IS_DECLARED 1 #endif +#define YYRHSLOC(rhs, k) ((rhs)[k]) /* compatibility with bison */ #ifdef YYPARSE_PARAM @@ -196,10 +198,10 @@ typedef struct YYLTYPE /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(YYLTYPE loc, const char *s) +#define YYERROR_DECL() yyerror(YYLTYPE *loc, const char *s) #endif #ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(yylloc, msg) +#define YYERROR_CALL(msg) yyerror(&yylloc, msg) #endif #ifndef YYDESTRUCT_DECL @@ -230,10 +232,12 @@ static const YYINT err_inherit4_defred[] = { 0, 5, 6, 7, 8, 0, 0, 0, 1, 10, 0, 4, 2, 9, 0, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT err_inherit4_stos[] = { 0, 257, 258, 259, 260, 263, 266, 267, 267, 261, 264, 265, 268, 261, 269, 264, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT err_inherit4_dgoto[] = { 5, 10, 11, 6, 7, 12, 14, }; @@ -425,15 +429,15 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 80 "err_inherit4.y" extern int YYLEX_DECL(); extern void YYERROR_DECL(); -#line 437 "err_inherit4.tab.c" +#line 441 "err_inherit4.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED @@ -446,17 +450,17 @@ YYDESTRUCT_DECL() #line 28 "err_inherit4.y" { } break; -#line 450 "err_inherit4.tab.c" +#line 454 "err_inherit4.tab.c" case 264: #line 28 "err_inherit4.y" { } break; -#line 455 "err_inherit4.tab.c" +#line 459 "err_inherit4.tab.c" case 265: #line 28 "err_inherit4.y" { } break; -#line 460 "err_inherit4.tab.c" +#line 464 "err_inherit4.tab.c" } } #define YYDESTRUCT_IS_DECLARED 1 @@ -663,10 +667,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -676,7 +680,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -777,7 +781,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -801,7 +805,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1175,7 +1179,7 @@ case 11: #line 77 "err_inherit4.y" { yyval.nlist = yystack.l_mark[0].nlist; yyloc = yystack.p_mark[1]; } break; -#line 1179 "err_inherit4.tab.c" +#line 1183 "err_inherit4.tab.c" default: break; } @@ -1230,12 +1234,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1246,7 +1250,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/err_inherit4.tab.h b/test/btyacc/err_inherit4.tab.h index 5561fd858d2..758d426b54f 100644 --- a/test/btyacc/err_inherit4.tab.h +++ b/test/btyacc/err_inherit4.tab.h @@ -22,4 +22,18 @@ typedef union #endif /* !YYSTYPE_IS_DECLARED */ extern YYSTYPE err_inherit4_lval; +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +/* Default: YYLTYPE is the text position type. */ +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; + unsigned source; +} YYLTYPE; +#define YYLTYPE_IS_DECLARED 1 +#endif +#define YYRHSLOC(rhs, k) ((rhs)[k]) + #endif /* _err_inherit4__defines_h_ */ diff --git a/test/btyacc/err_syntax10.tab.c b/test/btyacc/err_syntax10.tab.c index 8d1d20f8b09..bdbc7f71ff3 100644 --- a/test/btyacc/err_syntax10.tab.c +++ b/test/btyacc/err_syntax10.tab.c @@ -164,9 +164,11 @@ static const YYINT err_syntax10_len[] = { 2, static const YYINT err_syntax10_defred[] = { 0, 1, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT err_syntax10_stos[] = { 0, 256, 258, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT err_syntax10_dgoto[] = { 2, }; static const YYINT err_syntax10_sindex[] = { -256, @@ -337,9 +339,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 12 "err_syntax10.y" @@ -363,7 +365,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 367 "err_syntax10.tab.c" +#line 369 "err_syntax10.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -566,10 +568,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -579,7 +581,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -680,7 +682,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -704,7 +706,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1084,12 +1086,12 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1100,7 +1102,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/err_syntax11.tab.c b/test/btyacc/err_syntax11.tab.c index d94910295b8..f1e09db1a84 100644 --- a/test/btyacc/err_syntax11.tab.c +++ b/test/btyacc/err_syntax11.tab.c @@ -170,9 +170,11 @@ static const YYINT err_syntax11_len[] = { 2, static const YYINT err_syntax11_defred[] = { 0, 1, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT err_syntax11_stos[] = { 0, 256, 258, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT err_syntax11_dgoto[] = { 2, }; static const YYINT err_syntax11_sindex[] = { -256, @@ -343,9 +345,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 12 "err_syntax11.y" @@ -369,7 +371,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 373 "err_syntax11.tab.c" +#line 375 "err_syntax11.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -572,10 +574,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -585,7 +587,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -686,7 +688,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -710,7 +712,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1090,12 +1092,12 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1106,7 +1108,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/err_syntax12.tab.c b/test/btyacc/err_syntax12.tab.c index 5a3105eaef4..8590cad61ce 100644 --- a/test/btyacc/err_syntax12.tab.c +++ b/test/btyacc/err_syntax12.tab.c @@ -171,9 +171,11 @@ static const YYINT err_syntax12_len[] = { 2, static const YYINT err_syntax12_defred[] = { 0, 1, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT err_syntax12_stos[] = { 0, 256, 458, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT err_syntax12_dgoto[] = { 2, }; static const YYINT err_syntax12_sindex[] = { -256, @@ -349,9 +351,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 12 "err_syntax12.y" @@ -375,7 +377,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 379 "err_syntax12.tab.c" +#line 381 "err_syntax12.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -578,10 +580,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -591,7 +593,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -692,7 +694,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -716,7 +718,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1096,12 +1098,12 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1112,7 +1114,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/err_syntax18.tab.c b/test/btyacc/err_syntax18.tab.c index 1221906298b..57a06168888 100644 --- a/test/btyacc/err_syntax18.tab.c +++ b/test/btyacc/err_syntax18.tab.c @@ -170,9 +170,11 @@ static const YYINT err_syntax18_len[] = { 2, static const YYINT err_syntax18_defred[] = { 0, 0, 0, 0, 1, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT err_syntax18_stos[] = { 0, 40, 258, 258, 41, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT err_syntax18_dgoto[] = { 2, }; static const YYINT err_syntax18_sindex[] = { -40, @@ -346,9 +348,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 13 "err_syntax18.y" @@ -372,7 +374,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 376 "err_syntax18.tab.c" +#line 378 "err_syntax18.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -575,10 +577,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -588,7 +590,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -689,7 +691,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -713,7 +715,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1043,7 +1045,7 @@ case 1: #line 9 "err_syntax18.y" { yyval = yystack.l_mark[1]; } break; -#line 1047 "err_syntax18.tab.c" +#line 1049 "err_syntax18.tab.c" default: break; } @@ -1098,12 +1100,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1114,7 +1116,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/err_syntax20.tab.c b/test/btyacc/err_syntax20.tab.c index 73f2074c565..42ac3e102da 100644 --- a/test/btyacc/err_syntax20.tab.c +++ b/test/btyacc/err_syntax20.tab.c @@ -165,9 +165,11 @@ static const YYINT err_syntax20_len[] = { 2, static const YYINT err_syntax20_defred[] = { 0, 0, 0, 0, 1, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT err_syntax20_stos[] = { 0, 40, 259, 257, 41, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT err_syntax20_dgoto[] = { 2, }; static const YYINT err_syntax20_sindex[] = { -40, @@ -341,9 +343,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 16 "err_syntax20.y" @@ -367,7 +369,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 371 "err_syntax20.tab.c" +#line 373 "err_syntax20.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -570,10 +572,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -583,7 +585,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -684,7 +686,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -708,7 +710,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1038,7 +1040,7 @@ case 1: #line 12 "err_syntax20.y" { yystack.l_mark[-1].rechk = 3; } break; -#line 1042 "err_syntax20.tab.c" +#line 1044 "err_syntax20.tab.c" default: break; } @@ -1093,12 +1095,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1109,7 +1111,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/error.tab.c b/test/btyacc/error.tab.c index 493690de270..26de46d8e63 100644 --- a/test/btyacc/error.tab.c +++ b/test/btyacc/error.tab.c @@ -170,9 +170,11 @@ static const YYINT error_len[] = { 2, static const YYINT error_defred[] = { 0, 1, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT error_stos[] = { 0, 256, 258, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT error_dgoto[] = { 2, }; static const YYINT error_sindex[] = { -256, @@ -342,9 +344,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 8 "error.y" @@ -368,7 +370,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 372 "error.tab.c" +#line 374 "error.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -571,10 +573,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -584,7 +586,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -685,7 +687,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -709,7 +711,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1089,12 +1091,12 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1105,7 +1107,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/grammar.tab.c b/test/btyacc/grammar.tab.c index 2d3e4ec00d3..187d06493eb 100644 --- a/test/btyacc/grammar.tab.c +++ b/test/btyacc/grammar.tab.c @@ -519,6 +519,7 @@ static const YYINT grammar_defred[] = { 0, 29, 114, 0, 0, 0, 109, 0, 93, 95, 102, 18, 0, 0, 108, 113, 112, 0, 24, 27, 111, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT grammar_stos[] = { 0, 256, 40, 42, 38, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, @@ -536,6 +537,7 @@ static const YYINT grammar_stos[] = { 0, 285, 41, 305, 307, 40, 283, 306, 286, 309, 316, 59, 44, 331, 41, 41, 41, 307, 303, 285, 41, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT grammar_dgoto[] = { 33, 87, 35, 36, 37, 38, 39, 40, 69, 70, 41, 42, 119, 120, 100, 101, 102, 103, 104, 43, 44, @@ -1166,9 +1168,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 1014 "grammar.y" @@ -1341,7 +1343,7 @@ free_parser(void) #endif } #endif -#line 1345 "grammar.tab.c" +#line 1347 "grammar.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -1544,10 +1546,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -1557,7 +1559,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -1658,7 +1660,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -1682,7 +1684,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -2682,7 +2684,7 @@ case 114: yyval.declarator->func_def = FUNC_ANSI; } break; -#line 2686 "grammar.tab.c" +#line 2688 "grammar.tab.c" default: break; } @@ -2737,12 +2739,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -2753,7 +2755,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/inherit0.tab.c b/test/btyacc/inherit0.tab.c index 1c75db5b8ae..264aed94410 100644 --- a/test/btyacc/inherit0.tab.c +++ b/test/btyacc/inherit0.tab.c @@ -184,10 +184,12 @@ static const YYINT inherit0_defred[] = { 0, 3, 4, 5, 6, 0, 0, 9, 0, 2, 10, 8, 0, 0, 7, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT inherit0_stos[] = { 0, 257, 258, 259, 260, 263, 264, 265, 265, 267, 268, 261, 266, 269, 261, 266, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT inherit0_dgoto[] = { 5, 6, 7, 12, 9, 10, 13, }; @@ -379,15 +381,15 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 46 "inherit0.y" extern int YYLEX_DECL(); extern void YYERROR_DECL(); -#line 391 "inherit0.tab.c" +#line 393 "inherit0.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -590,10 +592,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -603,7 +605,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -704,7 +706,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -728,7 +730,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1098,7 +1100,7 @@ case 11: #line 43 "inherit0.y" { yyval = yystack.l_mark[0]; } break; -#line 1102 "inherit0.tab.c" +#line 1104 "inherit0.tab.c" default: break; } @@ -1153,12 +1155,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1169,7 +1171,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/inherit1.tab.c b/test/btyacc/inherit1.tab.c index 99bbddb2838..f454a81725a 100644 --- a/test/btyacc/inherit1.tab.c +++ b/test/btyacc/inherit1.tab.c @@ -205,10 +205,12 @@ static const YYINT inherit1_defred[] = { 0, 3, 4, 5, 6, 0, 0, 9, 0, 2, 10, 8, 0, 0, 7, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT inherit1_stos[] = { 0, 257, 258, 259, 260, 263, 266, 267, 267, 265, 268, 261, 264, 269, 261, 264, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT inherit1_dgoto[] = { 5, 12, 9, 6, 7, 10, 13, }; @@ -400,15 +402,15 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 74 "inherit1.y" extern int YYLEX_DECL(); extern void YYERROR_DECL(); -#line 412 "inherit1.tab.c" +#line 414 "inherit1.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -611,10 +613,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -624,7 +626,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -725,7 +727,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -749,7 +751,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1123,7 +1125,7 @@ case 11: #line 71 "inherit1.y" { yyval.nlist = yystack.l_mark[0].nlist; } break; -#line 1127 "inherit1.tab.c" +#line 1129 "inherit1.tab.c" default: break; } @@ -1178,12 +1180,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1194,7 +1196,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/inherit2.tab.c b/test/btyacc/inherit2.tab.c index e14f6015b6d..821d65039cb 100644 --- a/test/btyacc/inherit2.tab.c +++ b/test/btyacc/inherit2.tab.c @@ -210,10 +210,12 @@ static const YYINT inherit2_defred[] = { 0, 5, 6, 7, 8, 0, 0, 11, 1, 4, 2, 2, 0, 0, 10, 0, 0, 9, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT inherit2_stos[] = { 0, 257, 258, 259, 260, 263, 266, 267, 267, 265, 270, 268, 269, 269, 261, 264, 264, 261, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT inherit2_dgoto[] = { 5, 15, 9, 6, 7, 11, 12, 10, }; @@ -407,15 +409,15 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 78 "inherit2.y" extern int YYLEX_DECL(); extern void YYERROR_DECL(); -#line 419 "inherit2.tab.c" +#line 421 "inherit2.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED @@ -435,7 +437,7 @@ YYDESTRUCT_DECL() } } break; -#line 439 "inherit2.tab.c" +#line 441 "inherit2.tab.c" case 264: #line 30 "inherit2.y" { @@ -447,7 +449,7 @@ YYDESTRUCT_DECL() } } break; -#line 451 "inherit2.tab.c" +#line 453 "inherit2.tab.c" case 265: #line 30 "inherit2.y" { @@ -459,7 +461,7 @@ YYDESTRUCT_DECL() } } break; -#line 463 "inherit2.tab.c" +#line 465 "inherit2.tab.c" } } #define YYDESTRUCT_IS_DECLARED 1 @@ -666,10 +668,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -679,7 +681,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -780,7 +782,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -804,7 +806,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1182,7 +1184,7 @@ case 12: #line 75 "inherit2.y" { yyval.nlist = yystack.l_mark[0].nlist; } break; -#line 1186 "inherit2.tab.c" +#line 1188 "inherit2.tab.c" default: break; } @@ -1237,12 +1239,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1253,7 +1255,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/ok_syntax1.tab.c b/test/btyacc/ok_syntax1.tab.c index 71773748200..85b682c4532 100644 --- a/test/btyacc/ok_syntax1.tab.c +++ b/test/btyacc/ok_syntax1.tab.c @@ -213,12 +213,14 @@ static const YYINT ok_syntax1_defred[] = { 1, 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, 10, 11, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT ok_syntax1_stos[] = { 0, 275, 256, 257, 258, 45, 40, 276, 277, 278, 10, 61, 258, 277, 277, 10, 124, 38, 43, 45, 42, 47, 37, 257, 277, 41, 277, 277, 277, 277, 277, 277, 277, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT ok_syntax1_dgoto[] = { 1, 7, 8, 9, }; @@ -493,7 +495,7 @@ YYLEX_DECL() } return( c ); } -#line 497 "ok_syntax1.tab.c" +#line 499 "ok_syntax1.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -672,9 +674,9 @@ YYPARSE_DECL() #endif /* Current position at lexical token queue */ - static short *yylexp = 0; + static YYINT *yylexp = 0; - static short *yylexemes = 0; + static YYINT *yylexemes = 0; #endif /* YYBTYACC */ int yym, yyn, yystate, yyresult; #if YYBTYACC @@ -746,10 +748,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -759,7 +761,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -860,7 +862,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -884,7 +886,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1270,7 +1272,7 @@ case 18: #line 101 "ok_syntax1.y" { yyval.ival = (*base) * yystack.l_mark[-1].ival + yystack.l_mark[0].ival; } break; -#line 1274 "ok_syntax1.tab.c" +#line 1276 "ok_syntax1.tab.c" default: break; } @@ -1325,12 +1327,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1341,7 +1343,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/pure_calc.tab.c b/test/btyacc/pure_calc.tab.c index 380bccf9854..9bb89595293 100644 --- a/test/btyacc/pure_calc.tab.c +++ b/test/btyacc/pure_calc.tab.c @@ -195,12 +195,14 @@ static const YYINT calc_defred[] = { 1, 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, 10, 11, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT calc_stos[] = { 0, 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, 263, 263, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT calc_dgoto[] = { 1, 7, 8, 9, }; @@ -466,7 +468,7 @@ YYLEX_DECL() } return( c ); } -#line 470 "pure_calc.tab.c" +#line 472 "pure_calc.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -645,9 +647,9 @@ YYPARSE_DECL() #endif /* Current position at lexical token queue */ - static short *yylexp = 0; + static YYINT *yylexp = 0; - static short *yylexemes = 0; + static YYINT *yylexemes = 0; #endif /* YYBTYACC */ int yym, yyn, yystate, yyresult; #if YYBTYACC @@ -719,10 +721,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -732,7 +734,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -833,7 +835,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -857,7 +859,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1243,7 +1245,7 @@ case 18: #line 69 "pure_calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1247 "pure_calc.tab.c" +#line 1249 "pure_calc.tab.c" default: break; } @@ -1298,12 +1300,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1314,7 +1316,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/pure_error.tab.c b/test/btyacc/pure_error.tab.c index c8953481203..07dd116887f 100644 --- a/test/btyacc/pure_error.tab.c +++ b/test/btyacc/pure_error.tab.c @@ -182,9 +182,11 @@ static const YYINT error_len[] = { 2, static const YYINT error_defred[] = { 0, 1, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT error_stos[] = { 0, 256, 258, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT error_dgoto[] = { 2, }; static const YYINT error_sindex[] = { -256, @@ -334,7 +336,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 338 "pure_error.tab.c" +#line 340 "pure_error.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -513,9 +515,9 @@ YYPARSE_DECL() #endif /* Current position at lexical token queue */ - static short *yylexp = 0; + static YYINT *yylexp = 0; - static short *yylexemes = 0; + static YYINT *yylexemes = 0; #endif /* YYBTYACC */ int yym, yyn, yystate, yyresult; #if YYBTYACC @@ -587,10 +589,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -600,7 +602,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -701,7 +703,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -725,7 +727,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1105,12 +1107,12 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1121,7 +1123,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/quote_calc-s.tab.c b/test/btyacc/quote_calc-s.tab.c index 5860296e8d5..1f84f7ddd36 100644 --- a/test/btyacc/quote_calc-s.tab.c +++ b/test/btyacc/quote_calc-s.tab.c @@ -191,12 +191,14 @@ static const YYINT quote_calc_defred[] = { 1, 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 0, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT quote_calc_stos[] = { 0, 273, 256, 259, 269, 270, 40, 274, 275, 276, 10, 270, 275, 61, 275, 10, 257, 259, 261, 263, 265, 267, 124, 269, 275, 41, 275, 275, 275, 275, 275, 275, 275, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT quote_calc_dgoto[] = { 1, 7, 8, 9, }; @@ -475,9 +477,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 73 "quote_calc.y" /* start of programs */ @@ -520,7 +522,7 @@ yylex(void) { } return( c ); } -#line 524 "quote_calc-s.tab.c" +#line 526 "quote_calc-s.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -723,10 +725,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -736,7 +738,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -837,7 +839,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -861,7 +863,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1247,7 +1249,7 @@ case 18: #line 70 "quote_calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1251 "quote_calc-s.tab.c" +#line 1253 "quote_calc-s.tab.c" default: break; } @@ -1302,12 +1304,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1318,7 +1320,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/quote_calc.tab.c b/test/btyacc/quote_calc.tab.c index 0fa5e60a75d..08661fe7be9 100644 --- a/test/btyacc/quote_calc.tab.c +++ b/test/btyacc/quote_calc.tab.c @@ -197,12 +197,14 @@ static const YYINT quote_calc_defred[] = { 1, 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 0, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT quote_calc_stos[] = { 0, 273, 256, 259, 269, 270, 40, 274, 275, 276, 10, 270, 275, 61, 275, 10, 257, 259, 261, 263, 265, 267, 124, 269, 275, 41, 275, 275, 275, 275, 275, 275, 275, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT quote_calc_dgoto[] = { 1, 7, 8, 9, }; @@ -481,9 +483,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 73 "quote_calc.y" /* start of programs */ @@ -526,7 +528,7 @@ yylex(void) { } return( c ); } -#line 530 "quote_calc.tab.c" +#line 532 "quote_calc.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -729,10 +731,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -742,7 +744,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -843,7 +845,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -867,7 +869,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1253,7 +1255,7 @@ case 18: #line 70 "quote_calc.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1257 "quote_calc.tab.c" +#line 1259 "quote_calc.tab.c" default: break; } @@ -1308,12 +1310,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1324,7 +1326,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/quote_calc2-s.tab.c b/test/btyacc/quote_calc2-s.tab.c index 72ea6ec8475..ed86452b37a 100644 --- a/test/btyacc/quote_calc2-s.tab.c +++ b/test/btyacc/quote_calc2-s.tab.c @@ -191,12 +191,14 @@ static const YYINT quote_calc2_defred[] = { 1, 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 0, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT quote_calc2_stos[] = { 0, 273, 256, 260, 269, 270, 40, 274, 275, 276, 10, 270, 275, 61, 275, 10, 258, 260, 262, 264, 266, 268, 124, 269, 275, 41, 275, 275, 275, 275, 275, 275, 275, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT quote_calc2_dgoto[] = { 1, 7, 8, 9, }; @@ -475,9 +477,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 73 "quote_calc2.y" /* start of programs */ @@ -520,7 +522,7 @@ yylex(void) { } return( c ); } -#line 524 "quote_calc2-s.tab.c" +#line 526 "quote_calc2-s.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -723,10 +725,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -736,7 +738,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -837,7 +839,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -861,7 +863,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1247,7 +1249,7 @@ case 18: #line 70 "quote_calc2.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1251 "quote_calc2-s.tab.c" +#line 1253 "quote_calc2-s.tab.c" default: break; } @@ -1302,12 +1304,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1318,7 +1320,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/quote_calc2.tab.c b/test/btyacc/quote_calc2.tab.c index c5e2430824a..5378828659e 100644 --- a/test/btyacc/quote_calc2.tab.c +++ b/test/btyacc/quote_calc2.tab.c @@ -197,12 +197,14 @@ static const YYINT quote_calc2_defred[] = { 1, 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 0, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT quote_calc2_stos[] = { 0, 273, 256, 260, 269, 270, 40, 274, 275, 276, 10, 270, 275, 61, 275, 10, 258, 260, 262, 264, 266, 268, 124, 269, 275, 41, 275, 275, 275, 275, 275, 275, 275, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT quote_calc2_dgoto[] = { 1, 7, 8, 9, }; @@ -481,9 +483,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 73 "quote_calc2.y" /* start of programs */ @@ -526,7 +528,7 @@ yylex(void) { } return( c ); } -#line 530 "quote_calc2.tab.c" +#line 532 "quote_calc2.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -729,10 +731,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -742,7 +744,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -843,7 +845,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -867,7 +869,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1253,7 +1255,7 @@ case 18: #line 70 "quote_calc2.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1257 "quote_calc2.tab.c" +#line 1259 "quote_calc2.tab.c" default: break; } @@ -1308,12 +1310,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1324,7 +1326,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/quote_calc3-s.tab.c b/test/btyacc/quote_calc3-s.tab.c index 93af811f2bf..14caffb3809 100644 --- a/test/btyacc/quote_calc3-s.tab.c +++ b/test/btyacc/quote_calc3-s.tab.c @@ -191,12 +191,14 @@ static const YYINT quote_calc3_defred[] = { 1, 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 0, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT quote_calc3_stos[] = { 0, 273, 256, 259, 269, 270, 40, 274, 275, 276, 10, 270, 275, 61, 275, 10, 257, 259, 261, 263, 265, 267, 124, 269, 275, 41, 275, 275, 275, 275, 275, 275, 275, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT quote_calc3_dgoto[] = { 1, 7, 8, 9, }; @@ -476,9 +478,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 73 "quote_calc3.y" /* start of programs */ @@ -521,7 +523,7 @@ yylex(void) { } return( c ); } -#line 525 "quote_calc3-s.tab.c" +#line 527 "quote_calc3-s.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -724,10 +726,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -737,7 +739,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -838,7 +840,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -862,7 +864,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1248,7 +1250,7 @@ case 18: #line 70 "quote_calc3.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1252 "quote_calc3-s.tab.c" +#line 1254 "quote_calc3-s.tab.c" default: break; } @@ -1303,12 +1305,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1319,7 +1321,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/quote_calc3.tab.c b/test/btyacc/quote_calc3.tab.c index 2e929c53803..1e4087dea8b 100644 --- a/test/btyacc/quote_calc3.tab.c +++ b/test/btyacc/quote_calc3.tab.c @@ -191,12 +191,14 @@ static const YYINT quote_calc3_defred[] = { 1, 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 0, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT quote_calc3_stos[] = { 0, 273, 256, 259, 269, 270, 40, 274, 275, 276, 10, 270, 275, 61, 275, 10, 257, 259, 261, 263, 265, 267, 124, 269, 275, 41, 275, 275, 275, 275, 275, 275, 275, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT quote_calc3_dgoto[] = { 1, 7, 8, 9, }; @@ -476,9 +478,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 73 "quote_calc3.y" /* start of programs */ @@ -521,7 +523,7 @@ yylex(void) { } return( c ); } -#line 525 "quote_calc3.tab.c" +#line 527 "quote_calc3.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -724,10 +726,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -737,7 +739,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -838,7 +840,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -862,7 +864,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1248,7 +1250,7 @@ case 18: #line 70 "quote_calc3.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1252 "quote_calc3.tab.c" +#line 1254 "quote_calc3.tab.c" default: break; } @@ -1303,12 +1305,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1319,7 +1321,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/quote_calc4-s.tab.c b/test/btyacc/quote_calc4-s.tab.c index e95a5997c4e..6f91ab75800 100644 --- a/test/btyacc/quote_calc4-s.tab.c +++ b/test/btyacc/quote_calc4-s.tab.c @@ -191,12 +191,14 @@ static const YYINT quote_calc4_defred[] = { 1, 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 0, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT quote_calc4_stos[] = { 0, 273, 256, 260, 269, 270, 40, 274, 275, 276, 10, 270, 275, 61, 275, 10, 258, 260, 262, 264, 266, 268, 124, 269, 275, 41, 275, 275, 275, 275, 275, 275, 275, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT quote_calc4_dgoto[] = { 1, 7, 8, 9, }; @@ -476,9 +478,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 73 "quote_calc4.y" /* start of programs */ @@ -521,7 +523,7 @@ yylex(void) { } return( c ); } -#line 525 "quote_calc4-s.tab.c" +#line 527 "quote_calc4-s.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -724,10 +726,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -737,7 +739,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -838,7 +840,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -862,7 +864,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1248,7 +1250,7 @@ case 18: #line 70 "quote_calc4.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1252 "quote_calc4-s.tab.c" +#line 1254 "quote_calc4-s.tab.c" default: break; } @@ -1303,12 +1305,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1319,7 +1321,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/quote_calc4.tab.c b/test/btyacc/quote_calc4.tab.c index fd5fc8e8ecd..ab9505809bb 100644 --- a/test/btyacc/quote_calc4.tab.c +++ b/test/btyacc/quote_calc4.tab.c @@ -191,12 +191,14 @@ static const YYINT quote_calc4_defred[] = { 1, 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 0, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT quote_calc4_stos[] = { 0, 273, 256, 260, 269, 270, 40, 274, 275, 276, 10, 270, 275, 61, 275, 10, 258, 260, 262, 264, 266, 268, 124, 269, 275, 41, 275, 275, 275, 275, 275, 275, 275, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT quote_calc4_dgoto[] = { 1, 7, 8, 9, }; @@ -476,9 +478,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 73 "quote_calc4.y" /* start of programs */ @@ -521,7 +523,7 @@ yylex(void) { } return( c ); } -#line 525 "quote_calc4.tab.c" +#line 527 "quote_calc4.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -724,10 +726,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -737,7 +739,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -838,7 +840,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -862,7 +864,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1248,7 +1250,7 @@ case 18: #line 70 "quote_calc4.y" { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } break; -#line 1252 "quote_calc4.tab.c" +#line 1254 "quote_calc4.tab.c" default: break; } @@ -1303,12 +1305,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1319,7 +1321,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/rename_debug.c b/test/btyacc/rename_debug.c index ecb12212946..ce7cb3d9613 100644 --- a/test/btyacc/rename_debug.c +++ b/test/btyacc/rename_debug.c @@ -29,9 +29,11 @@ static const YYINT yylen[] = { 2, static const YYINT yydefred[] = { 0, 1, 0, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT yystos[] = { 0, 256, 258, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT yydgoto[] = { 2, }; static const YYINT yysindex[] = { -256, @@ -201,9 +203,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 12 "code_debug.y" @@ -231,7 +233,7 @@ yyerror(const char* s) { printf("%s\n", s); } -#line 236 "rename_debug.c" +#line 238 "rename_debug.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -434,10 +436,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -447,7 +449,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -548,7 +550,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -572,7 +574,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -952,12 +954,12 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -968,7 +970,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/test/btyacc/varsyntax_calc1.tab.c b/test/btyacc/varsyntax_calc1.tab.c index 16422a96f8a..48723e1645a 100644 --- a/test/btyacc/varsyntax_calc1.tab.c +++ b/test/btyacc/varsyntax_calc1.tab.c @@ -216,6 +216,7 @@ static const YYINT varsyntax_calc1_defred[] = { 0, 0, 0, 0, 0, 5, 6, 0, 0, 0, 12, 13, 17, }; +#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT varsyntax_calc1_stos[] = { 0, 256, 257, 258, 259, 45, 40, 262, 263, 264, 10, 61, 61, 257, 258, 263, 264, 263, 264, 43, 45, @@ -225,6 +226,7 @@ static const YYINT varsyntax_calc1_stos[] = { 0, 43, 45, 42, 47, 10, 10, 263, 263, 263, 263, 263, 41, }; +#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT varsyntax_calc1_dgoto[] = { 7, 32, 9, 0, }; @@ -512,9 +514,9 @@ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ -static short *yylexp = 0; +static YYINT *yylexp = 0; -static short *yylexemes = 0; +static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 178 "varsyntax_calc1.y" /* beginning of subroutines section */ @@ -647,7 +649,7 @@ vdiv(double a, double b, INTERVAL v) { return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); } -#line 651 "varsyntax_calc1.tab.c" +#line 653 "varsyntax_calc1.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) @@ -850,10 +852,10 @@ YYPARSE_DECL() size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; @@ -863,7 +865,7 @@ YYPARSE_DECL() #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) @@ -964,7 +966,7 @@ YYPARSE_DECL() /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { - yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); + yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; @@ -988,7 +990,7 @@ YYPARSE_DECL() #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif - *yylexp = (short) yychar; + *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } @@ -1477,7 +1479,7 @@ case 28: yyval.vval = yystack.l_mark[-1].vval; } break; -#line 1481 "varsyntax_calc1.tab.c" +#line 1483 "varsyntax_calc1.tab.c" default: break; } @@ -1532,12 +1534,12 @@ break; size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; - if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) + if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; - if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) + if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) - if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) + if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; @@ -1548,7 +1550,7 @@ break; #endif yylexp = yylexemes + p; } - *yylexp = (short) YYLEX; + *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) diff --git a/yaccpar.c b/yaccpar.c index a77a5394a78..53fcbd8c0b7 100644 --- a/yaccpar.c +++ b/yaccpar.c @@ -1,5 +1,5 @@ /* This file generated automatically using - * @Id: skel2c,v 1.3 2014/04/06 19:48:04 tom Exp @ + * @Id: skel2c,v 1.4 2016/06/07 00:26:09 tom Exp @ */ /* @Id: yaccpar.skel,v 1.7 2016/06/06 23:35:55 Tom.Shields Exp @ */ @@ -211,6 +211,11 @@ const char *const body_2[] = " }", "#endif", "", + 0 +}; + +const char *const body_3[] = +{ " yym = 0;", " yyn = 0;", " yynerrs = 0;", diff --git a/yaccpar.skel b/yaccpar.skel index 3148ef58850..c303b005466 100644 --- a/yaccpar.skel +++ b/yaccpar.skel @@ -1,4 +1,4 @@ -/* $Id: yaccpar.skel,v 1.7 2016/06/06 23:35:55 Tom.Shields Exp $ */ +/* $Id: yaccpar.skel,v 1.8 2016/12/02 21:44:42 tom Exp $ */ #include "defs.h" @@ -166,6 +166,7 @@ YYPARSE_DECL() } #endif +%% body_3 yym = 0; yyn = 0; yynerrs = 0; From 480f31c214725f732a6d0e8ef4cd7c56ff98e155 Mon Sep 17 00:00:00 2001 From: Konrad Witaszczyk Date: Sat, 10 Dec 2016 16:20:39 +0000 Subject: [PATCH 002/226] Add support for encrypted kernel crash dumps. Changes include modifications in kernel crash dump routines, dumpon(8) and savecore(8). A new tool called decryptcore(8) was added. A new DIOCSKERNELDUMP I/O control was added to send a kernel crash dump configuration in the diocskerneldump_arg structure to the kernel. The old DIOCSKERNELDUMP I/O control was renamed to DIOCSKERNELDUMP_FREEBSD11 for backward ABI compatibility. dumpon(8) generates an one-time random symmetric key and encrypts it using an RSA public key in capability mode. Currently only AES-256-CBC is supported but EKCD was designed to implement support for other algorithms in the future. The public key is chosen using the -k flag. The dumpon rc(8) script can do this automatically during startup using the dumppubkey rc.conf(5) variable. Once the keys are calculated dumpon sends them to the kernel via DIOCSKERNELDUMP I/O control. When the kernel receives the DIOCSKERNELDUMP I/O control it generates a random IV and sets up the key schedule for the specified algorithm. Each time the kernel tries to write a crash dump to the dump device, the IV is replaced by a SHA-256 hash of the previous value. This is intended to make a possible differential cryptanalysis harder since it is possible to write multiple crash dumps without reboot by repeating the following commands: # sysctl debug.kdb.enter=1 db> call doadump(0) db> continue # savecore A kernel dump key consists of an algorithm identifier, an IV and an encrypted symmetric key. The kernel dump key size is included in a kernel dump header. The size is an unsigned 32-bit integer and it is aligned to a block size. The header structure has 512 bytes to match the block size so it was required to make a panic string 4 bytes shorter to add a new field to the header structure. If the kernel dump key size in the header is nonzero it is assumed that the kernel dump key is placed after the first header on the dump device and the core dump is encrypted. Separate functions were implemented to write the kernel dump header and the kernel dump key as they need to be unencrypted. The dump_write function encrypts data if the kernel was compiled with the EKCD option. Encrypted kernel textdumps are not supported due to the way they are constructed which makes it impossible to use the CBC mode for encryption. It should be also noted that textdumps don't contain sensitive data by design as a user decides what information should be dumped. savecore(8) writes the kernel dump key to a key.# file if its size in the header is nonzero. # is the number of the current core dump. decryptcore(8) decrypts the core dump using a private RSA key and the kernel dump key. This is performed by a child process in capability mode. If the decryption was not successful the parent process removes a partially decrypted core dump. Description on how to encrypt crash dumps was added to the decryptcore(8), dumpon(8), rc.conf(5) and savecore(8) manual pages. EKCD was tested on amd64 using bhyve and i386, mipsel and sparc64 using QEMU. The feature still has to be tested on arm and arm64 as it wasn't possible to run FreeBSD due to the problems with QEMU emulation and lack of hardware. Designed by: def, pjd Reviewed by: cem, oshogbo, pjd Partial review: delphij, emaste, jhb, kib Approved by: pjd (mentor) Differential Revision: https://reviews.freebsd.org/D4712 --- etc/defaults/rc.conf | 2 + etc/rc.d/dumpon | 7 +- sbin/Makefile | 1 + sbin/decryptcore/Makefile | 13 + sbin/decryptcore/decryptcore.8 | 114 +++++++++ sbin/decryptcore/decryptcore.c | 373 +++++++++++++++++++++++++++++ sbin/dumpon/Makefile | 8 + sbin/dumpon/dumpon.8 | 118 ++++++++- sbin/dumpon/dumpon.c | 111 ++++++++- sbin/savecore/savecore.8 | 7 +- sbin/savecore/savecore.c | 92 ++++++- share/man/man5/rc.conf.5 | 14 +- sys/amd64/amd64/minidump_machdep.c | 27 ++- sys/arm/arm/minidump_machdep.c | 27 ++- sys/arm64/arm64/minidump_machdep.c | 27 ++- sys/conf/NOTES | 3 + sys/conf/files | 6 +- sys/conf/options | 3 + sys/ddb/db_textdump.c | 17 +- sys/dev/null/null.c | 7 +- sys/geom/geom_dev.c | 82 +++++-- sys/i386/i386/minidump_machdep.c | 28 ++- sys/kern/kern_dump.c | 53 +++- sys/kern/kern_shutdown.c | 362 ++++++++++++++++++++++++++-- sys/mips/mips/minidump_machdep.c | 27 ++- sys/sparc64/sparc64/dump_machdep.c | 23 +- sys/sys/conf.h | 10 +- sys/sys/disk.h | 15 +- sys/sys/kerneldump.h | 31 ++- 29 files changed, 1485 insertions(+), 123 deletions(-) create mode 100644 sbin/decryptcore/Makefile create mode 100644 sbin/decryptcore/decryptcore.8 create mode 100644 sbin/decryptcore/decryptcore.c diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf index f4fa7a8846d..c8a3061b62f 100644 --- a/etc/defaults/rc.conf +++ b/etc/defaults/rc.conf @@ -607,6 +607,8 @@ chkprintcap_enable="NO" # Run chkprintcap(8) before running lpd. chkprintcap_flags="-d" # Create missing directories by default. dumpdev="AUTO" # Device to crashdump to (device name, AUTO, or NO). dumpdir="/var/crash" # Directory where crash dumps are to be stored +dumppubkey="" # Public key for encrypted kernel crash dumps. + # See dumpon(8) for more details. savecore_enable="YES" # Extract core from dump devices if any savecore_flags="-m 10" # Used if dumpdev is enabled above, and present. # By default, only the 10 most recent kernel dumps diff --git a/etc/rc.d/dumpon b/etc/rc.d/dumpon index 66276eb5053..87bdd3eb0b3 100755 --- a/etc/rc.d/dumpon +++ b/etc/rc.d/dumpon @@ -16,7 +16,12 @@ stop_cmd="dumpon_stop" dumpon_try() { - if /sbin/dumpon "${1}" ; then + if [ -n "${dumppubkey}" ]; then + /sbin/dumpon -k "${dumppubkey}" "${1}" + else + /sbin/dumpon "${1}" + fi + if [ $? -eq 0 ]; then # Make a symlink in devfs for savecore ln -fs "${1}" /dev/dumpdev return 0 diff --git a/sbin/Makefile b/sbin/Makefile index 4826bc09b26..39e417acbac 100644 --- a/sbin/Makefile +++ b/sbin/Makefile @@ -83,6 +83,7 @@ SUBDIR.${MK_IPFW}+= natd SUBDIR.${MK_ISCSI}+= iscontrol SUBDIR.${MK_NAND}+= nandfs SUBDIR.${MK_NAND}+= newfs_nandfs +SUBDIR.${MK_OPENSSL}+= decryptcore SUBDIR.${MK_PF}+= pfctl SUBDIR.${MK_PF}+= pflogd SUBDIR.${MK_QUOTAS}+= quotacheck diff --git a/sbin/decryptcore/Makefile b/sbin/decryptcore/Makefile new file mode 100644 index 00000000000..be8b6d1c593 --- /dev/null +++ b/sbin/decryptcore/Makefile @@ -0,0 +1,13 @@ +# $FreeBSD$ + +PROG= decryptcore + +LIBADD= crypto pjdlog + +MAN= decryptcore.8 + +CFLAGS+=-I${.CURDIR}/../../lib/libpjdlog + +WARNS?= 6 + +.include diff --git a/sbin/decryptcore/decryptcore.8 b/sbin/decryptcore/decryptcore.8 new file mode 100644 index 00000000000..d21667c0784 --- /dev/null +++ b/sbin/decryptcore/decryptcore.8 @@ -0,0 +1,114 @@ +.\" Copyright (c) 2016 Konrad Witaszczyk +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd December 10, 2016 +.Dt DECRYPTCORE 8 +.Os +.Sh NAME +.Nm decryptcore +.Nd "decrypt a core dump of the operating system" +.Sh SYNOPSIS +.Nm +.Op Fl Lv +.Fl p Ar privatekeyfile +.Fl k Ar keyfile +.Fl e Ar encryptedcore +.Fl c Ar core +.Nm +.Op Fl Lv +.Op Fl d Ar crashdir +.Fl p Ar privatekeyfile +.Fl n Ar dumpnr +.Sh DESCRIPTION +The +.Nm +first decrypts +.Ar keyfile +using +.Ar privatekeyfile +and then uses the resulting key to decrypt +.Ar encryptedcore +saved by +.Xr savecore 8 . +Result is saved in +.Ar core . +.Pp +Alternatively a user can decrypt a core dump numbered +.Ar dumpnr +from the +.Ar crashdir +directory. +In this case a dump key from the +.Pa key.# +file is used and the result is saved in the +.Pa vmcore.# +file where +.Dq # +corresponds to +.Ar dumpnr . +.Pp +The +.Nm +utility can be started with the following command line arguments: +.Bl -tag -width ".Fl e Ar encryptedcore" +.It Fl L +Write log messages to +.Xr syslogd 8 . +.It Fl v +Print or log verbose/debugging information. +This option can be specified multiple times to raise the verbosity +level. +.It Fl p Ar privatekeyfile +Specify location of a private key file which will be used to decrypt a dump key +file. +.It Fl k Ar keyfile +Specify location of a dump key file. +.It Fl e Ar encrytpedcore +Specify location of an encrypted core. +.It Fl c Ar core +Specify location of a resulting decrypted core dump. +.It Fl d Ar crashdir +Specify an alternative crash dump directory. The default crash dump directory is +.Pa /var/crash . +.It Fl n Ar dumpnr +Specify a number of a crash dump to be decrypted. +.El +.Sh EXIT STATUS +The +.Nm +utility exits 0 on success, and >0 if an error occurs. +.Sh SEE ALSO +.Xr capsicum 4 , +.Xr dumpon 8 , +.Xr kgdb 1 , +.Xr savecore 8 , +.Xr syslogd 8 +.Sh AUTHORS +The +.Nm +was implemented by +.An -nosplit +.An Konrad Witaszczyk Aq Mt def@FreeBSD.org . diff --git a/sbin/decryptcore/decryptcore.c b/sbin/decryptcore/decryptcore.c new file mode 100644 index 00000000000..758e4c8c0fe --- /dev/null +++ b/sbin/decryptcore/decryptcore.c @@ -0,0 +1,373 @@ +/*- + * Copyright (c) 2016 Konrad Witaszczyk + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "pjdlog.h" + +#define DECRYPTCORE_CRASHDIR "/var/crash" + +static void +usage(void) +{ + + pjdlog_exitx(1, + "usage: decryptcore [-Lv] -p privatekeyfile -k keyfile -e encryptedcore -c core\n" + " decryptcore [-Lv] [-d crashdir] -p privatekeyfile -n dumpnr"); +} + +static int +wait_for_process(pid_t pid) +{ + int status; + + if (waitpid(pid, &status, WUNTRACED | WEXITED) == -1) { + pjdlog_errno(LOG_ERR, "Unable to wait for a child process"); + return (1); + } + + if (WIFEXITED(status)) + return (WEXITSTATUS(status)); + + return (1); +} + +static struct kerneldumpkey * +read_key(int kfd) +{ + struct kerneldumpkey *kdk; + ssize_t size; + size_t kdksize; + + PJDLOG_ASSERT(kfd >= 0); + + kdksize = sizeof(*kdk); + kdk = calloc(1, kdksize); + if (kdk == NULL) { + pjdlog_errno(LOG_ERR, "Unable to allocate kernel dump key"); + goto failed; + } + + size = read(kfd, kdk, kdksize); + if (size == (ssize_t)kdksize) { + kdk->kdk_encryptedkeysize = dtoh32(kdk->kdk_encryptedkeysize); + kdksize += (size_t)kdk->kdk_encryptedkeysize; + kdk = realloc(kdk, kdksize); + if (kdk == NULL) { + pjdlog_errno(LOG_ERR, "Unable to reallocate kernel dump key"); + goto failed; + } + size += read(kfd, &kdk->kdk_encryptedkey, + kdk->kdk_encryptedkeysize); + } + if (size != (ssize_t)kdksize) { + pjdlog_errno(LOG_ERR, "Unable to read key"); + goto failed; + } + + return (kdk); +failed: + free(kdk); + return (NULL); +} + +static bool +decrypt(const char *privkeyfile, const char *keyfile, const char *input, + const char *output) +{ + uint8_t buf[KERNELDUMP_BUFFER_SIZE], key[KERNELDUMP_KEY_MAX_SIZE]; + EVP_CIPHER_CTX ctx; + const EVP_CIPHER *cipher; + FILE *fp; + struct kerneldumpkey *kdk; + RSA *privkey; + int ifd, kfd, ofd, olen, privkeysize; + ssize_t bytes; + pid_t pid; + + PJDLOG_ASSERT(privkeyfile != NULL); + PJDLOG_ASSERT(keyfile != NULL); + PJDLOG_ASSERT(input != NULL); + PJDLOG_ASSERT(output != NULL); + + privkey = NULL; + + /* + * Decrypt a core dump in a child process so we can unlink a partially + * decrypted core if the child process fails. + */ + pid = fork(); + if (pid == -1) { + pjdlog_errno(LOG_ERR, "Unable to create child process"); + return (false); + } + + if (pid > 0) + return (wait_for_process(pid) == 0); + + kfd = open(keyfile, O_RDONLY); + if (kfd == -1) { + pjdlog_errno(LOG_ERR, "Unable to open %s", keyfile); + goto failed; + } + ifd = open(input, O_RDONLY); + if (ifd == -1) { + pjdlog_errno(LOG_ERR, "Unable to open %s", input); + goto failed; + } + ofd = open(output, O_WRONLY | O_CREAT | O_TRUNC, 0600); + if (ofd == -1) { + pjdlog_errno(LOG_ERR, "Unable to open %s", output); + goto failed; + } + fp = fopen(privkeyfile, "r"); + if (fp == NULL) { + pjdlog_errno(LOG_ERR, "Unable to open %s", privkeyfile); + goto failed; + } + + if (cap_enter() < 0 && errno != ENOSYS) { + pjdlog_errno(LOG_ERR, "Unable to enter capability mode"); + goto failed; + } + + privkey = RSA_new(); + if (privkey == NULL) { + pjdlog_error("Unable to allocate an RSA structure: %s", + ERR_error_string(ERR_get_error(), NULL)); + goto failed; + } + EVP_CIPHER_CTX_init(&ctx); + + kdk = read_key(kfd); + close(kfd); + if (kdk == NULL) + goto failed; + + privkey = PEM_read_RSAPrivateKey(fp, &privkey, NULL, NULL); + fclose(fp); + if (privkey == NULL) { + pjdlog_error("Unable to read data from %s.", privkeyfile); + goto failed; + } + + privkeysize = RSA_size(privkey); + if (privkeysize != (int)kdk->kdk_encryptedkeysize) { + pjdlog_error("RSA modulus size mismatch: equals %db and should be %ub.", + 8 * privkeysize, 8 * kdk->kdk_encryptedkeysize); + goto failed; + } + + switch (kdk->kdk_encryption) { + case KERNELDUMP_ENC_AES_256_CBC: + cipher = EVP_aes_256_cbc(); + break; + default: + pjdlog_error("Invalid encryption algorithm."); + goto failed; + } + + if (RSA_private_decrypt(kdk->kdk_encryptedkeysize, + kdk->kdk_encryptedkey, key, privkey, + RSA_PKCS1_PADDING) != sizeof(key)) { + pjdlog_error("Unable to decrypt key: %s", + ERR_error_string(ERR_get_error(), NULL)); + goto failed; + } + RSA_free(privkey); + privkey = NULL; + + EVP_DecryptInit_ex(&ctx, cipher, NULL, key, kdk->kdk_iv); + EVP_CIPHER_CTX_set_padding(&ctx, 0); + + explicit_bzero(key, sizeof(key)); + + do { + bytes = read(ifd, buf, sizeof(buf)); + if (bytes < 0) { + pjdlog_errno(LOG_ERR, "Unable to read data from %s", + input); + goto failed; + } else if (bytes == 0) { + break; + } + + if (bytes > 0) { + if (EVP_DecryptUpdate(&ctx, buf, &olen, buf, + bytes) == 0) { + pjdlog_error("Unable to decrypt core."); + goto failed; + } + } else { + if (EVP_DecryptFinal_ex(&ctx, buf, &olen) == 0) { + pjdlog_error("Unable to decrypt core."); + goto failed; + } + } + + if (olen == 0) + continue; + + if (write(ofd, buf, olen) != olen) { + pjdlog_errno(LOG_ERR, "Unable to write data to %s", + output); + goto failed; + } + } while (bytes > 0); + + explicit_bzero(buf, sizeof(buf)); + EVP_CIPHER_CTX_cleanup(&ctx); + exit(0); +failed: + explicit_bzero(key, sizeof(key)); + explicit_bzero(buf, sizeof(buf)); + RSA_free(privkey); + EVP_CIPHER_CTX_cleanup(&ctx); + exit(1); +} + +int +main(int argc, char **argv) +{ + char core[PATH_MAX], encryptedcore[PATH_MAX], keyfile[PATH_MAX]; + struct stat sb; + const char *crashdir, *dumpnr, *privatekey; + int ch, debug; + size_t ii; + bool usesyslog; + + pjdlog_init(PJDLOG_MODE_STD); + pjdlog_prefix_set("(decryptcore) "); + + debug = 0; + *core = '\0'; + crashdir = NULL; + dumpnr = NULL; + *encryptedcore = '\0'; + *keyfile = '\0'; + privatekey = NULL; + usesyslog = false; + while ((ch = getopt(argc, argv, "Lc:d:e:k:n:p:v")) != -1) { + switch (ch) { + case 'L': + usesyslog = true; + break; + case 'c': + strncpy(core, optarg, sizeof(core)); + break; + case 'd': + crashdir = optarg; + break; + case 'e': + strncpy(encryptedcore, optarg, sizeof(encryptedcore)); + break; + case 'k': + strncpy(keyfile, optarg, sizeof(keyfile)); + break; + case 'n': + dumpnr = optarg; + break; + case 'p': + privatekey = optarg; + break; + case 'v': + debug++; + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + + if (argc != 0) + usage(); + + /* Verify mutually exclusive options. */ + if ((crashdir != NULL || dumpnr != NULL) && + (*keyfile != '\0' || *encryptedcore != '\0' || *core != '\0')) { + usage(); + } + + /* + * Set key, encryptedcore and core file names using crashdir and dumpnr. + */ + if (dumpnr != NULL) { + for (ii = 0; ii < strnlen(dumpnr, PATH_MAX); ii++) { + if (isdigit((int)dumpnr[ii]) == 0) + usage(); + } + + if (crashdir == NULL) + crashdir = DECRYPTCORE_CRASHDIR; + PJDLOG_VERIFY(snprintf(keyfile, sizeof(keyfile), + "%s/key.%s", crashdir, dumpnr) > 0); + PJDLOG_VERIFY(snprintf(core, sizeof(core), + "%s/vmcore.%s", crashdir, dumpnr) > 0); + PJDLOG_VERIFY(snprintf(encryptedcore, sizeof(encryptedcore), + "%s/vmcore_encrypted.%s", crashdir, dumpnr) > 0); + } + + if (privatekey == NULL || *keyfile == '\0' || *encryptedcore == '\0' || + *core == '\0') { + usage(); + } + + if (usesyslog) + pjdlog_mode_set(PJDLOG_MODE_SYSLOG); + pjdlog_debug_set(debug); + + if (!decrypt(privatekey, keyfile, encryptedcore, core)) { + if (stat(core, &sb) == 0 && unlink(core) != 0) + pjdlog_exit(1, "Unable to remove core"); + exit(1); + } + + pjdlog_fini(); + + exit(0); +} diff --git a/sbin/dumpon/Makefile b/sbin/dumpon/Makefile index 782117c16ff..d0700ab16a8 100644 --- a/sbin/dumpon/Makefile +++ b/sbin/dumpon/Makefile @@ -1,7 +1,15 @@ # $FreeBSD$ +.include + PACKAGE=runtime PROG= dumpon + +.if ${MK_OPENSSL} != "no" +LIBADD= crypto +CFLAGS+=-DHAVE_CRYPTO +.endif + MAN= dumpon.8 .include diff --git a/sbin/dumpon/dumpon.8 b/sbin/dumpon/dumpon.8 index 81377124d80..14b0665ec1b 100644 --- a/sbin/dumpon/dumpon.8 +++ b/sbin/dumpon/dumpon.8 @@ -28,7 +28,7 @@ .\" From: @(#)swapon.8 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd October 3, 2016 +.Dd December 10, 2016 .Dt DUMPON 8 .Os .Sh NAME @@ -37,6 +37,7 @@ .Sh SYNOPSIS .Nm .Op Fl v +.Op Fl k Ar public_key_file .Ar special_file .Nm .Op Fl v @@ -56,7 +57,9 @@ normally occur from the system multi-user initialization file .Pa /etc/rc , controlled by the .Dq dumpdev -variable in the boot time configuration file +and +.Dq dumppubkey +variables in the boot time configuration file .Pa /etc/rc.conf . .Pp The default type of kernel crash dump is the mini crash dump. @@ -82,6 +85,35 @@ total amount of physical memory as reported by the variable. .Pp The +.Op Fl k Ar public_key_file +flag causes +.Nm +to generate a one-time key for kernel crash dump encryption. +The key will be replaced by a new one when the +.Nm +utility is run again. +The key is encrypted using +.Ar public_key_file . +This process is sandboxed using +.Xr capsicum 4 . +Both plain and encrypted keys are sent to the kernel using +.Dv DIOCSKERNELDUMP +.Xr ioctl 2 . +A user can specify the +.Ar public_key_file +in the +.Dq dumppubkey +variable defined in +.Pa /etc/rc.conf +for use with the +.Pa /etc/rc.d/dumpon +.Xr rc 8 +script. +This flag requires a kernel compiled with the +.Dv EKCD +kernel option. +.Pp +The .Fl l flag causes .Nm @@ -140,13 +172,95 @@ standard swap areas .It Pa /etc/rc.conf boot-time system configuration .El +.Sh EXAMPLES +In order to generate an RSA private key a user can use the +.Xr genrsa 1 +tool: +.Pp +.Dl # openssl genrsa -out private.pem 4096 +.Pp +A public key can be extracted from the private key using the +.Xr rsa 1 +tool: +.Pp +.Dl # openssl rsa -in private.pem -out public.pem -pubout +.Pp +Once the RSA keys are created the private key should be moved to a safe place. +Now +.Pa public.pem +can be used by +.Nm +to configure encrypted kernel crash dumps: +.Pp +.Dl # dumpon -k public.pem /dev/ada0s1b +.Pp +It is recommended to test if the kernel saves encrypted crash dumps using the +current configuration. +The easiest way to do that is to cause a kernel panic using the +.Xr ddb 4 +debugger: +.Pp +.Dl # sysctl debug.kdb.panic=1 +.Pp +In the debugger the following commands should be typed to write a core dump and +reboot: +.Pp +.Dl db> call doadump(0) +.Dl db> reset +.Pp +After reboot +.Xr savecore 8 +should be able to save the core dump in the core directory which is +.Pa /var/crash +by default: +.Pp +.Dl # savecore /var/crash /dev/ada0s1b +.Pp +Three files should be created in the core directory: +.Pa info.# , +.Pa key.# +and +.Pa vmcore_encrypted.# +where +.Dq # +is the number of the last core dump saved by +.Xr savecore 8 . +The +.Pa vmcore_encrypted.# +can be decrypted using the +.Xr decryptcore 8 +utility: +.Pp +.Dl # decryptcore -p private.pem -k key.# -e vmcore_encrypted.# -c vmcore.# +.Pp +or shorter: +.Pp +.Dl # decryptcore -p private.pem -n # +.Pp +The +.Pa vmcore.# +can be now examined using +.Xr kgdb 1 : +.Pp +.Dl # kgdb /usr/obj/sys/GENERIC/kernel.debug vmcore.# +.Pp +or shorter: +.Pp +.Dl # kgdb -n # /usr/obj/sys/GENERIC/kernel.debug +.Pp +The core was decrypted properly if +.Xr kgdb 1 +does not print any errors. .Sh SEE ALSO +.Xr kgdb 1 , +.Xr ddb 4 , .Xr fstab 5 , .Xr rc.conf 5 , .Xr config 8 , .Xr init 8 , .Xr loader 8 , .Xr rc 8 , +.Xr decryptcore 8 , .Xr savecore 8 , .Xr swapon 8 , .Xr panic 9 diff --git a/sbin/dumpon/dumpon.c b/sbin/dumpon/dumpon.c index 8407111c7f6..a1d77c852a4 100644 --- a/sbin/dumpon/dumpon.c +++ b/sbin/dumpon/dumpon.c @@ -42,13 +42,16 @@ static char sccsid[] = "From: @(#)swapon.c 8.1 (Berkeley) 6/5/93"; __FBSDID("$FreeBSD$"); #include +#include #include #include +#include #include #include #include #include +#include #include #include #include @@ -56,13 +59,19 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef HAVE_CRYPTO +#include +#include +#include +#endif + static int verbose; static void usage(void) { fprintf(stderr, "%s\n%s\n%s\n", - "usage: dumpon [-v] special_file", + "usage: dumpon [-v] [-k public_key_file] special_file", " dumpon [-v] off", " dumpon [-v] -l"); exit(EX_USAGE); @@ -94,6 +103,59 @@ check_size(int fd, const char *fn) } } +#ifdef HAVE_CRYPTO +static void +genkey(const char *pubkeyfile, struct diocskerneldump_arg *kda) +{ + FILE *fp; + RSA *pubkey; + + assert(pubkeyfile != NULL); + assert(kda != NULL); + + fp = NULL; + pubkey = NULL; + + fp = fopen(pubkeyfile, "r"); + if (fp == NULL) + err(1, "Unable to open %s", pubkeyfile); + + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "Unable to enter capability mode"); + + pubkey = RSA_new(); + if (pubkey == NULL) { + errx(1, "Unable to allocate an RSA structure: %s", + ERR_error_string(ERR_get_error(), NULL)); + } + + pubkey = PEM_read_RSA_PUBKEY(fp, &pubkey, NULL, NULL); + fclose(fp); + fp = NULL; + if (pubkey == NULL) + errx(1, "Unable to read data from %s.", pubkeyfile); + + kda->kda_encryptedkeysize = RSA_size(pubkey); + if (kda->kda_encryptedkeysize > KERNELDUMP_ENCKEY_MAX_SIZE) { + errx(1, "Public key has to be at most %db long.", + 8 * KERNELDUMP_ENCKEY_MAX_SIZE); + } + + kda->kda_encryptedkey = calloc(1, kda->kda_encryptedkeysize); + if (kda->kda_encryptedkey == NULL) + err(1, "Unable to allocate encrypted key"); + + kda->kda_encryption = KERNELDUMP_ENC_AES_256_CBC; + arc4random_buf(kda->kda_key, sizeof(kda->kda_key)); + if (RSA_public_encrypt(sizeof(kda->kda_key), kda->kda_key, + kda->kda_encryptedkey, pubkey, + RSA_PKCS1_PADDING) != (int)kda->kda_encryptedkeysize) { + errx(1, "Unable to encrypt the one-time key."); + } + RSA_free(pubkey); +} +#endif + static void listdumpdev(void) { @@ -123,13 +185,20 @@ listdumpdev(void) int main(int argc, char *argv[]) { + struct diocskerneldump_arg kda; + const char *pubkeyfile; int ch; int i, fd; - u_int u; int do_listdumpdev = 0; + bool enable; - while ((ch = getopt(argc, argv, "lv")) != -1) + pubkeyfile = NULL; + + while ((ch = getopt(argc, argv, "k:lv")) != -1) switch((char)ch) { + case 'k': + pubkeyfile = optarg; + break; case 'l': do_listdumpdev = 1; break; @@ -151,7 +220,15 @@ main(int argc, char *argv[]) if (argc != 1) usage(); - if (strcmp(argv[0], "off") != 0) { + enable = (strcmp(argv[0], "off") != 0); +#ifndef HAVE_CRYPTO + if (pubkeyfile != NULL) { + enable = false; + warnx("Unable to use the public key. Recompile dumpon with OpenSSL support."); + } +#endif + + if (enable) { char tmp[PATH_MAX]; char *dumpdev; @@ -171,18 +248,32 @@ main(int argc, char *argv[]) if (fd < 0) err(EX_OSFILE, "%s", dumpdev); check_size(fd, dumpdev); - u = 0; - i = ioctl(fd, DIOCSKERNELDUMP, &u); - u = 1; - i = ioctl(fd, DIOCSKERNELDUMP, &u); + bzero(&kda, sizeof(kda)); + + kda.kda_enable = 0; + i = ioctl(fd, DIOCSKERNELDUMP, &kda); + explicit_bzero(&kda, sizeof(kda)); + +#ifdef HAVE_CRYPTO + if (pubkeyfile != NULL) + genkey(pubkeyfile, &kda); +#endif + + kda.kda_enable = 1; + i = ioctl(fd, DIOCSKERNELDUMP, &kda); + explicit_bzero(kda.kda_encryptedkey, kda.kda_encryptedkeysize); + free(kda.kda_encryptedkey); + explicit_bzero(&kda, sizeof(kda)); if (i == 0 && verbose) printf("kernel dumps on %s\n", dumpdev); } else { fd = open(_PATH_DEVNULL, O_RDONLY); if (fd < 0) err(EX_OSFILE, "%s", _PATH_DEVNULL); - u = 0; - i = ioctl(fd, DIOCSKERNELDUMP, &u); + + kda.kda_enable = 0; + i = ioctl(fd, DIOCSKERNELDUMP, &kda); + explicit_bzero(&kda, sizeof(kda)); if (i == 0 && verbose) printf("kernel dumps disabled\n"); } diff --git a/sbin/savecore/savecore.8 b/sbin/savecore/savecore.8 index af46d05e4d6..7d54c823aff 100644 --- a/sbin/savecore/savecore.8 +++ b/sbin/savecore/savecore.8 @@ -28,7 +28,7 @@ .\" From: @(#)savecore.8 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd December 1, 2015 +.Dd December 10, 2016 .Dt SAVECORE 8 .Os .Sh NAME @@ -119,6 +119,10 @@ If it passes these checks, it saves the core image in .Ar directory Ns Pa /vmcore.# and information about the core in .Ar directory Ns Pa /info.# . +If the core is encrypted, it saves the dump key in +.Ar directory Ns Pa /key.# . +The core can be later decrypted using +.Xr decryptcore 8 . For kernel textdumps generated with the .Xr textdump 4 facility, output will be stored in the @@ -166,6 +170,7 @@ is meant to be called near the end of the initialization file .Xr xo_parse_args 3 , .Xr textdump 4 , .Xr tar 5 , +.Xr decryptcore 8 , .Xr dumpon 8 , .Xr syslogd 8 .Sh HISTORY diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c index 94b80090917..b07e7e1e018 100644 --- a/sbin/savecore/savecore.c +++ b/sbin/savecore/savecore.c @@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -183,6 +184,28 @@ writebounds(int bounds) { fclose(fp); } +static bool +writekey(const char *keyname, uint8_t *dumpkey, uint32_t dumpkeysize) +{ + int fd; + + fd = open(keyname, O_WRONLY | O_CREAT | O_TRUNC, 0600); + if (fd == -1) { + syslog(LOG_ERR, "Unable to open %s to write the key: %m.", + keyname); + return (false); + } + + if (write(fd, dumpkey, dumpkeysize) != (ssize_t)dumpkeysize) { + syslog(LOG_ERR, "Unable to write the key to %s: %m.", keyname); + close(fd); + return (false); + } + + close(fd); + return (true); +} + static off_t file_size(const char *path) { @@ -238,8 +261,11 @@ symlinks_remove(void) { (void)unlink("info.last"); + (void)unlink("key.last"); (void)unlink("vmcore.last"); (void)unlink("vmcore.last.gz"); + (void)unlink("vmcore_encrypted.last"); + (void)unlink("vmcore_encrypted.last.gz"); (void)unlink("textdump.tar.last"); (void)unlink("textdump.tar.last.gz"); } @@ -292,8 +318,8 @@ check_space(const char *savedir, off_t dumpsize, int bounds) #define BLOCKMASK (~(BLOCKSIZE-1)) static int -DoRegularFile(int fd, off_t dumpsize, char *buf, const char *device, - const char *filename, FILE *fp) +DoRegularFile(int fd, bool isencrypted, off_t dumpsize, char *buf, + const char *device, const char *filename, FILE *fp) { int he, hs, nr, nw, wl; off_t dmpcnt, origsize; @@ -315,7 +341,7 @@ DoRegularFile(int fd, off_t dumpsize, char *buf, const char *device, nerr++; return (-1); } - if (compress) { + if (compress || isencrypted) { nw = fwrite(buf, 1, wl, fp); } else { for (nw = 0; nw < nr; nw = he) { @@ -436,9 +462,11 @@ DoFile(const char *savedir, const char *device) { xo_handle_t *xostdout, *xoinfo; static char infoname[PATH_MAX], corename[PATH_MAX], linkname[PATH_MAX]; + static char keyname[PATH_MAX]; static char *buf = NULL; char *temp = NULL; struct kerneldumpheader kdhf, kdhl; + uint8_t *dumpkey; off_t mediasize, dumpsize, firsthd, lasthd; FILE *info, *fp; mode_t oumask; @@ -446,6 +474,8 @@ DoFile(const char *savedir, const char *device) int bounds, status; u_int sectorsize, xostyle; int istextdump; + uint32_t dumpkeysize; + bool isencrypted, ret; bounds = getbounds(); mediasize = 0; @@ -581,7 +611,8 @@ DoFile(const char *savedir, const char *device) goto closefd; } dumpsize = dtoh64(kdhl.dumplength); - firsthd = lasthd - dumpsize - sectorsize; + dumpkeysize = dtoh32(kdhl.dumpkeysize); + firsthd = lasthd - dumpsize - sectorsize - dumpkeysize; if (lseek(fd, firsthd, SEEK_SET) != firsthd || read(fd, temp, sectorsize) != (ssize_t)sectorsize) { syslog(LOG_ERR, @@ -649,13 +680,16 @@ DoFile(const char *savedir, const char *device) } oumask = umask(S_IRWXG|S_IRWXO); /* Restrict access to the core file.*/ + isencrypted = (dumpkeysize > 0); if (compress) { snprintf(corename, sizeof(corename), "%s.%d.gz", - istextdump ? "textdump.tar" : "vmcore", bounds); + istextdump ? "textdump.tar" : + (isencrypted ? "vmcore_encrypted" : "vmcore"), bounds); fp = zopen(corename, "w"); } else { snprintf(corename, sizeof(corename), "%s.%d", - istextdump ? "textdump.tar" : "vmcore", bounds); + istextdump ? "textdump.tar" : + (isencrypted ? "vmcore_encrypted" : "vmcore"), bounds); fp = fopen(corename, "w"); } if (fp == NULL) { @@ -692,17 +726,42 @@ DoFile(const char *savedir, const char *device) xo_finish_h(xoinfo); fclose(info); - syslog(LOG_NOTICE, "writing %score to %s/%s", - compress ? "compressed " : "", savedir, corename); + if (isencrypted) { + dumpkey = calloc(1, dumpkeysize); + if (dumpkey == NULL) { + syslog(LOG_ERR, "Unable to allocate kernel dump key."); + nerr++; + goto closeall; + } + + if (read(fd, dumpkey, dumpkeysize) != (ssize_t)dumpkeysize) { + syslog(LOG_ERR, "Unable to read kernel dump key: %m."); + nerr++; + goto closeall; + } + + snprintf(keyname, sizeof(keyname), "key.%d", bounds); + ret = writekey(keyname, dumpkey, dumpkeysize); + explicit_bzero(dumpkey, dumpkeysize); + if (!ret) { + nerr++; + goto closeall; + } + } + + syslog(LOG_NOTICE, "writing %s%score to %s/%s", + isencrypted ? "encrypted " : "", compress ? "compressed " : "", + savedir, corename); if (istextdump) { if (DoTextdumpFile(fd, dumpsize, lasthd, buf, device, corename, fp) < 0) goto closeall; } else { - if (DoRegularFile(fd, dumpsize, buf, device, corename, fp) - < 0) + if (DoRegularFile(fd, isencrypted, dumpsize, buf, device, + corename, fp) < 0) { goto closeall; + } } if (verbose) printf("\n"); @@ -718,12 +777,21 @@ DoFile(const char *savedir, const char *device) syslog(LOG_WARNING, "unable to create symlink %s/%s: %m", savedir, "info.last"); } + if (isencrypted) { + if (symlink(keyname, "key.last") == -1) { + syslog(LOG_WARNING, + "unable to create symlink %s/%s: %m", savedir, + "key.last"); + } + } if (compress) { snprintf(linkname, sizeof(linkname), "%s.last.gz", - istextdump ? "textdump.tar" : "vmcore"); + istextdump ? "textdump.tar" : + (isencrypted ? "vmcore_encrypted" : "vmcore")); } else { snprintf(linkname, sizeof(linkname), "%s.last", - istextdump ? "textdump.tar" : "vmcore"); + istextdump ? "textdump.tar" : + (isencrypted ? "vmcore_encrypted" : "vmcore")); } if (symlink(corename, linkname) == -1) { syslog(LOG_WARNING, "unable to create symlink %s/%s: %m", diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index ed04a77b7a0..46b6aa2063e 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 13, 2016 +.Dd December 10, 2016 .Dt RC.CONF 5 .Os .Sh NAME @@ -3502,6 +3502,18 @@ to not run at boot time when .Va dumpdir is set. +.It Va dumppubkey +.Pq Vt str +Path to a public key. +It is used by +.Xr dumpon 8 +to encrypt a one-time key for a crash dump. +The public key has to match a private key used by +.Xr decryptcore 8 +to decrypt a crash dump after reboot. +See +.Xr dumpon 8 +for more details. .It Va savecore_enable .Pq Vt bool If set to diff --git a/sys/amd64/amd64/minidump_machdep.c b/sys/amd64/amd64/minidump_machdep.c index 11bcf5f863c..a758c7b24d6 100644 --- a/sys/amd64/amd64/minidump_machdep.c +++ b/sys/amd64/amd64/minidump_machdep.c @@ -223,7 +223,6 @@ minidumpsys(struct dumperinfo *di) int error; uint64_t bits; uint64_t *pml4, *pdp, *pd, *pt, pa; - size_t size; int i, ii, j, k, n, bit; int retry_count; struct minidumphdr mdhdr; @@ -321,14 +320,21 @@ minidumpsys(struct dumperinfo *di) dumpsize += PAGE_SIZE; /* Determine dump offset on device. */ - if (di->mediasize < SIZEOF_METADATA + dumpsize + di->blocksize * 2) { + if (di->mediasize < SIZEOF_METADATA + dumpsize + di->blocksize * 2 + + kerneldumpcrypto_dumpkeysize(di->kdc)) { error = E2BIG; goto fail; } dumplo = di->mediaoffset + di->mediasize - dumpsize; dumplo -= di->blocksize * 2; + dumplo -= kerneldumpcrypto_dumpkeysize(di->kdc); progress = dumpsize; + /* Initialize kernel dump crypto. */ + error = kerneldumpcrypto_init(di->kdc); + if (error) + goto fail; + /* Initialize mdhdr */ bzero(&mdhdr, sizeof(mdhdr)); strcpy(mdhdr.magic, MINIDUMP_MAGIC); @@ -340,16 +346,23 @@ minidumpsys(struct dumperinfo *di) mdhdr.dmapbase = DMAP_MIN_ADDRESS; mdhdr.dmapend = DMAP_MAX_ADDRESS; - mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_AMD64_VERSION, dumpsize, di->blocksize); + mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_AMD64_VERSION, dumpsize, + kerneldumpcrypto_dumpkeysize(di->kdc), di->blocksize); printf("Dumping %llu out of %ju MB:", (long long)dumpsize >> 20, ptoa((uintmax_t)physmem) / 1048576); /* Dump leader */ - error = dump_write_pad(di, &kdh, 0, dumplo, sizeof(kdh), &size); + error = dump_write_header(di, &kdh, 0, dumplo); if (error) goto fail; - dumplo += size; + dumplo += di->blocksize; + + /* Dump key */ + error = dump_write_key(di, 0, dumplo); + if (error) + goto fail; + dumplo += kerneldumpcrypto_dumpkeysize(di->kdc); /* Dump my header */ bzero(&fakepd, sizeof(fakepd)); @@ -434,10 +447,10 @@ minidumpsys(struct dumperinfo *di) goto fail; /* Dump trailer */ - error = dump_write_pad(di, &kdh, 0, dumplo, sizeof(kdh), &size); + error = dump_write_header(di, &kdh, 0, dumplo); if (error) goto fail; - dumplo += size; + dumplo += di->blocksize; /* Signal completion, signoff and exit stage left. */ dump_write(di, NULL, 0, 0, 0); diff --git a/sys/arm/arm/minidump_machdep.c b/sys/arm/arm/minidump_machdep.c index e7340dcf33d..c5a139f7470 100644 --- a/sys/arm/arm/minidump_machdep.c +++ b/sys/arm/arm/minidump_machdep.c @@ -238,15 +238,22 @@ minidumpsys(struct dumperinfo *di) dumpsize += PAGE_SIZE; /* Determine dump offset on device. */ - if (di->mediasize < SIZEOF_METADATA + dumpsize + sizeof(kdh) * 2) { + if (di->mediasize < SIZEOF_METADATA + dumpsize + di->blocksize * 2 + + kerneldumpcrypto_dumpkeysize(di->kdc)) { error = ENOSPC; goto fail; } dumplo = di->mediaoffset + di->mediasize - dumpsize; - dumplo -= sizeof(kdh) * 2; + dumplo -= di->blocksize * 2; + dumplo -= kerneldumpcrypto_dumpkeysize(di->kdc); progress = dumpsize; + /* Initialize kernel dump crypto. */ + error = kerneldumpcrypto_init(di->kdc); + if (error) + goto fail; + /* Initialize mdhdr */ bzero(&mdhdr, sizeof(mdhdr)); strcpy(mdhdr.magic, MINIDUMP_MAGIC); @@ -262,16 +269,22 @@ minidumpsys(struct dumperinfo *di) mdhdr.mmuformat = MINIDUMP_MMU_FORMAT_V4; #endif mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_ARM_VERSION, dumpsize, - di->blocksize); + kerneldumpcrypto_dumpkeysize(di->kdc), di->blocksize); printf("Physical memory: %u MB\n", ptoa((uintmax_t)physmem) / 1048576); printf("Dumping %llu MB:", (long long)dumpsize >> 20); /* Dump leader */ - error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh)); + error = dump_write_header(di, &kdh, 0, dumplo); if (error) goto fail; - dumplo += sizeof(kdh); + dumplo += di->blocksize; + + /* Dump key */ + error = dump_write_key(di, 0, dumplo); + if (error) + goto fail; + dumplo += kerneldumpcrypto_dumpkeysize(di->kdc); /* Dump my header */ bzero(dumpbuf, sizeof(dumpbuf)); @@ -348,10 +361,10 @@ minidumpsys(struct dumperinfo *di) goto fail; /* Dump trailer */ - error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh)); + error = dump_write_header(di, &kdh, 0, dumplo); if (error) goto fail; - dumplo += sizeof(kdh); + dumplo += di->blocksize; /* Signal completion, signoff and exit stage left. */ dump_write(di, NULL, 0, 0, 0); diff --git a/sys/arm64/arm64/minidump_machdep.c b/sys/arm64/arm64/minidump_machdep.c index 27c2081ef78..2aeb07d0736 100644 --- a/sys/arm64/arm64/minidump_machdep.c +++ b/sys/arm64/arm64/minidump_machdep.c @@ -281,14 +281,21 @@ minidumpsys(struct dumperinfo *di) dumpsize += PAGE_SIZE; /* Determine dump offset on device. */ - if (di->mediasize < SIZEOF_METADATA + dumpsize + sizeof(kdh) * 2) { + if (di->mediasize < SIZEOF_METADATA + dumpsize + di->blocksize * 2 + + kerneldumpcrypto_dumpkeysize(di->kdc)) { error = E2BIG; goto fail; } dumplo = di->mediaoffset + di->mediasize - dumpsize; - dumplo -= sizeof(kdh) * 2; + dumplo -= di->blocksize * 2; + dumplo -= kerneldumpcrypto_dumpkeysize(di->kdc); progress = dumpsize; + /* Initialize kernel dump crypto. */ + error = kerneldumpcrypto_init(di->kdc); + if (error) + goto fail; + /* Initialize mdhdr */ bzero(&mdhdr, sizeof(mdhdr)); strcpy(mdhdr.magic, MINIDUMP_MAGIC); @@ -302,16 +309,22 @@ minidumpsys(struct dumperinfo *di) mdhdr.dmapend = DMAP_MAX_ADDRESS; mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_AARCH64_VERSION, - dumpsize, di->blocksize); + dumpsize, kerneldumpcrypto_dumpkeysize(di->kdc), di->blocksize); printf("Dumping %llu out of %ju MB:", (long long)dumpsize >> 20, ptoa((uintmax_t)physmem) / 1048576); /* Dump leader */ - error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh)); + error = dump_write_header(di, &kdh, 0, dumplo); if (error) goto fail; - dumplo += sizeof(kdh); + dumplo += di->blocksize; + + /* Dump key */ + error = dump_write_key(di, 0, dumplo); + if (error) + goto fail; + dumplo += kerneldumpcrypto_dumpkeysize(di->kdc); /* Dump my header */ bzero(&tmpbuffer, sizeof(tmpbuffer)); @@ -410,10 +423,10 @@ minidumpsys(struct dumperinfo *di) goto fail; /* Dump trailer */ - error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh)); + error = dump_write_header(di, &kdh, 0, dumplo); if (error) goto fail; - dumplo += sizeof(kdh); + dumplo += di->blocksize; /* Signal completion, signoff and exit stage left. */ dump_write(di, NULL, 0, 0, 0); diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 06143861557..cbd0934a032 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -3072,3 +3072,6 @@ options EVDEV_SUPPORT # evdev support in legacy drivers options EVDEV_DEBUG # enable event debug msgs device uinput # install /dev/uinput cdev options UINPUT_DEBUG # enable uinput debug msgs + +# Encrypted kernel crash dumps. +options EKCD diff --git a/sys/conf/files b/sys/conf/files index 9b4042726f6..23e9c6f32a5 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -594,13 +594,13 @@ crypto/camellia/camellia-api.c optional crypto | ipsec crypto/des/des_ecb.c optional crypto | ipsec | netsmb crypto/des/des_setkey.c optional crypto | ipsec | netsmb crypto/rc4/rc4.c optional netgraph_mppc_encryption | kgssapi -crypto/rijndael/rijndael-alg-fst.c optional crypto | geom_bde | \ +crypto/rijndael/rijndael-alg-fst.c optional crypto | ekcd | geom_bde | \ ipsec | random !random_loadable | wlan_ccmp -crypto/rijndael/rijndael-api-fst.c optional geom_bde | random !random_loadable +crypto/rijndael/rijndael-api-fst.c optional ekcd | geom_bde | random !random_loadable crypto/rijndael/rijndael-api.c optional crypto | ipsec | wlan_ccmp crypto/sha1.c optional carp | crypto | ipsec | \ netgraph_mppc_encryption | sctp -crypto/sha2/sha256c.c optional crypto | geom_bde | ipsec | random !random_loadable | \ +crypto/sha2/sha256c.c optional crypto | ekcd | geom_bde | ipsec | random !random_loadable | \ sctp | zfs crypto/sha2/sha512c.c optional crypto | geom_bde | ipsec | zfs crypto/skein/skein.c optional crypto | zfs diff --git a/sys/conf/options b/sys/conf/options index 07d76390505..1f20983c209 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -1004,3 +1004,6 @@ UINPUT_DEBUG opt_evdev.h # Hyper-V network driver HN_DEBUG opt_hn.h + +# Encrypted kernel crash dumps +EKCD opt_ekcd.h diff --git a/sys/ddb/db_textdump.c b/sys/ddb/db_textdump.c index aeeeec863ce..66d8d2c8403 100644 --- a/sys/ddb/db_textdump.c +++ b/sys/ddb/db_textdump.c @@ -427,6 +427,7 @@ textdump_dump_version(struct dumperinfo *di) void textdump_dumpsys(struct dumperinfo *di) { + struct kerneldumpcrypto *kdc; off_t dumplen, trailer_offset; if (di->blocksize != TEXTDUMP_BLOCKSIZE) { @@ -448,6 +449,12 @@ textdump_dumpsys(struct dumperinfo *di) } textdump_error = 0; + /* + * Disable EKCD because we don't provide encrypted textdumps. + */ + kdc = di->kdc; + di->kdc = NULL; + /* * Position the start of the dump so that we'll write the kernel dump * trailer immediately before the end of the partition, and then work @@ -456,7 +463,8 @@ textdump_dumpsys(struct dumperinfo *di) */ textdump_offset = di->mediasize - sizeof(kdh); textdump_saveoff(&trailer_offset); - mkdumpheader(&kdh, TEXTDUMPMAGIC, KERNELDUMP_TEXT_VERSION, 0, TEXTDUMP_BLOCKSIZE); + mkdumpheader(&kdh, TEXTDUMPMAGIC, KERNELDUMP_TEXT_VERSION, 0, 0, + TEXTDUMP_BLOCKSIZE); (void)textdump_writenextblock(di, (char *)&kdh); /* @@ -481,7 +489,7 @@ textdump_dumpsys(struct dumperinfo *di) * size. */ dumplen = trailer_offset - (textdump_offset + TEXTDUMP_BLOCKSIZE); - mkdumpheader(&kdh, TEXTDUMPMAGIC, KERNELDUMP_TEXT_VERSION, dumplen, + mkdumpheader(&kdh, TEXTDUMPMAGIC, KERNELDUMP_TEXT_VERSION, dumplen, 0, TEXTDUMP_BLOCKSIZE); (void)textdump_writenextblock(di, (char *)&kdh); textdump_restoreoff(trailer_offset); @@ -499,6 +507,11 @@ textdump_dumpsys(struct dumperinfo *di) else printf("Textdump complete.\n"); textdump_pending = 0; + + /* + * Restore EKCD status. + */ + di->kdc = kdc; } /*- diff --git a/sys/dev/null/null.c b/sys/dev/null/null.c index c8966df8ac4..d946da6208f 100644 --- a/sys/dev/null/null.c +++ b/sys/dev/null/null.c @@ -30,6 +30,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_compat.h" + #include #include #include @@ -108,8 +110,11 @@ null_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t data __unused, error = 0; switch (cmd) { +#ifdef COMPAT_FREEBSD11 + case DIOCSKERNELDUMP_FREEBSD11: +#endif case DIOCSKERNELDUMP: - error = set_dumper(NULL, NULL, td); + error = set_dumper(NULL, NULL, td, 0, NULL, 0, NULL); break; case FIONBIO: break; diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c index 3ccbd583fa2..82f7d4bdb9c 100644 --- a/sys/geom/geom_dev.c +++ b/sys/geom/geom_dev.c @@ -36,6 +36,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_compat.h" + #include #include #include @@ -128,36 +130,44 @@ g_dev_fini(struct g_class *mp) } static int -g_dev_setdumpdev(struct cdev *dev, struct thread *td) +g_dev_setdumpdev(struct cdev *dev, struct diocskerneldump_arg *kda, + struct thread *td) { struct g_kerneldump kd; struct g_consumer *cp; int error, len; - if (dev == NULL) - return (set_dumper(NULL, NULL, td)); + if (dev == NULL || kda == NULL) + return (set_dumper(NULL, NULL, td, 0, NULL, 0, NULL)); cp = dev->si_drv2; len = sizeof(kd); kd.offset = 0; kd.length = OFF_MAX; error = g_io_getattr("GEOM::kerneldump", cp, &len, &kd); - if (error == 0) { - error = set_dumper(&kd.di, devtoname(dev), td); - if (error == 0) - dev->si_flags |= SI_DUMPDEV; - } + if (error != 0) + return (error); + + error = set_dumper(&kd.di, devtoname(dev), td, kda->kda_encryption, + kda->kda_key, kda->kda_encryptedkeysize, kda->kda_encryptedkey); + if (error == 0) + dev->si_flags |= SI_DUMPDEV; + return (error); } static int init_dumpdev(struct cdev *dev) { + struct diocskerneldump_arg kda; struct g_consumer *cp; const char *devprefix = "/dev/", *devname; int error; size_t len; + bzero(&kda, sizeof(kda)); + kda.kda_enable = 1; + if (dumpdev == NULL) return (0); @@ -173,7 +183,7 @@ init_dumpdev(struct cdev *dev) if (error != 0) return (error); - error = g_dev_setdumpdev(dev, curthread); + error = g_dev_setdumpdev(dev, &kda, curthread); if (error == 0) { freeenv(dumpdev); dumpdev = NULL; @@ -493,12 +503,56 @@ g_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread case DIOCGFRONTSTUFF: error = g_io_getattr("GEOM::frontstuff", cp, &i, data); break; - case DIOCSKERNELDUMP: - if (*(u_int *)data == 0) - error = g_dev_setdumpdev(NULL, td); +#ifdef COMPAT_FREEBSD11 + case DIOCSKERNELDUMP_FREEBSD11: + { + struct diocskerneldump_arg kda; + + bzero(&kda, sizeof(kda)); + kda.kda_encryption = KERNELDUMP_ENC_NONE; + kda.kda_enable = (uint8_t)*(u_int *)data; + if (kda.kda_enable == 0) + error = g_dev_setdumpdev(NULL, NULL, td); else - error = g_dev_setdumpdev(dev, td); + error = g_dev_setdumpdev(dev, &kda, td); break; + } +#endif + case DIOCSKERNELDUMP: + { + struct diocskerneldump_arg *kda; + uint8_t *encryptedkey; + + kda = (struct diocskerneldump_arg *)data; + if (kda->kda_enable == 0) { + error = g_dev_setdumpdev(NULL, NULL, td); + break; + } + + if (kda->kda_encryption != KERNELDUMP_ENC_NONE) { + if (kda->kda_encryptedkeysize <= 0 || + kda->kda_encryptedkeysize > + KERNELDUMP_ENCKEY_MAX_SIZE) { + return (EINVAL); + } + encryptedkey = malloc(kda->kda_encryptedkeysize, M_TEMP, + M_WAITOK); + error = copyin(kda->kda_encryptedkey, encryptedkey, + kda->kda_encryptedkeysize); + } else { + encryptedkey = NULL; + } + if (error == 0) { + kda->kda_encryptedkey = encryptedkey; + error = g_dev_setdumpdev(dev, kda, td); + } + if (encryptedkey != NULL) { + explicit_bzero(encryptedkey, kda->kda_encryptedkeysize); + free(encryptedkey, M_TEMP); + } + explicit_bzero(kda, sizeof(*kda)); + break; + } case DIOCGFLUSH: error = g_io_flush(cp); break; @@ -756,7 +810,7 @@ g_dev_orphan(struct g_consumer *cp) /* Reset any dump-area set on this device */ if (dev->si_flags & SI_DUMPDEV) - (void)set_dumper(NULL, NULL, curthread); + (void)set_dumper(NULL, NULL, curthread, 0, NULL, 0, NULL); /* Destroy the struct cdev *so we get no more requests */ destroy_dev_sched_cb(dev, g_dev_callback, cp); diff --git a/sys/i386/i386/minidump_machdep.c b/sys/i386/i386/minidump_machdep.c index 6fd11f3721a..b50a0de82a6 100644 --- a/sys/i386/i386/minidump_machdep.c +++ b/sys/i386/i386/minidump_machdep.c @@ -245,14 +245,21 @@ minidumpsys(struct dumperinfo *di) dumpsize += PAGE_SIZE; /* Determine dump offset on device. */ - if (di->mediasize < SIZEOF_METADATA + dumpsize + sizeof(kdh) * 2) { + if (di->mediasize < SIZEOF_METADATA + dumpsize + di->blocksize * 2 + + kerneldumpcrypto_dumpkeysize(di->kdc)) { error = ENOSPC; goto fail; } dumplo = di->mediaoffset + di->mediasize - dumpsize; - dumplo -= sizeof(kdh) * 2; + dumplo -= di->blocksize * 2; + dumplo -= kerneldumpcrypto_dumpkeysize(di->kdc); progress = dumpsize; + /* Initialize kernel dump crypto. */ + error = kerneldumpcrypto_init(di->kdc); + if (error) + goto fail; + /* Initialize mdhdr */ bzero(&mdhdr, sizeof(mdhdr)); strcpy(mdhdr.magic, MINIDUMP_MAGIC); @@ -265,16 +272,23 @@ minidumpsys(struct dumperinfo *di) mdhdr.paemode = 1; #endif - mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_I386_VERSION, dumpsize, di->blocksize); + mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_I386_VERSION, dumpsize, + kerneldumpcrypto_dumpkeysize(di->kdc), di->blocksize); printf("Physical memory: %ju MB\n", ptoa((uintmax_t)physmem) / 1048576); printf("Dumping %llu MB:", (long long)dumpsize >> 20); /* Dump leader */ - error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh)); + error = dump_write_header(di, &kdh, 0, dumplo); if (error) goto fail; - dumplo += sizeof(kdh); + dumplo += di->blocksize; + + /* Dump key */ + error = dump_write_key(di, 0, dumplo); + if (error) + goto fail; + dumplo += kerneldumpcrypto_dumpkeysize(di->kdc); /* Dump my header */ bzero(&fakept, sizeof(fakept)); @@ -349,10 +363,10 @@ minidumpsys(struct dumperinfo *di) goto fail; /* Dump trailer */ - error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh)); + error = dump_write_header(di, &kdh, 0, dumplo); if (error) goto fail; - dumplo += sizeof(kdh); + dumplo += di->blocksize; /* Signal completion, signoff and exit stage left. */ dump_write(di, NULL, 0, 0, 0); diff --git a/sys/kern/kern_dump.c b/sys/kern/kern_dump.c index 8e922a1e1bd..986149782e7 100644 --- a/sys/kern/kern_dump.c +++ b/sys/kern/kern_dump.c @@ -116,6 +116,29 @@ dumpsys_gen_write_aux_headers(struct dumperinfo *di) } #endif +int +dumpsys_buf_seek(struct dumperinfo *di, size_t sz) +{ + static uint8_t buf[DEV_BSIZE]; + size_t nbytes; + int error; + + bzero(buf, sizeof(buf)); + + while (sz > 0) { + nbytes = MIN(sz, sizeof(buf)); + + error = dump_write(di, buf, 0, dumplo, nbytes); + if (error) + return (error); + dumplo += nbytes; + + sz -= nbytes; + } + + return (0); +} + int dumpsys_buf_write(struct dumperinfo *di, char *ptr, size_t sz) { @@ -284,7 +307,7 @@ dumpsys_generic(struct dumperinfo *di) Elf_Ehdr ehdr; uint64_t dumpsize; off_t hdrgap; - size_t hdrsz, size; + size_t hdrsz; int error; #ifndef __powerpc__ @@ -325,24 +348,37 @@ dumpsys_generic(struct dumperinfo *di) hdrgap = fileofs - roundup2((off_t)hdrsz, di->blocksize); /* Determine dump offset on device. */ - if (di->mediasize < SIZEOF_METADATA + dumpsize + di->blocksize * 2) { + if (di->mediasize < SIZEOF_METADATA + dumpsize + di->blocksize * 2 + + kerneldumpcrypto_dumpkeysize(di->kdc)) { error = ENOSPC; goto fail; } dumplo = di->mediaoffset + di->mediasize - dumpsize; dumplo -= di->blocksize * 2; + dumplo -= kerneldumpcrypto_dumpkeysize(di->kdc); + + /* Initialize kernel dump crypto. */ + error = kerneldumpcrypto_init(di->kdc); + if (error) + goto fail; mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_ARCH_VERSION, dumpsize, - di->blocksize); + kerneldumpcrypto_dumpkeysize(di->kdc), di->blocksize); printf("Dumping %ju MB (%d chunks)\n", (uintmax_t)dumpsize >> 20, ehdr.e_phnum - DUMPSYS_NUM_AUX_HDRS); /* Dump leader */ - error = dump_write_pad(di, &kdh, 0, dumplo, sizeof(kdh), &size); + error = dump_write_header(di, &kdh, 0, dumplo); if (error) goto fail; - dumplo += size; + dumplo += di->blocksize; + + /* Dump key */ + error = dump_write_key(di, 0, dumplo); + if (error) + goto fail; + dumplo += kerneldumpcrypto_dumpkeysize(di->kdc); /* Dump ELF header */ error = dumpsys_buf_write(di, (char*)&ehdr, sizeof(ehdr)); @@ -365,7 +401,9 @@ dumpsys_generic(struct dumperinfo *di) * boundary. We cannot use MD_ALIGN on dumplo, because we don't * care and may very well be unaligned within the dump device. */ - dumplo += hdrgap; + error = dumpsys_buf_seek(di, (size_t)hdrgap); + if (error) + goto fail; /* Dump memory chunks (updates dumplo) */ error = dumpsys_foreach_chunk(dumpsys_cb_dumpdata, di); @@ -373,9 +411,10 @@ dumpsys_generic(struct dumperinfo *di) goto fail; /* Dump trailer */ - error = dump_write_pad(di, &kdh, 0, dumplo, sizeof(kdh), &size); + error = dump_write_header(di, &kdh, 0, dumplo); if (error) goto fail; + dumplo += di->blocksize; /* Signal completion, signoff and exit stage left. */ dump_write(di, NULL, 0, 0, 0); diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index 79c4c30d7cc..f981c809362 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include "opt_ddb.h" +#include "opt_ekcd.h" #include "opt_kdb.h" #include "opt_panic.h" #include "opt_sched.h" @@ -71,6 +72,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include + #include #include @@ -143,6 +147,22 @@ int suspend_blocked = 0; SYSCTL_INT(_kern, OID_AUTO, suspend_blocked, CTLFLAG_RW, &suspend_blocked, 0, "Block suspend due to a pending shutdown"); +#ifdef EKCD +FEATURE(ekcd, "Encrypted kernel crash dumps support"); + +MALLOC_DEFINE(M_EKCD, "ekcd", "Encrypted kernel crash dumps data"); + +struct kerneldumpcrypto { + uint8_t kdc_encryption; + uint8_t kdc_iv[KERNELDUMP_IV_MAX_SIZE]; + keyInstance kdc_ki; + cipherInstance kdc_ci; + off_t kdc_nextoffset; + uint32_t kdc_dumpkeysize; + struct kerneldumpkey kdc_dumpkey[]; +}; +#endif + /* * Variable panicstr contains argument to first call to panic; used as flag * to indicate that the kernel has already called panic. @@ -838,9 +858,111 @@ static char dumpdevname[sizeof(((struct cdev*)NULL)->si_name)]; SYSCTL_STRING(_kern_shutdown, OID_AUTO, dumpdevname, CTLFLAG_RD, dumpdevname, 0, "Device for kernel dumps"); +#ifdef EKCD +static struct kerneldumpcrypto * +kerneldumpcrypto_create(size_t blocksize, uint8_t encryption, + const uint8_t *key, uint32_t encryptedkeysize, const uint8_t *encryptedkey) +{ + struct kerneldumpcrypto *kdc; + struct kerneldumpkey *kdk; + uint32_t dumpkeysize; + + dumpkeysize = roundup2(sizeof(*kdk) + encryptedkeysize, blocksize); + kdc = malloc(sizeof(*kdc) + dumpkeysize, M_EKCD, M_WAITOK | M_ZERO); + + arc4rand(kdc->kdc_iv, sizeof(kdc->kdc_iv), 0); + + kdc->kdc_encryption = encryption; + switch (kdc->kdc_encryption) { + case KERNELDUMP_ENC_AES_256_CBC: + if (rijndael_makeKey(&kdc->kdc_ki, DIR_ENCRYPT, 256, key) <= 0) + goto failed; + break; + default: + goto failed; + } + + kdc->kdc_dumpkeysize = dumpkeysize; + kdk = kdc->kdc_dumpkey; + kdk->kdk_encryption = kdc->kdc_encryption; + memcpy(kdk->kdk_iv, kdc->kdc_iv, sizeof(kdk->kdk_iv)); + kdk->kdk_encryptedkeysize = htod32(encryptedkeysize); + memcpy(kdk->kdk_encryptedkey, encryptedkey, encryptedkeysize); + + return (kdc); +failed: + explicit_bzero(kdc, sizeof(*kdc) + dumpkeysize); + free(kdc, M_EKCD); + return (NULL); +} +#endif /* EKCD */ + +int +kerneldumpcrypto_init(struct kerneldumpcrypto *kdc) +{ +#ifndef EKCD + return (0); +#else + uint8_t hash[SHA256_DIGEST_LENGTH]; + SHA256_CTX ctx; + struct kerneldumpkey *kdk; + int error; + + error = 0; + + if (kdc == NULL) + return (0); + + /* + * When a user enters ddb it can write a crash dump multiple times. + * Each time it should be encrypted using a different IV. + */ + SHA256_Init(&ctx); + SHA256_Update(&ctx, kdc->kdc_iv, sizeof(kdc->kdc_iv)); + SHA256_Final(hash, &ctx); + bcopy(hash, kdc->kdc_iv, sizeof(kdc->kdc_iv)); + + switch (kdc->kdc_encryption) { + case KERNELDUMP_ENC_AES_256_CBC: + if (rijndael_cipherInit(&kdc->kdc_ci, MODE_CBC, + kdc->kdc_iv) <= 0) { + error = EINVAL; + goto out; + } + break; + default: + error = EINVAL; + goto out; + } + + kdc->kdc_nextoffset = 0; + + kdk = kdc->kdc_dumpkey; + memcpy(kdk->kdk_iv, kdc->kdc_iv, sizeof(kdk->kdk_iv)); +out: + explicit_bzero(hash, sizeof(hash)); + return (error); +#endif +} + +uint32_t +kerneldumpcrypto_dumpkeysize(const struct kerneldumpcrypto *kdc) +{ + +#ifdef EKCD + if (kdc == NULL) + return (0); + return (kdc->kdc_dumpkeysize); +#else + return (0); +#endif +} + /* Registration of dumpers */ int -set_dumper(struct dumperinfo *di, const char *devname, struct thread *td) +set_dumper(struct dumperinfo *di, const char *devname, struct thread *td, + uint8_t encryption, const uint8_t *key, uint32_t encryptedkeysize, + const uint8_t *encryptedkey) { size_t wantcopy; int error; @@ -850,28 +972,56 @@ set_dumper(struct dumperinfo *di, const char *devname, struct thread *td) return (error); if (di == NULL) { - if (dumper.blockbuf != NULL) - free(dumper.blockbuf, M_DUMPER); - bzero(&dumper, sizeof(dumper)); - dumpdevname[0] = '\0'; - return (0); + error = 0; + goto cleanup; } if (dumper.dumper != NULL) return (EBUSY); dumper = *di; + dumper.blockbuf = NULL; + dumper.kdc = NULL; + + if (encryption != KERNELDUMP_ENC_NONE) { +#ifdef EKCD + dumper.kdc = kerneldumpcrypto_create(di->blocksize, encryption, + key, encryptedkeysize, encryptedkey); + if (dumper.kdc == NULL) { + error = EINVAL; + goto cleanup; + } +#else + error = EOPNOTSUPP; + goto cleanup; +#endif + } + wantcopy = strlcpy(dumpdevname, devname, sizeof(dumpdevname)); if (wantcopy >= sizeof(dumpdevname)) { printf("set_dumper: device name truncated from '%s' -> '%s'\n", devname, dumpdevname); } + dumper.blockbuf = malloc(di->blocksize, M_DUMPER, M_WAITOK | M_ZERO); return (0); +cleanup: +#ifdef EKCD + if (dumper.kdc != NULL) { + explicit_bzero(dumper.kdc, sizeof(*dumper.kdc) + + dumper.kdc->kdc_dumpkeysize); + free(dumper.kdc, M_EKCD); + } +#endif + if (dumper.blockbuf != NULL) { + explicit_bzero(dumper.blockbuf, dumper.blocksize); + free(dumper.blockbuf, M_DUMPER); + } + explicit_bzero(&dumper, sizeof(dumper)); + dumpdevname[0] = '\0'; + return (error); } -/* Call dumper with bounds checking. */ -int -dump_write(struct dumperinfo *di, void *virtual, vm_offset_t physical, - off_t offset, size_t length) +static int +dump_check_bounds(struct dumperinfo *di, off_t offset, size_t length) { if (length != 0 && (offset < di->mediaoffset || @@ -882,37 +1032,202 @@ dump_write(struct dumperinfo *di, void *virtual, vm_offset_t physical, (uintmax_t)length, (intmax_t)di->mediasize); return (ENOSPC); } + + return (0); +} + +#ifdef EKCD +static int +dump_encrypt(struct kerneldumpcrypto *kdc, uint8_t *buf, size_t size) +{ + + switch (kdc->kdc_encryption) { + case KERNELDUMP_ENC_AES_256_CBC: + if (rijndael_blockEncrypt(&kdc->kdc_ci, &kdc->kdc_ki, buf, + 8 * size, buf) <= 0) { + return (EIO); + } + if (rijndael_cipherInit(&kdc->kdc_ci, MODE_CBC, + buf + size - 16 /* IV size for AES-256-CBC */) <= 0) { + return (EIO); + } + break; + default: + return (EINVAL); + } + + return (0); +} + +/* Encrypt data and call dumper. */ +static int +dump_encrypted_write(struct dumperinfo *di, void *virtual, vm_offset_t physical, + off_t offset, size_t length) +{ + static uint8_t buf[KERNELDUMP_BUFFER_SIZE]; + struct kerneldumpcrypto *kdc; + int error; + size_t nbytes; + off_t nextoffset; + + kdc = di->kdc; + + error = dump_check_bounds(di, offset, length); + if (error != 0) + return (error); + + /* Signal completion. */ + if (virtual == NULL && physical == 0 && offset == 0 && length == 0) { + return (di->dumper(di->priv, virtual, physical, offset, + length)); + } + + /* Data have to be aligned to block size. */ + if ((length % di->blocksize) != 0) + return (EINVAL); + + /* + * Data have to be written continuously becase we're encrypting using + * CBC mode which has this assumption. + */ + if (kdc->kdc_nextoffset != 0 && kdc->kdc_nextoffset != offset) + return (EINVAL); + + nextoffset = offset + (off_t)length; + + while (length > 0) { + nbytes = MIN(length, sizeof(buf)); + bcopy(virtual, buf, nbytes); + + if (dump_encrypt(kdc, buf, nbytes) != 0) + return (EIO); + + error = di->dumper(di->priv, buf, physical, offset, nbytes); + if (error != 0) + return (error); + + offset += nbytes; + virtual = (void *)((uint8_t *)virtual + nbytes); + length -= nbytes; + } + + kdc->kdc_nextoffset = nextoffset; + + return (0); +} +#endif /* EKCD */ + +/* Call dumper with bounds checking. */ +static int +dump_raw_write(struct dumperinfo *di, void *virtual, vm_offset_t physical, + off_t offset, size_t length) +{ + int error; + + error = dump_check_bounds(di, offset, length); + if (error != 0) + return (error); + return (di->dumper(di->priv, virtual, physical, offset, length)); } -/* Call dumper with bounds checking. */ int -dump_write_pad(struct dumperinfo *di, void *virtual, vm_offset_t physical, - off_t offset, size_t length, size_t *size) +dump_write(struct dumperinfo *di, void *virtual, vm_offset_t physical, + off_t offset, size_t length) +{ + +#ifdef EKCD + if (di->kdc != NULL) { + return (dump_encrypted_write(di, virtual, physical, offset, + length)); + } +#endif + + return (dump_raw_write(di, virtual, physical, offset, length)); +} + +static int +dump_pad(struct dumperinfo *di, void *virtual, size_t length, void **buf, + size_t *size) { - char *temp; - int ret; if (length > di->blocksize) return (ENOMEM); *size = di->blocksize; - if (length == di->blocksize) - temp = virtual; - else { - temp = di->blockbuf; - memset(temp + length, 0, di->blocksize - length); - memcpy(temp, virtual, length); + if (length == di->blocksize) { + *buf = virtual; + } else { + *buf = di->blockbuf; + memcpy(*buf, virtual, length); + memset((uint8_t *)*buf + length, 0, di->blocksize - length); } - ret = dump_write(di, temp, physical, offset, *size); + return (0); +} + +static int +dump_raw_write_pad(struct dumperinfo *di, void *virtual, vm_offset_t physical, + off_t offset, size_t length, size_t *size) +{ + void *buf; + int error; + + error = dump_pad(di, virtual, length, &buf, size); + if (error != 0) + return (error); + + return (dump_raw_write(di, buf, physical, offset, *size)); +} + +int +dump_write_pad(struct dumperinfo *di, void *virtual, vm_offset_t physical, + off_t offset, size_t length, size_t *size) +{ + void *buf; + int error; + + error = dump_pad(di, virtual, length, &buf, size); + if (error != 0) + return (error); + + return (dump_write(di, buf, physical, offset, *size)); +} + +int +dump_write_header(struct dumperinfo *di, struct kerneldumpheader *kdh, + vm_offset_t physical, off_t offset) +{ + size_t size; + int ret; + + ret = dump_raw_write_pad(di, kdh, physical, offset, sizeof(*kdh), + &size); + if (ret == 0 && size != di->blocksize) + ret = EINVAL; return (ret); } +int +dump_write_key(struct dumperinfo *di, vm_offset_t physical, off_t offset) +{ +#ifndef EKCD + return (0); +#else /* EKCD */ + struct kerneldumpcrypto *kdc; + + kdc = di->kdc; + if (kdc == NULL) + return (0); + + return (dump_raw_write(di, kdc->kdc_dumpkey, physical, offset, + kdc->kdc_dumpkeysize)); +#endif /* !EKCD */ +} void mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver, - uint64_t dumplen, uint32_t blksz) + uint64_t dumplen, uint32_t dumpkeysize, uint32_t blksz) { bzero(kdh, sizeof(*kdh)); @@ -922,6 +1237,7 @@ mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver, kdh->architectureversion = htod32(archver); kdh->dumplength = htod64(dumplen); kdh->dumptime = htod64(time_second); + kdh->dumpkeysize = htod32(dumpkeysize); kdh->blocksize = htod32(blksz); strlcpy(kdh->hostname, prison0.pr_hostname, sizeof(kdh->hostname)); strlcpy(kdh->versionstring, version, sizeof(kdh->versionstring)); diff --git a/sys/mips/mips/minidump_machdep.c b/sys/mips/mips/minidump_machdep.c index d9e3b47c555..c0dba4c5da6 100644 --- a/sys/mips/mips/minidump_machdep.c +++ b/sys/mips/mips/minidump_machdep.c @@ -219,15 +219,22 @@ minidumpsys(struct dumperinfo *di) dumpsize += PAGE_SIZE; /* Determine dump offset on device. */ - if (di->mediasize < SIZEOF_METADATA + dumpsize + sizeof(kdh) * 2) { + if (di->mediasize < SIZEOF_METADATA + dumpsize + di->blocksize * 2 + + kerneldumpcrypto_dumpkeysize(di->kdc)) { error = ENOSPC; goto fail; } origdumplo = dumplo = di->mediaoffset + di->mediasize - dumpsize; - dumplo -= sizeof(kdh) * 2; + dumplo -= di->blocksize * 2; + dumplo -= kerneldumpcrypto_dumpkeysize(di->kdc); progress = dumpsize; + /* Initialize kernel dump crypto. */ + error = kerneldumpcrypto_init(di->kdc); + if (error) + goto fail; + /* Initialize mdhdr */ bzero(&mdhdr, sizeof(mdhdr)); strcpy(mdhdr.magic, MINIDUMP_MAGIC); @@ -238,17 +245,23 @@ minidumpsys(struct dumperinfo *di) mdhdr.kernbase = VM_MIN_KERNEL_ADDRESS; mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_MIPS_VERSION, dumpsize, - di->blocksize); + kerneldumpcrypto_dumpkeysize(di->kdc), di->blocksize); printf("Physical memory: %ju MB\n", (uintmax_t)ptoa((uintmax_t)physmem) / 1048576); printf("Dumping %llu MB:", (long long)dumpsize >> 20); /* Dump leader */ - error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh)); + error = dump_write_header(di, &kdh, 0, dumplo); if (error) goto fail; - dumplo += sizeof(kdh); + dumplo += di->blocksize; + + /* Dump key */ + error = dump_write_key(di, 0, dumplo); + if (error) + goto fail; + dumplo += kerneldumpcrypto_dumpkeysize(di->kdc); /* Dump my header */ bzero(tmpbuffer, sizeof(tmpbuffer)); @@ -316,10 +329,10 @@ minidumpsys(struct dumperinfo *di) } /* Dump trailer */ - error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh)); + error = dump_write_header(di, &kdh, 0, dumplo); if (error) goto fail; - dumplo += sizeof(kdh); + dumplo += di->blocksize; /* Signal completion, signoff and exit stage left. */ dump_write(di, NULL, 0, 0, 0); diff --git a/sys/sparc64/sparc64/dump_machdep.c b/sys/sparc64/sparc64/dump_machdep.c index 9cb1aabd132..6dc1fa425b9 100644 --- a/sys/sparc64/sparc64/dump_machdep.c +++ b/sys/sparc64/sparc64/dump_machdep.c @@ -94,7 +94,8 @@ dumpsys(struct dumperinfo *di) DEV_BSIZE); size += hdrsize; - totsize = size + 2 * sizeof(kdh); + totsize = size + 2 * di->blocksize + + kerneldumpcrypto_dumpkeysize(di->kdc); if (totsize > di->mediasize) { printf("Insufficient space on device (need %ld, have %ld), " "refusing to dump.\n", (long)totsize, @@ -106,16 +107,27 @@ dumpsys(struct dumperinfo *di) /* Determine dump offset on device. */ dumplo = di->mediaoffset + di->mediasize - totsize; + /* Initialize kernel dump crypto. */ + error = kerneldumpcrypto_init(di->kdc); + if (error) + goto fail; + mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_SPARC64_VERSION, size, - di->blocksize); + kerneldumpcrypto_dumpkeysize(di->kdc), di->blocksize); printf("Dumping %lu MB (%d chunks)\n", (u_long)(size >> 20), nreg); /* Dump leader */ - error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh)); + error = dump_write_header(di, &kdh, 0, dumplo); if (error) goto fail; - dumplo += sizeof(kdh); + dumplo += di->blocksize; + + /* Dump key */ + error = dump_write_key(di, 0, dumplo); + if (error) + goto fail; + dumplo += kerneldumpcrypto_dumpkeysize(di->kdc); /* Dump the private header. */ hdr.dh_hdr_size = hdrsize; @@ -143,9 +155,10 @@ dumpsys(struct dumperinfo *di) goto fail; /* Dump trailer */ - error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh)); + error = dump_write_header(di, &kdh, 0, dumplo); if (error) goto fail; + dumplo += di->blocksize; /* Signal completion, signoff and exit stage left. */ dump_write(di, NULL, 0, 0, 0); diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 2bfc14f56e4..4cfb74476b0 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -325,6 +325,8 @@ int dev_stdclone(char *_name, char **_namep, const char *_stem, int *_unit); EVENTHANDLER_DECLARE(dev_clone, dev_clone_fn); /* Stuff relating to kernel-dump */ +struct kerneldumpcrypto; +struct kerneldumpheader; struct dumperinfo { dumper_t *dumper; /* Dumping function. */ @@ -334,12 +336,18 @@ struct dumperinfo { off_t mediaoffset; /* Initial offset in bytes. */ off_t mediasize; /* Space available in bytes. */ void *blockbuf; /* Buffer for padding shorter dump blocks */ + struct kerneldumpcrypto *kdc; /* Kernel dump crypto. */ }; -int set_dumper(struct dumperinfo *, const char *_devname, struct thread *td); +int set_dumper(struct dumperinfo *di, const char *devname, struct thread *td, + uint8_t encrypt, const uint8_t *key, uint32_t encryptedkeysize, + const uint8_t *encryptedkey); int dump_write(struct dumperinfo *, void *, vm_offset_t, off_t, size_t); int dump_write_pad(struct dumperinfo *, void *, vm_offset_t, off_t, size_t, size_t *); +int dump_write_header(struct dumperinfo *di, struct kerneldumpheader *kdh, + vm_offset_t physical, off_t offset); +int dump_write_key(struct dumperinfo *di, vm_offset_t physical, off_t offset); int doadump(boolean_t); extern int dumping; /* system is dumping */ diff --git a/sys/sys/disk.h b/sys/sys/disk.h index 6b35d748ce7..873efd1ee21 100644 --- a/sys/sys/disk.h +++ b/sys/sys/disk.h @@ -14,6 +14,7 @@ #define _SYS_DISK_H_ #include +#include #include #include @@ -54,7 +55,7 @@ void disk_err(struct bio *bp, const char *what, int blkdone, int nl); * disk label formats. Don't use it unless you have to. */ -#define DIOCSKERNELDUMP _IOW('d', 133, u_int) /* Set/Clear kernel dumps */ +#define DIOCSKERNELDUMP_FREEBSD11 _IOW('d', 133, u_int) /* * Enable/Disable (the argument is boolean) the device for kernel * core dumps. @@ -139,4 +140,16 @@ struct diocgattr_arg { #define DIOCZONECMD _IOWR('d', 143, struct disk_zone_args) +struct diocskerneldump_arg { + uint8_t kda_enable; + uint8_t kda_encryption; + uint8_t kda_key[KERNELDUMP_KEY_MAX_SIZE]; + uint32_t kda_encryptedkeysize; + uint8_t *kda_encryptedkey; +}; +#define DIOCSKERNELDUMP _IOW('d', 144, struct diocskerneldump_arg) + /* + * Enable/Disable the device for kernel core dumps. + */ + #endif /* _SYS_DISK_H_ */ diff --git a/sys/sys/kerneldump.h b/sys/sys/kerneldump.h index 13bef698ffc..3fb6a7ad18b 100644 --- a/sys/sys/kerneldump.h +++ b/sys/sys/kerneldump.h @@ -38,6 +38,9 @@ #ifndef _SYS_KERNELDUMP_H #define _SYS_KERNELDUMP_H +#include +#include + #include #if BYTE_ORDER == LITTLE_ENDIAN @@ -52,6 +55,14 @@ #define htod64(x) (x) #endif +#define KERNELDUMP_ENC_NONE 0 +#define KERNELDUMP_ENC_AES_256_CBC 1 + +#define KERNELDUMP_BUFFER_SIZE 1024 +#define KERNELDUMP_IV_MAX_SIZE 32 +#define KERNELDUMP_KEY_MAX_SIZE 64 +#define KERNELDUMP_ENCKEY_MAX_SIZE (16384 / 8) + /* * All uintX_t fields are in dump byte order, which is the same as * network byte order. Use the macros defined above to read or @@ -64,8 +75,8 @@ struct kerneldumpheader { #define KERNELDUMPMAGIC_CLEARED "Cleared Kernel Dump" char architecture[12]; uint32_t version; -#define KERNELDUMPVERSION 1 -#define KERNELDUMP_TEXT_VERSION 1 +#define KERNELDUMPVERSION 2 +#define KERNELDUMP_TEXT_VERSION 2 uint32_t architectureversion; #define KERNELDUMP_AARCH64_VERSION 1 #define KERNELDUMP_AMD64_VERSION 2 @@ -77,13 +88,21 @@ struct kerneldumpheader { #define KERNELDUMP_SPARC64_VERSION 1 uint64_t dumplength; /* excl headers */ uint64_t dumptime; + uint32_t dumpkeysize; uint32_t blocksize; char hostname[64]; char versionstring[192]; - char panicstring[192]; + char panicstring[188]; uint32_t parity; }; +struct kerneldumpkey { + uint8_t kdk_encryption; + uint8_t kdk_iv[KERNELDUMP_IV_MAX_SIZE]; + uint32_t kdk_encryptedkeysize; + uint8_t kdk_encryptedkey[]; +} __packed; + /* * Parity calculation is endian insensitive. */ @@ -106,8 +125,11 @@ struct dump_pa { vm_paddr_t pa_size; }; +int kerneldumpcrypto_init(struct kerneldumpcrypto *kdc); +uint32_t kerneldumpcrypto_dumpkeysize(const struct kerneldumpcrypto *kdc); + void mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver, - uint64_t dumplen, uint32_t blksz); + uint64_t dumplen, uint32_t dumpkeysize, uint32_t blksz); int dumpsys_generic(struct dumperinfo *); @@ -115,6 +137,7 @@ void dumpsys_map_chunk(vm_paddr_t, size_t, void **); typedef int dumpsys_callback_t(struct dump_pa *, int, void *); int dumpsys_foreach_chunk(dumpsys_callback_t, void *); int dumpsys_cb_dumpdata(struct dump_pa *, int, void *); +int dumpsys_buf_seek(struct dumperinfo *, size_t); int dumpsys_buf_write(struct dumperinfo *, char *, size_t); int dumpsys_buf_flush(struct dumperinfo *); From 7a4575d0b57ce6fd7795ff3f12c8aed497fc7795 Mon Sep 17 00:00:00 2001 From: Andriy Voskoboinyk Date: Sat, 10 Dec 2016 17:06:55 +0000 Subject: [PATCH 003/226] rsu: increase Rx buffer size from 8k to 30k. This is required for USB Rx aggregation (and fixes 'could not allocate RX mbuf' / few other failures). While here, reduce the number of Rx buffers from 100 to 1 - the driver never uses more than one Rx buffer. Tested with Asus USB-N10. --- sys/dev/usb/wlan/if_rsureg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/usb/wlan/if_rsureg.h b/sys/dev/usb/wlan/if_rsureg.h index b1fd048095d..dec1eaab85a 100644 --- a/sys/dev/usb/wlan/if_rsureg.h +++ b/sys/dev/usb/wlan/if_rsureg.h @@ -688,10 +688,10 @@ struct r92s_add_ba_req { /* * Driver definitions. */ -#define RSU_RX_LIST_COUNT 100 +#define RSU_RX_LIST_COUNT 1 #define RSU_TX_LIST_COUNT 32 -#define RSU_RXBUFSZ (8 * 1024) +#define RSU_RXBUFSZ (30 * 1024) #define RSU_TXBUFSZ \ ((sizeof(struct r92s_tx_desc) + IEEE80211_MAX_LEN + 3) & ~3) From c837b8e35f0aca3f3fa8bb2c053724ac57d4dead Mon Sep 17 00:00:00 2001 From: Oleksandr Tymoshenko Date: Sat, 10 Dec 2016 17:59:34 +0000 Subject: [PATCH 004/226] [iwn] Perform BUS_DMASYNC_PREREAD when initializing RX buffer BUS_DMASYNC_PREREAD is required when setting up RX buffer, otherwise data provided by card can be overwritten by data evicted from cache Also use proper tag when setting up RX descriptor Reviewed by: adrian, avos, ivadasz Differential Revision: https://reviews.freebsd.org/D8717 --- sys/dev/iwn/if_iwn.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c index b2107ae9fc5..f5d298bd864 100644 --- a/sys/dev/iwn/if_iwn.c +++ b/sys/dev/iwn/if_iwn.c @@ -1910,6 +1910,9 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, struct iwn_rx_ring *ring) goto fail; } + bus_dmamap_sync(ring->data_dmat, data->map, + BUS_DMASYNC_PREREAD); + /* Set physical address of RX buffer (256-byte aligned). */ ring->desc[i] = htole32(paddr >> 8); } @@ -3040,14 +3043,19 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc, if (error != 0 && error != EFBIG) { panic("%s: could not load old RX mbuf", __func__); } + bus_dmamap_sync(ring->data_dmat, data->map, + BUS_DMASYNC_PREREAD); /* Physical address may have changed. */ ring->desc[ring->cur] = htole32(paddr >> 8); - bus_dmamap_sync(ring->data_dmat, ring->desc_dma.map, + bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map, BUS_DMASYNC_PREWRITE); counter_u64_add(ic->ic_ierrors, 1); return; } + bus_dmamap_sync(ring->data_dmat, data->map, + BUS_DMASYNC_PREREAD); + m = data->m; data->m = m1; /* Update RX descriptor. */ From 4af79d4f2b824eb8695f874084da7d1682aa4d05 Mon Sep 17 00:00:00 2001 From: Oleksandr Tymoshenko Date: Sat, 10 Dec 2016 18:07:16 +0000 Subject: [PATCH 005/226] [evdev] Adds evdev support to sysmouse(4) driver For horizontal (T-axis) wheel reporting which is not supported by sysmouse protocol kern.evdev.sysmouse_t_axis sysctl is introduced. It can take following values: 0 - no T-axis events (default) 1 - T-axis events are originated in ums(4) driver. 2 - T-axis events are originated in psm(4) driver. Submitted by: Vladimir Kondratiev MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D8597 --- sys/dev/evdev/evdev.c | 3 ++ sys/dev/evdev/evdev.h | 16 ++++++++ sys/dev/syscons/sysmouse.c | 84 +++++++++++++++++++++++++++++++++++++- sys/dev/vt/vt_sysmouse.c | 79 +++++++++++++++++++++++++++++++++++ 4 files changed, 181 insertions(+), 1 deletion(-) diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c index 4de5dee8db0..9827a7a9cd9 100644 --- a/sys/dev/evdev/evdev.c +++ b/sys/dev/evdev/evdev.c @@ -63,11 +63,14 @@ enum evdev_sparse_result MALLOC_DEFINE(M_EVDEV, "evdev", "evdev memory"); int evdev_rcpt_mask = EVDEV_RCPT_SYSMOUSE | EVDEV_RCPT_KBDMUX; +int evdev_sysmouse_t_axis = 0; SYSCTL_NODE(_kern, OID_AUTO, evdev, CTLFLAG_RW, 0, "Evdev args"); SYSCTL_INT(_kern_evdev, OID_AUTO, rcpt_mask, CTLFLAG_RW, &evdev_rcpt_mask, 0, "Who is receiving events: bit0 - sysmouse, bit1 - kbdmux, " "bit2 - mouse hardware, bit3 - keyboard hardware"); +SYSCTL_INT(_kern_evdev, OID_AUTO, sysmouse_t_axis, CTLFLAG_RW, + &evdev_sysmouse_t_axis, 0, "Extract T-axis from 0-none, 1-ums, 2-psm"); static void evdev_start_repeat(struct evdev_dev *, uint16_t); static void evdev_stop_repeat(struct evdev_dev *); diff --git a/sys/dev/evdev/evdev.h b/sys/dev/evdev/evdev.h index 34808b4b563..946913c4dd8 100644 --- a/sys/dev/evdev/evdev.h +++ b/sys/dev/evdev/evdev.h @@ -56,6 +56,22 @@ typedef void (evdev_keycode_t)(struct evdev_dev *, void *, #define EVDEV_RCPT_HW_MOUSE (1<<2) #define EVDEV_RCPT_HW_KBD (1<<3) extern int evdev_rcpt_mask; +/* + * Sysmouse protocol does not support horizontal wheel movement reporting. + * To overcome this limitation different drivers use different sysmouse proto + * extensions. Set kern.evdev.sysmouse_t_axis to tell sysmouse evdev driver + * which protocol extension is used. + * 0 - do not extract horizontal wheel movement (default). + * 1 - ums(4) horizontal wheel encoding. T-axis is mapped to buttons 6 and 7 + * 2 - psm(4) wheels encoding: z = 1,-1 - vert. wheel, z = 2,-2 - horiz. wheel + */ +enum +{ + EVDEV_SYSMOUSE_T_AXIS_NONE = 0, + EVDEV_SYSMOUSE_T_AXIS_UMS = 1, + EVDEV_SYSMOUSE_T_AXIS_PSM = 2, +}; +extern int evdev_sysmouse_t_axis; #define ABS_MT_FIRST ABS_MT_TOUCH_MAJOR #define ABS_MT_LAST ABS_MT_TOOL_Y diff --git a/sys/dev/syscons/sysmouse.c b/sys/dev/syscons/sysmouse.c index e6684978792..3582ad584a8 100644 --- a/sys/dev/syscons/sysmouse.c +++ b/sys/dev/syscons/sysmouse.c @@ -28,6 +28,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_evdev.h" #include "opt_syscons.h" #include @@ -43,6 +44,11 @@ __FBSDID("$FreeBSD$"); #include +#ifdef EVDEV_SUPPORT +#include +#include +#endif + #ifndef SC_NO_SYSMOUSE /* local variables */ @@ -50,6 +56,72 @@ static struct tty *sysmouse_tty; static int mouse_level; /* sysmouse protocol level */ static mousestatus_t mouse_status; +#ifdef EVDEV_SUPPORT +static struct evdev_dev *sysmouse_evdev; + +static void +smdev_evdev_init(void) +{ + int i; + + sysmouse_evdev = evdev_alloc(); + evdev_set_name(sysmouse_evdev, "System mouse"); + evdev_set_phys(sysmouse_evdev, "sysmouse"); + evdev_set_id(sysmouse_evdev, BUS_VIRTUAL, 0, 0, 0); + evdev_support_prop(sysmouse_evdev, INPUT_PROP_POINTER); + evdev_support_event(sysmouse_evdev, EV_SYN); + evdev_support_event(sysmouse_evdev, EV_REL); + evdev_support_event(sysmouse_evdev, EV_KEY); + evdev_support_rel(sysmouse_evdev, REL_X); + evdev_support_rel(sysmouse_evdev, REL_Y); + evdev_support_rel(sysmouse_evdev, REL_WHEEL); + evdev_support_rel(sysmouse_evdev, REL_HWHEEL); + for (i = 0; i < 8; i++) + evdev_support_key(sysmouse_evdev, BTN_MOUSE + i); + if (evdev_register(sysmouse_evdev)) { + evdev_free(sysmouse_evdev); + sysmouse_evdev = NULL; + } +} + +static void +smdev_evdev_write(int x, int y, int z, int buttons) +{ + + if (sysmouse_evdev == NULL || !(evdev_rcpt_mask & EVDEV_RCPT_SYSMOUSE)) + return; + + evdev_push_event(sysmouse_evdev, EV_REL, REL_X, x); + evdev_push_event(sysmouse_evdev, EV_REL, REL_Y, y); + switch (evdev_sysmouse_t_axis) { + case EVDEV_SYSMOUSE_T_AXIS_PSM: + switch (z) { + case 1: + case -1: + evdev_push_rel(sysmouse_evdev, REL_WHEEL, -z); + break; + case 2: + case -2: + evdev_push_rel(sysmouse_evdev, REL_HWHEEL, z / 2); + break; + } + break; + case EVDEV_SYSMOUSE_T_AXIS_UMS: + /* XXX: Edge triggering should be used here */ + if (buttons & (1 << 5)) + evdev_push_rel(sysmouse_evdev, REL_HWHEEL, 1); + else if (buttons & (1 << 6)) + evdev_push_rel(sysmouse_evdev, REL_HWHEEL, -1); + /* PASSTHROUGH */ + case EVDEV_SYSMOUSE_T_AXIS_NONE: + default: + evdev_push_rel(sysmouse_evdev, REL_WHEEL, -z); + } + evdev_push_mouse_btn(sysmouse_evdev, buttons); + evdev_sync(sysmouse_evdev); +} +#endif + static void smdev_close(struct tty *tp) { @@ -170,6 +242,9 @@ sm_attach_mouse(void *unused) return; sysmouse_tty = tty_alloc(&smdev_ttydevsw, NULL); tty_makedev(sysmouse_tty, NULL, "sysmouse"); +#ifdef EVDEV_SUPPORT + smdev_evdev_init(); +#endif } SYSINIT(sysmouse, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, sm_attach_mouse, NULL); @@ -220,7 +295,14 @@ sysmouse_event(mouse_info_t *info) mouse_status.flags |= ((x || y || z) ? MOUSE_POSCHANGED : 0) | (mouse_status.obutton ^ mouse_status.button); flags = mouse_status.flags; - if (flags == 0 || !tty_opened(sysmouse_tty)) + if (flags == 0) + goto done; + +#ifdef EVDEV_SUPPORT + smdev_evdev_write(x, y, z, mouse_status.button); +#endif + + if (!tty_opened(sysmouse_tty)) goto done; /* the first five bytes are compatible with MouseSystems' */ diff --git a/sys/dev/vt/vt_sysmouse.c b/sys/dev/vt/vt_sysmouse.c index 618ff0f6948..78e85ab65ec 100644 --- a/sys/dev/vt/vt_sysmouse.c +++ b/sys/dev/vt/vt_sysmouse.c @@ -33,6 +33,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_evdev.h" + #include #include #include @@ -50,6 +52,11 @@ __FBSDID("$FreeBSD$"); #include +#ifdef EVDEV_SUPPORT +#include +#include +#endif + static d_open_t sysmouse_open; static d_close_t sysmouse_close; static d_read_t sysmouse_read; @@ -81,6 +88,72 @@ static MALLOC_DEFINE(M_SYSMOUSE, "sysmouse", "sysmouse device"); static unsigned char *sysmouse_buffer; static unsigned int sysmouse_start, sysmouse_length; +#ifdef EVDEV_SUPPORT +static struct evdev_dev *sysmouse_evdev; + +static void +sysmouse_evdev_init(void) +{ + int i; + + sysmouse_evdev = evdev_alloc(); + evdev_set_name(sysmouse_evdev, "System mouse"); + evdev_set_phys(sysmouse_evdev, "sysmouse"); + evdev_set_id(sysmouse_evdev, BUS_VIRTUAL, 0, 0, 0); + evdev_support_prop(sysmouse_evdev, INPUT_PROP_POINTER); + evdev_support_event(sysmouse_evdev, EV_SYN); + evdev_support_event(sysmouse_evdev, EV_REL); + evdev_support_event(sysmouse_evdev, EV_KEY); + evdev_support_rel(sysmouse_evdev, REL_X); + evdev_support_rel(sysmouse_evdev, REL_Y); + evdev_support_rel(sysmouse_evdev, REL_WHEEL); + evdev_support_rel(sysmouse_evdev, REL_HWHEEL); + for (i = 0; i < 8; i++) + evdev_support_key(sysmouse_evdev, BTN_MOUSE + i); + if (evdev_register(sysmouse_evdev)) { + evdev_free(sysmouse_evdev); + sysmouse_evdev = NULL; + } +} + +static void +sysmouse_evdev_store(int x, int y, int z, int buttons) +{ + + if (sysmouse_evdev == NULL || !(evdev_rcpt_mask & EVDEV_RCPT_SYSMOUSE)) + return; + + evdev_push_event(sysmouse_evdev, EV_REL, REL_X, x); + evdev_push_event(sysmouse_evdev, EV_REL, REL_Y, y); + switch (evdev_sysmouse_t_axis) { + case EVDEV_SYSMOUSE_T_AXIS_PSM: + switch (z) { + case 1: + case -1: + evdev_push_rel(sysmouse_evdev, REL_WHEEL, -z); + break; + case 2: + case -2: + evdev_push_rel(sysmouse_evdev, REL_HWHEEL, z / 2); + break; + } + break; + case EVDEV_SYSMOUSE_T_AXIS_UMS: + /* XXX: Edge triggering should be used here */ + if (buttons & (1 << 5)) + evdev_push_rel(sysmouse_evdev, REL_HWHEEL, 1); + else if (buttons & (1 << 6)) + evdev_push_rel(sysmouse_evdev, REL_HWHEEL, -1); + /* PASSTHROUGH */ + case EVDEV_SYSMOUSE_T_AXIS_NONE: + default: + evdev_push_rel(sysmouse_evdev, REL_WHEEL, -z); + } + evdev_push_mouse_btn(sysmouse_evdev, buttons); + evdev_sync(sysmouse_evdev); +} +#endif + static int sysmouse_buf_read(struct uio *uio, unsigned int length) { @@ -170,6 +243,9 @@ sysmouse_process_event(mouse_info_t *mi) if (sysmouse_status.flags == 0) goto done; +#ifdef EVDEV_SUPPORT + sysmouse_evdev_store(x, y, z, sysmouse_status.button); +#endif /* The first five bytes are compatible with MouseSystems. */ buf[0] = MOUSE_MSC_SYNC | @@ -404,6 +480,9 @@ sysmouse_drvinit(void *unused) cv_init(&sysmouse_sleep, "sysmrd"); make_dev(&sysmouse_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "sysmouse"); +#ifdef EVDEV_SUPPORT + sysmouse_evdev_init(); +#endif } SYSINIT(sysmouse, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, sysmouse_drvinit, NULL); From 629582ca4620880576b0434d234e43f375a0beb0 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sat, 10 Dec 2016 18:29:39 +0000 Subject: [PATCH 006/226] Now that external gcc directly natively links to libc++ we can remove the dirty hack made to fake libstdc++ --- Makefile.inc1 | 2 +- lib/libc++/Makefile | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index a4a638cf0a1..aa71e6862e0 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -591,7 +591,7 @@ XCFLAGS+= -B${WORLDTMP}/usr/lib # XXX: This should be checking MK_GNUCXX == no .if ${X_COMPILER_VERSION} >= 40800 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \ - -nostdinc++ -L${WORLDTMP}/../lib/libc++ + -nostdinc++ .endif .elif ${WANT_COMPILER_TYPE} == clang || \ (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang) diff --git a/lib/libc++/Makefile b/lib/libc++/Makefile index 1a506578289..36471f055eb 100644 --- a/lib/libc++/Makefile +++ b/lib/libc++/Makefile @@ -242,14 +242,4 @@ EXT+= ${HDRDIR}/ext/${hdr} .endfor EXTDIR= ${CXXINCLUDEDIR}/ext -.if ${MK_GNUCXX} == "no" && ${COMPILER_TYPE} == "gcc" -CLEANFILES+= libstdc++.so libstdc++.a - -afterinstall: - ${INSTALL_SYMLINK} ${DESTDIR}${LIBDIR}/lib${LIB}.so \ - ${.OBJDIR}/libstdc++.so - ${INSTALL_SYMLINK} ${DESTDIR}${LIBDIR}/lib${LIB}.a \ - ${.OBJDIR}/libstdc++.a -.endif - .include From f06ccf881ec71ef6c37f6adef64fd7d0edece72d Mon Sep 17 00:00:00 2001 From: Andriy Voskoboinyk Date: Sat, 10 Dec 2016 18:47:13 +0000 Subject: [PATCH 007/226] rsu: add promiscuous mode support. - Add partial promiscuous mode support (no management frames; they cannot be received by the firmware and net80211 at the same time). - Add monitor mode support (all frames). Tested with Asus, USB-N10. --- sys/dev/usb/wlan/if_rsu.c | 172 +++++++++++++++++++++++++++++++++-- sys/dev/usb/wlan/if_rsureg.h | 36 ++++++++ 2 files changed, 198 insertions(+), 10 deletions(-) diff --git a/sys/dev/usb/wlan/if_rsu.c b/sys/dev/usb/wlan/if_rsu.c index c4a9c7616b2..71ffe728180 100644 --- a/sys/dev/usb/wlan/if_rsu.c +++ b/sys/dev/usb/wlan/if_rsu.c @@ -23,7 +23,7 @@ __FBSDID("$FreeBSD$"); * * TODO: * o tx a-mpdu - * o monitor / hostap / ibss / mesh + * o hostap / ibss / mesh * o power-save operation */ @@ -175,6 +175,7 @@ static void rsu_getradiocaps(struct ieee80211com *, int, int *, static void rsu_set_channel(struct ieee80211com *); static void rsu_scan_curchan(struct ieee80211_scan_state *, unsigned long); static void rsu_scan_mindwell(struct ieee80211_scan_state *); +static void rsu_update_promisc(struct ieee80211com *); static uint8_t rsu_get_multi_pos(const uint8_t[]); static void rsu_set_multi(struct rsu_softc *); static void rsu_update_mcast(struct ieee80211com *); @@ -202,6 +203,9 @@ static int rsu_read_rom(struct rsu_softc *); static int rsu_fw_cmd(struct rsu_softc *, uint8_t, void *, int); static void rsu_calib_task(void *, int); static void rsu_tx_task(void *, int); +static void rsu_set_led(struct rsu_softc *, int); +static int rsu_monitor_newstate(struct ieee80211vap *, + enum ieee80211_state, int); static int rsu_newstate(struct ieee80211vap *, enum ieee80211_state, int); static int rsu_key_alloc(struct ieee80211vap *, struct ieee80211_key *, ieee80211_keyix *, ieee80211_keyix *); @@ -244,6 +248,9 @@ static struct mbuf * static void rsu_txeof(struct usb_xfer *, struct rsu_data *); static int rsu_raw_xmit(struct ieee80211_node *, struct mbuf *, const struct ieee80211_bpf_params *); +static void rsu_rxfilter_init(struct rsu_softc *); +static void rsu_rxfilter_set(struct rsu_softc *, uint32_t, uint32_t); +static void rsu_rxfilter_refresh(struct rsu_softc *); static void rsu_init(struct rsu_softc *); static int rsu_tx_start(struct rsu_softc *, struct ieee80211_node *, struct mbuf *, struct rsu_data *); @@ -536,6 +543,7 @@ rsu_attach(device_t self) /* Set device capabilities. */ ic->ic_caps = IEEE80211_C_STA | /* station mode */ + IEEE80211_C_MONITOR | /* monitor mode supported */ #if 0 IEEE80211_C_BGSCAN | /* Background scan. */ #endif @@ -582,6 +590,7 @@ rsu_attach(device_t self) ic->ic_scan_mindwell = rsu_scan_mindwell; ic->ic_vap_create = rsu_vap_create; ic->ic_vap_delete = rsu_vap_delete; + ic->ic_update_promisc = rsu_update_promisc; ic->ic_update_mcast = rsu_update_mcast; ic->ic_parent = rsu_parent; ic->ic_transmit = rsu_transmit; @@ -688,7 +697,10 @@ rsu_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit, /* override state transition machine */ uvp->newstate = vap->iv_newstate; - vap->iv_newstate = rsu_newstate; + if (opmode == IEEE80211_M_MONITOR) + vap->iv_newstate = rsu_monitor_newstate; + else + vap->iv_newstate = rsu_newstate; vap->iv_key_alloc = rsu_key_alloc; vap->iv_key_set = rsu_key_set; vap->iv_key_delete = rsu_key_delete; @@ -759,9 +771,30 @@ rsu_getradiocaps(struct ieee80211com *ic, } static void -rsu_set_channel(struct ieee80211com *ic __unused) +rsu_set_channel(struct ieee80211com *ic) { - /* We are unable to switch channels, yet. */ + struct rsu_softc *sc = ic->ic_softc; + + /* + * Only need to set the channel in Monitor mode. AP scanning and auth + * are already taken care of by their respective firmware commands. + */ + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + struct r92s_set_channel cmd; + int error; + + cmd.channel = IEEE80211_CHAN2IEEE(ic->ic_curchan); + + RSU_LOCK(sc); + error = rsu_fw_cmd(sc, R92S_CMD_SET_CHANNEL, &cmd, + sizeof(cmd)); + if (error != 0) { + device_printf(sc->sc_dev, + "%s: error %d setting channel\n", __func__, + error); + } + RSU_UNLOCK(sc); + } } static void @@ -782,6 +815,17 @@ rsu_scan_mindwell(struct ieee80211_scan_state *ss) /* NB: don't try to abort scan; wait for firmware to finish */ } +static void +rsu_update_promisc(struct ieee80211com *ic) +{ + struct rsu_softc *sc = ic->ic_softc; + + RSU_LOCK(sc); + if (sc->sc_running) + rsu_rxfilter_refresh(sc); + RSU_UNLOCK(sc); +} + /* * The same as rtwn_get_multi_pos() / rtwn_set_multi(). */ @@ -1343,6 +1387,47 @@ rsu_set_fw_power_state(struct rsu_softc *sc, int state) return (error); } +static void +rsu_set_led(struct rsu_softc *sc, int on) +{ + rsu_write_1(sc, R92S_LEDCFG, + (rsu_read_1(sc, R92S_LEDCFG) & 0xf0) | (!on << 3)); +} + +static int +rsu_monitor_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, + int arg) +{ + struct ieee80211com *ic = vap->iv_ic; + struct rsu_softc *sc = ic->ic_softc; + struct rsu_vap *uvp = RSU_VAP(vap); + + if (vap->iv_state != nstate) { + IEEE80211_UNLOCK(ic); + RSU_LOCK(sc); + + switch (nstate) { + case IEEE80211_S_INIT: + sc->sc_vap_is_running = 0; + rsu_set_led(sc, 0); + break; + case IEEE80211_S_RUN: + sc->sc_vap_is_running = 1; + rsu_set_led(sc, 1); + break; + default: + /* NOTREACHED */ + break; + } + rsu_rxfilter_refresh(sc); + + RSU_UNLOCK(sc); + IEEE80211_LOCK(ic); + } + + return (uvp->newstate(vap, nstate, arg)); +} + static int rsu_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) { @@ -1376,6 +1461,12 @@ rsu_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) RSU_LOCK(sc); /* Disassociate from our current BSS. */ rsu_disconnect(sc); + usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(10)); + + /* Refresh Rx filter (may be modified by firmware). */ + sc->sc_vap_is_running = 0; + rsu_rxfilter_refresh(sc); + /* Reinstall static keys. */ if (sc->sc_running) rsu_reinit_static_keys(sc); @@ -2030,6 +2121,11 @@ rsu_event_join_bss(struct rsu_softc *sc, uint8_t *buf, int len) __func__, ether_sprintf(rsp->bss.macaddr), tmp); /* XXX is this required? What's the top two bits for again? */ ni->ni_associd = tmp | 0xc000; + + /* Refresh Rx filter (was changed by firmware). */ + sc->sc_vap_is_running = 1; + rsu_rxfilter_refresh(sc); + RSU_UNLOCK(sc); ieee80211_new_state(vap, IEEE80211_S_RUN, IEEE80211_FC0_SUBTYPE_ASSOC_RESP); @@ -3328,6 +3424,65 @@ rsu_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, return (0); } +static void +rsu_rxfilter_init(struct rsu_softc *sc) +{ + uint32_t reg; + + RSU_ASSERT_LOCKED(sc); + + /* Setup multicast filter. */ + rsu_set_multi(sc); + + /* Adjust Rx filter. */ + reg = rsu_read_4(sc, R92S_RCR); + reg &= ~R92S_RCR_AICV; + reg |= R92S_RCR_APP_PHYSTS; + rsu_write_4(sc, R92S_RCR, reg); + + /* Update dynamic Rx filter parts. */ + rsu_rxfilter_refresh(sc); +} + +static void +rsu_rxfilter_set(struct rsu_softc *sc, uint32_t clear, uint32_t set) +{ + /* NB: firmware can touch this register too. */ + rsu_write_4(sc, R92S_RCR, + (rsu_read_4(sc, R92S_RCR) & ~clear) | set); +} + +static void +rsu_rxfilter_refresh(struct rsu_softc *sc) +{ + struct ieee80211com *ic = &sc->sc_ic; + uint32_t mask_all, mask_min; + + RSU_ASSERT_LOCKED(sc); + + /* NB: RCR_AMF / RXFLTMAP_MGT are used by firmware. */ + mask_all = R92S_RCR_ACF | R92S_RCR_AAP; + mask_min = R92S_RCR_APM; + if (sc->sc_vap_is_running) + mask_min |= R92S_RCR_CBSSID; + else + mask_all |= R92S_RCR_ADF; + + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + uint16_t rxfltmap; + if (sc->sc_vap_is_running) + rxfltmap = 0; + else + rxfltmap = R92S_RXFLTMAP_MGT_DEF; + rsu_write_2(sc, R92S_RXFLTMAP_MGT, rxfltmap); + } + + if (ic->ic_promisc == 0 && ic->ic_opmode != IEEE80211_M_MONITOR) + rsu_rxfilter_set(sc, mask_all, mask_min); + else + rsu_rxfilter_set(sc, mask_min, mask_all); +} + static void rsu_init(struct rsu_softc *sc) { @@ -3394,12 +3549,8 @@ rsu_init(struct rsu_softc *sc) goto fail; } - /* Append PHY status. */ - rsu_write_4(sc, R92S_RCR, - rsu_read_4(sc, R92S_RCR) | 0x02000000); - - /* Setup multicast filter (must be done after firmware loading). */ - rsu_set_multi(sc); + /* Initialize Rx filter. */ + rsu_rxfilter_init(sc); /* Set PS mode fully active */ error = rsu_set_fw_power_state(sc, RSU_PWR_ACTIVE); @@ -3433,6 +3584,7 @@ rsu_stop(struct rsu_softc *sc) RSU_ASSERT_LOCKED(sc); sc->sc_running = 0; + sc->sc_vap_is_running = 0; sc->sc_calibrating = 0; taskqueue_cancel_timeout(taskqueue_thread, &sc->calib_task, NULL); taskqueue_cancel(taskqueue_thread, &sc->tx_task, NULL); diff --git a/sys/dev/usb/wlan/if_rsureg.h b/sys/dev/usb/wlan/if_rsureg.h index dec1eaab85a..ffa7aabddd0 100644 --- a/sys/dev/usb/wlan/if_rsureg.h +++ b/sys/dev/usb/wlan/if_rsureg.h @@ -54,6 +54,12 @@ #define R92S_TIMECTRL 0x0080 #define R92S_TSFTR (R92S_TIMECTRL + 0x000) +#define R92S_FIFOCTRL 0x00a0 +#define R92S_RXFLTMAP_MGT (R92S_FIFOCTRL + 0x076) +#define R92S_RXFLTMAP_CTL (R92S_FIFOCTRL + 0x078) +#define R92S_RXFLTMAP_DATA (R92S_FIFOCTRL + 0x07a) +#define R92S_RXFLTMAP_MESH (R92S_FIFOCTRL + 0x07c) + #define R92S_SECURITY 0x0240 #define R92S_CAMCMD (R92S_SECURITY + 0x000) #define R92S_CAMWRITE (R92S_SECURITY + 0x004) @@ -63,6 +69,7 @@ #define R92S_GPIO_CTRL (R92S_GP + 0x00c) #define R92S_GPIO_IO_SEL (R92S_GP + 0x00e) #define R92S_MAC_PINMUX_CTRL (R92S_GP + 0x011) +#define R92S_LEDCFG (R92S_GP + 0x012) #define R92S_IOCMD_CTRL 0x0370 #define R92S_IOCMD_DATA 0x0374 @@ -141,6 +148,29 @@ #define R92S_TCR_IMEM_RDY 0x20 #define R92S_TCR_FWRDY 0x80 +/* Bits for R92S_RCR. */ +#define R92S_RCR_AAP 0x00000001 +#define R92S_RCR_APM 0x00000002 +#define R92S_RCR_AM 0x00000004 +#define R92S_RCR_AB 0x00000008 +#define R92S_RCR_ACRC32 0x00000020 +#define R92S_RCR_AICV 0x00001000 +#define R92S_RCR_APP_ICV 0x00010000 +#define R92S_RCR_APP_MIC 0x00020000 +#define R92S_RCR_ADF 0x00040000 +#define R92S_RCR_ACF 0x00080000 +#define R92S_RCR_AMF 0x00100000 +#define R92S_RCR_ADD3 0x00200000 +#define R92S_RCR_APWRMGT 0x00400000 +#define R92S_RCR_CBSSID 0x00800000 +#define R92S_RCR_APP_PHYSTS 0x02000000 +#define R92S_RCR_ENMBID 0x08000000 + +/* Bits for R92S_RXFLTMAP*. */ +#define R92S_RXFLTMAP_MGT_DEF 0x3f3f +#define R92S_RXFLTMAP_FW(subtype) \ + (1 << ((subtype) >> IEEE80211_FC0_SUBTYPE_SHIFT)) + /* Bits for R92S_GPIO_IO_SEL. */ #define R92S_GPIO_WPS 0x10 @@ -546,6 +576,11 @@ struct r92s_set_pwr_mode { uint8_t bcn_pass_time; } __packed; +/* Structure for R92S_CMD_SET_CHANNEL. */ +struct r92s_set_channel { + uint32_t channel; +} __packed; + /* Structure for event R92S_EVENT_JOIN_BSS. */ struct r92s_event_join_bss { uint32_t next; @@ -817,6 +852,7 @@ struct rsu_softc { int sc_currssi; u_int sc_running:1, + sc_vap_is_running:1, sc_calibrating:1, sc_active_scan:1, sc_extra_scan:1; From 4b8f6069476a53f8dfe10c39ae1ba5eabca26727 Mon Sep 17 00:00:00 2001 From: Andriy Voskoboinyk Date: Sat, 10 Dec 2016 19:14:51 +0000 Subject: [PATCH 008/226] rsu(4): refresh the manpage. - Add monitor mode into the list of supported modes. - Describe promiscuous mode limitations in CAVEATS section. Reported by: adrian --- share/man/man4/rsu.4 | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/share/man/man4/rsu.4 b/share/man/man4/rsu.4 index b7198a16940..94ee51b52a7 100644 --- a/share/man/man4/rsu.4 +++ b/share/man/man4/rsu.4 @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd December 5, 2016 +.Dd December 10, 2016 .Dt RSU 4 .Os .Sh NAME @@ -78,6 +78,12 @@ Also known as mode, this is used when associating with an access point, through which all traffic passes. This mode is the default. +.It monitor mode +In this mode the driver is able to receive packets without +associating with an access point. +This disables the internal receive filter and enables the card to +capture packets from networks which it wouldn't normally have access to, +or to scan for access points. .El .Pp The @@ -183,3 +189,9 @@ The .Nm driver currently does not support 802.11n transmit aggregation, either A-MSDU or A-MPDU. +.Pp +The +.Nm +driver does not capture management frames in non-monitor modes; +without this limitation some firmware functions (e.g., 'join bss') +will not work properly. From 88c2e36adbde7491895cd06e6ac25e1492eb2b56 Mon Sep 17 00:00:00 2001 From: Andriy Voskoboinyk Date: Sat, 10 Dec 2016 20:19:57 +0000 Subject: [PATCH 009/226] rsu: use bitmap for all debug messages. - Replace all remaining DPRINTF(N)'s with RSU_DPRINTF. - Add new RSU_DEBUG_USB flag to track error codes returned by usbd_do_request_flags(). - Improve few messages. --- sys/dev/usb/wlan/if_rsu.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/sys/dev/usb/wlan/if_rsu.c b/sys/dev/usb/wlan/if_rsu.c index 71ffe728180..71d1ceb126c 100644 --- a/sys/dev/usb/wlan/if_rsu.c +++ b/sys/dev/usb/wlan/if_rsu.c @@ -68,9 +68,6 @@ __FBSDID("$FreeBSD$"); #include #include "usbdevs.h" -#define USB_DEBUG_VAR rsu_debug -#include - #include #ifdef USB_DEBUG @@ -103,6 +100,7 @@ TUNABLE_INT("hw.usb.rsu.enable_11n", &rsu_enable_11n); #define RSU_DEBUG_FWDBG 0x00000200 #define RSU_DEBUG_AMPDU 0x00000400 #define RSU_DEBUG_KEY 0x00000800 +#define RSU_DEBUG_USB 0x00001000 static const STRUCT_USB_HOST_ID rsu_devs[] = { #define RSU_HT_NOT_SUPPORTED 0 @@ -665,8 +663,9 @@ rsu_do_request(struct rsu_softc *sc, struct usb_device_request *req, req, data, 0, NULL, 250 /* ms */); if (err == 0 || err == USB_ERR_NOT_CONFIGURED) break; - DPRINTFN(1, "Control request failed, %s (retrying)\n", - usbd_errstr(err)); + RSU_DPRINTF(sc, RSU_DEBUG_USB, + "Control request failed, %s (retries left: %d)\n", + usbd_errstr(err), ntries); rsu_ms_delay(sc, 10); } @@ -1207,7 +1206,7 @@ rsu_read_rom(struct rsu_softc *sc) } } #ifdef USB_DEBUG - if (rsu_debug >= 5) { + if (rsu_debug & RSU_DEBUG_RESET) { /* Dump ROM content. */ printf("\n"); for (i = 0; i < sizeof(sc->rom); i++) @@ -1294,7 +1293,7 @@ rsu_calib_task(void *arg, int pending __unused) rsu_read_1(sc, R92S_GPIO_IO_SEL) & ~R92S_GPIO_WPS); reg = rsu_read_1(sc, R92S_GPIO_CTRL); if (reg != 0xff && (reg & R92S_GPIO_WPS)) - DPRINTF(("WPS PBC is pushed\n")); + RSU_DPRINTF(sc, RSU_DEBUG_CALIB, "WPS PBC is pushed\n"); #endif /* Read current signal level. */ if (rsu_fw_iocmd(sc, 0xf4000001) == 0) { @@ -2113,7 +2112,7 @@ rsu_event_join_bss(struct rsu_softc *sc, uint8_t *buf, int len) tmp = le32toh(rsp->associd); if (tmp >= vap->iv_max_aid) { - DPRINTF("Assoc ID overflow\n"); + RSU_DPRINTF(sc, RSU_DEBUG_ANY, "Assoc ID overflow\n"); tmp = 1; } RSU_DPRINTF(sc, RSU_DEBUG_STATE | RSU_DEBUG_FWCMD, @@ -2306,8 +2305,9 @@ rsu_rx_copy_to_mbuf(struct rsu_softc *sc, struct r92s_rx_stat *stat, m = m_get2(totlen, M_NOWAIT, MT_DATA, M_PKTHDR); if (__predict_false(m == NULL)) { - device_printf(sc->sc_dev, "%s: could not allocate RX mbuf\n", - __func__); + device_printf(sc->sc_dev, + "%s: could not allocate RX mbuf, totlen %d\n", + __func__, totlen); goto fail; } @@ -2490,7 +2490,7 @@ rsu_rxeof(struct usb_xfer *xfer, struct rsu_data *data) usbd_xfer_status(xfer, &len, NULL, NULL, NULL); if (__predict_false(len < sizeof(*stat))) { - DPRINTF("xfer too short %d\n", len); + RSU_DPRINTF(sc, RSU_DEBUG_RX, "xfer too short %d\n", len); counter_u64_add(ic->ic_ierrors, 1); return (NULL); } @@ -3251,8 +3251,9 @@ rsu_load_firmware(struct rsu_softc *sc) error = EINVAL; goto fail; } - DPRINTF("FW V%d %02x-%02x %02x:%02x\n", le16toh(hdr->version), - hdr->month, hdr->day, hdr->hour, hdr->minute); + RSU_DPRINTF(sc, RSU_DEBUG_FW, "FW V%d %02x-%02x %02x:%02x\n", + le16toh(hdr->version), hdr->month, hdr->day, hdr->hour, + hdr->minute); /* Make sure that driver and firmware are in sync. */ if (hdr->privsz != htole32(sizeof(*dmem))) { From 2fb5d72d589ab3aa0cf663821a9980cdd1700df6 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sat, 10 Dec 2016 21:19:27 +0000 Subject: [PATCH 010/226] Add missed vfs.zfs.zfetch.max_idistance sysctl. --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c index 1eb2fa1ab36..4e3bee9b3fc 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c @@ -64,6 +64,8 @@ SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, min_sec_reap, CTLFLAG_RWTUN, &zfetch_min_sec_reap, 0, "Min time before stream reclaim"); SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, max_distance, CTLFLAG_RWTUN, &zfetch_max_distance, 0, "Max bytes to prefetch per stream"); +SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, max_idistance, CTLFLAG_RWTUN, + &zfetch_max_idistance, 0, "Max bytes to prefetch indirects for per stream"); SYSCTL_UQUAD(_vfs_zfs_zfetch, OID_AUTO, array_rd_sz, CTLFLAG_RWTUN, &zfetch_array_rd_sz, 0, "Number of bytes in a array_read at which we stop prefetching"); From e480fc73f577024be516f9ac474a40b9f8b8690f Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 10 Dec 2016 22:03:44 +0000 Subject: [PATCH 011/226] Tentatively apply https://reviews.llvm.org/D18730 to work around gcc PR 70528 (bogus error: constructor required before non-static data member). This should fix buildworld with the external gcc package. Reported by: https://jenkins.freebsd.org/job/FreeBSD_HEAD_amd64_gcc/ --- contrib/llvm/lib/Bitcode/Writer/ValueEnumerator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/llvm/lib/Bitcode/Writer/ValueEnumerator.h b/contrib/llvm/lib/Bitcode/Writer/ValueEnumerator.h index bff2de70b3e..a8d6cf965a4 100644 --- a/contrib/llvm/lib/Bitcode/Writer/ValueEnumerator.h +++ b/contrib/llvm/lib/Bitcode/Writer/ValueEnumerator.h @@ -95,7 +95,7 @@ class ValueEnumerator { /// Number of strings in the prefix of the metadata range. unsigned NumStrings = 0; - MDRange() = default; + MDRange() {} explicit MDRange(unsigned First) : First(First) {} }; SmallDenseMap FunctionMDInfo; From b1dd83d1d07b20f58f53bf818a620749d3514098 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sat, 10 Dec 2016 22:05:24 +0000 Subject: [PATCH 012/226] Add some tests for reaper functionality (in procctl()). MFC after: 1 week --- tests/sys/kern/Makefile | 1 + tests/sys/kern/reaper.c | 494 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 495 insertions(+) create mode 100644 tests/sys/kern/reaper.c diff --git a/tests/sys/kern/Makefile b/tests/sys/kern/Makefile index 06518521ab1..61b315f18d1 100644 --- a/tests/sys/kern/Makefile +++ b/tests/sys/kern/Makefile @@ -8,6 +8,7 @@ TESTSDIR= ${TESTSBASE}/sys/kern ATF_TESTS_C+= kern_copyin ATF_TESTS_C+= kern_descrip_test ATF_TESTS_C+= ptrace_test +ATF_TESTS_C+= reaper PLAIN_TESTS_C+= subr_unit_test ATF_TESTS_C+= unix_seqpacket_test ATF_TESTS_C+= unix_passfd_test diff --git a/tests/sys/kern/reaper.c b/tests/sys/kern/reaper.c new file mode 100644 index 00000000000..58e0261fb5c --- /dev/null +++ b/tests/sys/kern/reaper.c @@ -0,0 +1,494 @@ +/*- + * Copyright (c) 2016 Jilles Tjoelker + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include +#include +#include +#include + +ATF_TC_WITHOUT_HEAD(reaper_wait_child_first); +ATF_TC_BODY(reaper_wait_child_first, tc) +{ + pid_t parent, child, grandchild, pid; + int status, r; + int pip[2]; + + /* Be paranoid. */ + pid = waitpid(-1, NULL, WNOHANG); + ATF_REQUIRE(pid == -1 && errno == ECHILD); + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + r = pipe(pip); + ATF_REQUIRE_EQ(0, r); + + child = fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + if (close(pip[1]) != 0) + _exit(100); + grandchild = fork(); + if (grandchild == -1) + _exit(101); + else if (grandchild == 0) { + if (read(pip[0], &(uint8_t){ 0 }, 1) != 0) + _exit(102); + if (getppid() != parent) + _exit(103); + _exit(2); + } else + _exit(3); + } + + pid = waitpid(child, &status, 0); + ATF_REQUIRE_EQ(child, pid); + r = WIFEXITED(status) ? WEXITSTATUS(status) : -1; + ATF_CHECK_EQ(3, r); + + r = close(pip[1]); + ATF_REQUIRE_EQ(0, r); + + pid = waitpid(-1, &status, 0); + ATF_REQUIRE(pid > 0 && pid != child); + r = WIFEXITED(status) ? WEXITSTATUS(status) : -1; + ATF_CHECK_EQ(2, r); + + r = close(pip[0]); + ATF_REQUIRE_EQ(0, r); +} + +ATF_TC_WITHOUT_HEAD(reaper_wait_grandchild_first); +ATF_TC_BODY(reaper_wait_grandchild_first, tc) +{ + pid_t parent, child, grandchild, pid; + int status, r; + + /* Be paranoid. */ + pid = waitpid(-1, NULL, WNOHANG); + ATF_REQUIRE(pid == -1 && errno == ECHILD); + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + child = fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + grandchild = fork(); + if (grandchild == -1) + _exit(101); + else if (grandchild == 0) + _exit(2); + else { + if (waitid(P_PID, grandchild, NULL, + WNOWAIT | WEXITED) != 0) + _exit(102); + _exit(3); + } + } + + pid = waitpid(child, &status, 0); + ATF_REQUIRE_EQ(child, pid); + r = WIFEXITED(status) ? WEXITSTATUS(status) : -1; + ATF_CHECK_EQ(3, r); + + pid = waitpid(-1, &status, 0); + ATF_REQUIRE(pid > 0 && pid != child); + r = WIFEXITED(status) ? WEXITSTATUS(status) : -1; + ATF_CHECK_EQ(2, r); +} + +ATF_TC_WITHOUT_HEAD(reaper_status); +ATF_TC_BODY(reaper_status, tc) +{ + struct procctl_reaper_status st; + ssize_t sr; + pid_t parent, child, pid; + int r, status; + int pip[2]; + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_STATUS, &st); + ATF_REQUIRE_EQ(0, r); + ATF_CHECK_EQ(0, st.rs_flags & REAPER_STATUS_OWNED); + ATF_CHECK(st.rs_children > 0); + ATF_CHECK(st.rs_descendants > 0); + ATF_CHECK(st.rs_descendants >= st.rs_children); + ATF_CHECK(st.rs_reaper != parent); + ATF_CHECK(st.rs_reaper > 0); + + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + r = procctl(P_PID, parent, PROC_REAP_STATUS, &st); + ATF_REQUIRE_EQ(0, r); + ATF_CHECK_EQ(REAPER_STATUS_OWNED, + st.rs_flags & (REAPER_STATUS_OWNED | REAPER_STATUS_REALINIT)); + ATF_CHECK_EQ(0, st.rs_children); + ATF_CHECK_EQ(0, st.rs_descendants); + ATF_CHECK(st.rs_reaper == parent); + ATF_CHECK_EQ(-1, st.rs_pid); + + r = pipe(pip); + ATF_REQUIRE_EQ(0, r); + child = fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + if (close(pip[0]) != 0) + _exit(100); + if (procctl(P_PID, parent, PROC_REAP_STATUS, &st) != 0) + _exit(101); + if (write(pip[1], &st, sizeof(st)) != (ssize_t)sizeof(st)) + _exit(102); + if (procctl(P_PID, getpid(), PROC_REAP_STATUS, &st) != 0) + _exit(103); + if (write(pip[1], &st, sizeof(st)) != (ssize_t)sizeof(st)) + _exit(104); + _exit(0); + } + r = close(pip[1]); + ATF_REQUIRE_EQ(0, r); + + sr = read(pip[0], &st, sizeof(st)); + ATF_REQUIRE_EQ((ssize_t)sizeof(st), sr); + ATF_CHECK_EQ(REAPER_STATUS_OWNED, + st.rs_flags & (REAPER_STATUS_OWNED | REAPER_STATUS_REALINIT)); + ATF_CHECK_EQ(1, st.rs_children); + ATF_CHECK_EQ(1, st.rs_descendants); + ATF_CHECK(st.rs_reaper == parent); + ATF_CHECK_EQ(child, st.rs_pid); + sr = read(pip[0], &st, sizeof(st)); + ATF_REQUIRE_EQ((ssize_t)sizeof(st), sr); + ATF_CHECK_EQ(0, + st.rs_flags & (REAPER_STATUS_OWNED | REAPER_STATUS_REALINIT)); + ATF_CHECK_EQ(1, st.rs_children); + ATF_CHECK_EQ(1, st.rs_descendants); + ATF_CHECK(st.rs_reaper == parent); + ATF_CHECK_EQ(child, st.rs_pid); + + r = close(pip[0]); + ATF_REQUIRE_EQ(0, r); + pid = waitpid(child, &status, 0); + ATF_REQUIRE_EQ(child, pid); + ATF_CHECK_EQ(0, status); + + r = procctl(P_PID, parent, PROC_REAP_STATUS, &st); + ATF_REQUIRE_EQ(0, r); + ATF_CHECK_EQ(REAPER_STATUS_OWNED, + st.rs_flags & (REAPER_STATUS_OWNED | REAPER_STATUS_REALINIT)); + ATF_CHECK_EQ(0, st.rs_children); + ATF_CHECK_EQ(0, st.rs_descendants); + ATF_CHECK(st.rs_reaper == parent); + ATF_CHECK_EQ(-1, st.rs_pid); +} + +ATF_TC_WITHOUT_HEAD(reaper_getpids); +ATF_TC_BODY(reaper_getpids, tc) +{ + struct procctl_reaper_pidinfo info[10]; + ssize_t sr; + pid_t parent, child, grandchild, pid; + int r, status, childidx; + int pipa[2], pipb[2]; + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + memset(info, '\0', sizeof(info)); + r = procctl(P_PID, parent, PROC_REAP_GETPIDS, + &(struct procctl_reaper_pids){ + .rp_count = sizeof(info) / sizeof(info[0]), + .rp_pids = info + }); + ATF_CHECK_EQ(0, r); + ATF_CHECK_EQ(0, info[0].pi_flags & REAPER_PIDINFO_VALID); + + r = pipe(pipa); + ATF_REQUIRE_EQ(0, r); + r = pipe(pipb); + ATF_REQUIRE_EQ(0, r); + child = fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + if (close(pipa[1]) != 0) + _exit(100); + if (close(pipb[0]) != 0) + _exit(100); + if (read(pipa[0], &(uint8_t){ 0 }, 1) != 1) + _exit(101); + grandchild = fork(); + if (grandchild == -1) + _exit(102); + if (grandchild == 0) { + if (write(pipb[1], &(uint8_t){ 0 }, 1) != 1) + _exit(103); + if (read(pipa[0], &(uint8_t){ 0 }, 1) != 1) + _exit(104); + _exit(0); + } + for (;;) + pause(); + } + r = close(pipa[0]); + ATF_REQUIRE_EQ(0, r); + r = close(pipb[1]); + ATF_REQUIRE_EQ(0, r); + + memset(info, '\0', sizeof(info)); + r = procctl(P_PID, parent, PROC_REAP_GETPIDS, + &(struct procctl_reaper_pids){ + .rp_count = sizeof(info) / sizeof(info[0]), + .rp_pids = info + }); + ATF_CHECK_EQ(0, r); + ATF_CHECK_EQ(REAPER_PIDINFO_VALID | REAPER_PIDINFO_CHILD, + info[0].pi_flags & (REAPER_PIDINFO_VALID | REAPER_PIDINFO_CHILD)); + ATF_CHECK_EQ(child, info[0].pi_pid); + ATF_CHECK_EQ(child, info[0].pi_subtree); + ATF_CHECK_EQ(0, info[1].pi_flags & REAPER_PIDINFO_VALID); + + sr = write(pipa[1], &(uint8_t){ 0 }, 1); + ATF_REQUIRE_EQ(1, sr); + sr = read(pipb[0], &(uint8_t){ 0 }, 1); + ATF_REQUIRE_EQ(1, sr); + + memset(info, '\0', sizeof(info)); + r = procctl(P_PID, parent, PROC_REAP_GETPIDS, + &(struct procctl_reaper_pids){ + .rp_count = sizeof(info) / sizeof(info[0]), + .rp_pids = info + }); + ATF_CHECK_EQ(0, r); + ATF_CHECK_EQ(REAPER_PIDINFO_VALID, + info[0].pi_flags & REAPER_PIDINFO_VALID); + ATF_CHECK_EQ(REAPER_PIDINFO_VALID, + info[1].pi_flags & REAPER_PIDINFO_VALID); + ATF_CHECK_EQ(0, info[2].pi_flags & REAPER_PIDINFO_VALID); + ATF_CHECK_EQ(child, info[0].pi_subtree); + ATF_CHECK_EQ(child, info[1].pi_subtree); + childidx = info[1].pi_pid == child ? 1 : 0; + ATF_CHECK_EQ(REAPER_PIDINFO_CHILD, + info[childidx].pi_flags & REAPER_PIDINFO_CHILD); + ATF_CHECK_EQ(0, info[childidx ^ 1].pi_flags & REAPER_PIDINFO_CHILD); + ATF_CHECK(info[childidx].pi_pid == child); + grandchild = info[childidx ^ 1].pi_pid; + ATF_CHECK(grandchild > 0); + ATF_CHECK(grandchild != child); + ATF_CHECK(grandchild != parent); + + r = kill(child, SIGTERM); + ATF_REQUIRE_EQ(0, r); + + pid = waitpid(child, &status, 0); + ATF_REQUIRE_EQ(child, pid); + ATF_CHECK(WIFSIGNALED(status) && WTERMSIG(status) == SIGTERM); + + memset(info, '\0', sizeof(info)); + r = procctl(P_PID, parent, PROC_REAP_GETPIDS, + &(struct procctl_reaper_pids){ + .rp_count = sizeof(info) / sizeof(info[0]), + .rp_pids = info + }); + ATF_CHECK_EQ(0, r); + ATF_CHECK_EQ(REAPER_PIDINFO_VALID, + info[0].pi_flags & REAPER_PIDINFO_VALID); + ATF_CHECK_EQ(0, info[1].pi_flags & REAPER_PIDINFO_VALID); + ATF_CHECK_EQ(child, info[0].pi_subtree); + ATF_CHECK_EQ(REAPER_PIDINFO_CHILD, + info[0].pi_flags & REAPER_PIDINFO_CHILD); + ATF_CHECK_EQ(grandchild, info[0].pi_pid); + + sr = write(pipa[1], &(uint8_t){ 0 }, 1); + ATF_REQUIRE_EQ(1, sr); + + memset(info, '\0', sizeof(info)); + r = procctl(P_PID, parent, PROC_REAP_GETPIDS, + &(struct procctl_reaper_pids){ + .rp_count = sizeof(info) / sizeof(info[0]), + .rp_pids = info + }); + ATF_CHECK_EQ(0, r); + ATF_CHECK_EQ(REAPER_PIDINFO_VALID, + info[0].pi_flags & REAPER_PIDINFO_VALID); + ATF_CHECK_EQ(0, info[1].pi_flags & REAPER_PIDINFO_VALID); + ATF_CHECK_EQ(child, info[0].pi_subtree); + ATF_CHECK_EQ(REAPER_PIDINFO_CHILD, + info[0].pi_flags & REAPER_PIDINFO_CHILD); + ATF_CHECK_EQ(grandchild, info[0].pi_pid); + + pid = waitpid(grandchild, &status, 0); + ATF_REQUIRE_EQ(grandchild, pid); + ATF_CHECK_EQ(0, status); + + memset(info, '\0', sizeof(info)); + r = procctl(P_PID, parent, PROC_REAP_GETPIDS, + &(struct procctl_reaper_pids){ + .rp_count = sizeof(info) / sizeof(info[0]), + .rp_pids = info + }); + ATF_CHECK_EQ(0, r); + ATF_CHECK_EQ(0, info[0].pi_flags & REAPER_PIDINFO_VALID); + + r = close(pipa[1]); + ATF_REQUIRE_EQ(0, r); + r = close(pipb[0]); + ATF_REQUIRE_EQ(0, r); +} + +ATF_TC_WITHOUT_HEAD(reaper_kill_badsig); +ATF_TC_BODY(reaper_kill_badsig, tc) +{ + struct procctl_reaper_kill params; + pid_t parent; + int r; + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + params.rk_sig = -1; + params.rk_flags = 0; + r = procctl(P_PID, parent, PROC_REAP_KILL, ¶ms); + ATF_CHECK(r == -1 && errno == EINVAL); +} + +ATF_TC_WITHOUT_HEAD(reaper_kill_sigzero); +ATF_TC_BODY(reaper_kill_sigzero, tc) +{ + struct procctl_reaper_kill params; + pid_t parent; + int r; + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + params.rk_sig = 0; + params.rk_flags = 0; + r = procctl(P_PID, parent, PROC_REAP_KILL, ¶ms); + ATF_CHECK(r == -1 && errno == EINVAL); +} + +ATF_TC_WITHOUT_HEAD(reaper_kill_empty); +ATF_TC_BODY(reaper_kill_empty, tc) +{ + struct procctl_reaper_kill params; + pid_t parent; + int r; + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + params.rk_sig = SIGTERM; + params.rk_flags = 0; + params.rk_killed = 77; + r = procctl(P_PID, parent, PROC_REAP_KILL, ¶ms); + ATF_CHECK(r == -1 && errno == ESRCH); + ATF_CHECK_EQ(0, params.rk_killed); +} + +ATF_TC_WITHOUT_HEAD(reaper_kill_normal); +ATF_TC_BODY(reaper_kill_normal, tc) +{ + struct procctl_reaper_kill params; + ssize_t sr; + pid_t parent, child, grandchild, pid; + int r, status; + int pip[2]; + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + r = pipe(pip); + ATF_REQUIRE_EQ(0, r); + child = fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + if (close(pip[0]) != 0) + _exit(100); + grandchild = fork(); + if (grandchild == -1) + _exit(101); + if (grandchild == 0) { + if (write(pip[1], &(uint8_t){ 0 }, 1) != 1) + _exit(102); + for (;;) + pause(); + } + for (;;) + pause(); + } + r = close(pip[1]); + ATF_REQUIRE_EQ(0, r); + + sr = read(pip[0], &(uint8_t){ 0 }, 1); + ATF_REQUIRE_EQ(1, sr); + + params.rk_sig = SIGTERM; + params.rk_flags = 0; + params.rk_killed = 77; + r = procctl(P_PID, parent, PROC_REAP_KILL, ¶ms); + ATF_CHECK_EQ(0, r); + ATF_CHECK_EQ(2, params.rk_killed); + + pid = waitpid(child, &status, 0); + ATF_REQUIRE_EQ(child, pid); + ATF_CHECK(WIFSIGNALED(status) && WTERMSIG(status) == SIGTERM); + + pid = waitpid(-1, &status, 0); + ATF_REQUIRE(pid > 0); + ATF_CHECK(pid != parent); + ATF_CHECK(pid != child); + ATF_CHECK(WIFSIGNALED(status) && WTERMSIG(status) == SIGTERM); + + r = close(pip[0]); + ATF_REQUIRE_EQ(0, r); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, reaper_wait_child_first); + ATF_TP_ADD_TC(tp, reaper_wait_grandchild_first); + ATF_TP_ADD_TC(tp, reaper_status); + ATF_TP_ADD_TC(tp, reaper_getpids); + ATF_TP_ADD_TC(tp, reaper_kill_badsig); + ATF_TP_ADD_TC(tp, reaper_kill_sigzero); + ATF_TP_ADD_TC(tp, reaper_kill_empty); + ATF_TP_ADD_TC(tp, reaper_kill_normal); + return (atf_no_error()); +} From cc7734cbac0b640c33f4ecaf6b4071bfafe77c61 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Sat, 10 Dec 2016 22:08:33 +0000 Subject: [PATCH 013/226] Change the process limits for RLIMIT_MEMLOCK to RLIM_INFINITY when executing :mincore_resid The default process limits in FreeBSD is 64kB for unprivileged users, which empirically is too low to run the :mincore_resid testcase. Process limits are inherited, so even though the default limit for root users is RLIM_INFINITY, the inherited limit with "sudo" with the default login.conf will be 64kB. Use setrlimit to set rlim_max for RLIMIT_MEMLOCK to RLIM_INFINITY to avoid ENOMEM issues when calling mlock to wire the mmap'ed address space. setrlimit requires root access to increase rlim_max, so require root privileges when running the test Discovered when executing the tests with sudo, e.g. "sudo kyua test -k /usr/tests/lib/libc/sys/Kyuafile mincore_test" MFC after: 2 weeks --- contrib/netbsd-tests/lib/libc/sys/t_mincore.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/contrib/netbsd-tests/lib/libc/sys/t_mincore.c b/contrib/netbsd-tests/lib/libc/sys/t_mincore.c index 872856eba46..72355e2c30a 100644 --- a/contrib/netbsd-tests/lib/libc/sys/t_mincore.c +++ b/contrib/netbsd-tests/lib/libc/sys/t_mincore.c @@ -144,6 +144,9 @@ ATF_TC_WITH_CLEANUP(mincore_resid); ATF_TC_HEAD(mincore_resid, tc) { atf_tc_set_md_var(tc, "descr", "Test page residency with mincore(2)"); +#ifdef __FreeBSD__ + atf_tc_set_md_var(tc, "require.user", "root"); +#endif } ATF_TC_BODY(mincore_resid, tc) @@ -155,6 +158,13 @@ ATF_TC_BODY(mincore_resid, tc) struct rlimit rlim; ATF_REQUIRE(getrlimit(RLIMIT_MEMLOCK, &rlim) == 0); +#ifdef __FreeBSD__ + /* + * Bump the mlock limit to unlimited so the rest of the testcase + * passes instead of failing on the mlock call. + */ + rlim.rlim_max = RLIM_INFINITY; +#endif rlim.rlim_cur = rlim.rlim_max; ATF_REQUIRE(setrlimit(RLIMIT_MEMLOCK, &rlim) == 0); @@ -206,8 +216,9 @@ ATF_TC_BODY(mincore_resid, tc) "might be low on memory"); #ifdef __FreeBSD__ - ATF_REQUIRE_MSG(mlock(addr, npgs * page) == 0, "mlock failed: %s", - strerror(errno)); + if (mlock(addr, npgs * page) == -1 && errno != ENOMEM) + atf_tc_skip("could not wire anonymous test area, system might " + "be low on memory"); #endif ATF_REQUIRE(check_residency(addr, npgs) == npgs); ATF_REQUIRE(munmap(addr, npgs * page) == 0); From 14a8d2f99548a173f3d0950e7bc88c08435e46c6 Mon Sep 17 00:00:00 2001 From: Andriy Voskoboinyk Date: Sat, 10 Dec 2016 22:31:49 +0000 Subject: [PATCH 014/226] rsu: various initialization fixes. - Do not ignore initialization errors; call ieee80211_stop() when initialization failed. - Use usb_pause_mtx() instead of DELAY() while waiting for firmware loading; this fixes system freeze during firmware startup. - Do not execute rsu_stop() when device is powered off; fixes 'unknown board type (rfconfig=0xff)' error when the device is reattached. Tested with Asus USB-N10. --- sys/dev/usb/wlan/if_rsu.c | 46 ++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/sys/dev/usb/wlan/if_rsu.c b/sys/dev/usb/wlan/if_rsu.c index 71d1ceb126c..ff19b0da617 100644 --- a/sys/dev/usb/wlan/if_rsu.c +++ b/sys/dev/usb/wlan/if_rsu.c @@ -249,7 +249,7 @@ static int rsu_raw_xmit(struct ieee80211_node *, struct mbuf *, static void rsu_rxfilter_init(struct rsu_softc *); static void rsu_rxfilter_set(struct rsu_softc *, uint32_t, uint32_t); static void rsu_rxfilter_refresh(struct rsu_softc *); -static void rsu_init(struct rsu_softc *); +static int rsu_init(struct rsu_softc *); static int rsu_tx_start(struct rsu_softc *, struct ieee80211_node *, struct mbuf *, struct rsu_data *); static int rsu_transmit(struct ieee80211com *, struct mbuf *); @@ -620,9 +620,7 @@ rsu_detach(device_t self) struct rsu_softc *sc = device_get_softc(self); struct ieee80211com *ic = &sc->sc_ic; - RSU_LOCK(sc); rsu_stop(sc); - RSU_UNLOCK(sc); usbd_transfer_unsetup(sc->sc_xfer, RSU_N_TRANSFER); @@ -2921,20 +2919,17 @@ static void rsu_parent(struct ieee80211com *ic) { struct rsu_softc *sc = ic->ic_softc; - int startall = 0; - RSU_LOCK(sc); if (ic->ic_nrunning > 0) { - if (!sc->sc_running) { - rsu_init(sc); - startall = 1; + if (rsu_init(sc) == 0) + ieee80211_start_all(ic); + else { + struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); + if (vap != NULL) + ieee80211_stop(vap); } - } else if (sc->sc_running) + } else rsu_stop(sc); - RSU_UNLOCK(sc); - - if (startall) - ieee80211_start_all(ic); } /* @@ -3484,7 +3479,7 @@ rsu_rxfilter_refresh(struct rsu_softc *sc) rsu_rxfilter_set(sc, mask_min, mask_all); } -static void +static int rsu_init(struct rsu_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; @@ -3493,7 +3488,12 @@ rsu_init(struct rsu_softc *sc) int error; int i; - RSU_ASSERT_LOCKED(sc); + RSU_LOCK(sc); + + if (sc->sc_running) { + RSU_UNLOCK(sc); + return (0); + } /* Ensure the mbuf queue is drained */ rsu_drain_mbufq(sc); @@ -3538,7 +3538,7 @@ rsu_init(struct rsu_softc *sc) rsu_write_region_1(sc, R92S_MACID, macaddr, IEEE80211_ADDR_LEN); /* It really takes 1.5 seconds for the firmware to boot: */ - rsu_ms_delay(sc, 2000); + usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(2000)); RSU_DPRINTF(sc, RSU_DEBUG_RESET, "%s: setting MAC address to %s\n", __func__, @@ -3570,11 +3570,16 @@ rsu_init(struct rsu_softc *sc) /* We're ready to go. */ sc->sc_running = 1; - return; + RSU_UNLOCK(sc); + + return (0); fail: /* Need to stop all failed transfers, if any */ for (i = 0; i != RSU_N_TRANSFER; i++) usbd_transfer_stop(sc->sc_xfer[i]); + RSU_UNLOCK(sc); + + return (error); } static void @@ -3582,7 +3587,11 @@ rsu_stop(struct rsu_softc *sc) { int i; - RSU_ASSERT_LOCKED(sc); + RSU_LOCK(sc); + if (!sc->sc_running) { + RSU_UNLOCK(sc); + return; + } sc->sc_running = 0; sc->sc_vap_is_running = 0; @@ -3605,6 +3614,7 @@ rsu_stop(struct rsu_softc *sc) /* Ensure the mbuf queue is drained */ rsu_drain_mbufq(sc); + RSU_UNLOCK(sc); } /* From 110559ba69022872aea7eb150e57bdc8a15d68df Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Sat, 10 Dec 2016 23:26:34 +0000 Subject: [PATCH 015/226] free/NULL out variables prior to calling strdup to avoid leaking memory if arguments are specified more than once with "camcontrol timestamp". CID: 1366829, 1366831 MFC after: 1 week --- sbin/camcontrol/timestamp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sbin/camcontrol/timestamp.c b/sbin/camcontrol/timestamp.c index 642a15a007f..5f3adfe8b9b 100644 --- a/sbin/camcontrol/timestamp.c +++ b/sbin/camcontrol/timestamp.c @@ -336,6 +336,11 @@ timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt, int single_arg = 0; int do_utc = 0; +#define FREE(x) do { \ + free(x); \ + x = NULL; \ +} while(0) + while ((c = getopt(argc, argv, combinedopt)) != -1) { switch (c) { case 'r': { @@ -358,6 +363,7 @@ timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt, } case 'f': { single_arg++; + FREE(format_string); format_string = strdup(optarg); if (format_string == NULL) { warn("Error allocating memory for format " @@ -369,6 +375,7 @@ timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt, } case 'm': { single_arg++; + FREE(format_string); format_string = strdup(MIL); if (format_string == NULL) { warn("Error allocating memory"); @@ -382,6 +389,7 @@ timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt, break; } case 'T': + FREE(timestamp_string); timestamp_string = strdup(optarg); if (timestamp_string == NULL) { warn("Error allocating memory for format " @@ -395,6 +403,8 @@ timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt, } } +#undef FREE + if (action == -1) { warnx("Must specify an action, either -r or -s"); error = 1; From f2a12bce273c808ba0ccf05f7141095db1e2e273 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Sat, 10 Dec 2016 23:58:14 +0000 Subject: [PATCH 016/226] Cut to the chase and just call free instead of free(x) + x = NULL NULLing out x wasn't required as the memory was immediately scribbled over with strdup in the following call. MFC after: 1 week Submitted by: imp --- sbin/camcontrol/timestamp.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/sbin/camcontrol/timestamp.c b/sbin/camcontrol/timestamp.c index 5f3adfe8b9b..032357be832 100644 --- a/sbin/camcontrol/timestamp.c +++ b/sbin/camcontrol/timestamp.c @@ -336,11 +336,6 @@ timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt, int single_arg = 0; int do_utc = 0; -#define FREE(x) do { \ - free(x); \ - x = NULL; \ -} while(0) - while ((c = getopt(argc, argv, combinedopt)) != -1) { switch (c) { case 'r': { @@ -363,7 +358,7 @@ timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt, } case 'f': { single_arg++; - FREE(format_string); + free(format_string); format_string = strdup(optarg); if (format_string == NULL) { warn("Error allocating memory for format " @@ -375,7 +370,7 @@ timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt, } case 'm': { single_arg++; - FREE(format_string); + free(format_string); format_string = strdup(MIL); if (format_string == NULL) { warn("Error allocating memory"); @@ -389,7 +384,7 @@ timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt, break; } case 'T': - FREE(timestamp_string); + free(timestamp_string); timestamp_string = strdup(optarg); if (timestamp_string == NULL) { warn("Error allocating memory for format " @@ -403,8 +398,6 @@ timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt, } } -#undef FREE - if (action == -1) { warnx("Must specify an action, either -r or -s"); error = 1; From 8b9c95f4a96bb558743a86b1b19c8d6c88cd8c31 Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Sun, 11 Dec 2016 13:26:35 +0000 Subject: [PATCH 017/226] Ensure that the reported ppid and tsn are taken from the first fragment. This fixes a bug where the wrong ppid was reported, if * I-DATA was used on the first fragement was not received first * DATA was used and different ppids where used. Thanks to Julian Cordes for making me aware of the issue. MFC after: 1 week --- sys/netinet/sctp_indata.c | 133 ++++++++++++++++++++------------------ sys/netinet/sctputil.c | 2 +- 2 files changed, 71 insertions(+), 64 deletions(-) diff --git a/sys/netinet/sctp_indata.c b/sys/netinet/sctp_indata.c index f3776a05e18..215f7b000f9 100644 --- a/sys/netinet/sctp_indata.c +++ b/sys/netinet/sctp_indata.c @@ -333,10 +333,10 @@ sctp_place_control_in_stream(struct sctp_stream_in *strm, { struct sctp_queued_to_read *at; struct sctp_readhead *q; - uint8_t bits, unordered; + uint8_t flags, unordered; - bits = (control->sinfo_flags >> 8); - unordered = bits & SCTP_DATA_UNORDERED; + flags = (control->sinfo_flags >> 8); + unordered = flags & SCTP_DATA_UNORDERED; if (unordered) { q = &strm->uno_inqueue; if (asoc->idata_supported == 0) { @@ -352,8 +352,10 @@ sctp_place_control_in_stream(struct sctp_stream_in *strm, } else { q = &strm->inqueue; } - if ((bits & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) { - control->end_added = control->last_frag_seen = control->first_frag_seen = 1; + if ((flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) { + control->end_added = 1; + control->first_frag_seen = 1; + control->last_frag_seen = 1; } if (TAILQ_EMPTY(q)) { /* Empty queue */ @@ -394,8 +396,7 @@ sctp_place_control_in_stream(struct sctp_stream_in *strm, sctp_log_strm_del(control, at, SCTP_STR_LOG_FROM_INSERT_TL); } - TAILQ_INSERT_AFTER(q, - at, control, next_instrm); + TAILQ_INSERT_AFTER(q, at, control, next_instrm); if (unordered) { control->on_strm_q = SCTP_ON_UNORDERED; } else { @@ -972,7 +973,8 @@ sctp_inject_old_unordered_data(struct sctp_tcb *stcb, goto place_chunk; } control->first_frag_seen = 1; - control->top_fsn = control->fsn_included = chk->rec.data.fsn; + control->fsn_included = chk->rec.data.fsn; + control->top_fsn = chk->rec.data.fsn; control->sinfo_tsn = chk->rec.data.tsn; control->sinfo_ppid = chk->rec.data.ppid; control->data = chk->data; @@ -1236,6 +1238,8 @@ sctp_add_chk_to_control(struct sctp_queued_to_read *control, chk->data = NULL; if (chk->rec.data.rcv_flags & SCTP_DATA_FIRST_FRAG) { control->first_frag_seen = 1; + control->sinfo_tsn = chk->rec.data.tsn; + control->sinfo_ppid = chk->rec.data.ppid; } if (chk->rec.data.rcv_flags & SCTP_DATA_LAST_FRAG) { /* Its complete */ @@ -1347,6 +1351,8 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc, return; } control->first_frag_seen = 1; + control->sinfo_ppid = chk->rec.data.ppid; + control->sinfo_tsn = chk->rec.data.tsn; control->fsn_included = chk->rec.data.fsn; control->data = chk->data; sctp_mark_non_revokable(asoc, chk->rec.data.tsn); @@ -1560,12 +1566,10 @@ static int sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, struct mbuf **m, int offset, int chk_length, struct sctp_nets *net, uint32_t * high_tsn, int *abort_flag, - int *break_flag, int last_chunk, uint8_t chtype) + int *break_flag, int last_chunk, uint8_t chk_type) { /* Process a data chunk */ /* struct sctp_tmit_chunk *chk; */ - struct sctp_data_chunk *ch; - struct sctp_idata_chunk *nch, chunk_buf; struct sctp_tmit_chunk *chk; uint32_t tsn, fsn, gap, mid; struct mbuf *dmbuf; @@ -1576,58 +1580,64 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, char msg[SCTP_DIAG_INFO_LEN]; struct sctp_queued_to_read *control = NULL; uint32_t ppid; - uint8_t chunk_flags; + uint8_t chk_flags; struct sctp_stream_reset_list *liste; struct sctp_stream_in *strm; int ordered; size_t clen; int created_control = 0; - chk = NULL; - if (chtype == SCTP_IDATA) { - nch = (struct sctp_idata_chunk *)sctp_m_getptr(*m, offset, + if (chk_type == SCTP_IDATA) { + struct sctp_idata_chunk *chunk, chunk_buf; + + chunk = (struct sctp_idata_chunk *)sctp_m_getptr(*m, offset, sizeof(struct sctp_idata_chunk), (uint8_t *) & chunk_buf); - ch = (struct sctp_data_chunk *)nch; + chk_flags = chunk->ch.chunk_flags; clen = sizeof(struct sctp_idata_chunk); - tsn = ntohl(ch->dp.tsn); - mid = ntohl(nch->dp.mid); - ppid = nch->dp.ppid_fsn.ppid; - if (ch->ch.chunk_flags & SCTP_DATA_FIRST_FRAG) + tsn = ntohl(chunk->dp.tsn); + sid = ntohs(chunk->dp.sid); + mid = ntohl(chunk->dp.mid); + if (chk_flags & SCTP_DATA_FIRST_FRAG) { fsn = 0; - else - fsn = ntohl(nch->dp.ppid_fsn.fsn); + ppid = chunk->dp.ppid_fsn.ppid; + } else { + fsn = ntohl(chunk->dp.ppid_fsn.fsn); + ppid = 0xffffffff; /* Use as an invalid value. */ + } } else { - ch = (struct sctp_data_chunk *)sctp_m_getptr(*m, offset, + struct sctp_data_chunk *chunk, chunk_buf; + + chunk = (struct sctp_data_chunk *)sctp_m_getptr(*m, offset, sizeof(struct sctp_data_chunk), (uint8_t *) & chunk_buf); - tsn = ntohl(ch->dp.tsn); - ppid = ch->dp.ppid; + chk_flags = chunk->ch.chunk_flags; clen = sizeof(struct sctp_data_chunk); + tsn = ntohl(chunk->dp.tsn); + sid = ntohs(chunk->dp.sid); + mid = (uint32_t) (ntohs(chunk->dp.ssn)); fsn = tsn; - mid = (uint32_t) (ntohs(ch->dp.ssn)); - nch = NULL; + ppid = chunk->dp.ppid; } - chunk_flags = ch->ch.chunk_flags; if ((size_t)chk_length == clen) { /* * Need to send an abort since we had a empty data chunk. */ - op_err = sctp_generate_no_user_data_cause(ch->dp.tsn); + op_err = sctp_generate_no_user_data_cause(tsn); stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_14; sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); *abort_flag = 1; return (0); } - if ((chunk_flags & SCTP_DATA_SACK_IMMEDIATELY) == SCTP_DATA_SACK_IMMEDIATELY) { + if ((chk_flags & SCTP_DATA_SACK_IMMEDIATELY) == SCTP_DATA_SACK_IMMEDIATELY) { asoc->send_sack = 1; } - ordered = ((chunk_flags & SCTP_DATA_UNORDERED) == 0); + ordered = ((chk_flags & SCTP_DATA_UNORDERED) == 0); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MAP_LOGGING_ENABLE) { sctp_log_map(tsn, asoc->cumulative_tsn, asoc->highest_tsn_inside_map, SCTP_MAP_TSN_ENTERS); } if (stcb == NULL) { return (0); } - SCTP_LTRACE_CHK(stcb->sctp_ep, stcb, ch->ch.chunk_type, tsn); + SCTP_LTRACE_CHK(stcb->sctp_ep, stcb, chk_type, tsn); if (SCTP_TSN_GE(asoc->cumulative_tsn, tsn)) { /* It is a duplicate */ SCTP_STAT_INCR(sctps_recvdupdata); @@ -1690,8 +1700,6 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, */ /* Is the stream valid? */ - sid = ntohs(ch->dp.sid); - if (sid >= asoc->streamincnt) { struct sctp_error_invalid_stream *cause; @@ -1709,7 +1717,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, SCTP_BUF_LEN(op_err) = sizeof(struct sctp_error_invalid_stream); cause->cause.code = htons(SCTP_CAUSE_INVALID_STREAM); cause->cause.length = htons(sizeof(struct sctp_error_invalid_stream)); - cause->stream_id = ch->dp.sid; + cause->stream_id = htons(sid); cause->reserved = htons(0); sctp_queue_op_err(stcb, op_err); } @@ -1730,8 +1738,8 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, * If its a fragmented message, lets see if we can find the control * on the reassembly queues. */ - if ((chtype == SCTP_IDATA) && - ((chunk_flags & SCTP_DATA_FIRST_FRAG) == 0) && + if ((chk_type == SCTP_IDATA) && + ((chk_flags & SCTP_DATA_FIRST_FRAG) == 0) && (fsn == 0)) { /* * The first *must* be fsn 0, and other (middle/end) pieces @@ -1739,13 +1747,13 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, * wrap around. Ignore is for now. */ snprintf(msg, sizeof(msg), "FSN zero for MID=%8.8x, but flags=%2.2x", - mid, chunk_flags); + mid, chk_flags); goto err_out; } control = sctp_find_reasm_entry(strm, mid, ordered, asoc->idata_supported); SCTPDBG(SCTP_DEBUG_XXX, "chunk_flags:0x%x look for control on queues %p\n", - chunk_flags, control); - if ((chunk_flags & SCTP_DATA_NOT_FRAG) != SCTP_DATA_NOT_FRAG) { + chk_flags, control); + if ((chk_flags & SCTP_DATA_NOT_FRAG) != SCTP_DATA_NOT_FRAG) { /* See if we can find the re-assembly entity */ if (control != NULL) { /* We found something, does it belong? */ @@ -1782,7 +1790,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, if (control != NULL) { if (ordered || asoc->idata_supported) { SCTPDBG(SCTP_DEBUG_XXX, "chunk_flags: 0x%x dup detected on MID: %u\n", - chunk_flags, mid); + chk_flags, mid); snprintf(msg, sizeof(msg), "Duplicate MID=%8.8x detected.", mid); goto err_out; } else { @@ -1828,7 +1836,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, #endif } /* now is it in the mapping array of what we have accepted? */ - if (nch == NULL) { + if (chk_type == SCTP_DATA) { if (SCTP_TSN_GT(tsn, asoc->highest_tsn_inside_map) && SCTP_TSN_GT(tsn, asoc->highest_tsn_inside_nr_map)) { /* Nope not in the valid range dump it */ @@ -1876,9 +1884,9 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, * way our stream sequence numbers could have wrapped. We of course * only validate the FIRST fragment so the bit must be set. */ - if ((chunk_flags & SCTP_DATA_FIRST_FRAG) && + if ((chk_flags & SCTP_DATA_FIRST_FRAG) && (TAILQ_EMPTY(&asoc->resetHead)) && - (chunk_flags & SCTP_DATA_UNORDERED) == 0 && + (chk_flags & SCTP_DATA_UNORDERED) == 0 && SCTP_MID_GE(asoc->idata_supported, asoc->strmin[sid].last_mid_delivered, mid)) { /* The incoming sseq is behind where we last delivered? */ SCTPDBG(SCTP_DEBUG_INDATA1, "EVIL/Broken-Dup S-SEQ: %u delivered: %u from peer, Abort!\n", @@ -1903,17 +1911,13 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, *abort_flag = 1; return (0); } - /************************************ - * From here down we may find ch-> invalid - * so its a good idea NOT to use it. - *************************************/ - if (nch) { + if (chk_type == SCTP_IDATA) { the_len = (chk_length - sizeof(struct sctp_idata_chunk)); } else { the_len = (chk_length - sizeof(struct sctp_data_chunk)); } if (last_chunk == 0) { - if (nch) { + if (chk_type == SCTP_IDATA) { dmbuf = SCTP_M_COPYM(*m, (offset + sizeof(struct sctp_idata_chunk)), the_len, M_NOWAIT); @@ -1933,7 +1937,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, dmbuf = *m; /* lop off the top part */ - if (nch) { + if (chk_type == SCTP_IDATA) { m_adj(dmbuf, (offset + sizeof(struct sctp_idata_chunk))); } else { m_adj(dmbuf, (offset + sizeof(struct sctp_data_chunk))); @@ -1962,7 +1966,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, return (0); } /* - * Now no matter what we need a control, get one if we don't have + * Now no matter what, we need a control, get one if we don't have * one (we may have gotten it above when we found the message was * fragmented */ @@ -1971,23 +1975,26 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, sctp_build_readq_entry_mac(control, stcb, asoc->context, net, tsn, ppid, sid, - chunk_flags, + chk_flags, NULL, fsn, mid); if (control == NULL) { SCTP_STAT_INCR(sctps_nomem); return (0); } - if ((chunk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) { + if ((chk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) { control->data = dmbuf; control->tail_mbuf = NULL; - control->end_added = control->last_frag_seen = control->first_frag_seen = 1; - control->top_fsn = control->fsn_included = fsn; + control->end_added = 1; + control->last_frag_seen = 1; + control->first_frag_seen = 1; + control->fsn_included = fsn; + control->top_fsn = fsn; } created_control = 1; } SCTPDBG(SCTP_DEBUG_XXX, "chunk_flags: 0x%x ordered: %d MID: %u control: %p\n", - chunk_flags, ordered, mid, control); - if ((chunk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG && + chk_flags, ordered, mid, control); + if ((chk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG && TAILQ_EMPTY(&asoc->resetHead) && ((ordered == 0) || (SCTP_MID_EQ(asoc->idata_supported, asoc->strmin[sid].last_mid_delivered + 1, mid) && @@ -2011,7 +2018,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, control, &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED); - if ((chunk_flags & SCTP_DATA_UNORDERED) == 0) { + if ((chk_flags & SCTP_DATA_UNORDERED) == 0) { /* for ordered, bump what we delivered */ strm->last_mid_delivered++; } @@ -2024,7 +2031,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, goto finish_express_del; } /* Now will we need a chunk too? */ - if ((chunk_flags & SCTP_DATA_NOT_FRAG) != SCTP_DATA_NOT_FRAG) { + if ((chk_flags & SCTP_DATA_NOT_FRAG) != SCTP_DATA_NOT_FRAG) { sctp_alloc_a_chunk(stcb, chk); if (chk == NULL) { /* No memory so we drop the chunk */ @@ -2043,7 +2050,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, chk->rec.data.ppid = ppid; chk->rec.data.context = stcb->asoc.context; chk->rec.data.doing_fast_retransmit = 0; - chk->rec.data.rcv_flags = chunk_flags; + chk->rec.data.rcv_flags = chk_flags; chk->asoc = asoc; chk->send_size = the_len; chk->whoTo = net; @@ -2066,7 +2073,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, } } /* Now is it complete (i.e. not fragmented)? */ - if ((chunk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) { + if ((chk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) { /* * Special check for when streams are resetting. We could be * more smart about this and check the actual stream to see @@ -2110,7 +2117,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, } goto finish_express_del; } - if (chunk_flags & SCTP_DATA_UNORDERED) { + if (chk_flags & SCTP_DATA_UNORDERED) { /* queue directly into socket buffer */ SCTPDBG(SCTP_DEBUG_XXX, "Unordered data to be read control: %p MID: %u\n", control, mid); diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index 61d3732b132..b4f6c1fb2c6 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -4639,7 +4639,7 @@ sctp_generate_no_user_data_cause(uint32_t tsn) no_user_data_cause = mtod(m, struct sctp_error_no_user_data *); no_user_data_cause->cause.code = htons(SCTP_CAUSE_NO_USER_DATA); no_user_data_cause->cause.length = htons(len); - no_user_data_cause->tsn = tsn; /* tsn is passed in as NBO */ + no_user_data_cause->tsn = htonl(tsn); } return (m); } From ef06a176eb8be66c35bfde889d6e8664eaa7a1c9 Mon Sep 17 00:00:00 2001 From: Andriy Voskoboinyk Date: Sun, 11 Dec 2016 17:15:25 +0000 Subject: [PATCH 018/226] rsu: fix and enable Rx TCP checksum offloading. Tested with Asus USB-N10, STA mode. --- sys/dev/usb/wlan/if_rsu.c | 101 +++++++++++++++++++++++++++++++++-- sys/dev/usb/wlan/if_rsureg.h | 2 + 2 files changed, 98 insertions(+), 5 deletions(-) diff --git a/sys/dev/usb/wlan/if_rsu.c b/sys/dev/usb/wlan/if_rsu.c index ff19b0da617..5faa570182a 100644 --- a/sys/dev/usb/wlan/if_rsu.c +++ b/sys/dev/usb/wlan/if_rsu.c @@ -255,6 +255,7 @@ static int rsu_tx_start(struct rsu_softc *, struct ieee80211_node *, static int rsu_transmit(struct ieee80211com *, struct mbuf *); static void rsu_start(struct rsu_softc *); static void _rsu_start(struct rsu_softc *); +static int rsu_ioctl_net(struct ieee80211com *, u_long, void *); static void rsu_parent(struct ieee80211com *); static void rsu_stop(struct rsu_softc *); static void rsu_ms_delay(struct rsu_softc *, int); @@ -444,6 +445,7 @@ rsu_attach(device_t self) device_set_usb_desc(self); sc->sc_udev = uaa->device; sc->sc_dev = self; + sc->sc_rx_checksum_enable = 1; if (rsu_enable_11n) sc->sc_ht = !! (USB_GET_DRIVER_INFO(uaa) & RSU_HT_SUPPORTED); @@ -590,6 +592,7 @@ rsu_attach(device_t self) ic->ic_vap_delete = rsu_vap_delete; ic->ic_update_promisc = rsu_update_promisc; ic->ic_update_mcast = rsu_update_mcast; + ic->ic_ioctl = rsu_ioctl_net; ic->ic_parent = rsu_parent; ic->ic_transmit = rsu_transmit; ic->ic_send_mgmt = rsu_send_mgmt; @@ -676,8 +679,10 @@ rsu_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit, const uint8_t bssid[IEEE80211_ADDR_LEN], const uint8_t mac[IEEE80211_ADDR_LEN]) { + struct rsu_softc *sc = ic->ic_softc; struct rsu_vap *uvp; struct ieee80211vap *vap; + struct ifnet *ifp; if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */ return (NULL); @@ -692,6 +697,13 @@ rsu_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit, return (NULL); } + ifp = vap->iv_ifp; + ifp->if_capabilities = IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6; + RSU_LOCK(sc); + if (sc->sc_rx_checksum_enable) + ifp->if_capenable |= IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6; + RSU_UNLOCK(sc); + /* override state transition machine */ uvp->newstate = vap->iv_newstate; if (opmode == IEEE80211_M_MONITOR) @@ -2396,9 +2408,37 @@ rsu_rx_frame(struct rsu_softc *sc, struct mbuf *m, int8_t *rssi_p) }; /* Hardware does Rx TCP checksum offload. */ + /* + * This flag can be set for some other + * (e.g., EAPOL) frame types, so don't rely on it. + */ if (rxdw3 & R92S_RXDW3_TCPCHKVALID) { - if (__predict_true(rxdw3 & R92S_RXDW3_TCPCHKRPT)) + RSU_DPRINTF(sc, RSU_DEBUG_RX, + "%s: TCP/IP checksums: %schecked / %schecked\n", + __func__, + (rxdw3 & R92S_RXDW3_TCPCHKRPT) ? "" : "not ", + (rxdw3 & R92S_RXDW3_IPCHKRPT) ? "" : "not "); + + /* + * 'IP header checksum valid' bit will not be set if + * the frame was not checked / has incorrect checksum / + * does not have checksum (IPv6). + * + * NB: if DF bit is not set then frame will not be checked. + */ + if (rxdw3 & R92S_RXDW3_IPCHKRPT) { + m->m_pkthdr.csum_flags = CSUM_IP_CHECKED; + m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + } + + /* + * This is independent of the above check. + */ + if (rxdw3 & R92S_RXDW3_TCPCHKRPT) { m->m_pkthdr.csum_flags |= CSUM_DATA_VALID; + m->m_pkthdr.csum_flags |= CSUM_PSEUDO_HDR; + m->m_pkthdr.csum_data = 0xffff; + } } /* Drop descriptor. */ @@ -2915,6 +2955,59 @@ rsu_start(struct rsu_softc *sc) taskqueue_enqueue(taskqueue_thread, &sc->tx_task); } +static int +rsu_ioctl_net(struct ieee80211com *ic, u_long cmd, void *data) +{ + struct rsu_softc *sc = ic->ic_softc; + struct ifreq *ifr = (struct ifreq *)data; + int error; + + error = 0; + switch (cmd) { + case SIOCSIFCAP: + { + struct ieee80211vap *vap; + int rxmask; + + rxmask = ifr->ifr_reqcap & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6); + + RSU_LOCK(sc); + /* Both RXCSUM bits must be set (or unset). */ + if (sc->sc_rx_checksum_enable && + rxmask != (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)) { + rxmask = 0; + sc->sc_rx_checksum_enable = 0; + rsu_rxfilter_set(sc, R92S_RCR_TCP_OFFLD_EN, 0); + } else if (!sc->sc_rx_checksum_enable && rxmask != 0) { + rxmask = IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6; + sc->sc_rx_checksum_enable = 1; + rsu_rxfilter_set(sc, 0, R92S_RCR_TCP_OFFLD_EN); + } else { + /* Nothing to do. */ + RSU_UNLOCK(sc); + break; + } + RSU_UNLOCK(sc); + + IEEE80211_LOCK(ic); /* XXX */ + TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { + struct ifnet *ifp = vap->iv_ifp; + + ifp->if_capenable &= + ~(IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6); + ifp->if_capenable |= rxmask; + } + IEEE80211_UNLOCK(ic); + break; + } + default: + error = ENOTTY; /* for net80211 */ + break; + } + + return (error); +} + static void rsu_parent(struct ieee80211com *ic) { @@ -3434,6 +3527,8 @@ rsu_rxfilter_init(struct rsu_softc *sc) reg = rsu_read_4(sc, R92S_RCR); reg &= ~R92S_RCR_AICV; reg |= R92S_RCR_APP_PHYSTS; + if (sc->sc_rx_checksum_enable) + reg |= R92S_RCR_TCP_OFFLD_EN; rsu_write_4(sc, R92S_RCR, reg); /* Update dynamic Rx filter parts. */ @@ -3512,10 +3607,6 @@ rsu_init(struct rsu_softc *sc) if (error != 0) goto fail; - /* Enable Rx TCP checksum offload. */ - rsu_write_4(sc, R92S_RCR, - rsu_read_4(sc, R92S_RCR) | 0x04000000); - rsu_write_4(sc, R92S_CR, rsu_read_4(sc, R92S_CR) & ~0xff000000); diff --git a/sys/dev/usb/wlan/if_rsureg.h b/sys/dev/usb/wlan/if_rsureg.h index ffa7aabddd0..973280cf975 100644 --- a/sys/dev/usb/wlan/if_rsureg.h +++ b/sys/dev/usb/wlan/if_rsureg.h @@ -164,6 +164,7 @@ #define R92S_RCR_APWRMGT 0x00400000 #define R92S_RCR_CBSSID 0x00800000 #define R92S_RCR_APP_PHYSTS 0x02000000 +#define R92S_RCR_TCP_OFFLD_EN 0x04000000 #define R92S_RCR_ENMBID 0x08000000 /* Bits for R92S_RXFLTMAP*. */ @@ -853,6 +854,7 @@ struct rsu_softc { u_int sc_running:1, sc_vap_is_running:1, + sc_rx_checksum_enable:1, sc_calibrating:1, sc_active_scan:1, sc_extra_scan:1; From 5ab0f0c3f01579a2fc9f102e4a5956e1bcb233ef Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sun, 11 Dec 2016 19:01:27 +0000 Subject: [PATCH 019/226] Prefix hex memory addresses with 0x in diagnostic messages from the SRAT parser. Submitted by: Oliver Pinter MFC after: 1 week Differential revision: https://reviews.freebsd.org/D8750 --- sys/x86/acpica/srat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/x86/acpica/srat.c b/sys/x86/acpica/srat.c index 7eca75bafca..57e9798b86d 100644 --- a/sys/x86/acpica/srat.c +++ b/sys/x86/acpica/srat.c @@ -229,7 +229,7 @@ srat_parse_entry(ACPI_SUBTABLE_HEADER *entry, void *arg) mem = (ACPI_SRAT_MEM_AFFINITY *)entry; if (bootverbose) printf( - "SRAT: Found memory domain %d addr %jx len %jx: %s\n", + "SRAT: Found memory domain %d addr 0x%jx len 0x%jx: %s\n", mem->ProximityDomain, (uintmax_t)mem->BaseAddress, (uintmax_t)mem->Length, (mem->Flags & ACPI_SRAT_MEM_ENABLED) ? @@ -238,7 +238,7 @@ srat_parse_entry(ACPI_SUBTABLE_HEADER *entry, void *arg) break; if (!overlaps_phys_avail(mem->BaseAddress, mem->BaseAddress + mem->Length)) { - printf("SRAT: Ignoring memory at addr %jx\n", + printf("SRAT: Ignoring memory at addr 0x%jx\n", (uintmax_t)mem->BaseAddress); break; } @@ -335,7 +335,7 @@ check_phys_avail(void) address = mem_info[i].end + 1; } } - printf("SRAT: No memory region found for %jx - %jx\n", + printf("SRAT: No memory region found for 0x%jx - 0x%jx\n", (uintmax_t)phys_avail[j], (uintmax_t)phys_avail[j + 1]); return (ENXIO); } From 2d612d2dd27e24396e0aa3e7ba8be4ffb28c57b0 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 11 Dec 2016 19:24:41 +0000 Subject: [PATCH 020/226] When tmpfs and POSIX shm pagein a page for the sole purpose of performing truncation, immediately queue the page for asynchronous laundering rather than making the page pass through inactive queue first. Reviewed by: kib, markj --- sys/fs/tmpfs/tmpfs_subr.c | 10 +++++++++- sys/kern/uipc_shm.c | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index f1259c841cc..a8e31a44271 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -1376,7 +1376,15 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize, boolean_t ignerr) NULL); vm_page_lock(m); if (rv == VM_PAGER_OK) { - vm_page_deactivate(m); + /* + * Since the page was not resident, + * and therefore not recently + * accessed, immediately enqueue it + * for asynchronous laundering. The + * current operation is not regarded + * as an access. + */ + vm_page_launder(m); vm_page_unlock(m); vm_page_xunbusy(m); } else { diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index febba784835..e5b02fd3db5 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -460,7 +460,15 @@ shm_dotruncate(struct shmfd *shmfd, off_t length) NULL); vm_page_lock(m); if (rv == VM_PAGER_OK) { - vm_page_deactivate(m); + /* + * Since the page was not resident, + * and therefore not recently + * accessed, immediately enqueue it + * for asynchronous laundering. The + * current operation is not regarded + * as an access. + */ + vm_page_launder(m); vm_page_unlock(m); vm_page_xunbusy(m); } else { From 2823b6467ac5bf7c82485778ebe9237d8abf8381 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sun, 11 Dec 2016 19:50:39 +0000 Subject: [PATCH 021/226] Postpone ZVOL media/block size caching till first open. At least on FreeBSD there are no legal way to access media or get its size without opening device/provider first. Postponing this caching allows to skip several disk seeks per ZVOL/snapshot during import. For HDD pool with 1 ZVOL in dev mode with 1000 snapshots this reduces pool import time from 40 to 10 seconds. MFC after: 2 weeks Sponsored by: iXsystems, Inc. --- .../opensolaris/uts/common/fs/zfs/zvol.c | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c index 1847ad54906..ffe29c49e4b 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c @@ -585,14 +585,14 @@ zvol_create_minor(const char *name) zfs_soft_state_t *zs; zvol_state_t *zv; objset_t *os; - dmu_object_info_t doi; #ifdef illumos + dmu_object_info_t doi; minor_t minor = 0; char chrbuf[30], blkbuf[30]; #else struct g_provider *pp; struct g_geom *gp; - uint64_t volsize, mode; + uint64_t mode; #endif int error; @@ -658,20 +658,12 @@ zvol_create_minor(const char *name) zv = kmem_zalloc(sizeof(*zv), KM_SLEEP); zv->zv_state = 0; - error = zap_lookup(os, ZVOL_ZAP_OBJ, "size", 8, 1, &volsize); - if (error) { - kmem_free(zv, sizeof(*zv)); - dmu_objset_disown(os, zvol_tag); - mutex_exit(&zfsdev_state_lock); - return (error); - } error = dsl_prop_get_integer(name, zfs_prop_to_name(ZFS_PROP_VOLMODE), &mode, NULL); if (error != 0 || mode == ZFS_VOLMODE_DEFAULT) mode = volmode; DROP_GIANT(); - zv->zv_volsize = volsize; zv->zv_volmode = mode; if (zv->zv_volmode == ZFS_VOLMODE_GEOM) { g_topology_lock(); @@ -681,7 +673,7 @@ zvol_create_minor(const char *name) pp = g_new_providerf(gp, "%s/%s", ZVOL_DRIVER, name); pp->flags |= G_PF_DIRECT_RECEIVE | G_PF_DIRECT_SEND; pp->sectorsize = DEV_BSIZE; - pp->mediasize = zv->zv_volsize; + pp->mediasize = 0; pp->private = zv; zv->zv_provider = pp; @@ -724,10 +716,12 @@ zvol_create_minor(const char *name) sizeof (rl_t), offsetof(rl_t, r_node)); list_create(&zv->zv_extents, sizeof (zvol_extent_t), offsetof(zvol_extent_t, ze_node)); +#ifdef illumos /* get and cache the blocksize */ error = dmu_object_info(os, ZVOL_OBJ, &doi); ASSERT(error == 0); zv->zv_volblocksize = doi.doi_data_block_size; +#endif if (spa_writeable(dmu_objset_spa(os))) { if (zil_replay_disable) @@ -819,6 +813,7 @@ zvol_remove_minor(const char *name) int zvol_first_open(zvol_state_t *zv) { + dmu_object_info_t doi; objset_t *os; uint64_t volsize; int error; @@ -838,6 +833,15 @@ zvol_first_open(zvol_state_t *zv) return (error); } + /* get and cache the blocksize */ + error = dmu_object_info(os, ZVOL_OBJ, &doi); + if (error) { + ASSERT(error == 0); + dmu_objset_disown(os, zvol_tag); + return (error); + } + zv->zv_volblocksize = doi.doi_data_block_size; + error = dmu_bonus_hold(os, ZVOL_OBJ, zvol_tag, &zv->zv_dbuf); if (error) { dmu_objset_disown(os, zvol_tag); From b6ff672460ec0910c453d7de047119dd6d34db19 Mon Sep 17 00:00:00 2001 From: Hiren Panchasara Date: Sun, 11 Dec 2016 23:14:47 +0000 Subject: [PATCH 022/226] We currently don't do TSO if ip options are present. In case of IPv6, we look at in6p_options to check that. That is incorrect as we carry ip options in in6p_outputopts. Also, just checking for in6p_outputopts being NULL won't suffice as we combine ip options and ip header fields both in that one field. The commit fixes this by using ip6_optlen() which correctly calculates length of only ip options for IPv6. Reviewed by: ae, bz MFC after: 3 weeks Sponsored by: Limelight Networks --- sys/netinet/tcp_output.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index fd549944022..6b187dd810d 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -545,6 +545,11 @@ tcp_output(struct tcpcb *tp) * (except for the sequence number) for all generated packets. This * makes it impossible to transmit any options which vary per generated * segment or packet. + * + * IPv4 handling has a clear separation of ip options and ip header + * flags while IPv6 combines both in in6p_outputopts. ip6_optlen() does + * the right thing below to provide length of just ip options and thus + * checking for ipoptlen is enough to decide if ip options are present. */ #ifdef IPSEC /* @@ -553,14 +558,25 @@ tcp_output(struct tcpcb *tp) */ ipsec_optlen = ipsec_hdrsiz_tcp(tp); #endif + +#ifdef INET6 + if (isipv6) + ipoptlen = ip6_optlen(tp->t_inpcb); + else +#endif + if (tp->t_inpcb->inp_options) + ipoptlen = tp->t_inpcb->inp_options->m_len - + offsetof(struct ipoption, ipopt_list); + else + ipoptlen = 0; +#ifdef IPSEC + ipoptlen += ipsec_optlen; +#endif + if ((tp->t_flags & TF_TSO) && V_tcp_do_tso && len > tp->t_maxseg && ((tp->t_flags & TF_SIGNATURE) == 0) && tp->rcv_numsacks == 0 && sack_rxmit == 0 && -#ifdef IPSEC - ipsec_optlen == 0 && -#endif - tp->t_inpcb->inp_options == NULL && - tp->t_inpcb->in6p_options == NULL) + ipoptlen == 0) tso = 1; if (sack_rxmit) { @@ -833,20 +849,6 @@ tcp_output(struct tcpcb *tp) hdrlen += optlen = tcp_addoptions(&to, opt); } -#ifdef INET6 - if (isipv6) - ipoptlen = ip6_optlen(tp->t_inpcb); - else -#endif - if (tp->t_inpcb->inp_options) - ipoptlen = tp->t_inpcb->inp_options->m_len - - offsetof(struct ipoption, ipopt_list); - else - ipoptlen = 0; -#ifdef IPSEC - ipoptlen += ipsec_optlen; -#endif - /* * Adjust data length if insertion of options will * bump the packet length beyond the t_maxseg length. From 373c71780bbd7ca40869b8ccd6bcff934b171071 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 12 Dec 2016 02:09:31 +0000 Subject: [PATCH 023/226] Free p (the memory allocated via slurpfile) when done with the contents Reported by: Coverity CID: 1331631, 1331632, 1331633, 1331646 Obtained from: libarchive (ebe29c0ec3b1aaa424df9cf884721c6018c676f4) --- cpio/test/test_option_J_upper.c | 5 ++++- cpio/test/test_option_Z_upper.c | 5 ++++- cpio/test/test_option_u.c | 3 +++ cpio/test/test_option_y.c | 5 ++++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/cpio/test/test_option_J_upper.c b/cpio/test/test_option_J_upper.c index 532aacf39cc..1d7d05131b3 100644 --- a/cpio/test/test_option_J_upper.c +++ b/cpio/test/test_option_J_upper.c @@ -47,10 +47,13 @@ DEFINE_TEST(test_option_J_upper) } failure("-J option is broken"); assertEqualInt(r, 0); - return; + goto done; } + free(p); /* Check that the archive file has an xz signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "\3757zXZ", 5); +done: + free(p); } diff --git a/cpio/test/test_option_Z_upper.c b/cpio/test/test_option_Z_upper.c index 936ce0c2d3e..d69a85ea58a 100644 --- a/cpio/test/test_option_Z_upper.c +++ b/cpio/test/test_option_Z_upper.c @@ -47,10 +47,13 @@ DEFINE_TEST(test_option_Z_upper) } failure("-Z option is broken"); assertEqualInt(r, 0); - return; + goto done; } + free(p); /* Check that the archive file has a compress signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "\x1f\x9d", 2); +done: + free(p); } diff --git a/cpio/test/test_option_u.c b/cpio/test/test_option_u.c index b377def020f..cc790b1c0af 100644 --- a/cpio/test/test_option_u.c +++ b/cpio/test/test_option_u.c @@ -49,6 +49,7 @@ DEFINE_TEST(test_option_u) p = slurpfile(&s, "copy/f"); assertEqualInt(s, 1); assertEqualMem(p, "a", 1); + free(p); /* Recreate the file with a single "b" */ assertMakeFile("f", 0644, "b"); @@ -68,6 +69,7 @@ DEFINE_TEST(test_option_u) p = slurpfile(&s, "copy/f"); assertEqualInt(s, 1); assertEqualMem(p, "a", 1); + free(p); /* Copy the file to the "copy" dir with -u (force) */ r = systemf("echo f| %s -pud copy >copy.out 2>copy.err", @@ -78,4 +80,5 @@ DEFINE_TEST(test_option_u) p = slurpfile(&s, "copy/f"); assertEqualInt(s, 1); assertEqualMem(p, "b", 1); + free(p); } diff --git a/cpio/test/test_option_y.c b/cpio/test/test_option_y.c index 54f270b81e0..0397b3d1bf4 100644 --- a/cpio/test/test_option_y.c +++ b/cpio/test/test_option_y.c @@ -46,11 +46,14 @@ DEFINE_TEST(test_option_y) } failure("-y option is broken"); assertEqualInt(r, 0); - return; + goto done; } assertTextFileContents("1 block\n", "archive.err"); /* Check that the archive file has a bzip2 signature. */ + free(p); p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "BZh9", 4); +done: + free(p); } From 48de45414155afefbd9cffe45683257eb804f8ee Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 12 Dec 2016 02:11:30 +0000 Subject: [PATCH 024/226] Merge PR to address tar/test coverity issues Obtained from: libarchive (fd0ea220635939ffe4b9ffb5cacaaa526a25b5ae) --- tar/test/main.c | 39 ++++++++++++++++---------------- tar/test/test_leading_slash.c | 1 + tar/test/test_option_a.c | 7 ++++++ tar/test/test_option_b.c | 2 ++ tar/test/test_option_b64encode.c | 2 ++ tar/test/test_option_gid_gname.c | 4 ++++ tar/test/test_option_grzip.c | 3 +++ tar/test/test_option_j.c | 7 ++++-- tar/test/test_option_lrzip.c | 2 ++ tar/test/test_option_lz4.c | 12 ++++++---- tar/test/test_option_lzma.c | 5 +++- tar/test/test_option_lzop.c | 7 ++++-- tar/test/test_option_r.c | 34 +++++++++++++--------------- tar/test/test_option_uid_uname.c | 5 ++++ tar/test/test_option_uuencode.c | 2 ++ tar/test/test_option_xz.c | 7 ++++-- tar/test/test_option_z.c | 7 ++++-- tar/test/test_stdio.c | 1 + tar/test/test_version.c | 3 ++- 19 files changed, 98 insertions(+), 52 deletions(-) diff --git a/tar/test/main.c b/tar/test/main.c index 71a0c49e5e4..8d31706f0d6 100644 --- a/tar/test/main.c +++ b/tar/test/main.c @@ -1060,7 +1060,7 @@ assertion_file_contains_lines_any_order(const char *file, int line, char **expected = NULL; char *p, **actual = NULL; char c; - int expected_failure = 0, actual_failure = 0; + int expected_failure = 0, actual_failure = 0, retval = 0; assertion_count(file, line); @@ -1081,8 +1081,7 @@ assertion_file_contains_lines_any_order(const char *file, int line, if (expected == NULL) { failure_start(pathname, line, "Can't allocate memory"); failure_finish(NULL); - free(expected); - return (0); + goto done; } for (i = 0; lines[i] != NULL; ++i) { expected[i] = strdup(lines[i]); @@ -1103,8 +1102,7 @@ assertion_file_contains_lines_any_order(const char *file, int line, if (actual == NULL) { failure_start(pathname, line, "Can't allocate memory"); failure_finish(NULL); - free(expected); - return (0); + goto done; } for (j = 0, p = buff; p < buff + buff_size; p += 1 + strlen(p)) { @@ -1141,27 +1139,27 @@ assertion_file_contains_lines_any_order(const char *file, int line, ++actual_failure; } if (expected_failure == 0 && actual_failure == 0) { - free(buff); - free(expected); - free(actual); - return (1); + retval = 1; + goto done; } failure_start(file, line, "File doesn't match: %s", pathname); for (i = 0; i < expected_count; ++i) { - if (expected[i] != NULL) { + if (expected[i] != NULL) logprintf(" Expected but not present: %s\n", expected[i]); - free(expected[i]); - } } for (j = 0; j < actual_count; ++j) { if (actual[j] != NULL) logprintf(" Present but not expected: %s\n", actual[j]); } failure_finish(NULL); - free(buff); - free(expected); +done: free(actual); - return (0); + free(buff); + for (i = 0; i < expected_count; ++i) + free(expected[i]); + free(expected); + + return (retval); } /* Verify that a text file does not contains the specified strings */ @@ -1590,7 +1588,7 @@ is_symlink(const char *file, int line, * really not much point in bothering with this. */ return (0); #else - char buff[300]; + char buff[301]; struct stat st; ssize_t linklen; int r; @@ -1607,7 +1605,7 @@ is_symlink(const char *file, int line, return (0); if (contents == NULL) return (1); - linklen = readlink(pathname, buff, sizeof(buff)); + linklen = readlink(pathname, buff, sizeof(buff) - 1); if (linklen < 0) { failure_start(file, line, "Can't read symlink %s", pathname); failure_finish(NULL); @@ -2324,7 +2322,7 @@ extract_reference_file(const char *name) for (;;) { if (fgets(buff, sizeof(buff), in) == NULL) { /* TODO: This is a failure. */ - return; + goto done; } if (memcmp(buff, "begin ", 6) == 0) break; @@ -2365,6 +2363,7 @@ extract_reference_file(const char *name) } } fclose(out); +done: fclose(in); } @@ -2958,8 +2957,8 @@ main(int argc, char **argv) strftime(tmpdir_timestamp, sizeof(tmpdir_timestamp), "%Y-%m-%dT%H.%M.%S", localtime(&now)); - sprintf(tmpdir, "%s/%s.%s-%03d", tmp, progname, - tmpdir_timestamp, i); + snprintf(tmpdir, sizeof(tmpdir), "%s/%s.%s-%03d", tmp, + progname, tmpdir_timestamp, i); if (assertMakeDir(tmpdir,0755)) break; if (i >= 999) { diff --git a/tar/test/test_leading_slash.c b/tar/test/test_leading_slash.c index a8921ebcbae..572c45e3cbb 100644 --- a/tar/test/test_leading_slash.c +++ b/tar/test/test_leading_slash.c @@ -44,6 +44,7 @@ DEFINE_TEST(test_leading_slash) if (assertFileExists("test.err")) { errfile = slurpfile(&errfile_size, "test.err"); assert(strstr(errfile, expected_errmsg) != NULL); + free(errfile); } } diff --git a/tar/test/test_option_a.c b/tar/test/test_option_a.c index a000621cb8b..d9eed8777ff 100644 --- a/tar/test/test_option_a.c +++ b/tar/test/test_option_a.c @@ -43,6 +43,7 @@ DEFINE_TEST(test_option_a) assert(s > 2); failure("The archive should be compressed"); assertEqualMem(p, "\x1f\x9d", 2); + free(p); /* Test2: archive it with .taZ suffix. */ assertEqualInt(0, @@ -53,6 +54,7 @@ DEFINE_TEST(test_option_a) assert(s > 2); failure("The archive should be compressed"); assertEqualMem(p, "\x1f\x9d", 2); + free(p); /* Test3: archive it with .tar.Z.uu suffix. */ assertEqualInt(0, @@ -63,6 +65,7 @@ DEFINE_TEST(test_option_a) assert(s > 12); failure("The archive should be uuencoded"); assertEqualMem(p, "begin 644 -\n", 12); + free(p); /* Test4: archive it with .zip suffix. */ assertEqualInt(0, @@ -73,6 +76,7 @@ DEFINE_TEST(test_option_a) assert(s > 4); failure("The archive should be zipped"); assertEqualMem(p, "\x50\x4b\x03\x04", 4); + free(p); /* Test5: archive it with .tar.Z suffix and --uuencode option. */ assertEqualInt(0, @@ -84,6 +88,7 @@ DEFINE_TEST(test_option_a) assert(s > 2); failure("The archive should be compressed, ignoring --uuencode option"); assertEqualMem(p, "\x1f\x9d", 2); + free(p); /* Test6: archive it with .xxx suffix(unknown suffix) and * --uuencode option. */ @@ -96,6 +101,7 @@ DEFINE_TEST(test_option_a) assert(s > 12); failure("The archive should be uuencoded"); assertEqualMem(p, "begin 644 -\n", 12); + free(p); /* Test7: archive it with .tar.Z suffix using a long-name option. */ assertEqualInt(0, @@ -107,4 +113,5 @@ DEFINE_TEST(test_option_a) assert(s > 2); failure("The archive should be compressed"); assertEqualMem(p, "\x1f\x9d", 2); + free(p); } diff --git a/tar/test/test_option_b.c b/tar/test/test_option_b.c index 7c2f60476c5..0eee80d86f4 100644 --- a/tar/test/test_option_b.c +++ b/tar/test/test_option_b.c @@ -78,4 +78,6 @@ DEFINE_TEST(test_option_b) * Note: It's not possible to verify at this level that blocks * are getting written with the */ + + free(testprog_ustar); } diff --git a/tar/test/test_option_b64encode.c b/tar/test/test_option_b64encode.c index 1e7c57175ce..1d0420430e0 100644 --- a/tar/test/test_option_b64encode.c +++ b/tar/test/test_option_b64encode.c @@ -42,6 +42,7 @@ DEFINE_TEST(test_option_b64encode) p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "begin-base64 644", 16); + free(p); /* Archive it with uuencode only. */ assertEqualInt(0, @@ -51,4 +52,5 @@ DEFINE_TEST(test_option_b64encode) p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "begin-base64 644", 16); + free(p); } diff --git a/tar/test/test_option_gid_gname.c b/tar/test/test_option_gid_gname.c index e45da5b9146..4e5f51c8f48 100644 --- a/tar/test/test_option_gid_gname.c +++ b/tar/test/test_option_gid_gname.c @@ -53,6 +53,7 @@ DEFINE_TEST(test_option_gid_gname) /* Should force gid and gname fields in ustar header. */ assertEqualMem(data + 116, "000021 \0", 8); assertEqualMem(data + 297, "foofoofoo\0", 10); + free(data); /* Again with just --gname */ failure("Error invoking %s c", testprog); @@ -65,6 +66,8 @@ DEFINE_TEST(test_option_gid_gname) /* Gid should be unchanged from original reference. */ assertEqualMem(data + 116, reference + 116, 8); assertEqualMem(data + 297, "foofoofoo\0", 10); + free(data); + free(reference); /* Again with --gid and force gname to empty. */ failure("Error invoking %s c", testprog); @@ -77,6 +80,7 @@ DEFINE_TEST(test_option_gid_gname) assertEqualMem(data + 116, "000021 \0", 8); /* Gname field in ustar header should be empty. */ assertEqualMem(data + 297, "\0", 1); + free(data); /* TODO: It would be nice to verify that --gid= by itself * will look up the associated gname and use that, but diff --git a/tar/test/test_option_grzip.c b/tar/test/test_option_grzip.c index 5132eeec26e..fbff252421d 100644 --- a/tar/test/test_option_grzip.c +++ b/tar/test/test_option_grzip.c @@ -45,8 +45,11 @@ DEFINE_TEST(test_option_grzip) testprog)); p = slurpfile(&s, "archive.err"); p[s] = '\0'; + free(p); + /* Check that the archive file has an grzip signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "GRZipII\x00\x02\x04:)", 12); + free(p); } diff --git a/tar/test/test_option_j.c b/tar/test/test_option_j.c index 3202c3b8391..838234a2aeb 100644 --- a/tar/test/test_option_j.c +++ b/tar/test/test_option_j.c @@ -42,15 +42,18 @@ DEFINE_TEST(test_option_j) if (r != 0) { if (!canBzip2()) { skipping("bzip2 is not supported on this platform"); - return; + goto done; } failure("-j option is broken"); assertEqualInt(r, 0); - return; + goto done; } + free(p); assertEmptyFile("archive.err"); /* Check that the archive file has a bzip2 signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "BZh9", 4); +done: + free(p); } diff --git a/tar/test/test_option_lrzip.c b/tar/test/test_option_lrzip.c index d3486a3a27b..11e9827e040 100644 --- a/tar/test/test_option_lrzip.c +++ b/tar/test/test_option_lrzip.c @@ -45,8 +45,10 @@ DEFINE_TEST(test_option_lrzip) testprog)); p = slurpfile(&s, "archive.err"); p[s] = '\0'; + free(p); /* Check that the archive file has an lzma signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "LRZI\x00", 5); + free(p); } diff --git a/tar/test/test_option_lz4.c b/tar/test/test_option_lz4.c index 5dc94521630..1694e3ced37 100644 --- a/tar/test/test_option_lz4.c +++ b/tar/test/test_option_lz4.c @@ -43,7 +43,7 @@ DEFINE_TEST(test_option_lz4) if (strstr(p, "Unsupported compression") != NULL) { skipping("This version of bsdtar was compiled " "without lz4 support"); - return; + goto done; } /* POSIX permits different handling of the spawnp * system call used to launch the subsidiary @@ -52,7 +52,7 @@ DEFINE_TEST(test_option_lz4) if (strstr(p, "Can't launch") != NULL && !canLz4()) { skipping("This version of bsdtar uses an external lz4 program " "but no such program is available on this system."); - return; + goto done; } /* Some systems successfully spawn the new process, * but fail to exec a program within that process. @@ -61,14 +61,18 @@ DEFINE_TEST(test_option_lz4) if (strstr(p, "Can't write") != NULL && !canLz4()) { skipping("This version of bsdtar uses an external lz4 program " "but no such program is available on this system."); - return; + goto done; } failure("--lz4 option is broken: %s", p); assertEqualInt(r, 0); - return; + goto done; } + free(p); /* Check that the archive file has an lz4 signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "\x04\x22\x4d\x18", 4); + +done: + free(p); } diff --git a/tar/test/test_option_lzma.c b/tar/test/test_option_lzma.c index a845666e34f..a618ff8a340 100644 --- a/tar/test/test_option_lzma.c +++ b/tar/test/test_option_lzma.c @@ -48,10 +48,13 @@ DEFINE_TEST(test_option_lzma) } failure("--lzma option is broken"); assertEqualInt(r, 0); - return; + goto done; } + free(p); /* Check that the archive file has an lzma signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "\x5d\00\00", 3); +done: + free(p); } diff --git a/tar/test/test_option_lzop.c b/tar/test/test_option_lzop.c index 1145499a460..20ef06c5c8a 100644 --- a/tar/test/test_option_lzop.c +++ b/tar/test/test_option_lzop.c @@ -42,14 +42,17 @@ DEFINE_TEST(test_option_lzop) if (r != 0) { if (!canLzop()) { skipping("lzop is not supported on this platform"); - return; + goto done; } failure("--lzop option is broken"); assertEqualInt(r, 0); - return; + goto done; } + free(p); /* Check that the archive file has an lzma signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a", 9); +done: + free(p); } diff --git a/tar/test/test_option_r.c b/tar/test/test_option_r.c index 77876857ea7..287e80939ad 100644 --- a/tar/test/test_option_r.c +++ b/tar/test/test_option_r.c @@ -36,6 +36,10 @@ DEFINE_TEST(test_option_r) size_t s, buff_size_rounded; int r, i; + buff = NULL; + p0 = NULL; + p1 = NULL; + /* Create an archive with one file. */ assertMakeFile("f1", 0644, "abc"); r = systemf("%s cf archive.tar --format=ustar f1 >step1.out 2>step1.err", testprog); @@ -47,11 +51,9 @@ DEFINE_TEST(test_option_r) /* Do some basic validation of the constructed archive. */ p0 = slurpfile(&s, "archive.tar"); if (!assert(p0 != NULL)) - return; - if (!assert(s >= 2048)) { - free(p0); - return; - } + goto done; + if (!assert(s >= 2048)) + goto done; assertEqualMem(p0 + 0, "f1", 3); assertEqualMem(p0 + 512, "abc", 3); assertEqualMem(p0 + 1024, "\0\0\0\0\0\0\0\0", 8); @@ -60,10 +62,8 @@ DEFINE_TEST(test_option_r) /* Edit that file with a lot more data and update the archive with a new copy. */ buff = malloc(buff_size); assert(buff != NULL); - if (buff == NULL) { - free(p0); - return; - } + if (buff == NULL) + goto done; for (i = 0; i < (int)buff_size; ++i) buff[i] = "abcdefghijklmnopqrstuvwxyz"[rand() % 26]; @@ -77,10 +77,8 @@ DEFINE_TEST(test_option_r) /* The constructed archive should just have the new entry appended. */ p1 = slurpfile(&s, "archive.tar"); - if (!assert(p1 != NULL)) { - free(p0); - return; - } + if (!assert(p1 != NULL)) + goto done; buff_size_rounded = ((buff_size + 511) / 512) * 512; assert(s >= 2560 + buff_size_rounded); /* Verify first entry is unchanged. */ @@ -105,10 +103,8 @@ DEFINE_TEST(test_option_r) /* Validate the constructed archive. */ p1 = slurpfile(&s, "archive.tar"); - if (!assert(p1 != NULL)) { - free(p0); - return; - } + if (!assert(p1 != NULL)) + goto done; assert(s >= 3584 + buff_size_rounded); /* Verify first two entries are unchanged. */ assertEqualMem(p0, p1, 1536 + buff_size_rounded); @@ -118,7 +114,6 @@ DEFINE_TEST(test_option_r) /* Verify end-of-archive marker. */ assertEqualMem(p1 + 2560 + buff_size_rounded, "\0\0\0\0\0\0\0\0", 8); assertEqualMem(p1 + 3072 + buff_size_rounded, "\0\0\0\0\0\0\0\0", 8); - free(p0); free(p1); /* Unpack everything */ @@ -132,4 +127,7 @@ DEFINE_TEST(test_option_r) /* Verify that the second copy of f1 overwrote the first. */ assertFileContents(buff, (int)strlen(buff), "f1"); +done: + free(buff); + free(p0); } diff --git a/tar/test/test_option_uid_uname.c b/tar/test/test_option_uid_uname.c index 83ea5f1ecbb..0a8a9bb27a8 100644 --- a/tar/test/test_option_uid_uname.c +++ b/tar/test/test_option_uid_uname.c @@ -53,6 +53,7 @@ DEFINE_TEST(test_option_uid_uname) /* Should force uid and uname fields in ustar header. */ assertEqualMem(data + 108, "000021 \0", 8); assertEqualMem(data + 265, "foofoofoo\0", 10); + free(data); /* Again with just --uid */ failure("Error invoking %s c", testprog); @@ -65,6 +66,7 @@ DEFINE_TEST(test_option_uid_uname) assertEqualMem(data + 108, "000021 \0", 8); /* Uname field in ustar header should be empty. */ assertEqualMem(data + 265, "\0", 1); + free(data); /* Again with just --uname */ failure("Error invoking %s c", testprog); @@ -77,4 +79,7 @@ DEFINE_TEST(test_option_uid_uname) /* Uid should be unchanged from original reference. */ assertEqualMem(data + 108, reference + 108, 8); assertEqualMem(data + 265, "foofoofoo\0", 10); + free(data); + + free(reference); } diff --git a/tar/test/test_option_uuencode.c b/tar/test/test_option_uuencode.c index cdc6babd519..a28a8e3407a 100644 --- a/tar/test/test_option_uuencode.c +++ b/tar/test/test_option_uuencode.c @@ -42,6 +42,7 @@ DEFINE_TEST(test_option_uuencode) p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "begin 644", 9); + free(p); /* Archive it with uuencode only. */ assertEqualInt(0, @@ -51,4 +52,5 @@ DEFINE_TEST(test_option_uuencode) p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "begin 644", 9); + free(p); } diff --git a/tar/test/test_option_xz.c b/tar/test/test_option_xz.c index 7387a604e07..91da0730ac9 100644 --- a/tar/test/test_option_xz.c +++ b/tar/test/test_option_xz.c @@ -44,14 +44,17 @@ DEFINE_TEST(test_option_xz) if (strstr(p, "Unsupported compression") != NULL) { skipping("This version of bsdtar was compiled " "without xz support"); - return; + goto done; } failure("--xz option is broken"); assertEqualInt(r, 0); - return; + goto done; } + free(p); /* Check that the archive file has an xz signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "\xFD\x37\x7A\x58\x5A\x00", 6); +done: + free(p); } diff --git a/tar/test/test_option_z.c b/tar/test/test_option_z.c index 1f952abe3af..59744999fc5 100644 --- a/tar/test/test_option_z.c +++ b/tar/test/test_option_z.c @@ -42,14 +42,17 @@ DEFINE_TEST(test_option_z) if (r != 0) { if (!canGzip()) { skipping("gzip is not supported on this platform"); - return; + goto done; } failure("-z option is broken"); assertEqualInt(r, 0); - return; + goto done; } + free(p); /* Check that the archive file has a gzip signature. */ p = slurpfile(&s, "archive.out"); assert(s > 4); assertEqualMem(p, "\x1f\x8b\x08\x00", 4); +done: + free(p); } diff --git a/tar/test/test_stdio.c b/tar/test/test_stdio.c index bf5dd77443b..d6650a5eb20 100644 --- a/tar/test/test_stdio.c +++ b/tar/test/test_stdio.c @@ -116,6 +116,7 @@ DEFINE_TEST(test_stdio) assertEqualInt((int)s, 3); assertEqualMem(p, "abc", 3); /* TODO: Verify xvf.err */ + free(p); /* 'xvf -' should generate list on stderr, empty stdout. */ r = systemf("%s xvf - < archive >xvf-.out 2>xvf-.err", testprog); diff --git a/tar/test/test_version.c b/tar/test/test_version.c index 04d9e6c7ca9..0c904d705c2 100644 --- a/tar/test/test_version.c +++ b/tar/test/test_version.c @@ -53,7 +53,7 @@ DEFINE_TEST(test_version) assert(s > 6); failure("Version must start with 'bsdtar': ``%s''", p); if (!assertEqualMem(q, "bsdtar ", 7)) - return; + goto done; q += 7; s -= 7; /* Version number is a series of digits and periods. */ while (s > 0 && (*q == '.' || (*q >= '0' && *q <= '9'))) { @@ -98,5 +98,6 @@ DEFINE_TEST(test_version) failure("Version output must end with \\n or \\r\\n"); if (*q == '\r') { ++q; --s; } assertEqualMem(q, "\n", 1); +done: free(p); } From f428c3b114eca361b2c069d987e95553368cd827 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 12 Dec 2016 02:12:51 +0000 Subject: [PATCH 025/226] Merge PR to address libarchive/test coverity issues Obtained from: libarchive (f9e3de49fb294901374e0c8c6c2ceaeea7b6d6c0) --- libarchive/test/read_open_memory.c | 33 ++++++++++--------- libarchive/test/test_fuzz.c | 17 ++++++++-- .../test_read_disk_directory_traversals.c | 1 + libarchive/test/test_read_set_format.c | 8 ++--- 4 files changed, 36 insertions(+), 23 deletions(-) diff --git a/libarchive/test/read_open_memory.c b/libarchive/test/read_open_memory.c index f4162eb4bb4..2bb8d54751c 100644 --- a/libarchive/test/read_open_memory.c +++ b/libarchive/test/read_open_memory.c @@ -86,21 +86,7 @@ static int read_open_memory_internal(struct archive *a, const void *buff, size_t size, size_t read_size, int level) { - struct read_memory_data *mine; - - mine = (struct read_memory_data *)malloc(sizeof(*mine)); - if (mine == NULL) { - archive_set_error(a, ENOMEM, "No memory"); - return (ARCHIVE_FATAL); - } - memset(mine, 0, sizeof(*mine)); - mine->start = mine->p = (const unsigned char *)buff; - mine->end = mine->start + size; - mine->read_size = read_size; - mine->copy_buff_offset = 32; - mine->copy_buff_size = read_size + mine->copy_buff_offset * 2; - mine->copy_buff = malloc(mine->copy_buff_size); - memset(mine->copy_buff, 0xA5, mine->copy_buff_size); + struct read_memory_data *mine = NULL; switch (level) { case 3: @@ -109,6 +95,20 @@ read_open_memory_internal(struct archive *a, const void *buff, archive_read_set_open_callback(a, memory_read_open); archive_read_set_skip_callback(a, memory_read_skip); case 1: + mine = malloc(sizeof(*mine)); + if (mine == NULL) { + archive_set_error(a, ENOMEM, "No memory"); + return (ARCHIVE_FATAL); + } + memset(mine, 0, sizeof(*mine)); + mine->start = mine->p = (const unsigned char *)buff; + mine->end = mine->start + size; + mine->read_size = read_size; + mine->copy_buff_offset = 32; + mine->copy_buff_size = read_size + mine->copy_buff_offset * 2; + mine->copy_buff = malloc(mine->copy_buff_size); + memset(mine->copy_buff, 0xA5, mine->copy_buff_size); + archive_read_set_read_callback(a, memory_read); archive_read_set_close_callback(a, memory_read_close); archive_read_set_callback_data(a, mine); @@ -213,7 +213,8 @@ memory_read_close(struct archive *a, void *client_data) { struct read_memory_data *mine = (struct read_memory_data *)client_data; (void)a; /* UNUSED */ - free(mine->copy_buff); + if (mine != NULL) + free(mine->copy_buff); free(mine); return (ARCHIVE_OK); } diff --git a/libarchive/test/test_fuzz.c b/libarchive/test/test_fuzz.c index 602b894661c..ff064c07d49 100644 --- a/libarchive/test/test_fuzz.c +++ b/libarchive/test/test_fuzz.c @@ -104,16 +104,19 @@ test_fuzz(const struct files *filesets) } if (!assert(size < buffsize)) { free(rawimage); + rawimage = NULL; continue; } } else { for (i = 0; filesets[n].names[i] != NULL; ++i) { tmp = slurpfile(&size, filesets[n].names[i]); - char *newraw = (char *)realloc(rawimage, oldsize + size); + char *newraw = realloc(rawimage, oldsize + size); if (!assert(newraw != NULL)) { free(rawimage); + rawimage = NULL; + free(tmp); continue; } rawimage = newraw; @@ -123,14 +126,21 @@ test_fuzz(const struct files *filesets) free(tmp); } } - if (size == 0) + if (size == 0) { + free(rawimage); + rawimage = NULL; continue; + } image = malloc(size); assert(image != NULL); if (image == NULL) { free(rawimage); + rawimage = NULL; return; } + + assert(rawimage != NULL); + srand((unsigned)time(NULL)); for (i = 0; i < 1000; ++i) { @@ -162,6 +172,7 @@ test_fuzz(const struct files *filesets) Sleep(100); #endif } + assert(f != NULL); assertEqualInt((size_t)size, fwrite(image, 1, (size_t)size, f)); fclose(f); @@ -195,7 +206,7 @@ test_fuzz(const struct files *filesets) archive_read_close(a); } archive_read_free(a); -} + } free(image); free(rawimage); } diff --git a/libarchive/test/test_read_disk_directory_traversals.c b/libarchive/test/test_read_disk_directory_traversals.c index c16b0c65311..1d48cdde122 100644 --- a/libarchive/test/test_read_disk_directory_traversals.c +++ b/libarchive/test/test_read_disk_directory_traversals.c @@ -1327,6 +1327,7 @@ test_callbacks(void) if (assert((m = archive_match_new()) != NULL)) { archive_entry_free(ae); archive_read_free(a); + archive_match_free(m); return; } diff --git a/libarchive/test/test_read_set_format.c b/libarchive/test/test_read_set_format.c index fb5e0047443..b4f414fa2bb 100644 --- a/libarchive/test/test_read_set_format.c +++ b/libarchive/test/test_read_set_format.c @@ -219,8 +219,8 @@ DEFINE_TEST(test_read_append_filter_wrong_program) /* bunzip2 will write to stderr, redirect it to a file */ fflush(stderr); fgetpos(stderr, &pos); - fd = dup(fileno(stderr)); - fp = freopen("stderr1", "w", stderr); + assert((fd = dup(fileno(stderr))) != -1); + fp = freopen("stderr1", "w", stderr); #endif assert((a = archive_read_new()) != NULL); @@ -238,10 +238,10 @@ DEFINE_TEST(test_read_append_filter_wrong_program) if (fp != NULL) { fflush(stderr); dup2(fd, fileno(stderr)); - close(fd); clearerr(stderr); - fsetpos(stderr, &pos); + (void)fsetpos(stderr, &pos); } + close(fd); assertTextFileContents("bunzip2: (stdin) is not a bzip2 file.\n", "stderr1"); #endif } From 27150ef8bc3626955f6d285c813a210143a9459d Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Mon, 12 Dec 2016 03:46:40 +0000 Subject: [PATCH 026/226] ed(1): Prevent possible overflows during allocation. Make sure the parameters used for malloc(3) can hold size_t sizes. This should help ed(1) handle bigger data in the future. MFC after: 2 weeks --- bin/ed/ed.h | 4 ++-- bin/ed/glbl.c | 2 +- bin/ed/main.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ed/ed.h b/bin/ed/ed.h index 8cb8cec731e..597e3464e7f 100644 --- a/bin/ed/ed.h +++ b/bin/ed/ed.h @@ -115,7 +115,7 @@ if (--mutex == 0) { \ /* REALLOC: assure at least a minimum size for buffer b */ #define REALLOC(b,n,i,err) \ if ((i) > (n)) { \ - int ti = (n); \ + size_t ti = (n); \ char *ts; \ SPL1(); \ if ((b) != NULL) { \ @@ -141,7 +141,7 @@ if ((i) > (n)) { \ /* REALLOC: assure at least a minimum size for buffer b */ #define REALLOC(b,n,i,err) \ if ((i) > (n)) { \ - int ti = (n); \ + size_t ti = (n); \ char *ts; \ SPL1(); \ if ((ts = (char *) realloc((b), ti += max((i), MINBUFSZ))) == NULL) { \ diff --git a/bin/ed/glbl.c b/bin/ed/glbl.c index dfb44d28ca0..d3677989235 100644 --- a/bin/ed/glbl.c +++ b/bin/ed/glbl.c @@ -146,7 +146,7 @@ int set_active_node(line_t *lp) { if (active_last + 1 > active_size) { - int ti = active_size; + size_t ti = active_size; line_t **ts; SPL1(); #if defined(sun) || defined(NO_REALLOC_NULL) diff --git a/bin/ed/main.c b/bin/ed/main.c index 174931494e3..6cb7d03364d 100644 --- a/bin/ed/main.c +++ b/bin/ed/main.c @@ -1356,7 +1356,7 @@ handle_hup(int signo) char *hup = NULL; /* hup filename */ char *s; char ed_hup[] = "ed.hup"; - int n; + size_t n; if (!sigactive) quit(1); From b99113a1c114534f665834e4aae824cfdaadacf7 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Mon, 12 Dec 2016 05:04:55 +0000 Subject: [PATCH 027/226] hyperv/vmbus: Add channel polling support. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8738 --- sys/dev/hyperv/include/vmbus.h | 7 + sys/dev/hyperv/vmbus/vmbus_chan.c | 208 +++++++++++++++++++++++++++ sys/dev/hyperv/vmbus/vmbus_chanvar.h | 5 + 3 files changed, 220 insertions(+) diff --git a/sys/dev/hyperv/include/vmbus.h b/sys/dev/hyperv/include/vmbus.h index a6dfe5b6a59..4b0060e9241 100644 --- a/sys/dev/hyperv/include/vmbus.h +++ b/sys/dev/hyperv/include/vmbus.h @@ -49,6 +49,9 @@ #define VMBUS_VERSION_MAJOR(ver) (((uint32_t)(ver)) >> 16) #define VMBUS_VERSION_MINOR(ver) (((uint32_t)(ver)) & 0xffff) +#define VMBUS_CHAN_POLLHZ_MIN 100 /* 10ms interval */ +#define VMBUS_CHAN_POLLHZ_MAX 1000000 /* 1us interval */ + /* * GPA stuffs. */ @@ -220,4 +223,8 @@ bool vmbus_chan_tx_empty(const struct vmbus_channel *chan); struct taskqueue * vmbus_chan_mgmt_tq(const struct vmbus_channel *chan); +void vmbus_chan_poll_enable(struct vmbus_channel *chan, + u_int pollhz); +void vmbus_chan_poll_disable(struct vmbus_channel *chan); + #endif /* !_VMBUS_H_ */ diff --git a/sys/dev/hyperv/vmbus/vmbus_chan.c b/sys/dev/hyperv/vmbus/vmbus_chan.c index 0f26fc059cf..fe3746416ad 100644 --- a/sys/dev/hyperv/vmbus/vmbus_chan.c +++ b/sys/dev/hyperv/vmbus/vmbus_chan.c @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -50,6 +51,11 @@ __FBSDID("$FreeBSD$"); #include #include +struct vmbus_chan_pollarg { + struct vmbus_channel *poll_chan; + u_int poll_hz; +}; + static void vmbus_chan_update_evtflagcnt( struct vmbus_softc *, const struct vmbus_channel *); @@ -68,6 +74,10 @@ static void vmbus_chan_clear_chmap(struct vmbus_channel *); static void vmbus_chan_detach(struct vmbus_channel *); static bool vmbus_chan_wait_revoke( const struct vmbus_channel *, bool); +static void vmbus_chan_poll_timeout(void *); +static bool vmbus_chan_poll_cancel_intq( + struct vmbus_channel *); +static void vmbus_chan_poll_cancel(struct vmbus_channel *); static void vmbus_chan_ins_prilist(struct vmbus_softc *, struct vmbus_channel *); @@ -84,7 +94,11 @@ static void vmbus_chan_rem_sublist(struct vmbus_channel *, static void vmbus_chan_task(void *, int); static void vmbus_chan_task_nobatch(void *, int); +static void vmbus_chan_poll_task(void *, int); static void vmbus_chan_clrchmap_task(void *, int); +static void vmbus_chan_pollcfg_task(void *, int); +static void vmbus_chan_polldis_task(void *, int); +static void vmbus_chan_poll_cancel_task(void *, int); static void vmbus_prichan_attach_task(void *, int); static void vmbus_subchan_attach_task(void *, int); static void vmbus_prichan_detach_task(void *, int); @@ -782,6 +796,22 @@ vmbus_chan_set_chmap(struct vmbus_channel *chan) chan->ch_vmbus->vmbus_chmap[chan->ch_id] = chan; } +static void +vmbus_chan_poll_cancel_task(void *xchan, int pending __unused) +{ + + vmbus_chan_poll_cancel_intq(xchan); +} + +static void +vmbus_chan_poll_cancel(struct vmbus_channel *chan) +{ + struct task poll_cancel; + + TASK_INIT(&poll_cancel, 0, vmbus_chan_poll_cancel_task, chan); + vmbus_chan_run_task(chan, &poll_cancel); +} + static int vmbus_chan_close_internal(struct vmbus_channel *chan) { @@ -817,6 +847,11 @@ vmbus_chan_close_internal(struct vmbus_channel *chan) */ sysctl_ctx_free(&chan->ch_sysctl_ctx); + /* + * Cancel polling, if it is enabled. + */ + vmbus_chan_poll_cancel(chan); + /* * NOTE: * Order is critical. This channel _must_ be uninstalled first, @@ -1185,6 +1220,9 @@ vmbus_chan_task(void *xchan, int pending __unused) vmbus_chan_callback_t cb = chan->ch_cb; void *cbarg = chan->ch_cbarg; + KASSERT(chan->ch_poll_intvl == 0, + ("chan%u: interrupted in polling mode", chan->ch_id)); + /* * Optimize host to guest signaling by ensuring: * 1. While reading the channel, we disable interrupts from @@ -1216,9 +1254,145 @@ vmbus_chan_task_nobatch(void *xchan, int pending __unused) { struct vmbus_channel *chan = xchan; + KASSERT(chan->ch_poll_intvl == 0, + ("chan%u: interrupted in polling mode", chan->ch_id)); chan->ch_cb(chan, chan->ch_cbarg); } +static void +vmbus_chan_poll_timeout(void *xchan) +{ + struct vmbus_channel *chan = xchan; + + KASSERT(chan->ch_poll_intvl != 0, + ("chan%u: polling timeout in interrupt mode", chan->ch_id)); + taskqueue_enqueue(chan->ch_tq, &chan->ch_poll_task); +} + +static void +vmbus_chan_poll_task(void *xchan, int pending __unused) +{ + struct vmbus_channel *chan = xchan; + + KASSERT(chan->ch_poll_intvl != 0, + ("chan%u: polling in interrupt mode", chan->ch_id)); + callout_reset_sbt_curcpu(&chan->ch_poll_timeo, chan->ch_poll_intvl, 0, + vmbus_chan_poll_timeout, chan, chan->ch_poll_flags); + chan->ch_cb(chan, chan->ch_cbarg); +} + +static void +vmbus_chan_pollcfg_task(void *xarg, int pending __unused) +{ + const struct vmbus_chan_pollarg *arg = xarg; + struct vmbus_channel *chan = arg->poll_chan; + sbintime_t intvl; + int poll_flags; + + /* + * Save polling interval. + */ + intvl = SBT_1S / arg->poll_hz; + if (intvl == 0) + intvl = 1; + if (intvl == chan->ch_poll_intvl) { + /* Nothing changes; done */ + return; + } + chan->ch_poll_intvl = intvl; + + /* Adjust callout flags. */ + poll_flags = C_DIRECT_EXEC; + if (arg->poll_hz <= hz) + poll_flags |= C_HARDCLOCK; + chan->ch_poll_flags = poll_flags; + + /* + * Disable interrupt from the RX bufring (TX bufring does not + * generate interrupt to VM), and disconnect this channel from + * the channel map to make sure that ISR can not enqueue this + * channel task anymore. + */ + critical_enter(); + vmbus_rxbr_intr_mask(&chan->ch_rxbr); + chan->ch_vmbus->vmbus_chmap[chan->ch_id] = NULL; + critical_exit(); + + /* + * NOTE: + * At this point, this channel task will not be enqueued by + * the ISR anymore, time to cancel the pending one. + */ + taskqueue_cancel(chan->ch_tq, &chan->ch_task, NULL); + + /* Kick start! */ + taskqueue_enqueue(chan->ch_tq, &chan->ch_poll_task); +} + +static bool +vmbus_chan_poll_cancel_intq(struct vmbus_channel *chan) +{ + + if (chan->ch_poll_intvl == 0) { + /* Not enabled. */ + return (false); + } + + /* + * Stop polling callout, so that channel polling task + * will not be enqueued anymore. + */ + callout_drain(&chan->ch_poll_timeo); + + /* + * Disable polling by resetting polling interval. + * + * NOTE: + * The polling interval resetting MUST be conducted + * after the callout is drained; mainly to keep the + * proper assertion in place. + */ + chan->ch_poll_intvl = 0; + + /* + * NOTE: + * At this point, this channel polling task will not be + * enqueued by the callout anymore, time to cancel the + * pending one. + */ + taskqueue_cancel(chan->ch_tq, &chan->ch_poll_task, NULL); + + /* Polling was enabled. */ + return (true); +} + +static void +vmbus_chan_polldis_task(void *xchan, int pending __unused) +{ + struct vmbus_channel *chan = xchan; + + if (!vmbus_chan_poll_cancel_intq(chan)) { + /* Already disabled; done. */ + return; + } + + /* + * Plug this channel back to the channel map and unmask + * the RX bufring interrupt. + */ + critical_enter(); + chan->ch_vmbus->vmbus_chmap[chan->ch_id] = chan; + __compiler_membar(); + vmbus_rxbr_intr_unmask(&chan->ch_rxbr); + critical_exit(); + + /* + * Kick start the interrupt task, just in case unmasking + * interrupt races ISR. + */ + taskqueue_enqueue(chan->ch_tq, &chan->ch_task); +} + static __inline void vmbus_event_flags_proc(struct vmbus_softc *sc, volatile u_long *event_flags, int flag_cnt) @@ -1333,6 +1507,9 @@ vmbus_chan_alloc(struct vmbus_softc *sc) vmbus_rxbr_init(&chan->ch_rxbr); vmbus_txbr_init(&chan->ch_txbr); + TASK_INIT(&chan->ch_poll_task, 0, vmbus_chan_poll_task, chan); + callout_init(&chan->ch_poll_timeo, 1); + return chan; } @@ -1351,6 +1528,8 @@ vmbus_chan_free(struct vmbus_channel *chan) ("still has orphan xact installed")); KASSERT(chan->ch_refs == 0, ("chan%u: invalid refcnt %d", chan->ch_id, chan->ch_refs)); + KASSERT(chan->ch_poll_intvl == 0, ("chan%u: polling is activated", + chan->ch_id)); hyperv_dmamem_free(&chan->ch_monprm_dma, chan->ch_monprm); mtx_destroy(&chan->ch_subchan_lock); @@ -1998,3 +2177,32 @@ vmbus_chan_xact_wait(const struct vmbus_channel *chan, } return (ret); } + +void +vmbus_chan_poll_enable(struct vmbus_channel *chan, u_int pollhz) +{ + struct vmbus_chan_pollarg arg; + struct task poll_cfg; + + KASSERT(chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD, + ("enable polling on non-batch chan%u", chan->ch_id)); + KASSERT(pollhz >= VMBUS_CHAN_POLLHZ_MIN && + pollhz <= VMBUS_CHAN_POLLHZ_MAX, ("invalid pollhz %u", pollhz)); + + arg.poll_chan = chan; + arg.poll_hz = pollhz; + TASK_INIT(&poll_cfg, 0, vmbus_chan_pollcfg_task, &arg); + vmbus_chan_run_task(chan, &poll_cfg); +} + +void +vmbus_chan_poll_disable(struct vmbus_channel *chan) +{ + struct task poll_dis; + + KASSERT(chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD, + ("disable polling on non-batch chan%u", chan->ch_id)); + + TASK_INIT(&poll_dis, 0, vmbus_chan_polldis_task, chan); + vmbus_chan_run_task(chan, &poll_dis); +} diff --git a/sys/dev/hyperv/vmbus/vmbus_chanvar.h b/sys/dev/hyperv/vmbus/vmbus_chanvar.h index de5c1329cd3..ec78c47db44 100644 --- a/sys/dev/hyperv/vmbus/vmbus_chanvar.h +++ b/sys/dev/hyperv/vmbus/vmbus_chanvar.h @@ -30,6 +30,7 @@ #define _VMBUS_CHANVAR_H_ #include +#include #include #include #include @@ -49,6 +50,7 @@ struct vmbus_channel { * target CPU. */ uint32_t ch_flags; /* VMBUS_CHAN_FLAG_ */ + int ch_poll_flags; /* callout flags */ /* * RX bufring; immediately following ch_txbr. @@ -57,6 +59,9 @@ struct vmbus_channel { struct taskqueue *ch_tq; struct task ch_task; + struct task ch_poll_task; + sbintime_t ch_poll_intvl; + struct callout ch_poll_timeo; vmbus_chan_callback_t ch_cb; void *ch_cbarg; From 6c1204df36ac61e01a12c770d46a0acbd905e502 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Mon, 12 Dec 2016 05:18:03 +0000 Subject: [PATCH 028/226] hyperv/hn: Add polling support MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8739 --- sys/dev/hyperv/netvsc/if_hn.c | 79 ++++++++++++++++++++++++++++++++ sys/dev/hyperv/netvsc/if_hnvar.h | 2 + 2 files changed, 81 insertions(+) diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index 983fdc38456..90b5a852b7c 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -293,6 +293,7 @@ static int hn_txagg_size_sysctl(SYSCTL_HANDLER_ARGS); static int hn_txagg_pkts_sysctl(SYSCTL_HANDLER_ARGS); static int hn_txagg_pktmax_sysctl(SYSCTL_HANDLER_ARGS); static int hn_txagg_align_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_polling_sysctl(SYSCTL_HANDLER_ARGS); static void hn_stop(struct hn_softc *); static void hn_init_locked(struct hn_softc *); @@ -319,6 +320,8 @@ static void hn_resume_mgmt(struct hn_softc *); static void hn_suspend_mgmt_taskfunc(void *, int); static void hn_chan_drain(struct hn_softc *, struct vmbus_channel *); +static void hn_polling(struct hn_softc *, u_int); +static void hn_chan_polling(struct vmbus_channel *, u_int); static void hn_update_link_status(struct hn_softc *); static void hn_change_network(struct hn_softc *); @@ -1117,6 +1120,10 @@ hn_attach(device_t dev) hn_txagg_pkts_sysctl, "I", "Packet transmission aggregation packets, " "0 -- disable, -1 -- auto"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "polling", + CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, + hn_polling_sysctl, "I", + "Polling frequency: [100,1000000], 0 disable polling"); /* * Setup the ifmedia, which has been initialized earlier. @@ -2360,6 +2367,9 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; } + /* Disable polling. */ + hn_polling(sc, 0); + /* * Suspend this interface before the synthetic parts * are ripped. @@ -2405,6 +2415,13 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) */ hn_resume(sc); + /* + * Re-enable polling if this interface is running and + * the polling is requested. + */ + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) && sc->hn_pollhz > 0) + hn_polling(sc, sc->hn_pollhz); + HN_UNLOCK(sc); break; @@ -2531,6 +2548,9 @@ hn_stop(struct hn_softc *sc) KASSERT(sc->hn_flags & HN_FLAG_SYNTH_ATTACHED, ("synthetic parts were not attached")); + /* Disable polling. */ + hn_polling(sc, 0); + /* Clear RUNNING bit _before_ hn_suspend_data() */ atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); hn_suspend_data(sc); @@ -2568,6 +2588,10 @@ hn_init_locked(struct hn_softc *sc) /* Everything is ready; unleash! */ atomic_set_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); + + /* Re-enable polling if requested. */ + if (sc->hn_pollhz > 0) + hn_polling(sc, sc->hn_pollhz); } static void @@ -2875,6 +2899,61 @@ hn_txagg_align_sysctl(SYSCTL_HANDLER_ARGS) return (sysctl_handle_int(oidp, &align, 0, req)); } +static void +hn_chan_polling(struct vmbus_channel *chan, u_int pollhz) +{ + if (pollhz == 0) + vmbus_chan_poll_disable(chan); + else + vmbus_chan_poll_enable(chan, pollhz); +} + +static void +hn_polling(struct hn_softc *sc, u_int pollhz) +{ + int nsubch = sc->hn_rx_ring_inuse - 1; + + HN_LOCK_ASSERT(sc); + + if (nsubch > 0) { + struct vmbus_channel **subch; + int i; + + subch = vmbus_subchan_get(sc->hn_prichan, nsubch); + for (i = 0; i < nsubch; ++i) + hn_chan_polling(subch[i], pollhz); + vmbus_subchan_rel(subch, nsubch); + } + hn_chan_polling(sc->hn_prichan, pollhz); +} + +static int +hn_polling_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int pollhz, error; + + pollhz = sc->hn_pollhz; + error = sysctl_handle_int(oidp, &pollhz, 0, req); + if (error || req->newptr == NULL) + return (error); + + if (pollhz != 0 && + (pollhz < VMBUS_CHAN_POLLHZ_MIN || pollhz > VMBUS_CHAN_POLLHZ_MAX)) + return (EINVAL); + + HN_LOCK(sc); + if (sc->hn_pollhz != pollhz) { + sc->hn_pollhz = pollhz; + if ((sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) && + (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED)) + hn_polling(sc, sc->hn_pollhz); + } + HN_UNLOCK(sc); + + return (0); +} + static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS) { diff --git a/sys/dev/hyperv/netvsc/if_hnvar.h b/sys/dev/hyperv/netvsc/if_hnvar.h index 198d0d83e94..38d7b6f7040 100644 --- a/sys/dev/hyperv/netvsc/if_hnvar.h +++ b/sys/dev/hyperv/netvsc/if_hnvar.h @@ -212,6 +212,8 @@ struct hn_softc { uint32_t hn_caps; /* HN_CAP_ */ uint32_t hn_flags; /* HN_FLAG_ */ + u_int hn_pollhz; + void *hn_rxbuf; uint32_t hn_rxbuf_gpadl; struct hyperv_dma hn_rxbuf_dma; From 5a1842a24a32b1570c5798429a4cd0c4fecc39f5 Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Mon, 12 Dec 2016 10:57:32 +0000 Subject: [PATCH 029/226] Add ip6_tryforward() - a run to completion forwarding implementation for IPv6. It gets performance benefits from reduced number of checks. It doesn't copy mbuf to be able send ICMPv6 error message, because it keeps mbuf unchanged until the moment, when the route decision has been made. It doesn't do IPsec checks, and when some IPsec security policies present, ip6_input() uses normal slow path. Reviewed by: bz, gnn Obtained from: Yandex LLC MFC after: 1 month Sponsored by: Yandex LLC Differential Revision: https://reviews.freebsd.org/D8527 --- sys/conf/files | 1 + sys/netinet6/in6_var.h | 1 + sys/netinet6/ip6_fastfwd.c | 295 +++++++++++++++++++++++++++++++++++++ sys/netinet6/ip6_input.c | 20 ++- 4 files changed, 313 insertions(+), 4 deletions(-) create mode 100644 sys/netinet6/ip6_fastfwd.c diff --git a/sys/conf/files b/sys/conf/files index 23e9c6f32a5..88229b94f40 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -4129,6 +4129,7 @@ netinet6/in6_proto.c optional inet6 netinet6/in6_rmx.c optional inet6 netinet6/in6_rss.c optional inet6 rss netinet6/in6_src.c optional inet6 +netinet6/ip6_fastfwd.c optional inet6 netinet6/ip6_forward.c optional inet6 netinet6/ip6_gre.c optional gre inet6 netinet6/ip6_id.c optional inet6 diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h index 77e5920b069..d7c1038417e 100644 --- a/sys/netinet6/in6_var.h +++ b/sys/netinet6/in6_var.h @@ -819,6 +819,7 @@ void in6_newaddrmsg(struct in6_ifaddr *, int); /* * Extended API for IPv6 FIB support. */ +struct mbuf *ip6_tryforward(struct mbuf *); void in6_rtredirect(struct sockaddr *, struct sockaddr *, struct sockaddr *, int, struct sockaddr *, u_int); int in6_rtrequest(int, struct sockaddr *, struct sockaddr *, diff --git a/sys/netinet6/ip6_fastfwd.c b/sys/netinet6/ip6_fastfwd.c new file mode 100644 index 00000000000..5358868b68a --- /dev/null +++ b/sys/netinet6/ip6_fastfwd.c @@ -0,0 +1,295 @@ +/*- + * Copyright (c) 2014-2016 Andrey V. Elsukov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_inet6.h" +#include "opt_ipstealth.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int +ip6_findroute(struct nhop6_basic *pnh, const struct sockaddr_in6 *dst, + struct mbuf *m) +{ + + if (fib6_lookup_nh_basic(M_GETFIB(m), &dst->sin6_addr, + dst->sin6_scope_id, 0, dst->sin6_flowinfo, pnh) != 0) { + IP6STAT_INC(ip6s_noroute); + IP6STAT_INC(ip6s_cantforward); + icmp6_error(m, ICMP6_DST_UNREACH, + ICMP6_DST_UNREACH_NOROUTE, 0); + return (EHOSTUNREACH); + } + if (pnh->nh_flags & NHF_BLACKHOLE) { + IP6STAT_INC(ip6s_cantforward); + m_freem(m); + return (EHOSTUNREACH); + } + + if (pnh->nh_flags & NHF_REJECT) { + IP6STAT_INC(ip6s_cantforward); + icmp6_error(m, ICMP6_DST_UNREACH, + ICMP6_DST_UNREACH_REJECT, 0); + return (EHOSTUNREACH); + } + return (0); +} + +struct mbuf* +ip6_tryforward(struct mbuf *m) +{ + struct sockaddr_in6 dst; + struct nhop6_basic nh; + struct m_tag *fwd_tag; + struct ip6_hdr *ip6; + struct ifnet *rcvif; + uint32_t plen; + int error; + + /* + * Fallback conditions to ip6_input for slow path processing. + */ + ip6 = mtod(m, struct ip6_hdr *); + if (ip6->ip6_nxt == IPPROTO_HOPOPTS || + IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) || + IN6_IS_ADDR_LINKLOCAL(&ip6->ip6_dst) || + IN6_IS_ADDR_LINKLOCAL(&ip6->ip6_src) || + IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src) || + in6_localip(&ip6->ip6_dst)) + return (m); + /* + * Check that the amount of data in the buffers + * is as at least much as the IPv6 header would have us expect. + * Trim mbufs if longer than we expect. + * Drop packet if shorter than we expect. + */ + rcvif = m->m_pkthdr.rcvif; + plen = ntohs(ip6->ip6_plen); + if (plen == 0) { + /* + * Jumbograms must have hop-by-hop header and go via + * slow path. + */ + IP6STAT_INC(ip6s_badoptions); + goto dropin; + } + if (m->m_pkthdr.len - sizeof(struct ip6_hdr) < plen) { + IP6STAT_INC(ip6s_tooshort); + in6_ifstat_inc(rcvif, ifs6_in_truncated); + goto dropin; + } + if (m->m_pkthdr.len > sizeof(struct ip6_hdr) + plen) { + if (m->m_len == m->m_pkthdr.len) { + m->m_len = sizeof(struct ip6_hdr) + plen; + m->m_pkthdr.len = sizeof(struct ip6_hdr) + plen; + } else + m_adj(m, sizeof(struct ip6_hdr) + plen - + m->m_pkthdr.len); + } + + /* + * Hop limit. + */ +#ifdef IPSTEALTH + if (!V_ip6stealth) +#endif + if (ip6->ip6_hlim <= IPV6_HLIMDEC) { + icmp6_error(m, ICMP6_TIME_EXCEEDED, + ICMP6_TIME_EXCEED_TRANSIT, 0); + m = NULL; + goto dropin; + } + + bzero(&dst, sizeof(dst)); + dst.sin6_family = AF_INET6; + dst.sin6_len = sizeof(dst); + dst.sin6_addr = ip6->ip6_dst; + + /* + * Incoming packet firewall processing. + */ + if (!PFIL_HOOKED(&V_inet6_pfil_hook)) + goto passin; + if (pfil_run_hooks(&V_inet6_pfil_hook, &m, rcvif, PFIL_IN, + NULL) != 0 || m == NULL) + goto dropin; + /* + * If packet filter sets the M_FASTFWD_OURS flag, this means + * that new destination or next hop is our local address. + * So, we can just go back to ip6_input. + * XXX: should we decrement ip6_hlim in such case? + * + * Also it can forward packet to another destination, e.g. + * M_IP6_NEXTHOP flag is set and fwd_tag is attached to mbuf. + */ + if (m->m_flags & M_FASTFWD_OURS) + return (m); + + ip6 = mtod(m, struct ip6_hdr *); + if ((m->m_flags & M_IP6_NEXTHOP) && + (fwd_tag = m_tag_find(m, PACKET_TAG_IPFORWARD, NULL)) != NULL) { + /* + * Now we will find route to forwarded by pfil destination. + */ + bcopy((fwd_tag + 1), &dst, sizeof(dst)); + m->m_flags &= ~M_IP6_NEXTHOP; + m_tag_delete(m, fwd_tag); + } else { + /* Update dst since pfil could change it */ + dst.sin6_addr = ip6->ip6_dst; + } +passin: + /* + * Find route to destination. + */ + if (ip6_findroute(&nh, &dst, m) != 0) { + m = NULL; + in6_ifstat_inc(rcvif, ifs6_in_noroute); + goto dropin; + } + /* + * We used slow path processing for packets with scoped addresses. + * So, scope checks aren't needed here. + */ + if (m->m_pkthdr.len > nh.nh_mtu) { + in6_ifstat_inc(nh.nh_ifp, ifs6_in_toobig); + icmp6_error(m, ICMP6_PACKET_TOO_BIG, 0, nh.nh_mtu); + m = NULL; + goto dropout; + } + + /* + * Outgoing packet firewall processing. + */ + if (!PFIL_HOOKED(&V_inet6_pfil_hook)) + goto passout; + if (pfil_run_hooks(&V_inet6_pfil_hook, &m, nh.nh_ifp, PFIL_OUT, + NULL) != 0 || m == NULL) + goto dropout; + /* + * If packet filter sets the M_FASTFWD_OURS flag, this means + * that new destination or next hop is our local address. + * So, we can just go back to ip6_input. + * + * Also it can forward packet to another destination, e.g. + * M_IP6_NEXTHOP flag is set and fwd_tag is attached to mbuf. + */ + if (m->m_flags & M_FASTFWD_OURS) { + /* + * XXX: we did one hop and should decrement hop limit. But + * now we are the destination and just don't pay attention. + */ + return (m); + } + /* + * Again. A packet filter could change the destination address. + */ + ip6 = mtod(m, struct ip6_hdr *); + if (m->m_flags & M_IP6_NEXTHOP) + fwd_tag = m_tag_find(m, PACKET_TAG_IPFORWARD, NULL); + else + fwd_tag = NULL; + + if (fwd_tag != NULL || + !IN6_ARE_ADDR_EQUAL(&dst.sin6_addr, &ip6->ip6_dst)) { + if (fwd_tag != NULL) { + bcopy((fwd_tag + 1), &dst, sizeof(dst)); + m->m_flags &= ~M_IP6_NEXTHOP; + m_tag_delete(m, fwd_tag); + } else + dst.sin6_addr = ip6->ip6_dst; + /* + * Redo route lookup with new destination address + */ + if (ip6_findroute(&nh, &dst, m) != 0) { + m = NULL; + goto dropout; + } + } +passout: +#ifdef IPSTEALTH + if (!V_ip6stealth) +#endif + { + ip6->ip6_hlim -= IPV6_HLIMDEC; + } + + m_clrprotoflags(m); /* Avoid confusing lower layers. */ + IP_PROBE(send, NULL, NULL, ip6, nh.nh_ifp, NULL, ip6); + + /* + * XXX: we need to use destination address with embedded scope + * zone id, because LLTABLE uses such form of addresses for lookup. + */ + dst.sin6_addr = nh.nh_addr; + if (IN6_IS_SCOPE_LINKLOCAL(&dst.sin6_addr)) + dst.sin6_addr.s6_addr16[1] = htons(nh.nh_ifp->if_index & 0xffff); + + error = (*nh.nh_ifp->if_output)(nh.nh_ifp, m, + (struct sockaddr *)&dst, NULL); + if (error != 0) { + in6_ifstat_inc(nh.nh_ifp, ifs6_out_discard); + IP6STAT_INC(ip6s_cantforward); + } else { + in6_ifstat_inc(nh.nh_ifp, ifs6_out_forward); + IP6STAT_INC(ip6s_forward); + } + return (NULL); +dropin: + in6_ifstat_inc(rcvif, ifs6_in_discard); + goto drop; +dropout: + in6_ifstat_inc(nh.nh_ifp, ifs6_out_discard); +drop: + if (m != NULL) + m_freem(m); + return (NULL); +} + diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index 403e419d178..26d55ba4a1e 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -119,6 +119,7 @@ __FBSDID("$FreeBSD$"); #include #ifdef IPSEC +#include #include #include #include @@ -554,6 +555,12 @@ ip6_input(struct mbuf *m) int nxt, ours = 0; int srcrt = 0; + /* + * Drop the packet if IPv6 operation is disabled on the interface. + */ + if ((ND_IFINFO(m->m_pkthdr.rcvif)->flags & ND6_IFF_IFDISABLED)) + goto bad; + #ifdef IPSEC /* * should the inner packet be considered authentic? @@ -597,10 +604,6 @@ ip6_input(struct mbuf *m) IP6STAT_INC(ip6s_m1); } - /* drop the packet if IPv6 operation is disabled on the IF */ - if ((ND_IFINFO(m->m_pkthdr.rcvif)->flags & ND6_IFF_IFDISABLED)) - goto bad; - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_receive); IP6STAT_INC(ip6s_total); @@ -728,12 +731,21 @@ ip6_input(struct mbuf *m) goto bad; } #endif + /* Try to forward the packet, but if we fail continue */ #ifdef IPSEC + if (V_ip6_forwarding != 0 && !key_havesp(IPSEC_DIR_INBOUND) && + !key_havesp(IPSEC_DIR_OUTBOUND)) + if (ip6_tryforward(m) == NULL) + return; /* * Bypass packet filtering for packets previously handled by IPsec. */ if (ip6_ipsec_filtertunnel(m)) goto passin; +#else + if (V_ip6_forwarding != 0) + if (ip6_tryforward(m) == NULL) + return; #endif /* IPSEC */ /* From 545d31229353b58c550628b5eefff3436dc3ec66 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Mon, 12 Dec 2016 11:11:50 +0000 Subject: [PATCH 030/226] When a zombie gets reparented due to the parent exit, send SIGCHLD to the reaper. The traditional reaper init(8) is aware of zombies silently reparented to it after the parents exit, it loops around waitpid(2) to collect them. For other reapers, the silent reparenting is surprising and collecting zombies requires a thread blocking in waitpid(2) just for that purpose. It seems that sending second SIGCHLD is a better workaround than forcing all reapers to obey the setup. Reported by: Michael Zuo , jilles PR: 213928 Reviewed by: jilles (previous version) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks --- sys/kern/kern_exit.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index f4f453c3556..3e56ae3bef7 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -455,6 +455,11 @@ exit1(struct thread *td, int rval, int signo) if (!(q->p_flag & P_TRACED)) { proc_reparent(q, q->p_reaper); + if (q->p_state == PRS_ZOMBIE) { + PROC_LOCK(q->p_reaper); + pksignal(q->p_reaper, SIGCHLD, q->p_ksi); + PROC_UNLOCK(q->p_reaper); + } } else { /* * Traced processes are killed since their existence From 778aa66a68dc569ef2243e2579443f549f4225b7 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Mon, 12 Dec 2016 11:12:04 +0000 Subject: [PATCH 031/226] Enable lookup_cap_dotdot and lookup_cap_dotdot_nonlocal. Requested and reviewed by: cem Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D8746 --- sys/kern/vfs_lookup.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index bab4edf5b44..7885ec1e764 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -161,16 +161,11 @@ static int lookup_shared = 1; SYSCTL_INT(_vfs, OID_AUTO, lookup_shared, CTLFLAG_RWTUN, &lookup_shared, 0, "enables shared locks for path name translation"); -/* - * Intent is that lookup_cap_dotdot becomes unconditionally enabled, - * but it defaults to the disabled state until verification efforts - * are complete. - */ -static int lookup_cap_dotdot = 0; +static int lookup_cap_dotdot = 1; SYSCTL_INT(_vfs, OID_AUTO, lookup_cap_dotdot, CTLFLAG_RWTUN, &lookup_cap_dotdot, 0, "enables \"..\" components in path lookup in capability mode"); -static int lookup_cap_dotdot_nonlocal = 0; +static int lookup_cap_dotdot_nonlocal = 1; SYSCTL_INT(_vfs, OID_AUTO, lookup_cap_dotdot_nonlocal, CTLFLAG_RWTUN, &lookup_cap_dotdot_nonlocal, 0, "enables \"..\" components in path lookup in capability mode " From 8a030e9c6e6218952981de9f030ca4c946d976e4 Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Mon, 12 Dec 2016 11:26:59 +0000 Subject: [PATCH 032/226] Modify IPv6 statistic accounting in ip6_input(). Add rcvif local variable to keep inbound interface pointer. Count ifs6_in_discard errors in all "goto bad" cases. Now it will count errors even if mbuf was freed. Modify all places where m->m_pkthdr.rcvif is used to use local rcvif variable. Obtained from: Yandex LLC MFC after: 1 month --- sys/netinet6/ip6_input.c | 60 ++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index 26d55ba4a1e..78dcce73c04 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -549,6 +549,7 @@ ip6_input(struct mbuf *m) struct in6_addr odst; struct ip6_hdr *ip6; struct in6_ifaddr *ia; + struct ifnet *rcvif; u_int32_t plen; u_int32_t rtalert = ~0; int off = sizeof(struct ip6_hdr), nest; @@ -558,7 +559,8 @@ ip6_input(struct mbuf *m) /* * Drop the packet if IPv6 operation is disabled on the interface. */ - if ((ND_IFINFO(m->m_pkthdr.rcvif)->flags & ND6_IFF_IFDISABLED)) + rcvif = m->m_pkthdr.rcvif; + if ((ND_IFINFO(rcvif)->flags & ND6_IFF_IFDISABLED)) goto bad; #ifdef IPSEC @@ -595,16 +597,15 @@ ip6_input(struct mbuf *m) if (m->m_next) { if (m->m_flags & M_LOOP) { IP6STAT_INC(ip6s_m2m[V_loif->if_index]); - } else if (m->m_pkthdr.rcvif->if_index < IP6S_M2MMAX) - IP6STAT_INC( - ip6s_m2m[m->m_pkthdr.rcvif->if_index]); + } else if (rcvif->if_index < IP6S_M2MMAX) + IP6STAT_INC(ip6s_m2m[rcvif->if_index]); else IP6STAT_INC(ip6s_m2m[0]); } else IP6STAT_INC(ip6s_m1); } - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_receive); + in6_ifstat_inc(rcvif, ifs6_in_receive); IP6STAT_INC(ip6s_total); #ifndef PULLDOWN_TEST @@ -620,10 +621,8 @@ ip6_input(struct mbuf *m) n = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); else n = m_gethdr(M_NOWAIT, MT_DATA); - if (n == NULL) { - m_freem(m); - return; /* ENOBUFS */ - } + if (n == NULL) + goto bad; m_move_pkthdr(n, m); m_copydata(m, 0, n->m_pkthdr.len, mtod(n, caddr_t)); @@ -635,26 +634,22 @@ ip6_input(struct mbuf *m) #endif if (m->m_len < sizeof(struct ip6_hdr)) { - struct ifnet *inifp; - inifp = m->m_pkthdr.rcvif; if ((m = m_pullup(m, sizeof(struct ip6_hdr))) == NULL) { IP6STAT_INC(ip6s_toosmall); - in6_ifstat_inc(inifp, ifs6_in_hdrerr); - return; + in6_ifstat_inc(rcvif, ifs6_in_hdrerr); + goto bad; } } ip6 = mtod(m, struct ip6_hdr *); - if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) { IP6STAT_INC(ip6s_badvers); - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr); + in6_ifstat_inc(rcvif, ifs6_in_hdrerr); goto bad; } IP6STAT_INC(ip6s_nxthist[ip6->ip6_nxt]); - - IP_PROBE(receive, NULL, NULL, ip6, m->m_pkthdr.rcvif, NULL, ip6); + IP_PROBE(receive, NULL, NULL, ip6, rcvif, NULL, ip6); /* * Check against address spoofing/corruption. @@ -665,7 +660,7 @@ ip6_input(struct mbuf *m) * XXX: "badscope" is not very suitable for a multicast source. */ IP6STAT_INC(ip6s_badscope); - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr); + in6_ifstat_inc(rcvif, ifs6_in_addrerr); goto bad; } if (IN6_IS_ADDR_MC_INTFACELOCAL(&ip6->ip6_dst) && @@ -677,7 +672,7 @@ ip6_input(struct mbuf *m) * as the outgoing/incoming interface. */ IP6STAT_INC(ip6s_badscope); - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr); + in6_ifstat_inc(rcvif, ifs6_in_addrerr); goto bad; } if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) && @@ -689,7 +684,7 @@ ip6_input(struct mbuf *m) * a packet is received, it must be silently dropped. */ IP6STAT_INC(ip6s_badscope); - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr); + in6_ifstat_inc(rcvif, ifs6_in_addrerr); goto bad; } #ifdef ALTQ @@ -713,7 +708,7 @@ ip6_input(struct mbuf *m) if (IN6_IS_ADDR_V4MAPPED(&ip6->ip6_src) || IN6_IS_ADDR_V4MAPPED(&ip6->ip6_dst)) { IP6STAT_INC(ip6s_badscope); - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr); + in6_ifstat_inc(rcvif, ifs6_in_addrerr); goto bad; } #if 0 @@ -800,8 +795,8 @@ ip6_input(struct mbuf *m) IP6STAT_INC(ip6s_badscope); /* XXX */ goto bad; } - if (in6_setscope(&ip6->ip6_src, m->m_pkthdr.rcvif, NULL) || - in6_setscope(&ip6->ip6_dst, m->m_pkthdr.rcvif, NULL)) { + if (in6_setscope(&ip6->ip6_src, rcvif, NULL) || + in6_setscope(&ip6->ip6_dst, rcvif, NULL)) { IP6STAT_INC(ip6s_badscope); goto bad; } @@ -811,7 +806,7 @@ ip6_input(struct mbuf *m) */ if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) { ours = 1; - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_mcast); + in6_ifstat_inc(rcvif, ifs6_in_mcast); goto hbhcheck; } /* @@ -846,7 +841,6 @@ ip6_input(struct mbuf *m) */ if (!V_ip6_forwarding) { IP6STAT_INC(ip6s_cantforward); - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard); goto bad; } @@ -878,7 +872,7 @@ ip6_input(struct mbuf *m) */ if (m->m_pkthdr.len - sizeof(struct ip6_hdr) < plen) { IP6STAT_INC(ip6s_tooshort); - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated); + in6_ifstat_inc(rcvif, ifs6_in_truncated); goto bad; } if (m->m_pkthdr.len > sizeof(struct ip6_hdr) + plen) { @@ -905,10 +899,8 @@ ip6_input(struct mbuf *m) * XXX TODO: Check hlim and multicast scope here to avoid * unnecessarily calling into ip6_mforward(). */ - if (ip6_mforward && - ip6_mforward(ip6, m->m_pkthdr.rcvif, m)) { + if (ip6_mforward && ip6_mforward(ip6, rcvif, m)) { IP6STAT_INC(ip6s_cantforward); - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard); goto bad; } } else if (!ours) { @@ -930,7 +922,7 @@ ip6_input(struct mbuf *m) if (IN6_IS_ADDR_V4MAPPED(&ip6->ip6_src) || IN6_IS_ADDR_V4MAPPED(&ip6->ip6_dst)) { IP6STAT_INC(ip6s_badscope); - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr); + in6_ifstat_inc(rcvif, ifs6_in_addrerr); goto bad; } @@ -938,7 +930,7 @@ ip6_input(struct mbuf *m) * Tell launch routine the next header */ IP6STAT_INC(ip6s_delivered); - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_deliver); + in6_ifstat_inc(rcvif, ifs6_in_deliver); nest = 0; while (nxt != IPPROTO_DONE) { @@ -953,7 +945,7 @@ ip6_input(struct mbuf *m) */ if (m->m_pkthdr.len < off) { IP6STAT_INC(ip6s_tooshort); - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated); + in6_ifstat_inc(rcvif, ifs6_in_truncated); goto bad; } @@ -971,7 +963,9 @@ ip6_input(struct mbuf *m) } return; bad: - m_freem(m); + in6_ifstat_inc(rcvif, ifs6_in_discard); + if (m != NULL) + m_freem(m); } /* From 7d9082cafa3ca619fe36d043b2bb4b329afe0bdf Mon Sep 17 00:00:00 2001 From: "Jayachandran C." Date: Mon, 12 Dec 2016 15:17:56 +0000 Subject: [PATCH 033/226] Increase interrupt cells in generic_pcie_fdt_route_interrupt ARM GIC specification in device trees use 3 cells, so the current limit of 2 causes the last cell to be dropped. This in turn can cause the interrupt polarity and trigger settings to be incorrect. Increase the limit to 4 which should handle all reasonable cases. This fixes issues seen in QEMU when registering PCI interrupts. --- sys/dev/pci/pci_host_generic_fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/pci/pci_host_generic_fdt.c b/sys/dev/pci/pci_host_generic_fdt.c index 4eb25b44a1e..3ddf2b2c4e2 100644 --- a/sys/dev/pci/pci_host_generic_fdt.c +++ b/sys/dev/pci/pci_host_generic_fdt.c @@ -269,7 +269,7 @@ generic_pcie_fdt_route_interrupt(device_t bus, device_t dev, int pin) { struct generic_pcie_fdt_softc *sc; struct ofw_pci_register reg; - uint32_t pintr, mintr[2]; + uint32_t pintr, mintr[4]; phandle_t iparent; int intrcells; From 223cb0e434045e0c0f6318c9dfbc8de0f5d309bf Mon Sep 17 00:00:00 2001 From: Edward Tomasz Napierala Date: Mon, 12 Dec 2016 15:22:21 +0000 Subject: [PATCH 034/226] Avoid dereferencing NULL pointers in devtoname(). I've seen it panic, called from ufs_print() in DDB. MFC after: 1 month --- sys/kern/kern_conf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index ea68a6dea9a..381540574d3 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -1230,6 +1230,9 @@ const char * devtoname(struct cdev *dev) { + if (dev == NULL) + return (NULL); + return (dev->si_name); } From 3ce73b26621a2ba59955b88f8c26e99f4a86c7cb Mon Sep 17 00:00:00 2001 From: "Jayachandran C." Date: Mon, 12 Dec 2016 15:35:57 +0000 Subject: [PATCH 035/226] Fix gic_cpu_mask() calculation in ARM GIC r309616 changed the definition of GICD_ITARGETSR(n) to take the irq id as argument, but the usage of the macro in gic_cpu_mask() was not updated to reflect this. This causes the cpu mask to be computed incorrectly. Update the GICD_ITARGETSR() call to fix this, this fixes a hang seen while booting freebsd on qemu-system-aarch64 with SMP enabled. --- sys/arm/arm/gic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/arm/arm/gic.c b/sys/arm/arm/gic.c index bead6ec3cde..3148b24d14d 100644 --- a/sys/arm/arm/gic.c +++ b/sys/arm/arm/gic.c @@ -190,7 +190,7 @@ gic_cpu_mask(struct arm_gic_softc *sc) /* Read the current cpuid mask by reading ITARGETSR{0..7} */ for (i = 0; i < 8; i++) { - mask = gic_d_read_4(sc, GICD_ITARGETSR(i)); + mask = gic_d_read_4(sc, GICD_ITARGETSR(4 * i)); if (mask != 0) break; } From 5afb134c327818b1d960cd9573f4826c60ae7066 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Mon, 12 Dec 2016 15:37:11 +0000 Subject: [PATCH 036/226] vfs: add vrefact, to be used when the vnode has to be already active This allows blind increment of relevant counters which under contention is cheaper than inc-not-zero loops at least on amd64. Use it in some of the places which are guaranteed to see already active vnodes. Reviewed by: kib (previous version) --- sys/kern/kern_descrip.c | 46 ++++++++++++++++++++--------------------- sys/kern/kern_fork.c | 2 +- sys/kern/vfs_lookup.c | 8 +++---- sys/kern/vfs_subr.c | 22 ++++++++++++++++++++ sys/sys/vnode.h | 1 + 5 files changed, 51 insertions(+), 28 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 78cc6824ae4..a309eda77aa 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -318,11 +318,11 @@ pwd_ensure_dirs(void) FILEDESC_XLOCK(fdp); if (fdp->fd_cdir == NULL) { fdp->fd_cdir = rootvnode; - VREF(rootvnode); + vrefact(rootvnode); } if (fdp->fd_rdir == NULL) { fdp->fd_rdir = rootvnode; - VREF(rootvnode); + vrefact(rootvnode); } FILEDESC_XUNLOCK(fdp); } @@ -1860,13 +1860,13 @@ fdinit(struct filedesc *fdp, bool prepfiles) FILEDESC_SLOCK(fdp); newfdp->fd_cdir = fdp->fd_cdir; if (newfdp->fd_cdir) - VREF(newfdp->fd_cdir); + vrefact(newfdp->fd_cdir); newfdp->fd_rdir = fdp->fd_rdir; if (newfdp->fd_rdir) - VREF(newfdp->fd_rdir); + vrefact(newfdp->fd_rdir); newfdp->fd_jdir = fdp->fd_jdir; if (newfdp->fd_jdir) - VREF(newfdp->fd_jdir); + vrefact(newfdp->fd_jdir); if (!prepfiles) { FILEDESC_SUNLOCK(fdp); @@ -2769,7 +2769,7 @@ _fgetvp(struct thread *td, int fd, int flags, cap_rights_t *needrightsp, error = EINVAL; } else { *vpp = fp->f_vnode; - vref(*vpp); + vrefact(*vpp); } fdrop(fp, td); @@ -2807,7 +2807,7 @@ fgetvp_rights(struct thread *td, int fd, cap_rights_t *needrightsp, *havecaps = caps; *vpp = fp->f_vnode; - vref(*vpp); + vrefact(*vpp); return (0); out: @@ -3115,10 +3115,10 @@ pwd_chroot(struct thread *td, struct vnode *vp) } } oldvp = fdp->fd_rdir; - VREF(vp); + vrefact(vp); fdp->fd_rdir = vp; if (fdp->fd_jdir == NULL) { - VREF(vp); + vrefact(vp); fdp->fd_jdir = vp; } FILEDESC_XUNLOCK(fdp); @@ -3166,17 +3166,17 @@ mountcheckdirs(struct vnode *olddp, struct vnode *newdp) continue; FILEDESC_XLOCK(fdp); if (fdp->fd_cdir == olddp) { - vref(newdp); + vrefact(newdp); fdp->fd_cdir = newdp; nrele++; } if (fdp->fd_rdir == olddp) { - vref(newdp); + vrefact(newdp); fdp->fd_rdir = newdp; nrele++; } if (fdp->fd_jdir == olddp) { - vref(newdp); + vrefact(newdp); fdp->fd_jdir = newdp; nrele++; } @@ -3185,13 +3185,13 @@ mountcheckdirs(struct vnode *olddp, struct vnode *newdp) } sx_sunlock(&allproc_lock); if (rootvnode == olddp) { - vref(newdp); + vrefact(newdp); rootvnode = newdp; nrele++; } mtx_lock(&prison0.pr_mtx); if (prison0.pr_root == olddp) { - vref(newdp); + vrefact(newdp); prison0.pr_root = newdp; nrele++; } @@ -3200,7 +3200,7 @@ mountcheckdirs(struct vnode *olddp, struct vnode *newdp) TAILQ_FOREACH(pr, &allprison, pr_list) { mtx_lock(&pr->pr_mtx); if (pr->pr_root == olddp) { - vref(newdp); + vrefact(newdp); pr->pr_root = newdp; nrele++; } @@ -3527,17 +3527,17 @@ kern_proc_filedesc_out(struct proc *p, struct sbuf *sb, ssize_t maxlen, /* ktrace vnode */ tracevp = p->p_tracevp; if (tracevp != NULL) - vref(tracevp); + vrefact(tracevp); /* text vnode */ textvp = p->p_textvp; if (textvp != NULL) - vref(textvp); + vrefact(textvp); /* Controlling tty. */ cttyvp = NULL; if (p->p_pgrp != NULL && p->p_pgrp->pg_session != NULL) { cttyvp = p->p_pgrp->pg_session->s_ttyvp; if (cttyvp != NULL) - vref(cttyvp); + vrefact(cttyvp); } fdp = fdhold(p); PROC_UNLOCK(p); @@ -3561,17 +3561,17 @@ kern_proc_filedesc_out(struct proc *p, struct sbuf *sb, ssize_t maxlen, FILEDESC_SLOCK(fdp); /* working directory */ if (fdp->fd_cdir != NULL) { - vref(fdp->fd_cdir); + vrefact(fdp->fd_cdir); export_vnode_to_sb(fdp->fd_cdir, KF_FD_TYPE_CWD, FREAD, efbuf); } /* root directory */ if (fdp->fd_rdir != NULL) { - vref(fdp->fd_rdir); + vrefact(fdp->fd_rdir); export_vnode_to_sb(fdp->fd_rdir, KF_FD_TYPE_ROOT, FREAD, efbuf); } /* jail directory */ if (fdp->fd_jdir != NULL) { - vref(fdp->fd_jdir); + vrefact(fdp->fd_jdir); export_vnode_to_sb(fdp->fd_jdir, KF_FD_TYPE_JAIL, FREAD, efbuf); } for (i = 0; fdp->fd_refcnt > 0 && i <= fdp->fd_lastfile; i++) { @@ -3661,7 +3661,7 @@ export_vnode_for_osysctl(struct vnode *vp, int type, struct kinfo_file *kif, { int error; - vref(vp); + vrefact(vp); FILEDESC_SUNLOCK(fdp); export_vnode_to_kinfo(vp, type, 0, kif, KERN_FILEDESC_PACK_KINFO); kinfo_to_okinfo(kif, okif); @@ -3788,7 +3788,7 @@ kern_proc_cwd_out(struct proc *p, struct sbuf *sb, ssize_t maxlen) if (fdp->fd_cdir == NULL) error = EINVAL; else { - vref(fdp->fd_cdir); + vrefact(fdp->fd_cdir); error = export_vnode_to_sb(fdp->fd_cdir, KF_FD_TYPE_CWD, FREAD, efbuf); } diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 4f8baf8d5a6..7e340a9cdc9 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -547,7 +547,7 @@ do_fork(struct thread *td, struct fork_req *fr, struct proc *p2, struct thread * /* Bump references to the text vnode (for procfs). */ if (p2->p_textvp) - vref(p2->p_textvp); + vrefact(p2->p_textvp); /* * Set up linkage for kernel based threading. diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 7885ec1e764..73b10e15fa5 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -255,7 +255,7 @@ namei_handle_root(struct nameidata *ndp, struct vnode **dpp) ndp->ni_pathlen--; } *dpp = ndp->ni_rootdir; - VREF(*dpp); + vrefact(*dpp); return (0); } @@ -376,7 +376,7 @@ namei(struct nameidata *ndp) */ FILEDESC_SLOCK(fdp); ndp->ni_rootdir = fdp->fd_rdir; - VREF(ndp->ni_rootdir); + vrefact(ndp->ni_rootdir); ndp->ni_topdir = fdp->fd_jdir; /* @@ -398,7 +398,7 @@ namei(struct nameidata *ndp) startdir_used = 1; } else if (ndp->ni_dirfd == AT_FDCWD) { dp = fdp->fd_cdir; - VREF(dp); + vrefact(dp); } else { rights = ndp->ni_rightsneeded; cap_rights_set(&rights, CAP_LOOKUP); @@ -956,7 +956,7 @@ lookup(struct nameidata *ndp) vput(ndp->ni_dvp); else vrele(ndp->ni_dvp); - vref(vp_crossmp); + vrefact(vp_crossmp); ndp->ni_dvp = vp_crossmp; error = VFS_ROOT(mp, compute_cn_lkflags(mp, cnp->cn_lkflags, cnp->cn_flags), &tdp); diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index b728887b4fe..22636b0ca00 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -2647,6 +2647,28 @@ vrefl(struct vnode *vp) v_incr_usecount_locked(vp); } +void +vrefact(struct vnode *vp) +{ + + CTR2(KTR_VFS, "%s: vp %p", __func__, vp); + if (__predict_false(vp->v_type == VCHR)) { + VNASSERT(vp->v_holdcnt > 0 && vp->v_usecount > 0, vp, + ("%s: wrong ref counts", __func__)); + vref(vp); + return; + } +#ifdef INVARIANTS + int old = atomic_fetchadd_int(&vp->v_holdcnt, 1); + VNASSERT(old > 0, vp, ("%s: wrong hold count", __func__)); + old = atomic_fetchadd_int(&vp->v_usecount, 1); + VNASSERT(old > 0, vp, ("%s: wrong use count", __func__)); +#else + refcount_acquire(&vp->v_holdcnt); + refcount_acquire(&vp->v_usecount); +#endif +} + /* * Return reference count of a vnode. * diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 989af8bc13a..7c7be966c86 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -828,6 +828,7 @@ void vput(struct vnode *vp); void vrele(struct vnode *vp); void vref(struct vnode *vp); void vrefl(struct vnode *vp); +void vrefact(struct vnode *vp); int vrefcnt(struct vnode *vp); void v_addpollinfo(struct vnode *vp); From bbd72acb3be60492202b6575b60d2f40841bb820 Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Mon, 12 Dec 2016 16:43:31 +0000 Subject: [PATCH 037/226] clk_div: Add a div lookup table Some clocks on SoC have a diff between the value written in the register and the real divider. Add a table that where we can lookup the real value of the divider. Reviewed by: mmel (earlier revision) Differential Revision: https://reviews.freebsd.org/D8728 --- sys/dev/extres/clk/clk_div.c | 42 ++++++++++++++++++++++++++++++++++++ sys/dev/extres/clk/clk_div.h | 7 ++++++ 2 files changed, 49 insertions(+) diff --git a/sys/dev/extres/clk/clk_div.c b/sys/dev/extres/clk/clk_div.c index 51cc838303a..bf663f28c3a 100644 --- a/sys/dev/extres/clk/clk_div.c +++ b/sys/dev/extres/clk/clk_div.c @@ -68,6 +68,8 @@ struct clknode_div_sc { uint32_t f_width; int div_flags; uint32_t divider; /* in natural form */ + + struct clk_div_table *div_table; }; static clknode_method_t clknode_div_methods[] = { @@ -80,6 +82,36 @@ static clknode_method_t clknode_div_methods[] = { DEFINE_CLASS_1(clknode_div, clknode_div_class, clknode_div_methods, sizeof(struct clknode_div_sc), clknode_class); +static uint32_t +clknode_div_table_get_divider(struct clknode_div_sc *sc, uint32_t divider) +{ + struct clk_div_table *table; + + if (!(sc->div_flags & CLK_DIV_WITH_TABLE)) + return (divider); + + for (table = sc->div_table; table->divider != 0; table++) + if (table->value == sc->divider) + return (table->divider); + + return (0); +} + +static uint32_t +clknode_div_table_get_value(struct clknode_div_sc *sc, uint32_t divider) +{ + struct clk_div_table *table; + + if (!(sc->div_flags & CLK_DIV_WITH_TABLE)) + return (divider); + + for (table = sc->div_table; table->divider != 0; table++) + if (table->divider == sc->divider) + return (table->value); + + return (0); +} + static int clknode_div_init(struct clknode *clk, device_t dev) { @@ -101,6 +133,11 @@ clknode_div_init(struct clknode *clk, device_t dev) i_div++; f_div = (reg >> sc->f_shift) & sc->f_mask; sc->divider = i_div << sc->f_width | f_div; + + sc->divider = clknode_div_table_get_divider(sc, sc->divider); + if (sc->divider == 0) + panic("%s: divider is zero!\n", clknode_get_name(clk)); + clknode_init_parent_idx(clk, 0); return(0); } @@ -177,6 +214,10 @@ clknode_div_set_freq(struct clknode *clk, uint64_t fin, uint64_t *fout, (*fout != (_fin / divider))) return (ERANGE); + divider = clknode_div_table_get_value(sc, divider); + if (divider == 0) + return (ERANGE); + DEVICE_LOCK(clk); rv = MD4(clk, sc->offset, (sc->i_mask << sc->i_shift) | (sc->f_mask << sc->f_shift), @@ -214,6 +255,7 @@ clknode_div_register(struct clkdom *clkdom, struct clk_div_def *clkdef) sc->f_width = clkdef->f_width; sc->f_mask = (1 << clkdef->f_width) - 1; sc->div_flags = clkdef->div_flags; + sc->div_table = clkdef->div_table; clknode_register(clkdom, clk); return (0); diff --git a/sys/dev/extres/clk/clk_div.h b/sys/dev/extres/clk/clk_div.h index 85b8a0194eb..4d5f7fa3008 100644 --- a/sys/dev/extres/clk/clk_div.h +++ b/sys/dev/extres/clk/clk_div.h @@ -32,6 +32,12 @@ #include #define CLK_DIV_ZERO_BASED 0x0001 /* Zero based divider. */ +#define CLK_DIV_WITH_TABLE 0x0002 /* Table to lookup the real value */ + +struct clk_div_table { + uint32_t value; + uint32_t divider; +}; struct clk_div_def { struct clknode_init_def clkdef; @@ -41,6 +47,7 @@ struct clk_div_def { uint32_t f_shift; /* Fractional divide bits, */ uint32_t f_width; /* set to 0 for int divider */ int div_flags; /* Divider-specific flags */ + struct clk_div_table *div_table; /* Divider table */ }; int clknode_div_register(struct clkdom *clkdom, struct clk_div_def *clkdef); From f9a22a068dc9cee0a4c9b519e6dbb0d406e06c83 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 12 Dec 2016 16:53:55 +0000 Subject: [PATCH 038/226] On non-Intel platforms don't ignore the PCI root bridge mapping in acpi_set_resource, the mappings are needed on arm64. Obtained from: ABT Systenms Ltd Sponsored by: The FreeBSD Foundation --- sys/dev/acpica/acpi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index f50c2d8cbd2..12c9d25adab 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -1276,7 +1276,9 @@ acpi_set_resource(device_t dev, device_t child, int type, int rid, struct acpi_softc *sc = device_get_softc(dev); struct acpi_device *ad = device_get_ivars(child); struct resource_list *rl = &ad->ad_rl; +#if defined(__i386__) || defined(__amd64__) ACPI_DEVICE_INFO *devinfo; +#endif rman_res_t end; /* Ignore IRQ resources for PCI link devices. */ @@ -1292,13 +1294,11 @@ acpi_set_resource(device_t dev, device_t child, int type, int rid, * x86 of a PCI bridge claiming the I/O ports used for PCI config * access. */ +#if defined(__i386__) || defined(__amd64__) if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) { if (ACPI_SUCCESS(AcpiGetObjectInfo(ad->ad_handle, &devinfo))) { if ((devinfo->Flags & ACPI_PCI_ROOT_BRIDGE) != 0) { -#if defined(__i386__) || defined(__amd64__) - if (!(type == SYS_RES_IOPORT && start == CONF1_ADDR_PORT)) -#endif - { + if (!(type == SYS_RES_IOPORT && start == CONF1_ADDR_PORT)) { AcpiOsFree(devinfo); return (0); } @@ -1306,6 +1306,7 @@ acpi_set_resource(device_t dev, device_t child, int type, int rid, AcpiOsFree(devinfo); } } +#endif /* If the resource is already allocated, fail. */ if (resource_list_busy(rl, type, rid)) From f3c658a8691e63e6a782a0e243c680342f0f4c99 Mon Sep 17 00:00:00 2001 From: Ruslan Bukin Date: Mon, 12 Dec 2016 17:08:52 +0000 Subject: [PATCH 039/226] Apply clear_mask correctly. Reviewed by: jmcneill, kan Sponsored by: DARPA, AFRL --- sys/mips/ingenic/jz4780_clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/mips/ingenic/jz4780_clock.c b/sys/mips/ingenic/jz4780_clock.c index 7261cb00ee4..b4e24d4d8d5 100644 --- a/sys/mips/ingenic/jz4780_clock.c +++ b/sys/mips/ingenic/jz4780_clock.c @@ -589,7 +589,7 @@ jz4780_clock_modify_4(device_t dev, bus_addr_t addr, uint32_t clear_mask, sc = device_get_softc(dev); val = CSR_READ_4(sc, addr); - val &= clear_mask; + val &= ~clear_mask; val |= set_mask; CSR_WRITE_4(sc, addr, val); return (0); From 9f0136cb2664c6ea7e9f5f873cc239ec0a6f5be3 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Mon, 12 Dec 2016 17:23:09 +0000 Subject: [PATCH 040/226] Add basic ATF tests for Capability mode .. lookups A follow-up to r309887. Several tests copied verbatim from https://github.com/emaste/snippets/blob/master/test_openat.c . Reviewed by: kib@, ngie@ (earlier version) X-MFC-With: r309887 Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8748 --- tests/sys/vfs/Makefile | 3 + tests/sys/vfs/lookup_cap_dotdot.c | 251 ++++++++++++++++++++++++++++++ 2 files changed, 254 insertions(+) create mode 100644 tests/sys/vfs/lookup_cap_dotdot.c diff --git a/tests/sys/vfs/Makefile b/tests/sys/vfs/Makefile index cbab7e54fa7..9e2d79ef773 100644 --- a/tests/sys/vfs/Makefile +++ b/tests/sys/vfs/Makefile @@ -4,6 +4,9 @@ PACKAGE= tests TESTSDIR= ${TESTSBASE}/sys/vfs +ATF_TESTS_C+= lookup_cap_dotdot +CFLAGS.lookup_cap_dotdot.c+= -I${SRCTOP}/tests + PLAIN_TESTS_SH+= trailing_slash .include diff --git a/tests/sys/vfs/lookup_cap_dotdot.c b/tests/sys/vfs/lookup_cap_dotdot.c new file mode 100644 index 00000000000..88b13e59abe --- /dev/null +++ b/tests/sys/vfs/lookup_cap_dotdot.c @@ -0,0 +1,251 @@ +/*- + * Copyright (c) 2016 Ed Maste + * Copyright (c) 2016 Conrad Meyer + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "freebsd_test_suite/macros.h" + +static int dirfd = -1; +static char *abspath; + +static void +touchat(int dirfd, const char *name) +{ + int fd; + + ATF_REQUIRE((fd = openat(dirfd, name, O_CREAT | O_TRUNC | O_WRONLY, + 0777)) >= 0); + ATF_REQUIRE(close(fd) == 0); +} + +static void +prepare_dotdot_tests(void) +{ + char cwd[MAXPATHLEN]; + + ATF_REQUIRE(getcwd(cwd, sizeof(cwd)) != NULL); + asprintf(&abspath, "%s/testdir/d1/f1", cwd); + + ATF_REQUIRE(mkdir("testdir", 0777) == 0); + ATF_REQUIRE((dirfd = open("testdir", O_RDONLY)) >= 0); + + ATF_REQUIRE(mkdirat(dirfd, "d1", 0777) == 0); + ATF_REQUIRE(mkdirat(dirfd, "d1/d2", 0777) == 0); + ATF_REQUIRE(mkdirat(dirfd, "d1/d2/d3", 0777) == 0); + touchat(dirfd, "d1/f1"); + touchat(dirfd, "d1/d2/f2"); + touchat(dirfd, "d1/d2/d3/f3"); + ATF_REQUIRE(symlinkat("d1/d2/d3", dirfd, "l3") == 0); + ATF_REQUIRE(symlinkat("../testdir/d1", dirfd, "lup") == 0); + ATF_REQUIRE(symlinkat("../..", dirfd, "d1/d2/d3/ld1") == 0); + ATF_REQUIRE(symlinkat("../../f1", dirfd, "d1/d2/d3/lf1") == 0); +} + +static void +check_capsicum(void) +{ + ATF_REQUIRE_FEATURE("security_capabilities"); + ATF_REQUIRE_FEATURE("security_capability_mode"); +} + +/* + * Positive tests + */ +ATF_TC(openat__basic_positive); +ATF_TC_HEAD(openat__basic_positive, tc) +{ + atf_tc_set_md_var(tc, "descr", "Basic positive openat testcases"); +} + +ATF_TC_BODY(openat__basic_positive, tc) +{ + prepare_dotdot_tests(); + + ATF_REQUIRE(openat(dirfd, "d1/d2/d3/f3", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "d1/d2/d3/../../f1", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "l3/f3", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "l3/../../f1", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "../testdir/d1/f1", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "lup/f1", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "l3/ld1", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "l3/lf1", O_RDONLY) >= 0); + ATF_REQUIRE(open(abspath, O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, abspath, O_RDONLY) >= 0); +} + +ATF_TC(lookup_cap_dotdot__basic); +ATF_TC_HEAD(lookup_cap_dotdot__basic, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Validate cap-mode (testdir)/d1/.. lookup"); +} + +ATF_TC_BODY(lookup_cap_dotdot__basic, tc) +{ + cap_rights_t rights; + int fd; + + check_capsicum(); + prepare_dotdot_tests(); + + cap_rights_init(&rights, CAP_LOOKUP, CAP_READ); + ATF_REQUIRE(cap_rights_limit(dirfd, &rights) >= 0); + + ATF_REQUIRE(cap_enter() >= 0); + + ATF_REQUIRE_MSG(openat(dirfd, "d1/..", O_RDONLY) >= 0, "%s", + strerror(errno)); +} + +ATF_TC(lookup_cap_dotdot__advanced); +ATF_TC_HEAD(lookup_cap_dotdot__advanced, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Validate cap-mode (testdir)/d1/.. lookup"); +} + +ATF_TC_BODY(lookup_cap_dotdot__advanced, tc) +{ + cap_rights_t rights; + int fd; + + check_capsicum(); + prepare_dotdot_tests(); + + cap_rights_init(&rights, CAP_LOOKUP, CAP_READ); + ATF_REQUIRE(cap_rights_limit(dirfd, &rights) >= 0); + + ATF_REQUIRE(cap_enter() >= 0); + + ATF_REQUIRE(openat(dirfd, "d1/d2/d3/../../f1", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "l3/../../f1", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "l3/ld1", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "l3/lf1", O_RDONLY) >= 0); +} + +/* + * Negative tests + */ +ATF_TC(openat__basic_negative); +ATF_TC_HEAD(openat__basic_negative, tc) +{ + atf_tc_set_md_var(tc, "descr", "Basic negative openat testcases"); +} + +ATF_TC_BODY(openat__basic_negative, tc) +{ + prepare_dotdot_tests(); + + ATF_REQUIRE_ERRNO(ENOENT, + openat(dirfd, "does-not-exist", O_RDONLY) < 0); + ATF_REQUIRE_ERRNO(ENOENT, + openat(dirfd, "l3/does-not-exist", O_RDONLY) < 0); +} + +ATF_TC(capmode__negative); +ATF_TC_HEAD(capmode__negative, tc) +{ + atf_tc_set_md_var(tc, "descr", "Negative Capability mode testcases"); +} + +ATF_TC_BODY(capmode__negative, tc) +{ + int subdirfd; + + check_capsicum(); + prepare_dotdot_tests(); + + ATF_REQUIRE(cap_enter() == 0); + + /* open() not permitted in capability mode */ + ATF_REQUIRE_ERRNO(ECAPMODE, open("testdir", O_RDONLY) < 0); + + /* AT_FDCWD not permitted in capability mode */ + ATF_REQUIRE_ERRNO(ECAPMODE, openat(AT_FDCWD, "d1/f1", O_RDONLY) < 0); + + /* Relative path above dirfd not capable */ + ATF_REQUIRE_ERRNO(ENOTCAPABLE, openat(dirfd, "..", O_RDONLY) < 0); + ATF_REQUIRE((subdirfd = openat(dirfd, "l3", O_RDONLY)) >= 0); + ATF_REQUIRE_ERRNO(ENOTCAPABLE, + openat(subdirfd, "../../f1", O_RDONLY) < 0); + + /* Absolute paths not capable */ + ATF_REQUIRE_ERRNO(ENOTCAPABLE, openat(dirfd, abspath, O_RDONLY) < 0); + + /* Symlink above dirfd */ + ATF_REQUIRE_ERRNO(ENOTCAPABLE, openat(dirfd, "lup/f1", O_RDONLY) < 0); +} + +ATF_TC(lookup_cap_dotdot__negative); +ATF_TC_HEAD(lookup_cap_dotdot__negative, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Validate cap-mode (testdir)/.. lookup fails"); +} + +ATF_TC_BODY(lookup_cap_dotdot__negative, tc) +{ + cap_rights_t rights; + int fd; + + check_capsicum(); + prepare_dotdot_tests(); + + cap_rights_init(&rights, CAP_LOOKUP, CAP_READ); + ATF_REQUIRE(cap_rights_limit(dirfd, &rights) >= 0); + + ATF_REQUIRE(cap_enter() >= 0); + + ATF_REQUIRE_ERRNO(ENOTCAPABLE, openat(dirfd, "..", O_RDONLY) < 0); + ATF_REQUIRE_ERRNO(ENOTCAPABLE, openat(dirfd, "d1/../..", O_RDONLY) < 0); + ATF_REQUIRE_ERRNO(ENOTCAPABLE, openat(dirfd, "../testdir/d1/f1", O_RDONLY) < 0); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, openat__basic_positive); + ATF_TP_ADD_TC(tp, openat__basic_negative); + + ATF_TP_ADD_TC(tp, capmode__negative); + + ATF_TP_ADD_TC(tp, lookup_cap_dotdot__basic); + ATF_TP_ADD_TC(tp, lookup_cap_dotdot__advanced); + ATF_TP_ADD_TC(tp, lookup_cap_dotdot__negative); + + return (atf_no_error()); +} From 3453bca8649a03a6bd8f42db75c596585d2d245f Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 12 Dec 2016 17:47:09 +0000 Subject: [PATCH 041/226] Eliminate every mention of PG_CACHED pages from the comments in the machine- independent layer of the virtual memory system. Update some of the nearby comments to eliminate redundancy and improve clarity. In vm/vm_reserv.c, do not use hyphens after adverbs ending in -ly per The Chicago Manual of Style. Update the comment in vm/vm_page.h defining the four types of page queues to reflect the elimination of PG_CACHED pages and the introduction of the laundry queue. Reviewed by: kib, markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8752 --- sys/vm/vm_map.c | 4 +- sys/vm/vm_object.c | 7 ++-- sys/vm/vm_object.h | 11 ------ sys/vm/vm_page.c | 96 ++++++++++++++++++---------------------------- sys/vm/vm_page.h | 11 ++---- sys/vm/vm_reserv.c | 55 +++++++++++++------------- 6 files changed, 72 insertions(+), 112 deletions(-) diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index a23468e70f5..8b72128b9be 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -1858,9 +1858,7 @@ vm_map_submap( * limited number of page mappings are created at the low-end of the * specified address range. (For this purpose, a superpage mapping * counts as one page mapping.) Otherwise, all resident pages within - * the specified address range are mapped. Because these mappings are - * being created speculatively, cached pages are not reactivated and - * mapped. + * the specified address range are mapped. */ static void vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_prot_t prot, diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index df27e0c9ca4..8ec62cdd492 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -1356,7 +1356,7 @@ vm_object_split(vm_map_entry_t entry) goto retry; } - /* vm_page_rename() will handle dirty and cache. */ + /* vm_page_rename() will dirty the page. */ if (vm_page_rename(m, new_object, idx)) { VM_OBJECT_WUNLOCK(new_object); VM_OBJECT_WUNLOCK(orig_object); @@ -1446,7 +1446,7 @@ vm_object_scan_all_shadowed(vm_object_t object) /* * Initial conditions: * - * We do not want to have to test for the existence of cache or swap + * We do not want to have to test for the existence of swap * pages in the backing object. XXX but with the new swapper this * would be pretty easy to do. */ @@ -1590,8 +1590,7 @@ vm_object_collapse_scan(vm_object_t object, int op) * backing object to the main object. * * If the page was mapped to a process, it can remain mapped - * through the rename. vm_page_rename() will handle dirty and - * cache. + * through the rename. vm_page_rename() will dirty the page. */ if (vm_page_rename(p, object, new_pindex)) { next = vm_object_collapse_scan_wait(object, NULL, next, diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index ae450e09719..e26465c48fe 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -79,17 +79,6 @@ * * vm_object_t Virtual memory object. * - * The root of cached pages pool is protected by both the per-object lock - * and the free pages queue mutex. - * On insert in the cache radix trie, the per-object lock is expected - * to be already held and the free pages queue mutex will be - * acquired during the operation too. - * On remove and lookup from the cache radix trie, only the free - * pages queue mutex is expected to be locked. - * These rules allow for reliably checking for the presence of cached - * pages with only the per-object lock held, thereby reducing contention - * for the free pages queue mutex. - * * List of locks * (c) const until freed * (o) per-object lock diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 34841e019af..7f9b3299cc1 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -1409,9 +1409,7 @@ vm_page_replace(vm_page_t mnew, vm_object_t object, vm_pindex_t pindex) * * Note: we *always* dirty the page. It is necessary both for the * fact that we moved it, and because we may be invalidating - * swap. If the page is on the cache, we have to deactivate it - * or vm_page_dirty() will panic. Dirty pages are not allowed - * on the cache. + * swap. * * The objects must be locked. */ @@ -2042,18 +2040,18 @@ vm_page_scan_contig(u_long npages, vm_page_t m_start, vm_page_t m_end, } else if (level >= 0) { /* * The page is reserved but not yet allocated. In - * other words, it is still cached or free. Extend - * the current run by one page. + * other words, it is still free. Extend the current + * run by one page. */ run_ext = 1; #endif } else if ((order = m->order) < VM_NFREEORDER) { /* * The page is enqueued in the physical memory - * allocator's cache/free page queues. Moreover, it - * is the first page in a power-of-two-sized run of - * contiguous cache/free pages. Add these pages to - * the end of the current run, and jump ahead. + * allocator's free page queues. Moreover, it is the + * first page in a power-of-two-sized run of + * contiguous free pages. Add these pages to the end + * of the current run, and jump ahead. */ run_ext = 1 << order; m_inc = 1 << order; @@ -2061,16 +2059,15 @@ vm_page_scan_contig(u_long npages, vm_page_t m_start, vm_page_t m_end, /* * Skip the page for one of the following reasons: (1) * It is enqueued in the physical memory allocator's - * cache/free page queues. However, it is not the - * first page in a run of contiguous cache/free pages. - * (This case rarely occurs because the scan is - * performed in ascending order.) (2) It is not - * reserved, and it is transitioning from free to - * allocated. (Conversely, the transition from - * allocated to free for managed pages is blocked by - * the page lock.) (3) It is allocated but not - * contained by an object and not wired, e.g., - * allocated by Xen's balloon driver. + * free page queues. However, it is not the first + * page in a run of contiguous free pages. (This case + * rarely occurs because the scan is performed in + * ascending order.) (2) It is not reserved, and it is + * transitioning from free to allocated. (Conversely, + * the transition from allocated to free for managed + * pages is blocked by the page lock.) (3) It is + * allocated but not contained by an object and not + * wired, e.g., allocated by Xen's balloon driver. */ run_ext = 0; } @@ -2282,11 +2279,11 @@ vm_page_reclaim_run(int req_class, u_long npages, vm_page_t m_run, if (order < VM_NFREEORDER) { /* * The page is enqueued in the physical memory - * allocator's cache/free page queues. - * Moreover, it is the first page in a power- - * of-two-sized run of contiguous cache/free - * pages. Jump ahead to the last page within - * that run, and continue from there. + * allocator's free page queues. Moreover, it + * is the first page in a power-of-two-sized + * run of contiguous free pages. Jump ahead + * to the last page within that run, and + * continue from there. */ m += (1 << order) - 1; } @@ -2334,9 +2331,9 @@ CTASSERT(powerof2(NRUNS)); * conditions by relocating the virtual pages using that physical memory. * Returns true if reclamation is successful and false otherwise. Since * relocation requires the allocation of physical pages, reclamation may - * fail due to a shortage of cache/free pages. When reclamation fails, - * callers are expected to perform VM_WAIT before retrying a failed - * allocation operation, e.g., vm_page_alloc_contig(). + * fail due to a shortage of free pages. When reclamation fails, callers + * are expected to perform VM_WAIT before retrying a failed allocation + * operation, e.g., vm_page_alloc_contig(). * * The caller must always specify an allocation class through "req". * @@ -2371,8 +2368,8 @@ vm_page_reclaim_contig(int req, u_long npages, vm_paddr_t low, vm_paddr_t high, req_class = VM_ALLOC_SYSTEM; /* - * Return if the number of cached and free pages cannot satisfy the - * requested allocation. + * Return if the number of free pages cannot satisfy the requested + * allocation. */ count = vm_cnt.v_free_count; if (count < npages + vm_cnt.v_free_reserved || (count < npages + @@ -2642,9 +2639,8 @@ vm_page_activate(vm_page_t m) /* * vm_page_free_wakeup: * - * Helper routine for vm_page_free_toq() and vm_page_cache(). This - * routine is called when a page has been added to the cache or free - * queues. + * Helper routine for vm_page_free_toq(). This routine is called + * when a page is added to the free queues. * * The page queues must be locked. */ @@ -2732,8 +2728,8 @@ vm_page_free_toq(vm_page_t m) pmap_page_set_memattr(m, VM_MEMATTR_DEFAULT); /* - * Insert the page into the physical memory allocator's - * cache/free page queues. + * Insert the page into the physical memory allocator's free + * page queues. */ mtx_lock(&vm_page_queue_free_mtx); vm_phys_freecnt_adj(m, 1); @@ -2833,21 +2829,10 @@ vm_page_unwire(vm_page_t m, uint8_t queue) /* * Move the specified page to the inactive queue. * - * Many pages placed on the inactive queue should actually go - * into the cache, but it is difficult to figure out which. What - * we do instead, if the inactive target is well met, is to put - * clean pages at the head of the inactive queue instead of the tail. - * This will cause them to be moved to the cache more quickly and - * if not actively re-referenced, reclaimed more quickly. If we just - * stick these pages at the end of the inactive queue, heavy filesystem - * meta-data accesses can cause an unnecessary paging load on memory bound - * processes. This optimization causes one-time-use metadata to be - * reused more quickly. - * - * Normally noreuse is FALSE, resulting in LRU operation. noreuse is set - * to TRUE if we want this page to be 'as if it were placed in the cache', - * except without unmapping it from the process address space. In - * practice this is implemented by inserting the page at the head of the + * Normally, "noreuse" is FALSE, resulting in LRU ordering of the inactive + * queue. However, setting "noreuse" to TRUE will accelerate the specified + * page's reclamation, but it will not unmap the page from any address space. + * This is implemented by inserting the page near the head of the inactive * queue, using a marker page to guide FIFO insertion ordering. * * The page must be locked. @@ -2974,16 +2959,9 @@ vm_page_advise(vm_page_t m, int advice) if (advice == MADV_FREE) /* * Mark the page clean. This will allow the page to be freed - * up by the system. However, such pages are often reused - * quickly by malloc() so we do not do anything that would - * cause a page fault if we can help it. - * - * Specifically, we do not try to actually free the page now - * nor do we try to put it in the cache (which would cause a - * page fault on reuse). - * - * But we do make the page as freeable as we can without - * actually taking the step of unmapping it. + * without first paging it out. MADV_FREE pages are often + * quickly reused by malloc(3), so we do not do anything that + * would result in a page fault on a later access. */ vm_page_undirty(m); else if (advice != MADV_DONTNEED) diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h index 8d44e65c53a..6e177194a53 100644 --- a/sys/vm/vm_page.h +++ b/sys/vm/vm_page.h @@ -352,19 +352,16 @@ extern struct mtx_padalign pa_lock[]; * free * Available for allocation now. * - * cache - * Almost available for allocation. Still associated with - * an object, but clean and immediately freeable. - * - * The following lists are LRU sorted: - * * inactive * Low activity, candidates for reclamation. + * This list is approximately LRU ordered. + * + * laundry * This is the list of pages that should be * paged out next. * * active - * Pages that are "active" i.e. they have been + * Pages that are "active", i.e., they have been * recently referenced. * */ diff --git a/sys/vm/vm_reserv.c b/sys/vm/vm_reserv.c index 5519d2fc1a0..f0105f8e356 100644 --- a/sys/vm/vm_reserv.c +++ b/sys/vm/vm_reserv.c @@ -62,7 +62,7 @@ __FBSDID("$FreeBSD$"); /* * The reservation system supports the speculative allocation of large physical - * pages ("superpages"). Speculative allocation enables the fully-automatic + * pages ("superpages"). Speculative allocation enables the fully automatic * utilization of superpages by the virtual memory system. In other words, no * programmatic directives are required to use superpages. */ @@ -155,11 +155,11 @@ popmap_is_set(popmap_t popmap[], int i) * physical pages for the range [pindex, pindex + VM_LEVEL_0_NPAGES) of offsets * within that object. The reservation's "popcnt" tracks the number of these * small physical pages that are in use at any given time. When and if the - * reservation is not fully utilized, it appears in the queue of partially- + * reservation is not fully utilized, it appears in the queue of partially * populated reservations. The reservation always appears on the containing * object's list of reservations. * - * A partially-populated reservation can be broken and reclaimed at any time. + * A partially populated reservation can be broken and reclaimed at any time. */ struct vm_reserv { TAILQ_ENTRY(vm_reserv) partpopq; @@ -196,11 +196,11 @@ struct vm_reserv { static vm_reserv_t vm_reserv_array; /* - * The partially-populated reservation queue + * The partially populated reservation queue * - * This queue enables the fast recovery of an unused cached or free small page - * from a partially-populated reservation. The reservation at the head of - * this queue is the least-recently-changed, partially-populated reservation. + * This queue enables the fast recovery of an unused free small page from a + * partially populated reservation. The reservation at the head of this queue + * is the least recently changed, partially populated reservation. * * Access to this queue is synchronized by the free page queue lock. */ @@ -225,7 +225,7 @@ SYSCTL_PROC(_vm_reserv, OID_AUTO, fullpop, CTLTYPE_INT | CTLFLAG_RD, NULL, 0, static int sysctl_vm_reserv_partpopq(SYSCTL_HANDLER_ARGS); SYSCTL_OID(_vm_reserv, OID_AUTO, partpopq, CTLTYPE_STRING | CTLFLAG_RD, NULL, 0, - sysctl_vm_reserv_partpopq, "A", "Partially-populated reservation queues"); + sysctl_vm_reserv_partpopq, "A", "Partially populated reservation queues"); static long vm_reserv_reclaimed; SYSCTL_LONG(_vm_reserv, OID_AUTO, reclaimed, CTLFLAG_RD, @@ -267,7 +267,7 @@ sysctl_vm_reserv_fullpop(SYSCTL_HANDLER_ARGS) } /* - * Describes the current state of the partially-populated reservation queue. + * Describes the current state of the partially populated reservation queue. */ static int sysctl_vm_reserv_partpopq(SYSCTL_HANDLER_ARGS) @@ -301,7 +301,7 @@ sysctl_vm_reserv_partpopq(SYSCTL_HANDLER_ARGS) /* * Reduces the given reservation's population count. If the population count * becomes zero, the reservation is destroyed. Additionally, moves the - * reservation to the tail of the partially-populated reservation queue if the + * reservation to the tail of the partially populated reservation queue if the * population count is non-zero. * * The free page queue lock must be held. @@ -363,7 +363,7 @@ vm_reserv_has_pindex(vm_reserv_t rv, vm_pindex_t pindex) /* * Increases the given reservation's population count. Moves the reservation - * to the tail of the partially-populated reservation queue. + * to the tail of the partially populated reservation queue. * * The free page queue must be locked. */ @@ -597,7 +597,7 @@ vm_reserv_alloc_contig(vm_object_t object, vm_pindex_t pindex, u_long npages, } /* - * Allocates a page from an existing or newly-created reservation. + * Allocates a page from an existing or newly created reservation. * * The page "mpred" must immediately precede the offset "pindex" within the * specified object. @@ -721,12 +721,12 @@ vm_reserv_alloc_page(vm_object_t object, vm_pindex_t pindex, vm_page_t mpred) } /* - * Breaks the given reservation. Except for the specified cached or free - * page, all cached and free pages in the reservation are returned to the - * physical memory allocator. The reservation's population count and map are - * reset to their initial state. + * Breaks the given reservation. Except for the specified free page, all free + * pages in the reservation are returned to the physical memory allocator. + * The reservation's population count and map are reset to their initial + * state. * - * The given reservation must not be in the partially-populated reservation + * The given reservation must not be in the partially populated reservation * queue. The free page queue lock must be held. */ static void @@ -895,7 +895,7 @@ vm_reserv_level(vm_page_t m) } /* - * Returns a reservation level if the given page belongs to a fully-populated + * Returns a reservation level if the given page belongs to a fully populated * reservation and -1 otherwise. */ int @@ -908,8 +908,8 @@ vm_reserv_level_iffullpop(vm_page_t m) } /* - * Breaks the given partially-populated reservation, releasing its cached and - * free pages to the physical memory allocator. + * Breaks the given partially populated reservation, releasing its free pages + * to the physical memory allocator. * * The free page queue lock must be held. */ @@ -927,9 +927,9 @@ vm_reserv_reclaim(vm_reserv_t rv) } /* - * Breaks the reservation at the head of the partially-populated reservation - * queue, releasing its cached and free pages to the physical memory - * allocator. Returns TRUE if a reservation is broken and FALSE otherwise. + * Breaks the reservation at the head of the partially populated reservation + * queue, releasing its free pages to the physical memory allocator. Returns + * TRUE if a reservation is broken and FALSE otherwise. * * The free page queue lock must be held. */ @@ -947,11 +947,10 @@ vm_reserv_reclaim_inactive(void) } /* - * Searches the partially-populated reservation queue for the least recently - * active reservation with unused pages, i.e., cached or free, that satisfy the - * given request for contiguous physical memory. If a satisfactory reservation - * is found, it is broken. Returns TRUE if a reservation is broken and FALSE - * otherwise. + * Searches the partially populated reservation queue for the least recently + * changed reservation with free pages that satisfy the given request for + * contiguous physical memory. If a satisfactory reservation is found, it is + * broken. Returns TRUE if a reservation is broken and FALSE otherwise. * * The free page queue lock must be held. */ From 97a4c9f0dc4ad6c692ef2e0b4b581991836b1db3 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:05:54 +0000 Subject: [PATCH 042/226] Comments --- usr.sbin/bsdinstall/scripts/wlanconfig | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 1cf648765b4..8cbf05bb287 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -41,8 +41,10 @@ country_set() local iface_up= local ifconfig_args= + # # Setup what was selected - # NB: do not change order of arguments (or regdomain will be ignored) + # NB: Do not change order of arguments (or regdomain will be ignored) + # if [ ! -z "$2" ]; then ifconfig_args="${ifconfig_args}country $2" fi @@ -74,9 +76,9 @@ country_set() --yes-label Change --no-label Ignore --yesno \ "Error while applying chosen settings ($error_str)" 0 0 if [ $? -eq $DIALOG_OK ]; then - return $FAILURE # Restart + return $FAILURE # Restart else - return $SUCCESS # Skip + return $SUCCESS # Skip fi else : > $BSDINSTALL_TMPETC/rc.conf.net.wlan @@ -97,7 +99,9 @@ dialog_country_select() local regdomain= local country= + # # Parse available countries/regdomains + # input=`ifconfig $WLAN_IFACE list countries | sed 's/DEBUG//gi'` regdomains=`echo $input | sed 's/.*domains://' | tr ' ' '\n' | sort | tr '\n' ' '` @@ -164,8 +168,10 @@ echo "ap_scan=1" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf echo "fast_reauth=1" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf echo >> $BSDINSTALL_TMPETC/wpa_supplicant.conf +# # Try to reach wpa_supplicant. If it isn't running and we can modify the # existing system, start it. Otherwise, fail. +# (wpa_cli ping >/dev/null 2>/dev/null || ([ ! -z $BSDINSTALL_CONFIGCURRENT ] && wpa_supplicant -B -i $1 -c $BSDINSTALL_TMPETC/wpa_supplicant.conf)) || (dialog --backtitle "FreeBSD Installer" --title "Error" --msgbox \ @@ -179,8 +185,10 @@ if [ $? -ne 0 -a -z $BSDINSTALL_CONFIGCURRENT ]; then exit 1 fi +# # There is no way to check country/regdomain without (possible) # interface state modification +# if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then # Get current country/regdomain for selected interface WLAN_IFACE=`wpa_cli ifname | tail -n 1` @@ -242,10 +250,7 @@ do # here we ask if the user wants to select the network manually f_dialog_title "Network Selection" f_dialog_yesno "Do you want to select the network manually?" || exit 1 - # and take the manual input - # first, take the ssid f_dialog_input NETWORK "Enter SSID" || exit 1 - # then, the encryption ENCRYPTION=$( dialog --backtitle "$DIALOG_BACKTITLE" --title \ "$DIALOG_TITLE" --menu "Select encryption type" 0 0 0 \ "1 WPA/WPA2 PSK" "" "2 WPA/WPA2 EAP" "" "3 WEP" "" "0 None" "" 2>&1 1>&3 ) || exit 1 From 138ab67af49242c872478e80cd224921d5825ad6 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:10:33 +0000 Subject: [PATCH 043/226] Use $( ... ) instead of `...` --- usr.sbin/bsdinstall/scripts/wlanconfig | 58 +++++++++++++------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 8cbf05bb287..24aa25638f3 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -60,12 +60,12 @@ country_set() fi # Regdomain/country cannot be applied while interface is running - iface_up=`ifconfig -lu | grep -w $WLAN_IFACE` + iface_up=$( ifconfig -lu | grep -w $WLAN_IFACE ) if [ ! -z "$iface_up" ]; then ifconfig $WLAN_IFACE down fi - error_str=`ifconfig $WLAN_IFACE $ifconfig_args 2>&1 | - sed 's/ifconfig: //'` + error_str=$( ifconfig $WLAN_IFACE $ifconfig_args 2>&1 | + sed 's/ifconfig: //' ) if [ ! -z "$iface_up" ]; then # Restart wpa_supplicant(8) (should not fail). wpa_supplicant -B -i $WLAN_IFACE -c \ @@ -102,10 +102,10 @@ dialog_country_select() # # Parse available countries/regdomains # - input=`ifconfig $WLAN_IFACE list countries | sed 's/DEBUG//gi'` - regdomains=`echo $input | sed 's/.*domains://' | tr ' ' '\n' | - sort | tr '\n' ' '` - countries=`echo $input | sed 's/Country codes://' | + input=$( ifconfig $WLAN_IFACE list countries | sed 's/DEBUG//gi' ) + regdomains=$( echo $input | sed 's/.*domains://' | tr ' ' '\n' | + sort | tr '\n' ' ' ) + countries=$( echo $input | sed 's/Country codes://' | sed 's/Regulatory.*//' | awk '{ for (i = 1; i <= NF; i++) { printf "%s", $i @@ -117,7 +117,7 @@ dialog_country_select() else printf " " } - }' | sort -k 2 | tr '\n' ' '` + }' | sort -k 2 | tr '\n' ' ' ) # Change default cursor position (if required). if [ "$1" != "" ]; then @@ -130,7 +130,7 @@ dialog_country_select() f_dialog_menu_size height width rows \"Regdomain selection\" \ \"FreeBSD Installer\" \"Select your regdomain.\" \ \"\" $regdomains - regdomain=`sh -c "dialog \ + regdomain=$( sh -c "dialog \ --backtitle \"FreeBSD Installer\" \ --title \"Regdomain selection\" \ --cancel-label \"Skip\" \ @@ -138,19 +138,19 @@ dialog_country_select() --no-items \ --stdout \ --menu \"Select your regdomain.\" \ - $height $width $rows $regdomains"` + $height $width $rows $regdomains" ) f_dialog_menu_size height width rows \"Country selection\" \ \"FreeBSD Installer\" \"Select your country.\" \ \"\" $countries - country=`sh -c "dialog \ + country=$( sh -c "dialog \ --backtitle \"FreeBSD Installer\" \ --title \"Country selection\" \ --cancel-label \"Skip\" \ $def_item_country \ --stdout \ --menu \"Select your country.\" \ - $height $width $rows $countries"` + $height $width $rows $countries" ) country_set "$regdomain" "$country" @@ -191,13 +191,13 @@ fi # if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then # Get current country/regdomain for selected interface - WLAN_IFACE=`wpa_cli ifname | tail -n 1` - INPUT=`ifconfig $WLAN_IFACE list regdomain | head -n 1` - DEF_REGDOMAIN=`echo $INPUT | cut -w -f 2` + WLAN_IFACE=$( wpa_cli ifname | tail -n 1 ) + INPUT=$( ifconfig $WLAN_IFACE list regdomain | head -n 1 ) + DEF_REGDOMAIN=$( echo $INPUT | cut -w -f 2 ) if [ "$DEF_REGDOMAIN" = "0" ]; then DEF_REGDOMAIN="" fi - DEF_COUNTRY=`echo $INPUT | cut -w -f 4` + DEF_COUNTRY=$( echo $INPUT | cut -w -f 4 ) if [ "$DEF_COUNTRY" = "0" ]; then DEF_COUNTRY="" fi @@ -225,10 +225,10 @@ do --pause "Waiting 5 seconds to scan for wireless networks..." \ 9 40 5 || exit 1 - SCAN_RESULTS=`wpa_cli scan_results` - NETWORKS=`echo "$SCAN_RESULTS" | awk -F '\t' \ + SCAN_RESULTS=$( wpa_cli scan_results ) + NETWORKS=$( echo "$SCAN_RESULTS" | awk -F '\t' \ '/..:..:..:..:..:../ {if (length($5) > 0) \ - printf("\"%s\"\t%s\n", $5, $4);}' | sort | uniq` + printf("\"%s\"\t%s\n", $5, $4);}' | sort | uniq ) if [ -z "$NETWORKS" ]; then dialog --backtitle "FreeBSD Installer" --title "Error" \ @@ -238,10 +238,10 @@ do fi exec 3>&1 - NETWORK=`sh -c "dialog --extra-button --extra-label \"Rescan\" \ + NETWORK=$( sh -c "dialog --extra-button --extra-label \"Rescan\" \ --backtitle \"FreeBSD Installer\" --title \"Network Selection\" \ --menu \"Select a wireless network to connect to.\" 0 0 0 \ - $(echo $NETWORKS | tr '\n' ' ')" 2>&1 1>&3` + $(echo $NETWORKS | tr '\n' ' ')" 2>&1 1>&3 ) case $? in 0) # OK break @@ -264,16 +264,16 @@ do exec 3>&- done -[ -z "$ENCRYPTION" ] && ENCRYPTION=`echo "$NETWORKS" | awk -F '\t' \ - "/^\"$NETWORK\"\t/ {printf(\"%s\n\", \\\$2 );}"` +[ -z "$ENCRYPTION" ] && ENCRYPTION=$( echo "$NETWORKS" | awk -F '\t' \ + "/^\"$NETWORK\"\t/ {printf(\"%s\n\", \\\$2 );}" ) if echo $ENCRYPTION | grep -q 'PSK'; then exec 3>&1 - PASS=`dialog --insecure --backtitle "FreeBSD Installer" \ + PASS=$( dialog --insecure --backtitle "FreeBSD Installer" \ --title "WPA Setup" --mixedform "" 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "Password" 2 0 "" 2 12 15 63 1 \ - 2>&1 1>&3` \ + 2>&1 1>&3 ) \ || exec $0 $@ exec 3>&- echo "network={ @@ -284,12 +284,12 @@ echo "network={ }" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf elif echo $ENCRYPTION | grep -q EAP; then exec 3>&1 - USERPASS=`dialog --insecure --backtitle "FreeBSD Installer" \ + USERPASS=$( dialog --insecure --backtitle "FreeBSD Installer" \ --title "WPA-Enterprise Setup" --mixedform "" 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "Username" 2 0 "" 2 12 25 63 0 \ "Password" 3 0 "" 3 12 25 63 1 \ - 2>&1 1>&3` \ + 2>&1 1>&3 ) \ || exec $0 $@ exec 3>&- echo "network={ @@ -308,11 +308,11 @@ echo " priority=5 }" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf elif echo $ENCRYPTION | grep -q WEP; then exec 3>&1 - WEPKEY=`dialog --insecure --backtitle "FreeBSD Installer" \ + WEPKEY=$( dialog --insecure --backtitle "FreeBSD Installer" \ --title "WEP Setup" --mixedform "" 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "WEP Key 0" 2 0 "" 2 12 15 0 1 \ - 2>&1 1>&3` \ + 2>&1 1>&3 ) \ || exec $0 $@ echo "network={ ssid=\"$NETWORK\" From adca4ffc22a90c1c6ab071bd1dc18fce7d6b5906 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 12 Dec 2016 18:13:03 +0000 Subject: [PATCH 044/226] Enable ACPI on arm64. It's not yet functional, but it will help keeping the code building until it is ready. Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation --- sys/arm64/conf/GENERIC | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/arm64/conf/GENERIC b/sys/arm64/conf/GENERIC index 61aa25e2abd..1294303bd01 100644 --- a/sys/arm64/conf/GENERIC +++ b/sys/arm64/conf/GENERIC @@ -230,7 +230,7 @@ device bpf # Berkeley packet filter options THUNDERX_PASS_1_1_ERRATA options FDT -#device acpi +device acpi # The crypto framework is required by IPSEC device crypto # Required by IPSEC From 38a9942347c75e850f5c0d849bf7e9fccd9b5693 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:17:30 +0000 Subject: [PATCH 045/226] Change "[ ! -z ... ]" => "[ ... ]" and "[ -z ... ]" => "[ ! ... ]" --- usr.sbin/bsdinstall/scripts/wlanconfig | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 24aa25638f3..f0fdf9d242f 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -45,33 +45,33 @@ country_set() # Setup what was selected # NB: Do not change order of arguments (or regdomain will be ignored) # - if [ ! -z "$2" ]; then + if [ "$2" ]; then ifconfig_args="${ifconfig_args}country $2" fi - if [ ! -z "$1" ]; then - if [ ! -z "$2" ]; then + if [ "$1" ]; then + if [ "$2" ]; then ifconfig_args="${ifconfig_args} " fi ifconfig_args="${ifconfig_args}regdomain $1" fi - if [ -z "$ifconfig_args" ]; then + if [ ! "$ifconfig_args" ]; then # Nothing to do (everything was skipped) return $SUCCESS fi # Regdomain/country cannot be applied while interface is running iface_up=$( ifconfig -lu | grep -w $WLAN_IFACE ) - if [ ! -z "$iface_up" ]; then + if [ "$iface_up" ]; then ifconfig $WLAN_IFACE down fi error_str=$( ifconfig $WLAN_IFACE $ifconfig_args 2>&1 | sed 's/ifconfig: //' ) - if [ ! -z "$iface_up" ]; then + if [ "$iface_up" ]; then # Restart wpa_supplicant(8) (should not fail). wpa_supplicant -B -i $WLAN_IFACE -c \ $BSDINSTALL_TMPETC/wpa_supplicant.conf fi - if [ ! -z "$error_str" ]; then + if [ "$error_str" ]; then dialog --backtitle "FreeBSD Installer" --title "Error" \ --yes-label Change --no-label Ignore --yesno \ "Error while applying chosen settings ($error_str)" 0 0 @@ -172,14 +172,14 @@ echo >> $BSDINSTALL_TMPETC/wpa_supplicant.conf # Try to reach wpa_supplicant. If it isn't running and we can modify the # existing system, start it. Otherwise, fail. # -(wpa_cli ping >/dev/null 2>/dev/null || ([ ! -z $BSDINSTALL_CONFIGCURRENT ] && +(wpa_cli ping >/dev/null 2>/dev/null || ([ "$BSDINSTALL_CONFIGCURRENT" ] && wpa_supplicant -B -i $1 -c $BSDINSTALL_TMPETC/wpa_supplicant.conf)) || (dialog --backtitle "FreeBSD Installer" --title "Error" --msgbox \ "Could not start wpa_supplicant!" 0 0; exit 1) || exit 1 # See if we succeeded wpa_cli ping >/dev/null 2>/dev/null -if [ $? -ne 0 -a -z $BSDINSTALL_CONFIGCURRENT ]; then +if [ $? -ne 0 -a ! "$BSDINSTALL_CONFIGCURRENT" ]; then dialog --backtitle "FreeBSD Installer" --title "Error" --msgbox \ "Wireless cannot be configured without making changes to the local system!" \ 0 0 exit 1 @@ -189,7 +189,7 @@ fi # There is no way to check country/regdomain without (possible) # interface state modification # -if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then +if [ "$BSDINSTALL_CONFIGCURRENT" ]; then # Get current country/regdomain for selected interface WLAN_IFACE=$( wpa_cli ifname | tail -n 1 ) INPUT=$( ifconfig $WLAN_IFACE list regdomain | head -n 1 ) @@ -230,7 +230,7 @@ do '/..:..:..:..:..:../ {if (length($5) > 0) \ printf("\"%s\"\t%s\n", $5, $4);}' | sort | uniq ) - if [ -z "$NETWORKS" ]; then + if [ ! "$NETWORKS" ]; then dialog --backtitle "FreeBSD Installer" --title "Error" \ --yesno "No wireless networks were found. Rescan?" 0 0 && continue @@ -264,7 +264,7 @@ do exec 3>&- done -[ -z "$ENCRYPTION" ] && ENCRYPTION=$( echo "$NETWORKS" | awk -F '\t' \ +[ ! "$ENCRYPTION" ] && ENCRYPTION=$( echo "$NETWORKS" | awk -F '\t' \ "/^\"$NETWORK\"\t/ {printf(\"%s\n\", \\\$2 );}" ) if echo $ENCRYPTION | grep -q 'PSK'; then From 5b57fabb453e6573d9e0591bfe4bdeee48fbad37 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:20:56 +0000 Subject: [PATCH 046/226] Remove unnecessary local initializers --- usr.sbin/bsdinstall/scripts/wlanconfig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index f0fdf9d242f..5c7f5fe21ba 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -37,8 +37,8 @@ f_include $BSDCFG_SHARE/dialog.subr country_set() { - local error_str= - local iface_up= + local error_str + local iface_up local ifconfig_args= # @@ -91,13 +91,13 @@ country_set() dialog_country_select() { - local input= + local input local def_item_regdomain= local def_item_country= - local regdomains= - local countries= - local regdomain= - local country= + local regdomains + local countries + local regdomain + local country # # Parse available countries/regdomains From bede07080544af02df006ee99cb0c42a45f70b4c Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:21:56 +0000 Subject: [PATCH 047/226] Consolidate locals --- usr.sbin/bsdinstall/scripts/wlanconfig | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 5c7f5fe21ba..a073df23c04 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -37,9 +37,7 @@ f_include $BSDCFG_SHARE/dialog.subr country_set() { - local error_str - local iface_up - local ifconfig_args= + local error_str iface_up ifconfig_args= # # Setup what was selected @@ -91,13 +89,9 @@ country_set() dialog_country_select() { - local input + local input regdomains countries regdomain country local def_item_regdomain= local def_item_country= - local regdomains - local countries - local regdomain - local country # # Parse available countries/regdomains From 114a587e3b19a252025a3e783ff03575bfda90dc Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:24:41 +0000 Subject: [PATCH 048/226] Replace funny block with something easy to digest --- usr.sbin/bsdinstall/scripts/wlanconfig | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index a073df23c04..2f7de8733ea 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -43,19 +43,10 @@ country_set() # Setup what was selected # NB: Do not change order of arguments (or regdomain will be ignored) # - if [ "$2" ]; then - ifconfig_args="${ifconfig_args}country $2" - fi - if [ "$1" ]; then - if [ "$2" ]; then - ifconfig_args="${ifconfig_args} " - fi - ifconfig_args="${ifconfig_args}regdomain $1" - fi - if [ ! "$ifconfig_args" ]; then - # Nothing to do (everything was skipped) - return $SUCCESS - fi + [ "$2" ] && ifconfig_args="$ifconfig_args country $2" + [ "$1" ] && ifconfig_args="$ifconfig_args regdomain $1" + [ "$ifconfig_args" ] || return $SUCCESS # Nothing to do + ifconfig_args="${ifconfig_args# }" # Regdomain/country cannot be applied while interface is running iface_up=$( ifconfig -lu | grep -w $WLAN_IFACE ) From e20253348dfbfe8127fa6abd34b301d62ae35773 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:28:20 +0000 Subject: [PATCH 049/226] Collapse tiny if statements --- usr.sbin/bsdinstall/scripts/wlanconfig | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 2f7de8733ea..e27e13376e5 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -50,9 +50,7 @@ country_set() # Regdomain/country cannot be applied while interface is running iface_up=$( ifconfig -lu | grep -w $WLAN_IFACE ) - if [ "$iface_up" ]; then - ifconfig $WLAN_IFACE down - fi + [ "$iface_up" ] && ifconfig $WLAN_IFACE down error_str=$( ifconfig $WLAN_IFACE $ifconfig_args 2>&1 | sed 's/ifconfig: //' ) if [ "$iface_up" ]; then @@ -179,13 +177,9 @@ if [ "$BSDINSTALL_CONFIGCURRENT" ]; then WLAN_IFACE=$( wpa_cli ifname | tail -n 1 ) INPUT=$( ifconfig $WLAN_IFACE list regdomain | head -n 1 ) DEF_REGDOMAIN=$( echo $INPUT | cut -w -f 2 ) - if [ "$DEF_REGDOMAIN" = "0" ]; then - DEF_REGDOMAIN="" - fi + [ "$DEF_REGDOMAIN" = "0" ] && DEF_REGDOMAIN="" DEF_COUNTRY=$( echo $INPUT | cut -w -f 4 ) - if [ "$DEF_COUNTRY" = "0" ]; then - DEF_COUNTRY="" - fi + [ "$DEF_COUNTRY" = "0" ] && DEF_COUNTRY="" dialog --backtitle "FreeBSD Installer" --title "Regdomain/country" \ --yesno "Change regdomain/country (now \ $DEF_REGDOMAIN/$DEF_COUNTRY)?" 0 0 From e9c843adc71f3fbbb2fa982d5324e3b9179739e5 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:29:24 +0000 Subject: [PATCH 050/226] Change "[ ! ... ] && ..." to "[ ... ] || ..." --- usr.sbin/bsdinstall/scripts/wlanconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index e27e13376e5..e4c1a3509ed 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -243,7 +243,7 @@ do exec 3>&- done -[ ! "$ENCRYPTION" ] && ENCRYPTION=$( echo "$NETWORKS" | awk -F '\t' \ +[ "$ENCRYPTION" ] || ENCRYPTION=$( echo "$NETWORKS" | awk -F '\t' \ "/^\"$NETWORK\"\t/ {printf(\"%s\n\", \\\$2 );}" ) if echo $ENCRYPTION | grep -q 'PSK'; then From 0b04945dc0b6c448078a92331154edfa4e74a69c Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:33:40 +0000 Subject: [PATCH 051/226] Remove unnecessary quotes around number in test --- usr.sbin/bsdinstall/scripts/wlanconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index e4c1a3509ed..2379916f58f 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -177,9 +177,9 @@ if [ "$BSDINSTALL_CONFIGCURRENT" ]; then WLAN_IFACE=$( wpa_cli ifname | tail -n 1 ) INPUT=$( ifconfig $WLAN_IFACE list regdomain | head -n 1 ) DEF_REGDOMAIN=$( echo $INPUT | cut -w -f 2 ) - [ "$DEF_REGDOMAIN" = "0" ] && DEF_REGDOMAIN="" + [ "$DEF_REGDOMAIN" = 0 ] && DEF_REGDOMAIN="" DEF_COUNTRY=$( echo $INPUT | cut -w -f 4 ) - [ "$DEF_COUNTRY" = "0" ] && DEF_COUNTRY="" + [ "$DEF_COUNTRY" = 0 ] && DEF_COUNTRY="" dialog --backtitle "FreeBSD Installer" --title "Regdomain/country" \ --yesno "Change regdomain/country (now \ $DEF_REGDOMAIN/$DEF_COUNTRY)?" 0 0 From c62801e26d4c3c88ff399d9adad826a59165dd43 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:34:21 +0000 Subject: [PATCH 052/226] Group fallbacks together --- usr.sbin/bsdinstall/scripts/wlanconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 2379916f58f..f4009c97d60 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -177,8 +177,8 @@ if [ "$BSDINSTALL_CONFIGCURRENT" ]; then WLAN_IFACE=$( wpa_cli ifname | tail -n 1 ) INPUT=$( ifconfig $WLAN_IFACE list regdomain | head -n 1 ) DEF_REGDOMAIN=$( echo $INPUT | cut -w -f 2 ) - [ "$DEF_REGDOMAIN" = 0 ] && DEF_REGDOMAIN="" DEF_COUNTRY=$( echo $INPUT | cut -w -f 4 ) + [ "$DEF_REGDOMAIN" = 0 ] && DEF_REGDOMAIN="" [ "$DEF_COUNTRY" = 0 ] && DEF_COUNTRY="" dialog --backtitle "FreeBSD Installer" --title "Regdomain/country" \ --yesno "Change regdomain/country (now \ From 718860e4699d6a0023ac4e320b224a411e012d21 Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Mon, 12 Dec 2016 18:36:46 +0000 Subject: [PATCH 053/226] CS ivar is uint32_t, not int. MFC after: 3 days --- sys/arm/at91/at91_spi.c | 5 +++-- sys/arm/broadcom/bcm2835/bcm2835_spi.c | 5 +++-- sys/arm/ti/ti_spi.c | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sys/arm/at91/at91_spi.c b/sys/arm/at91/at91_spi.c index bbe80ab1d36..82eb6fa1fc0 100644 --- a/sys/arm/at91/at91_spi.c +++ b/sys/arm/at91/at91_spi.c @@ -290,7 +290,8 @@ at91_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) { struct at91_spi_softc *sc; bus_addr_t addr; - int err, i, j, mode[4], cs; + int err, i, j, mode[4]; + uint32_t cs; KASSERT(cmd->tx_cmd_sz == cmd->rx_cmd_sz, ("%s: TX/RX command sizes should be equal", __func__)); @@ -314,7 +315,7 @@ at91_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) * PSCDEC = 0 has a range of 0..3 for chip select. We * don't support PSCDEC = 1 which has a range of 0..15. */ - if (cs < 0 || cs > 3) { + if (cs > 3) { device_printf(dev, "Invalid chip select %d requested by %s\n", cs, device_get_nameunit(child)); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_spi.c b/sys/arm/broadcom/bcm2835/bcm2835_spi.c index dbfec6ea4f9..7c3a8329bc1 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_spi.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_spi.c @@ -421,7 +421,8 @@ static int bcm_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) { struct bcm_spi_softc *sc; - int cs, err; + uint32_t cs; + int err; sc = device_get_softc(dev); @@ -432,7 +433,7 @@ bcm_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) /* Get the proper chip select for this child. */ spibus_get_cs(child, &cs); - if (cs < 0 || cs > 2) { + if (cs > 2) { device_printf(dev, "Invalid chip select %d requested by %s\n", cs, device_get_nameunit(child)); diff --git a/sys/arm/ti/ti_spi.c b/sys/arm/ti/ti_spi.c index 75f3df77710..92586e1b9b4 100644 --- a/sys/arm/ti/ti_spi.c +++ b/sys/arm/ti/ti_spi.c @@ -444,9 +444,9 @@ ti_spi_gcd(int a, int b) static int ti_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) { - int cs, err; + int err; struct ti_spi_softc *sc; - uint32_t reg; + uint32_t reg, cs; sc = device_get_softc(dev); @@ -457,7 +457,7 @@ ti_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) /* Get the proper chip select for this child. */ spibus_get_cs(child, &cs); - if (cs < 0 || cs > sc->sc_numcs) { + if (cs > sc->sc_numcs) { device_printf(dev, "Invalid chip select %d requested by %s\n", cs, device_get_nameunit(child)); return (EINVAL); From 8d5182d698cf166a744c167325e7cfeca213c5b9 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:38:18 +0000 Subject: [PATCH 054/226] Allow $BSDINSTALL_TMPETC to contain whitespace or special chars --- usr.sbin/bsdinstall/scripts/wlanconfig | 36 +++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index f4009c97d60..2664a758dd9 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -56,7 +56,7 @@ country_set() if [ "$iface_up" ]; then # Restart wpa_supplicant(8) (should not fail). wpa_supplicant -B -i $WLAN_IFACE -c \ - $BSDINSTALL_TMPETC/wpa_supplicant.conf + "$BSDINSTALL_TMPETC/wpa_supplicant.conf" fi if [ "$error_str" ]; then dialog --backtitle "FreeBSD Installer" --title "Error" \ @@ -68,9 +68,9 @@ country_set() return $SUCCESS # Skip fi else - : > $BSDINSTALL_TMPETC/rc.conf.net.wlan + : > "$BSDINSTALL_TMPETC/rc.conf.net.wlan" echo create_args_$WLAN_IFACE=\"$ifconfig_args\" >> \ - $BSDINSTALL_TMPETC/rc.conf.net.wlan + "$BSDINSTALL_TMPETC/rc.conf.net.wlan" fi return $SUCCESS @@ -142,21 +142,21 @@ dialog_country_select() ############################################################ MAIN -echo -n > $BSDINSTALL_TMPETC/wpa_supplicant.conf -chmod 0600 $BSDINSTALL_TMPETC/wpa_supplicant.conf +echo -n > "$BSDINSTALL_TMPETC/wpa_supplicant.conf" +chmod 0600 "$BSDINSTALL_TMPETC/wpa_supplicant.conf" -echo "ctrl_interface=/var/run/wpa_supplicant" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf -echo "eapol_version=2" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf -echo "ap_scan=1" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf -echo "fast_reauth=1" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf -echo >> $BSDINSTALL_TMPETC/wpa_supplicant.conf +echo "ctrl_interface=/var/run/wpa_supplicant" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" +echo "eapol_version=2" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" +echo "ap_scan=1" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" +echo "fast_reauth=1" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" +echo >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" # # Try to reach wpa_supplicant. If it isn't running and we can modify the # existing system, start it. Otherwise, fail. # (wpa_cli ping >/dev/null 2>/dev/null || ([ "$BSDINSTALL_CONFIGCURRENT" ] && - wpa_supplicant -B -i $1 -c $BSDINSTALL_TMPETC/wpa_supplicant.conf)) || + wpa_supplicant -B -i $1 -c "$BSDINSTALL_TMPETC/wpa_supplicant.conf")) || (dialog --backtitle "FreeBSD Installer" --title "Error" --msgbox \ "Could not start wpa_supplicant!" 0 0; exit 1) || exit 1 @@ -260,7 +260,7 @@ echo "network={ scan_ssid=$SCANSSID psk=\"$PASS\" priority=5 -}" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf +}" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" elif echo $ENCRYPTION | grep -q EAP; then exec 3>&1 USERPASS=$( dialog --insecure --backtitle "FreeBSD Installer" \ @@ -274,7 +274,7 @@ elif echo $ENCRYPTION | grep -q EAP; then echo "network={ ssid=\"$NETWORK\" scan_ssid=$SCANSSID - key_mgmt=WPA-EAP" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf + key_mgmt=WPA-EAP" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" echo "$USERPASS" | awk ' { if (NR == 1) { @@ -282,9 +282,9 @@ echo "$USERPASS" | awk ' } else if (NR == 2) { printf " password=\"%s\"\n", $1; } -}' >> $BSDINSTALL_TMPETC/wpa_supplicant.conf +}' >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" echo " priority=5 -}" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf +}" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" elif echo $ENCRYPTION | grep -q WEP; then exec 3>&1 WEPKEY=$( dialog --insecure --backtitle "FreeBSD Installer" \ @@ -300,21 +300,21 @@ echo "network={ wep_key0=\"$WEPKEY\" wep_tx_keyidx=0 priority=5 -}" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf +}" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" else # Open echo "network={ ssid=\"$NETWORK\" scan_ssid=$SCANSSID key_mgmt=NONE priority=5 -}" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf +}" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" fi # Connect to any open networks policy echo "network={ priority=0 key_mgmt=NONE -}" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf +}" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" # Bring up new network if [ "$BSDINSTALL_CONFIGCURRENT" ]; then From 1cac9fc2a316e215486fd05f7322c4b7e66fdfb2 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:39:26 +0000 Subject: [PATCH 055/226] Add missing `-e' parameter to sed invocations --- usr.sbin/bsdinstall/scripts/wlanconfig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 2664a758dd9..ab329f27193 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -52,7 +52,7 @@ country_set() iface_up=$( ifconfig -lu | grep -w $WLAN_IFACE ) [ "$iface_up" ] && ifconfig $WLAN_IFACE down error_str=$( ifconfig $WLAN_IFACE $ifconfig_args 2>&1 | - sed 's/ifconfig: //' ) + sed -e 's/ifconfig: //' ) if [ "$iface_up" ]; then # Restart wpa_supplicant(8) (should not fail). wpa_supplicant -B -i $WLAN_IFACE -c \ @@ -85,11 +85,11 @@ dialog_country_select() # # Parse available countries/regdomains # - input=$( ifconfig $WLAN_IFACE list countries | sed 's/DEBUG//gi' ) - regdomains=$( echo $input | sed 's/.*domains://' | tr ' ' '\n' | + input=$( ifconfig $WLAN_IFACE list countries | sed -e 's/DEBUG//gi' ) + regdomains=$( echo $input | sed -e 's/.*domains://' | tr ' ' '\n' | sort | tr '\n' ' ' ) - countries=$( echo $input | sed 's/Country codes://' | - sed 's/Regulatory.*//' | awk '{ + countries=$( echo $input | sed -e 's/Country codes://' | + sed -e 's/Regulatory.*//' | awk '{ for (i = 1; i <= NF; i++) { printf "%s", $i if (match($i, "[[:lower:]]")) From edcf3303722906c603f2d26873a788e3f8252bdf Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:42:55 +0000 Subject: [PATCH 056/226] "echo | sed | sed | awk" is silly (changed to "echo | awk") --- usr.sbin/bsdinstall/scripts/wlanconfig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index ab329f27193..42f4f94f913 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -88,8 +88,9 @@ dialog_country_select() input=$( ifconfig $WLAN_IFACE list countries | sed -e 's/DEBUG//gi' ) regdomains=$( echo $input | sed -e 's/.*domains://' | tr ' ' '\n' | sort | tr '\n' ' ' ) - countries=$( echo $input | sed -e 's/Country codes://' | - sed -e 's/Regulatory.*//' | awk '{ + countries=$( echo $input | awk '{ + sub(/Country codes:/, "") + sub(/Regulatory.*/, "") for (i = 1; i <= NF; i++) { printf "%s", $i if (match($i, "[[:lower:]]")) From 4fa8c81cc3e4371e65526644891e308ced84b8da Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:43:42 +0000 Subject: [PATCH 057/226] Be internally consistent (": > ..." is used elsewhere in this file) --- usr.sbin/bsdinstall/scripts/wlanconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 42f4f94f913..2a2324a80fb 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -143,7 +143,7 @@ dialog_country_select() ############################################################ MAIN -echo -n > "$BSDINSTALL_TMPETC/wpa_supplicant.conf" +: > "$BSDINSTALL_TMPETC/wpa_supplicant.conf" chmod 0600 "$BSDINSTALL_TMPETC/wpa_supplicant.conf" echo "ctrl_interface=/var/run/wpa_supplicant" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" From 3204364296317a8f02c961f35321f7a9e93aede3 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:45:52 +0000 Subject: [PATCH 058/226] awk(1) match() takes a regex, use /.../ to remind ourselves of this NB: The difference between "..." and /.../ for a regex in awk is that quoted strings go through escape expansion first (e.g., \\ becomes \) --- usr.sbin/bsdinstall/scripts/wlanconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 2a2324a80fb..0d069fc6a6d 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -93,8 +93,8 @@ dialog_country_select() sub(/Regulatory.*/, "") for (i = 1; i <= NF; i++) { printf "%s", $i - if (match($i, "[[:lower:]]")) - if (match($(i+1), "[[:lower:]]")) + if (match($i, /[[:lower:]]/)) + if (match($(i+1), /[[:lower:]]/)) printf "\\\\\\ " else printf "\n" From 9ca8b7be34e57e2275bb627634be79a1387782b3 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:48:00 +0000 Subject: [PATCH 059/226] Remove unnecessary `-n' parameter to head/tail --- usr.sbin/bsdinstall/scripts/wlanconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 0d069fc6a6d..38fdb76fecc 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -175,8 +175,8 @@ fi # if [ "$BSDINSTALL_CONFIGCURRENT" ]; then # Get current country/regdomain for selected interface - WLAN_IFACE=$( wpa_cli ifname | tail -n 1 ) - INPUT=$( ifconfig $WLAN_IFACE list regdomain | head -n 1 ) + WLAN_IFACE=$( wpa_cli ifname | tail -1 ) + INPUT=$( ifconfig $WLAN_IFACE list regdomain | head -1 ) DEF_REGDOMAIN=$( echo $INPUT | cut -w -f 2 ) DEF_COUNTRY=$( echo $INPUT | cut -w -f 4 ) [ "$DEF_REGDOMAIN" = 0 ] && DEF_REGDOMAIN="" From 76b07bd950363c578113deb58f9db7522d687eea Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:52:22 +0000 Subject: [PATCH 060/226] Whitespace --- usr.sbin/bsdinstall/scripts/wlanconfig | 47 +++++++++++++------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 38fdb76fecc..8228998246c 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -56,12 +56,12 @@ country_set() if [ "$iface_up" ]; then # Restart wpa_supplicant(8) (should not fail). wpa_supplicant -B -i $WLAN_IFACE -c \ - "$BSDINSTALL_TMPETC/wpa_supplicant.conf" + "$BSDINSTALL_TMPETC/wpa_supplicant.conf" fi if [ "$error_str" ]; then dialog --backtitle "FreeBSD Installer" --title "Error" \ - --yes-label Change --no-label Ignore --yesno \ - "Error while applying chosen settings ($error_str)" 0 0 + --yes-label Change --no-label Ignore --yesno \ + "Error while applying chosen settings ($error_str)" 0 0 if [ $? -eq $DIALOG_OK ]; then return $FAILURE # Restart else @@ -101,7 +101,7 @@ dialog_country_select() else printf " " } - }' | sort -k 2 | tr '\n' ' ' ) + }' | sort -k 2 | tr '\n' ' ' ) # Change default cursor position (if required). if [ "$1" != "" ]; then @@ -112,29 +112,31 @@ dialog_country_select() fi f_dialog_menu_size height width rows \"Regdomain selection\" \ - \"FreeBSD Installer\" \"Select your regdomain.\" \ - \"\" $regdomains + \"FreeBSD Installer\" \"Select your regdomain.\" \ + \"\" $regdomains regdomain=$( sh -c "dialog \ - --backtitle \"FreeBSD Installer\" \ - --title \"Regdomain selection\" \ - --cancel-label \"Skip\" \ - $def_item_regdomain \ - --no-items \ - --stdout \ - --menu \"Select your regdomain.\" \ - $height $width $rows $regdomains" ) + --backtitle \"FreeBSD Installer\" \ + --title \"Regdomain selection\" \ + --cancel-label \"Skip\" \ + $def_item_regdomain \ + --no-items \ + --stdout \ + --menu \"Select your regdomain.\" \ + $height $width $rows $regdomains" + ) f_dialog_menu_size height width rows \"Country selection\" \ \"FreeBSD Installer\" \"Select your country.\" \ \"\" $countries country=$( sh -c "dialog \ - --backtitle \"FreeBSD Installer\" \ - --title \"Country selection\" \ - --cancel-label \"Skip\" \ - $def_item_country \ - --stdout \ - --menu \"Select your country.\" \ - $height $width $rows $countries" ) + --backtitle \"FreeBSD Installer\" \ + --title \"Country selection\" \ + --cancel-label \"Skip\" \ + $def_item_country \ + --stdout \ + --menu \"Select your country.\" \ + $height $width $rows $countries" + ) country_set "$regdomain" "$country" @@ -195,8 +197,7 @@ if [ "$BSDINSTALL_CONFIGCURRENT" ]; then fi fi -while : -do +while :; do SCANSSID=0 output=$( wpa_cli scan 2>&1 ) f_dprintf "%s" "$output" From 5357f8f7c801ce3e1f40276a9316b09f78ad64a0 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 18:55:41 +0000 Subject: [PATCH 061/226] Use provided API instead of hard-coded status integers --- usr.sbin/bsdinstall/scripts/wlanconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 8228998246c..e5f77ced91d 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -224,10 +224,10 @@ while :; do --menu \"Select a wireless network to connect to.\" 0 0 0 \ $(echo $NETWORKS | tr '\n' ' ')" 2>&1 1>&3 ) case $? in - 0) # OK + $DIALOG_OK) break ;; - 1) # Cancel + $DIALOG_CANCEL) # here we ask if the user wants to select the network manually f_dialog_title "Network Selection" f_dialog_yesno "Do you want to select the network manually?" || exit 1 @@ -239,7 +239,7 @@ while :; do f_dialog_title_restore break ;; - 3) # Rescan + $DIALOG_EXTRA) # Rescan ;; esac exec 3>&- From 94161f30b733a136361ba9bcedbd1b720dff9df6 Mon Sep 17 00:00:00 2001 From: Bartek Rutkowski Date: Mon, 12 Dec 2016 18:56:40 +0000 Subject: [PATCH 062/226] Fix regression when stdin/out/err fds are are overridden by shell. Submitted by: Pawel Biernacki Reported by: ngie Approved by: ngie Sponsored by: Mysterious Code Ltd. Differential Revision: https://reviews.freebsd.org/D8543 --- bin/dd/dd.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/dd/dd.c b/bin/dd/dd.c index 3c6720bacef..a5c24647535 100644 --- a/bin/dd/dd.c +++ b/bin/dd/dd.c @@ -142,8 +142,6 @@ setup(void) in.fd = open(in.name, O_RDONLY, 0); if (in.fd == -1) err(1, "%s", in.name); - if (caph_limit_stdin() == -1) - err(1, "unable to limit capability rights"); } getfdtype(&in); @@ -176,8 +174,6 @@ setup(void) } if (out.fd == -1) err(1, "%s", out.name); - if (caph_limit_stdout() == -1) - err(1, "unable to limit capability rights"); } getfdtype(&out); @@ -188,6 +184,16 @@ setup(void) errno != ENOSYS) err(1, "unable to limit capability rights"); + if (in.fd != STDIN_FILENO && out.fd != STDIN_FILENO) { + if (caph_limit_stdin() == -1) + err(1, "unable to limit capability rights"); + } + + if (in.fd != STDOUT_FILENO && out.fd != STDOUT_FILENO) { + if (caph_limit_stdout() == -1) + err(1, "unable to limit capability rights"); + } + if (in.fd != STDERR_FILENO && out.fd != STDERR_FILENO) { if (caph_limit_stderr() == -1) err(1, "unable to limit capability rights"); From 58dc38bd1c28a83b26e2b205e3e197f2bced7fba Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 19:01:04 +0000 Subject: [PATCH 063/226] Centralize backtitle string --- usr.sbin/bsdinstall/scripts/wlanconfig | 29 +++++++++++++------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index e5f77ced91d..0b9f97486ae 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -32,6 +32,7 @@ BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 f_include $BSDCFG_SHARE/dialog.subr +f_dialog_backtitle "FreeBSD Installer" ############################################################ FUNCTIONS @@ -59,7 +60,7 @@ country_set() "$BSDINSTALL_TMPETC/wpa_supplicant.conf" fi if [ "$error_str" ]; then - dialog --backtitle "FreeBSD Installer" --title "Error" \ + dialog --backtitle "$DIALOG_BACKTITLE" --title "Error" \ --yes-label Change --no-label Ignore --yesno \ "Error while applying chosen settings ($error_str)" 0 0 if [ $? -eq $DIALOG_OK ]; then @@ -112,10 +113,10 @@ dialog_country_select() fi f_dialog_menu_size height width rows \"Regdomain selection\" \ - \"FreeBSD Installer\" \"Select your regdomain.\" \ + \"$DIALOG_BACKTITLE\" \"Select your regdomain.\" \ \"\" $regdomains regdomain=$( sh -c "dialog \ - --backtitle \"FreeBSD Installer\" \ + --backtitle \"$DIALOG_BACKTITLE\" \ --title \"Regdomain selection\" \ --cancel-label \"Skip\" \ $def_item_regdomain \ @@ -126,10 +127,10 @@ dialog_country_select() ) f_dialog_menu_size height width rows \"Country selection\" \ - \"FreeBSD Installer\" \"Select your country.\" \ + \"$DIALOG_BACKTITLE\" \"Select your country.\" \ \"\" $countries country=$( sh -c "dialog \ - --backtitle \"FreeBSD Installer\" \ + --backtitle \"$DIALOG_BACKTITLE\" \ --title \"Country selection\" \ --cancel-label \"Skip\" \ $def_item_country \ @@ -160,13 +161,13 @@ echo >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" # (wpa_cli ping >/dev/null 2>/dev/null || ([ "$BSDINSTALL_CONFIGCURRENT" ] && wpa_supplicant -B -i $1 -c "$BSDINSTALL_TMPETC/wpa_supplicant.conf")) || - (dialog --backtitle "FreeBSD Installer" --title "Error" --msgbox \ + (dialog --backtitle "$DIALOG_BACKTITLE" --title "Error" --msgbox \ "Could not start wpa_supplicant!" 0 0; exit 1) || exit 1 # See if we succeeded wpa_cli ping >/dev/null 2>/dev/null if [ $? -ne 0 -a ! "$BSDINSTALL_CONFIGCURRENT" ]; then - dialog --backtitle "FreeBSD Installer" --title "Error" --msgbox \ + dialog --backtitle "$DIALOG_BACKTITLE" --title "Error" --msgbox \ "Wireless cannot be configured without making changes to the local system!" \ 0 0 exit 1 fi @@ -183,7 +184,7 @@ if [ "$BSDINSTALL_CONFIGCURRENT" ]; then DEF_COUNTRY=$( echo $INPUT | cut -w -f 4 ) [ "$DEF_REGDOMAIN" = 0 ] && DEF_REGDOMAIN="" [ "$DEF_COUNTRY" = 0 ] && DEF_COUNTRY="" - dialog --backtitle "FreeBSD Installer" --title "Regdomain/country" \ + dialog --backtitle "$DIALOG_BACKTITLE" --title "Regdomain/country" \ --yesno "Change regdomain/country (now \ $DEF_REGDOMAIN/$DEF_COUNTRY)?" 0 0 if [ $? -eq 0 ]; then @@ -201,7 +202,7 @@ while :; do SCANSSID=0 output=$( wpa_cli scan 2>&1 ) f_dprintf "%s" "$output" - dialog --backtitle "FreeBSD Installer" --title "Scanning" \ + dialog --backtitle "$DIALOG_BACKTITLE" --title "Scanning" \ --ok-label "Skip" \ --pause "Waiting 5 seconds to scan for wireless networks..." \ 9 40 5 || exit 1 @@ -212,7 +213,7 @@ while :; do printf("\"%s\"\t%s\n", $5, $4);}' | sort | uniq ) if [ ! "$NETWORKS" ]; then - dialog --backtitle "FreeBSD Installer" --title "Error" \ + dialog --backtitle "$DIALOG_BACKTITLE" --title "Error" \ --yesno "No wireless networks were found. Rescan?" 0 0 && continue exit 1 @@ -220,7 +221,7 @@ while :; do exec 3>&1 NETWORK=$( sh -c "dialog --extra-button --extra-label \"Rescan\" \ - --backtitle \"FreeBSD Installer\" --title \"Network Selection\" \ + --backtitle \"$DIALOG_BACKTITLE\" --title \"Network Selection\" \ --menu \"Select a wireless network to connect to.\" 0 0 0 \ $(echo $NETWORKS | tr '\n' ' ')" 2>&1 1>&3 ) case $? in @@ -250,7 +251,7 @@ done if echo $ENCRYPTION | grep -q 'PSK'; then exec 3>&1 - PASS=$( dialog --insecure --backtitle "FreeBSD Installer" \ + PASS=$( dialog --insecure --backtitle "$DIALOG_BACKTITLE" \ --title "WPA Setup" --mixedform "" 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "Password" 2 0 "" 2 12 15 63 1 \ @@ -265,7 +266,7 @@ echo "network={ }" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" elif echo $ENCRYPTION | grep -q EAP; then exec 3>&1 - USERPASS=$( dialog --insecure --backtitle "FreeBSD Installer" \ + USERPASS=$( dialog --insecure --backtitle "$DIALOG_BACKTITLE" \ --title "WPA-Enterprise Setup" --mixedform "" 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "Username" 2 0 "" 2 12 25 63 0 \ @@ -289,7 +290,7 @@ echo " priority=5 }" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" elif echo $ENCRYPTION | grep -q WEP; then exec 3>&1 - WEPKEY=$( dialog --insecure --backtitle "FreeBSD Installer" \ + WEPKEY=$( dialog --insecure --backtitle "$DIALOG_BACKTITLE" \ --title "WEP Setup" --mixedform "" 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "WEP Key 0" 2 0 "" 2 12 15 0 1 \ From 48e9fce2f56dc29954f8a72c3bb7e15c13085132 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 19:07:42 +0000 Subject: [PATCH 064/226] There is zero harm in always passing --default-item to dialog --- usr.sbin/bsdinstall/scripts/wlanconfig | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 0b9f97486ae..957d53ef662 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -80,8 +80,9 @@ country_set() dialog_country_select() { local input regdomains countries regdomain country - local def_item_regdomain= - local def_item_country= + local no_default="" + local def_item_regdomain="${1:-$no_default}" + local def_item_country="${2:-$no_default}" # # Parse available countries/regdomains @@ -104,14 +105,6 @@ dialog_country_select() } }' | sort -k 2 | tr '\n' ' ' ) - # Change default cursor position (if required). - if [ "$1" != "" ]; then - def_item_regdomain="--default-item $1" - fi - if [ "$2" != "" ]; then - def_item_country="--default-item $2" - fi - f_dialog_menu_size height width rows \"Regdomain selection\" \ \"$DIALOG_BACKTITLE\" \"Select your regdomain.\" \ \"\" $regdomains @@ -119,7 +112,7 @@ dialog_country_select() --backtitle \"$DIALOG_BACKTITLE\" \ --title \"Regdomain selection\" \ --cancel-label \"Skip\" \ - $def_item_regdomain \ + --default-item \"$def_item_regdomain\" \ --no-items \ --stdout \ --menu \"Select your regdomain.\" \ From 86e1d2977fb1405e8882d518bef3f799344d2748 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 19:09:17 +0000 Subject: [PATCH 065/226] Always pass --default-item parameter to dialog --- usr.sbin/bsdinstall/scripts/wlanconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 957d53ef662..34a3a6da0cb 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -126,7 +126,7 @@ dialog_country_select() --backtitle \"$DIALOG_BACKTITLE\" \ --title \"Country selection\" \ --cancel-label \"Skip\" \ - $def_item_country \ + --default-item \"$def_item_country\" \ --stdout \ --menu \"Select your country.\" \ $height $width $rows $countries" From 783e461c73b9bd5acee4c0099b283032911875e4 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Mon, 12 Dec 2016 19:10:14 +0000 Subject: [PATCH 066/226] - Refactor listening socket list. All of the listening sockets are now maintained in a single linked-list in a transport-independent manner. - Use queue.h for linked-list structure. - Use linked-list for AllowedPeers. - Use getaddrinfo(8) even for Unix Domain sockets. - Use macros to type-casting from/to struct sockaddr{,_in,_in6}. - Define fu_* macro for union f_un to shorten the member names. - Remove an extra #include . - Add "static" to non-exported symbols. - !INET support is still incomplete but will be fixed later. There is no functional change except for some minor debug messages. --- usr.sbin/syslogd/Makefile | 3 + usr.sbin/syslogd/syslogd.c | 790 ++++++++++++++++++------------------- 2 files changed, 379 insertions(+), 414 deletions(-) diff --git a/usr.sbin/syslogd/Makefile b/usr.sbin/syslogd/Makefile index 716efbe7d59..ac9acbfcea9 100644 --- a/usr.sbin/syslogd/Makefile +++ b/usr.sbin/syslogd/Makefile @@ -13,6 +13,9 @@ LIBADD= util WARNS?= 3 +.if ${MK_INET_SUPPORT} != "no" +CFLAGS+= -DINET +.endif .if ${MK_INET6_SUPPORT} != "no" CFLAGS+= -DINET6 .endif diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 50553d14206..b324fb2e383 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -88,7 +88,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -116,43 +115,60 @@ __FBSDID("$FreeBSD$"); #define SYSLOG_NAMES #include -const char *ConfFile = _PATH_LOGCONF; -const char *PidFile = _PATH_LOGPID; -const char ctty[] = _PATH_CONSOLE; -static const char include_str[] = "include"; -static const char include_ext[] = ".conf"; +static const char *ConfFile = _PATH_LOGCONF; +static const char *PidFile = _PATH_LOGPID; +static const char ctty[] = _PATH_CONSOLE; +static const char include_str[] = "include"; +static const char include_ext[] = ".conf"; #define dprintf if (Debug) printf #define MAXUNAMES 20 /* maximum number of user names */ +#define sstosa(ss) ((struct sockaddr *)(ss)) +#ifdef INET +#define satosin(sa) ((struct sockaddr_in *)(void *)(sa)) +#endif +#ifdef INET6 +#define satosin6(sa) ((struct sockaddr_in6 *)(void *)(sa)) +#define s6_addr32 __u6_addr.__u6_addr32 +#define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \ + (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \ + (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \ + (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \ + (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 ) +#endif /* - * List of hosts for binding. + * List of peers and sockets for binding. */ -static STAILQ_HEAD(, host) hqueue; -struct host { - char *name; - STAILQ_ENTRY(host) next; +struct peer { + const char *pe_name; + const char *pe_serv; + mode_t pe_mode; + STAILQ_ENTRY(peer) next; }; - -/* - * Unix sockets. - * We have two default sockets, one with 666 permissions, - * and one for privileged programs. - */ -struct funix { - int s; - const char *name; - mode_t mode; - STAILQ_ENTRY(funix) next; +struct socklist { + struct sockaddr_storage sl_ss; + int sl_socket; + struct peer *sl_peer; + STAILQ_ENTRY(socklist) next; }; -struct funix funix_secure = { -1, _PATH_LOG_PRIV, S_IRUSR | S_IWUSR, - { NULL } }; -struct funix funix_default = { -1, _PATH_LOG, DEFFILEMODE, - { &funix_secure } }; +static STAILQ_HEAD(, socklist) shead = STAILQ_HEAD_INITIALIZER(shead); -STAILQ_HEAD(, funix) funixes = { &funix_default, - &(funix_secure.next.stqe_next) }; +static struct peer funix_secure = { + .pe_name = _PATH_LOG_PRIV, + .pe_mode = S_IRUSR | S_IWUSR, + .next = {NULL}, +}; +static struct peer funix_default = { + .pe_name = _PATH_LOG, + .pe_mode = DEFFILEMODE, + .next = {&funix_secure}, +}; +static STAILQ_HEAD(, peer) pqueue = { + &funix_default, + &funix_secure.next.stqe_next, +}; /* * Flags to logmsg(). @@ -172,7 +188,7 @@ STAILQ_HEAD(, funix) funixes = { &funix_default, */ struct filed { - struct filed *f_next; /* next in linked list */ + STAILQ_ENTRY(filed) next; /* next in linked list */ short f_type; /* entry type, see below */ short f_file; /* file descriptor */ time_t f_time; /* time this was last written */ @@ -196,6 +212,12 @@ struct filed { pid_t f_pid; } f_pipe; } f_un; +#define fu_uname f_un.f_uname +#define fu_forw_hname f_un.f_forw.f_hname +#define fu_forw_addr f_un.f_forw.f_addr +#define fu_fname f_un.f_fname +#define fu_pipe_pname f_un.f_pipe.f_pname +#define fu_pipe_pid f_un.f_pipe.f_pid char f_prevline[MAXSVLINE]; /* last message logged */ char f_lasttime[16]; /* time of last occurrence */ char f_prevhost[MAXHOSTNAMELEN]; /* host from which recd. */ @@ -211,15 +233,12 @@ struct filed { /* * Queue of about-to-be dead processes we should watch out for. */ - -TAILQ_HEAD(stailhead, deadq_entry) deadq_head; -struct stailhead *deadq_headp; - struct deadq_entry { pid_t dq_pid; int dq_timeout; TAILQ_ENTRY(deadq_entry) dq_entries; }; +static TAILQ_HEAD(, deadq_entry) deadq_head; /* * The timeout to apply to processes waiting on the dead queue. Unit @@ -249,7 +268,9 @@ struct allowedpeer { #define a_addr u.numeric.addr #define a_mask u.numeric.mask #define a_name u.name + STAILQ_ENTRY(allowedpeer) next; }; +static STAILQ_HEAD(, allowedpeer) aphead = STAILQ_HEAD_INITIALIZER(aphead); /* @@ -257,7 +278,7 @@ struct allowedpeer { * in seconds after previous message is logged. After each flush, * we move to the next interval until we reach the largest. */ -int repeatinterval[] = { 30, 120, 600 }; /* # of secs before flush */ +static int repeatinterval[] = { 30, 120, 600 }; /* # of secs before flush */ #define MAXREPEAT ((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1) #define REPEATTIME(f) ((f)->f_time + repeatinterval[(f)->f_repeatcount]) #define BACKOFF(f) { if (++(f)->f_repeatcount > MAXREPEAT) \ @@ -274,12 +295,13 @@ int repeatinterval[] = { 30, 120, 600 }; /* # of secs before flush */ #define F_WALL 6 /* everyone logged on */ #define F_PIPE 7 /* pipe to program */ -const char *TypeNames[8] = { +static const char *TypeNames[8] = { "UNUSED", "FILE", "TTY", "CONSOLE", "FORW", "USERS", "WALL", "PIPE" }; -static struct filed *Files; /* Log files that we write to */ +static STAILQ_HEAD(, filed) fhead = + STAILQ_HEAD_INITIALIZER(fhead); /* Log files that we write to */ static struct filed consfile; /* Console */ static int Debug; /* debug flag */ @@ -287,7 +309,6 @@ static int Foreground = 0; /* Run in foreground, instead of daemonizing */ static int resolve = 1; /* resolve hostname */ static char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */ static const char *LocalDomain; /* our local domain name */ -static int *finet; /* Internet datagram sockets */ static int fklog = -1; /* /dev/klog */ static int Initialized; /* set when we have initialized ourselves */ static int MarkInterval = 20 * 60; /* interval between marks in seconds */ @@ -307,8 +328,6 @@ static int logflags = O_WRONLY|O_APPEND; /* flags used to open log files */ static char bootfile[MAXLINE+1]; /* booted kernel file */ -struct allowedpeer *AllowedPeers; /* List of allowed peers */ -static int NumAllowed; /* Number of entries in AllowedPeers */ static int RemoteAddDate; /* Always set the date on remote messages */ static int UniquePriority; /* Only log specified priority? */ @@ -318,7 +337,7 @@ static int KeepKernFac; /* Keep remotely logged kernel facility */ static int needdofsync = 0; /* Are any file(s) waiting to be fsynced? */ static struct pidfh *pfh; -volatile sig_atomic_t MarkSet, WantDie; +static volatile sig_atomic_t MarkSet, WantDie; static int allowaddr(char *); static void cfline(const char *, struct filed *, @@ -332,7 +351,7 @@ static void dodie(int); static void dofsync(void); static void domark(int); static void fprintlog(struct filed *, int, const char *); -static int *socksetup(int, char *); +static int socksetup(struct peer *); static void init(int); static void logerror(const char *); static void logmsg(int, const char *, const char *, int); @@ -368,31 +387,30 @@ close_filed(struct filed *f) int main(int argc, char *argv[]) { - int ch, i, fdsrmax = 0, l; - struct sockaddr_un sunx, fromunix; - struct sockaddr_storage frominet; + int ch, i, fdsrmax = 0; + struct sockaddr_storage ss; fd_set *fdsr = NULL; char line[MAXLINE + 1]; const char *hname; struct timeval tv, *tvp; struct sigaction sact; - struct host *host; - struct funix *fx, *fx1; + struct peer *pe; + struct socklist *sl; sigset_t mask; pid_t ppid = 1, spid; - socklen_t len; + socklen_t sslen; if (madvise(NULL, 0, MADV_PROTECT) != 0) dprintf("madvise() failed: %s\n", strerror(errno)); - STAILQ_INIT(&hqueue); - while ((ch = getopt(argc, argv, "468Aa:b:cCdf:Fkl:m:nNop:P:sS:Tuv")) != -1) switch (ch) { +#ifdef INET case '4': family = PF_INET; break; +#endif #ifdef INET6 case '6': family = PF_INET6; @@ -409,13 +427,12 @@ main(int argc, char *argv[]) usage(); break; case 'b': - { - if ((host = malloc(sizeof(struct host))) == NULL) + if ((pe = calloc(1, sizeof(*pe))) == NULL) err(1, "malloc failed"); - host->name = optarg; - STAILQ_INSERT_TAIL(&hqueue, host, next); + pe->pe_name = optarg; + pe->pe_serv = NULL; + STAILQ_INSERT_TAIL(&pqueue, pe, next); break; - } case 'c': no_compress++; break; @@ -458,17 +475,12 @@ main(int argc, char *argv[]) } else errx(1, "invalid mode %s, exiting", optarg); - } else /* doesn't begin with '/', and no ':' */ - errx(1, "can't parse path %s", optarg); - - if (strlen(name) >= sizeof(sunx.sun_path)) - errx(1, "%s path too long, exiting", name); - if ((fx = malloc(sizeof(struct funix))) == NULL) + } + if ((pe = calloc(1, sizeof(*pe))) == NULL) err(1, "malloc failed"); - fx->s = -1; - fx->name = name; - fx->mode = mode; - STAILQ_INSERT_TAIL(&funixes, fx, next); + pe->pe_name = name; + pe->pe_mode = mode; + STAILQ_INSERT_TAIL(&pqueue, pe, next); break; } case 'm': /* mark interval */ @@ -485,9 +497,7 @@ main(int argc, char *argv[]) use_bootfile = 1; break; case 'p': /* path */ - if (strlen(optarg) >= sizeof(sunx.sun_path)) - errx(1, "%s path too long, exiting", optarg); - funix_default.name = optarg; + funix_default.pe_name = optarg; break; case 'P': /* path for alt. PID */ PidFile = optarg; @@ -496,9 +506,7 @@ main(int argc, char *argv[]) SecureMode++; break; case 'S': /* path for privileged originator */ - if (strlen(optarg) >= sizeof(sunx.sun_path)) - errx(1, "%s path too long, exiting", optarg); - funix_secure.name = optarg; + funix_secure.pe_name = optarg; break; case 'T': RemoteAddDate = 1; @@ -514,6 +522,8 @@ main(int argc, char *argv[]) } if ((argc -= optind) != 0) usage(); + STAILQ_FOREACH(pe, &pqueue, next) + socksetup(pe); pfh = pidfile_open(PidFile, 0600, &spid); if (pfh == NULL) { @@ -529,16 +539,12 @@ main(int argc, char *argv[]) pidfile_remove(pfh); exit(1); } - } else if (Debug) { + } else if (Debug) setlinebuf(stdout); - } - - if (NumAllowed) - endservent(); consfile.f_type = F_CONSOLE; - (void)strlcpy(consfile.f_un.f_fname, ctty + sizeof _PATH_DEV - 1, - sizeof(consfile.f_un.f_fname)); + (void)strlcpy(consfile.fu_fname, ctty + sizeof _PATH_DEV - 1, + sizeof(consfile.fu_fname)); (void)strlcpy(bootfile, getbootfile(), sizeof(bootfile)); (void)signal(SIGTERM, dodie); (void)signal(SIGINT, Debug ? dodie : SIG_IGN); @@ -561,69 +567,6 @@ main(int argc, char *argv[]) TAILQ_INIT(&deadq_head); -#ifndef SUN_LEN -#define SUN_LEN(unp) (strlen((unp)->sun_path) + 2) -#endif - STAILQ_FOREACH_SAFE(fx, &funixes, next, fx1) { - (void)unlink(fx->name); - memset(&sunx, 0, sizeof(sunx)); - sunx.sun_family = AF_LOCAL; - (void)strlcpy(sunx.sun_path, fx->name, sizeof(sunx.sun_path)); - fx->s = socket(PF_LOCAL, SOCK_DGRAM, 0); - if (fx->s < 0 || - bind(fx->s, (struct sockaddr *)&sunx, SUN_LEN(&sunx)) < 0 || - chmod(fx->name, fx->mode) < 0) { - (void)snprintf(line, sizeof line, - "cannot create %s", fx->name); - logerror(line); - dprintf("cannot create %s (%d)\n", fx->name, errno); - if (fx == &funix_default || fx == &funix_secure) - die(0); - else { - STAILQ_REMOVE(&funixes, fx, funix, next); - continue; - } - } - increase_rcvbuf(fx->s); - } - if (SecureMode <= 1) { - if (STAILQ_EMPTY(&hqueue)) - finet = socksetup(family, NULL); - STAILQ_FOREACH(host, &hqueue, next) { - int *finet0, total; - finet0 = socksetup(family, host->name); - if (finet0 && !finet) { - finet = finet0; - } else if (finet0 && finet) { - total = *finet0 + *finet + 1; - finet = realloc(finet, total * sizeof(int)); - if (finet == NULL) - err(1, "realloc failed"); - for (i = 1; i <= *finet0; i++) { - finet[(*finet)+i] = finet0[i]; - } - *finet = total - 1; - free(finet0); - } - } - } - - if (finet) { - if (SecureMode) { - for (i = 0; i < *finet; i++) { - if (shutdown(finet[i+1], SHUT_RD) < 0 && - errno != ENOTCONN) { - logerror("shutdown"); - if (!Debug) - die(0); - } - } - } else { - dprintf("listening on inet and/or inet6 socket\n"); - } - dprintf("sending on inet and/or inet6 socket\n"); - } - if ((fklog = open(_PATH_KLOG, O_RDONLY|O_NONBLOCK, 0)) < 0) dprintf("can't open %s (%d)\n", _PATH_KLOG, errno); @@ -646,15 +589,10 @@ main(int argc, char *argv[]) if (fklog != -1 && fklog > fdsrmax) fdsrmax = fklog; - if (finet && !SecureMode) { - for (i = 0; i < *finet; i++) { - if (finet[i+1] != -1 && finet[i+1] > fdsrmax) - fdsrmax = finet[i+1]; - } + STAILQ_FOREACH(sl, &shead, next) { + if (sl->sl_socket > fdsrmax) + fdsrmax = sl->sl_socket; } - STAILQ_FOREACH(fx, &funixes, next) - if (fx->s > fdsrmax) - fdsrmax = fx->s; fdsr = (fd_set *)calloc(howmany(fdsrmax+1, NFDBITS), sizeof(fd_mask)); @@ -672,16 +610,11 @@ main(int argc, char *argv[]) if (fklog != -1) FD_SET(fklog, fdsr); - if (finet && !SecureMode) { - for (i = 0; i < *finet; i++) { - if (finet[i+1] != -1) - FD_SET(finet[i+1], fdsr); - } + STAILQ_FOREACH(sl, &shead, next) { + if (sl->sl_socket != -1) + FD_SET(sl->sl_socket, fdsr); } - STAILQ_FOREACH(fx, &funixes, next) - FD_SET(fx->s, fdsr); - - i = select(fdsrmax+1, fdsr, NULL, NULL, + i = select(fdsrmax + 1, fdsr, NULL, NULL, needdofsync ? &tv : tvp); switch (i) { case 0: @@ -700,34 +633,40 @@ main(int argc, char *argv[]) } if (fklog != -1 && FD_ISSET(fklog, fdsr)) readklog(); - if (finet && !SecureMode) { - for (i = 0; i < *finet; i++) { - if (FD_ISSET(finet[i+1], fdsr)) { - len = sizeof(frominet); - l = recvfrom(finet[i+1], line, MAXLINE, - 0, (struct sockaddr *)&frominet, - &len); - if (l > 0) { - line[l] = '\0'; - hname = cvthname((struct sockaddr *)&frominet); - unmapped((struct sockaddr *)&frominet); - if (validate((struct sockaddr *)&frominet, hname)) - printline(hname, line, RemoteAddDate ? ADDDATE : 0); - } else if (l < 0 && errno != EINTR) - logerror("recvfrom inet"); + STAILQ_FOREACH(sl, &shead, next) { + int date, len; + + if (FD_ISSET(sl->sl_socket, fdsr)) { + sslen = sizeof(ss); + dprintf("sslen(1) = %d\n", sslen); + len = recvfrom(sl->sl_socket, line, + sizeof(line) - 1, 0, + sstosa(&ss), &sslen); + dprintf("sslen(2) = %d\n", sslen); + if (len == 0) + continue; + if (len < 0) { + if (errno != EINTR) + logerror("recvfrom"); + continue; } - } - } - STAILQ_FOREACH(fx, &funixes, next) { - if (FD_ISSET(fx->s, fdsr)) { - len = sizeof(fromunix); - l = recvfrom(fx->s, line, MAXLINE, 0, - (struct sockaddr *)&fromunix, &len); - if (l > 0) { - line[l] = '\0'; - printline(LocalHostName, line, 0); - } else if (l < 0 && errno != EINTR) - logerror("recvfrom unix"); + /* Received valid data. */ + line[len] = '\0'; + if (sl->sl_ss.ss_family == AF_LOCAL) { + hname = LocalHostName; + date = 0; + } else { + hname = cvthname(sstosa(&ss)); + unmapped(sstosa(&ss)); + if (validate(sstosa(&ss), hname) == 0) + hname = NULL; + date = RemoteAddDate ? ADDDATE : 0; + } + if (hname != NULL) + printline(hname, line, date); + else + dprintf("Invalid msg from " + "%s was ignored.", hname); } } } @@ -735,30 +674,36 @@ main(int argc, char *argv[]) free(fdsr); } +#ifdef INET6 static void unmapped(struct sockaddr *sa) { struct sockaddr_in6 *sin6; struct sockaddr_in sin4; - if (sa->sa_family != AF_INET6) + if (sa == NULL || + sa->sa_family != AF_INET6 || + sa->sa_len != sizeof(*sin6)) return; - if (sa->sa_len != sizeof(struct sockaddr_in6) || - sizeof(sin4) > sa->sa_len) - return; - sin6 = (struct sockaddr_in6 *)sa; + sin6 = satosin6(sa); if (!IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) return; memset(&sin4, 0, sizeof(sin4)); sin4.sin_family = AF_INET; - sin4.sin_len = sizeof(struct sockaddr_in); + sin4.sin_len = sizeof(sin4); memcpy(&sin4.sin_addr, &sin6->sin6_addr.s6_addr[12], sizeof(sin4.sin_addr)); sin4.sin_port = sin6->sin6_port; memcpy(sa, &sin4, sin4.sin_len); } +#else +static void +unmapped(struct sockaddr *sa __unused) +{ +} +#endif static void usage(void) @@ -1043,7 +988,7 @@ logmsg(int pri, const char *msg, const char *from, int flags) (void)sigsetmask(omask); return; } - for (f = Files; f; f = f->f_next) { + STAILQ_FOREACH(f, &fhead, next) { /* skip messages that are incorrect priority */ if (!(((f->f_pcmp[fac] & PRI_EQ) && (f->f_pmask[fac] == prilev)) ||((f->f_pcmp[fac] & PRI_LT) && (f->f_pmask[fac] < prilev)) @@ -1120,7 +1065,7 @@ dofsync(void) { struct filed *f; - for (f = Files; f; f = f->f_next) { + STAILQ_FOREACH(f, &fhead, next) { if ((f->f_type == F_FILE) && (f->f_flags & FFLAG_NEEDSYNC)) { f->f_flags &= ~FFLAG_NEEDSYNC; @@ -1136,7 +1081,7 @@ fprintlog(struct filed *f, int flags, const char *msg) struct iovec iov[IOV_SIZE]; struct iovec *v; struct addrinfo *r; - int i, l, lsent = 0; + int l, lsent = 0; char line[MAXLINE + 1], repbuf[80], greetings[200], *wmsg = NULL; char nul[] = "", space[] = " ", lf[] = "\n", crlf[] = "\r\n"; const char *msgret; @@ -1244,12 +1189,11 @@ fprintlog(struct filed *f, int flags, const char *msg) break; case F_FORW: - port = (int)ntohs(((struct sockaddr_in *) - (f->f_un.f_forw.f_addr->ai_addr))->sin_port); + port = ntohs(satosin(f->fu_forw_addr->ai_addr)->sin_port); if (port != 514) { - dprintf(" %s:%d\n", f->f_un.f_forw.f_hname, port); + dprintf(" %s:%d\n", f->fu_forw_hname, port); } else { - dprintf(" %s\n", f->f_un.f_forw.f_hname); + dprintf(" %s\n", f->fu_forw_hname); } /* check for local vs remote messages */ if (strcasecmp(f->f_prevhost, LocalHostName)) @@ -1266,57 +1210,51 @@ fprintlog(struct filed *f, int flags, const char *msg) else if (l > MAXLINE) l = MAXLINE; - if (finet) { - for (r = f->f_un.f_forw.f_addr; r; r = r->ai_next) { - for (i = 0; i < *finet; i++) { -#if 0 - /* - * should we check AF first, or just - * trial and error? FWD - */ - if (r->ai_family == - address_family_of(finet[i+1])) -#endif - lsent = sendto(finet[i+1], line, l, 0, - r->ai_addr, r->ai_addrlen); - if (lsent == l) - break; - } - if (lsent == l && !send_to_all) + for (r = f->fu_forw_addr; r; r = r->ai_next) { + struct socklist *sl; + + STAILQ_FOREACH(sl, &shead, next) { + if (sl->sl_ss.ss_family == AF_LOCAL) + continue; + lsent = sendto(sl->sl_socket, line, l, 0, + r->ai_addr, r->ai_addrlen); + if (lsent == l) break; } - dprintf("lsent/l: %d/%d\n", lsent, l); - if (lsent != l) { - int e = errno; - logerror("sendto"); - errno = e; - switch (errno) { - case ENOBUFS: - case ENETDOWN: - case ENETUNREACH: - case EHOSTUNREACH: - case EHOSTDOWN: - case EADDRNOTAVAIL: - break; - /* case EBADF: */ - /* case EACCES: */ - /* case ENOTSOCK: */ - /* case EFAULT: */ - /* case EMSGSIZE: */ - /* case EAGAIN: */ - /* case ENOBUFS: */ - /* case ECONNREFUSED: */ - default: - dprintf("removing entry: errno=%d\n", e); - f->f_type = F_UNUSED; - break; - } + if (lsent == l && !send_to_all) + break; + } + dprintf("lsent/l: %d/%d\n", lsent, l); + if (lsent != l) { + int e = errno; + logerror("sendto"); + errno = e; + switch (errno) { + case ENOBUFS: + case ENETDOWN: + case ENETUNREACH: + case EHOSTUNREACH: + case EHOSTDOWN: + case EADDRNOTAVAIL: + break; + /* case EBADF: */ + /* case EACCES: */ + /* case ENOTSOCK: */ + /* case EFAULT: */ + /* case EMSGSIZE: */ + /* case EAGAIN: */ + /* case ENOBUFS: */ + /* case ECONNREFUSED: */ + default: + dprintf("removing entry: errno=%d\n", e); + f->f_type = F_UNUSED; + break; } } break; case F_FILE: - dprintf(" %s\n", f->f_un.f_fname); + dprintf(" %s\n", f->fu_fname); v->iov_base = lf; v->iov_len = 1; if (writev(f->f_file, iov, IOV_SIZE) < 0) { @@ -1329,7 +1267,7 @@ fprintlog(struct filed *f, int flags, const char *msg) int e = errno; close_filed(f); errno = e; - logerror(f->f_un.f_fname); + logerror(f->fu_fname); } } else if ((flags & SYNC_FILE) && (f->f_flags & FFLAG_SYNC)) { f->f_flags |= FFLAG_NEEDSYNC; @@ -1338,26 +1276,26 @@ fprintlog(struct filed *f, int flags, const char *msg) break; case F_PIPE: - dprintf(" %s\n", f->f_un.f_pipe.f_pname); + dprintf(" %s\n", f->fu_pipe_pname); v->iov_base = lf; v->iov_len = 1; - if (f->f_un.f_pipe.f_pid == 0) { - if ((f->f_file = p_open(f->f_un.f_pipe.f_pname, - &f->f_un.f_pipe.f_pid)) < 0) { + if (f->fu_pipe_pid == 0) { + if ((f->f_file = p_open(f->fu_pipe_pname, + &f->fu_pipe_pid)) < 0) { f->f_type = F_UNUSED; - logerror(f->f_un.f_pipe.f_pname); + logerror(f->fu_pipe_pname); break; } } if (writev(f->f_file, iov, IOV_SIZE) < 0) { int e = errno; close_filed(f); - if (f->f_un.f_pipe.f_pid > 0) - deadq_enter(f->f_un.f_pipe.f_pid, - f->f_un.f_pipe.f_pname); - f->f_un.f_pipe.f_pid = 0; + if (f->fu_pipe_pid > 0) + deadq_enter(f->fu_pipe_pid, + f->fu_pipe_pname); + f->fu_pipe_pid = 0; errno = e; - logerror(f->f_un.f_pipe.f_pname); + logerror(f->fu_pipe_pname); } break; @@ -1369,12 +1307,12 @@ fprintlog(struct filed *f, int flags, const char *msg) /* FALLTHROUGH */ case F_TTY: - dprintf(" %s%s\n", _PATH_DEV, f->f_un.f_fname); + dprintf(" %s%s\n", _PATH_DEV, f->fu_fname); v->iov_base = crlf; v->iov_len = 2; errno = 0; /* ttymsg() only sometimes returns an errno */ - if ((msgret = ttymsg(iov, IOV_SIZE, f->f_un.f_fname, 10))) { + if ((msgret = ttymsg(iov, IOV_SIZE, f->fu_fname, 10))) { f->f_type = F_UNUSED; logerror(msgret); } @@ -1423,9 +1361,9 @@ wallmsg(struct filed *f, struct iovec *iov, const int iovlen) } /* should we send the message to this user? */ for (i = 0; i < MAXUNAMES; i++) { - if (!f->f_un.f_uname[i][0]) + if (!f->fu_uname[i][0]) break; - if (!strcmp(f->f_un.f_uname[i], ut->ut_user)) { + if (!strcmp(f->fu_uname[i], ut->ut_user)) { if ((p = ttymsg_check(iov, iovlen, ut->ut_line, TTYMSGTIME)) != NULL) { errno = 0; /* already in msg */ @@ -1476,20 +1414,18 @@ reapchild(int signo __unused) /* First, look if it's a process from the dead queue. */ if (deadq_remove(pid)) - goto oncemore; + continue; /* Now, look in list of active processes. */ - for (f = Files; f; f = f->f_next) + STAILQ_FOREACH(f, &fhead, next) { if (f->f_type == F_PIPE && - f->f_un.f_pipe.f_pid == pid) { + f->fu_pipe_pid == pid) { close_filed(f); - f->f_un.f_pipe.f_pid = 0; - log_deadchild(pid, status, - f->f_un.f_pipe.f_pname); + f->fu_pipe_pid = 0; + log_deadchild(pid, status, f->fu_pipe_pname); break; } - oncemore: - continue; + } } } @@ -1503,9 +1439,9 @@ cvthname(struct sockaddr *f) sigset_t omask, nmask; static char hname[NI_MAXHOST], ip[NI_MAXHOST]; - error = getnameinfo((struct sockaddr *)f, - ((struct sockaddr *)f)->sa_len, - ip, sizeof ip, NULL, 0, NI_NUMERICHOST); + dprintf("cvthname(%d) len = %d, %zu\n", f->sa_family, f->sa_len, sizeof(struct sockaddr_in6)); + error = getnameinfo(f, f->sa_len, ip, sizeof(ip), NULL, 0, + NI_NUMERICHOST); dprintf("cvthname(%s)\n", ip); if (error) { @@ -1575,19 +1511,19 @@ static void die(int signo) { struct filed *f; - struct funix *fx; + struct socklist *sl; int was_initialized; char buf[100]; was_initialized = Initialized; Initialized = 0; /* Don't log SIGCHLDs. */ - for (f = Files; f != NULL; f = f->f_next) { + STAILQ_FOREACH(f, &fhead, next) { /* flush any pending output */ if (f->f_prevcount) fprintlog(f, 0, (char *)NULL); - if (f->f_type == F_PIPE && f->f_un.f_pipe.f_pid > 0) { + if (f->f_type == F_PIPE && f->fu_pipe_pid > 0) { close_filed(f); - f->f_un.f_pipe.f_pid = 0; + f->fu_pipe_pid = 0; } } Initialized = was_initialized; @@ -1597,8 +1533,10 @@ die(int signo) errno = 0; logerror(buf); } - STAILQ_FOREACH(fx, &funixes, next) - (void)unlink(fx->name); + STAILQ_FOREACH(sl, &shead, next) { + if (sl->sl_ss.ss_family == AF_LOCAL) + unlink(sl->sl_peer->pe_name); + } pidfile_remove(pfh); exit(1); @@ -1626,7 +1564,7 @@ configfiles(const struct dirent *dp) } static void -readconfigfile(FILE *cf, struct filed **nextp, int allow_includes) +readconfigfile(FILE *cf, int allow_includes) { FILE *cf2; struct filed *f; @@ -1686,7 +1624,7 @@ readconfigfile(FILE *cf, struct filed **nextp, int allow_includes) if (cf2 == NULL) continue; dprintf("reading %s\n", file); - readconfigfile(cf2, nextp, 0); + readconfigfile(cf2, 0); fclose(cf2); } free(ent); @@ -1749,8 +1687,7 @@ readconfigfile(FILE *cf, struct filed **nextp, int allow_includes) logerror("calloc"); exit(1); } - *nextp = f; - nextp = &f->f_next; + STAILQ_INSERT_TAIL(&fhead, f, next); cfline(cline, f, prog, host); } } @@ -1763,7 +1700,7 @@ init(int signo) { int i; FILE *cf; - struct filed *f, *next, **nextp; + struct filed *f; char *p; char oldLocalHostName[MAXHOSTNAMELEN]; char hostMsg[2*MAXHOSTNAMELEN+40]; @@ -1808,7 +1745,7 @@ init(int signo) * Close all open log files. */ Initialized = 0; - for (f = Files; f != NULL; f = next) { + STAILQ_FOREACH(f, &fhead, next) { /* flush any pending output */ if (f->f_prevcount) fprintlog(f, 0, (char *)NULL); @@ -1821,42 +1758,48 @@ init(int signo) close_filed(f); break; case F_PIPE: - if (f->f_un.f_pipe.f_pid > 0) { + if (f->fu_pipe_pid > 0) { close_filed(f); - deadq_enter(f->f_un.f_pipe.f_pid, - f->f_un.f_pipe.f_pname); + deadq_enter(f->fu_pipe_pid, + f->fu_pipe_pname); } - f->f_un.f_pipe.f_pid = 0; + f->fu_pipe_pid = 0; break; } - next = f->f_next; - if (f->f_program) free(f->f_program); - if (f->f_host) free(f->f_host); - free((char *)f); } - Files = NULL; + while(!STAILQ_EMPTY(&fhead)) { + f = STAILQ_FIRST(&fhead); + STAILQ_REMOVE_HEAD(&fhead, next); + free(f->f_program); + free(f->f_host); + free(f); + } nextp = &Files; /* open the configuration file */ if ((cf = fopen(ConfFile, "r")) == NULL) { dprintf("cannot open %s\n", ConfFile); - *nextp = (struct filed *)calloc(1, sizeof(*f)); - if (*nextp == NULL) { + f = calloc(1, sizeof(*f)); + if (f == NULL) { logerror("calloc"); exit(1); } - cfline("*.ERR\t/dev/console", *nextp, "*", "*"); - (*nextp)->f_next = (struct filed *)calloc(1, sizeof(*f)); - if ((*nextp)->f_next == NULL) { + cfline("*.ERR\t/dev/console", f, "*", "*"); + STAILQ_INSERT_TAIL(&fhead, f, next); + + f = calloc(1, sizeof(*f)); + if (f == NULL) { logerror("calloc"); exit(1); } - cfline("*.PANIC\t*", (*nextp)->f_next, "*", "*"); + cfline("*.PANIC\t*", f, "*", "*"); + STAILQ_INSERT_TAIL(&fhead, f, next); + Initialized = 1; return; } - readconfigfile(cf, &Files, 1); + readconfigfile(cf, 1); /* close the configuration file */ (void)fclose(cf); @@ -1865,7 +1808,7 @@ init(int signo) if (Debug) { int port; - for (f = Files; f; f = f->f_next) { + STAILQ_FOREACH(f, &fhead, next) { for (i = 0; i <= LOG_NFACILITIES; i++) if (f->f_pmask[i] == INTERNAL_NOPRI) printf("X "); @@ -1874,32 +1817,31 @@ init(int signo) printf("%s: ", TypeNames[f->f_type]); switch (f->f_type) { case F_FILE: - printf("%s", f->f_un.f_fname); + printf("%s", f->fu_fname); break; case F_CONSOLE: case F_TTY: - printf("%s%s", _PATH_DEV, f->f_un.f_fname); + printf("%s%s", _PATH_DEV, f->fu_fname); break; case F_FORW: - port = (int)ntohs(((struct sockaddr_in *) - (f->f_un.f_forw.f_addr->ai_addr))->sin_port); + port = ntohs(satosin(f->fu_forw_addr->ai_addr)->sin_port); if (port != 514) { printf("%s:%d", - f->f_un.f_forw.f_hname, port); + f->fu_forw_hname, port); } else { - printf("%s", f->f_un.f_forw.f_hname); + printf("%s", f->fu_forw_hname); } break; case F_PIPE: - printf("%s", f->f_un.f_pipe.f_pname); + printf("%s", f->fu_pipe_pname); break; case F_USERS: - for (i = 0; i < MAXUNAMES && *f->f_un.f_uname[i]; i++) - printf("%s, ", f->f_un.f_uname[i]); + for (i = 0; i < MAXUNAMES && *f->fu_uname[i]; i++) + printf("%s, ", f->fu_uname[i]); break; } if (f->f_program) @@ -2104,8 +2046,8 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) * scan forward to see if there is a port defined. * so we can't use strlcpy.. */ - i = sizeof(f->f_un.f_forw.f_hname); - tp = f->f_un.f_forw.f_hname; + i = sizeof(f->fu_forw_hname); + tp = f->fu_forw_hname; p++; /* @@ -2132,13 +2074,13 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) memset(&hints, 0, sizeof(hints)); hints.ai_family = family; hints.ai_socktype = SOCK_DGRAM; - error = getaddrinfo(f->f_un.f_forw.f_hname, + error = getaddrinfo(f->fu_forw_hname, p ? p : "syslog", &hints, &res); if (error) { logerror(gai_strerror(error)); break; } - f->f_un.f_forw.f_addr = res; + f->fu_forw_addr = res; f->f_type = F_FORW; break; @@ -2155,18 +2097,18 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) f->f_type = F_CONSOLE; else f->f_type = F_TTY; - (void)strlcpy(f->f_un.f_fname, p + sizeof(_PATH_DEV) - 1, - sizeof(f->f_un.f_fname)); + (void)strlcpy(f->fu_fname, p + sizeof(_PATH_DEV) - 1, + sizeof(f->fu_fname)); } else { - (void)strlcpy(f->f_un.f_fname, p, sizeof(f->f_un.f_fname)); + (void)strlcpy(f->fu_fname, p, sizeof(f->fu_fname)); f->f_type = F_FILE; } break; case '|': - f->f_un.f_pipe.f_pid = 0; - (void)strlcpy(f->f_un.f_pipe.f_pname, p + 1, - sizeof(f->f_un.f_pipe.f_pname)); + f->fu_pipe_pid = 0; + (void)strlcpy(f->fu_pipe_pname, p + 1, + sizeof(f->fu_pipe_pname)); f->f_type = F_PIPE; break; @@ -2178,11 +2120,11 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) for (i = 0; i < MAXUNAMES && *p; i++) { for (q = p; *q && *q != ','; ) q++; - (void)strncpy(f->f_un.f_uname[i], p, MAXLOGNAME - 1); + (void)strncpy(f->fu_uname[i], p, MAXLOGNAME - 1); if ((q - p) >= MAXLOGNAME) - f->f_un.f_uname[i][MAXLOGNAME - 1] = '\0'; + f->fu_uname[i][MAXLOGNAME - 1] = '\0'; else - f->f_un.f_uname[i][q - p] = '\0'; + f->fu_uname[i][q - p] = '\0'; while (*q == ',' || *q == ' ') q++; p = q; @@ -2233,7 +2175,7 @@ markit(void) MarkSeq = 0; } - for (f = Files; f; f = f->f_next) { + STAILQ_FOREACH(f, &fhead, next) { if (f->f_prevcount && now >= REPEATTIME(f)) { dprintf("flush %s: repeated %d times, %d sec.\n", TypeNames[f->f_type], f->f_prevcount, @@ -2494,7 +2436,7 @@ allowaddr(char *s) } if (Debug) { - printf("allowaddr: rule %d: ", NumAllowed); + printf("allowaddr: rule "); if (ap.isnumeric) { printf("numeric, "); getnameinfo((struct sockaddr *)&ap.a_addr, @@ -2510,14 +2452,6 @@ allowaddr(char *s) } printf("port = %d\n", ap.port); } - - if ((AllowedPeers = realloc(AllowedPeers, - ++NumAllowed * sizeof(struct allowedpeer))) - == NULL) { - logerror("realloc"); - exit(1); - } - memcpy(&AllowedPeers[NumAllowed - 1], &ap, sizeof(struct allowedpeer)); return (0); } @@ -2533,13 +2467,17 @@ validate(struct sockaddr *sa, const char *hname) struct allowedpeer *ap; struct sockaddr_in *sin4, *a4p = NULL, *m4p = NULL; #ifdef INET6 - int j, reject; + int reject; struct sockaddr_in6 *sin6, *a6p = NULL, *m6p = NULL; #endif struct addrinfo hints, *res; u_short sport; + int num = 0; - if (NumAllowed == 0) + STAILQ_FOREACH(ap, &aphead, next) + num++; + dprintf("# of validation rule: %d\n", num); + if (num == 0) /* traditional behaviour, allow everything */ return (1); @@ -2554,7 +2492,7 @@ validate(struct sockaddr *sa, const char *hname) strlcat(name, ".", sizeof name); strlcat(name, LocalDomain, sizeof name); } - if (getnameinfo(sa, sa->sa_len, ip, sizeof ip, port, sizeof port, + if (getnameinfo(sa, sa->sa_len, ip, sizeof(ip), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV) != 0) return (0); /* for safety, should not occur */ dprintf("validate: dgram from IP %s, port %s, name %s;\n", @@ -2562,9 +2500,12 @@ validate(struct sockaddr *sa, const char *hname) sport = atoi(port); /* now, walk down the list */ - for (i = 0, ap = AllowedPeers; i < NumAllowed; i++, ap++) { + i = 0; + STAILQ_FOREACH(ap, &aphead, next) { + i++; if (ap->port != 0 && ap->port != sport) { - dprintf("rejected in rule %d due to port mismatch.\n", i); + dprintf("rejected in rule %d due to port mismatch.\n", + i); continue; } @@ -2574,9 +2515,9 @@ validate(struct sockaddr *sa, const char *hname) continue; } if (ap->a_addr.ss_family == AF_INET) { - sin4 = (struct sockaddr_in *)sa; - a4p = (struct sockaddr_in *)&ap->a_addr; - m4p = (struct sockaddr_in *)&ap->a_mask; + sin4 = satosin(sa); + a4p = satosin(&ap->a_addr); + m4p = satosin(&ap->a_mask); if ((sin4->sin_addr.s_addr & m4p->sin_addr.s_addr) != a4p->sin_addr.s_addr) { dprintf("rejected in rule %d due to IP mismatch.\n", i); @@ -2585,21 +2526,19 @@ validate(struct sockaddr *sa, const char *hname) } #ifdef INET6 else if (ap->a_addr.ss_family == AF_INET6) { - sin6 = (struct sockaddr_in6 *)sa; - a6p = (struct sockaddr_in6 *)&ap->a_addr; - m6p = (struct sockaddr_in6 *)&ap->a_mask; + sin6 = satosin6(sa); + a6p = satosin6(&ap->a_addr); + m6p = satosin6(&ap->a_mask); if (a6p->sin6_scope_id != 0 && sin6->sin6_scope_id != a6p->sin6_scope_id) { dprintf("rejected in rule %d due to scope mismatch.\n", i); continue; } reject = 0; - for (j = 0; j < 16; j += 4) { - if ((*(u_int32_t *)&sin6->sin6_addr.s6_addr[j] & *(u_int32_t *)&m6p->sin6_addr.s6_addr[j]) - != *(u_int32_t *)&a6p->sin6_addr.s6_addr[j]) { - ++reject; - break; - } + if (IN6_ARE_MASKED_ADDR_EQUAL(&sin6->sin6_addr, + &a6p->sin6_addr, &m6p->sin6_addr) != 0) { + ++reject; + break; } if (reject) { dprintf("rejected in rule %d due to IP mismatch.\n", i); @@ -2756,11 +2695,13 @@ deadq_remove(pid_t pid) dq_t q; TAILQ_FOREACH(q, &deadq_head, dq_entries) { - if (q->dq_pid == pid) { - TAILQ_REMOVE(&deadq_head, q, dq_entries); - free(q); - return (1); - } + if (q->dq_pid == pid) + break; + } + if (q != NULL) { + TAILQ_REMOVE(&deadq_head, q, dq_entries); + free(q); + return (1); } return (0); @@ -2789,85 +2730,90 @@ log_deadchild(pid_t pid, int status, const char *name) logerror(buf); } -static int * -socksetup(int af, char *bindhostname) +static int +socksetup(struct peer *pe) { - struct addrinfo hints, *res, *r; - const char *bindservice; + struct addrinfo hints, *res, *res0; + struct socklist *sl; + int error; char *cp; - int error, maxs, *s, *socks; - /* * We have to handle this case for backwards compatibility: * If there are two (or more) colons but no '[' and ']', * assume this is an inet6 address without a service. */ - bindservice = "syslog"; - if (bindhostname != NULL) { + if (pe->pe_name != NULL) { #ifdef INET6 - if (*bindhostname == '[' && - (cp = strchr(bindhostname + 1, ']')) != NULL) { - ++bindhostname; + if (pe->pe_name[0] == '[' && + (cp = strchr(pe->pe_name + 1, ']')) != NULL) { + pe->pe_name = &pe->pe_name[1]; *cp = '\0'; if (cp[1] == ':' && cp[2] != '\0') - bindservice = cp + 2; + pe->pe_serv = cp + 2; } else { #endif - cp = strchr(bindhostname, ':'); + cp = strchr(pe->pe_name, ':'); if (cp != NULL && strchr(cp + 1, ':') == NULL) { *cp = '\0'; if (cp[1] != '\0') - bindservice = cp + 1; - if (cp == bindhostname) - bindhostname = NULL; + pe->pe_serv = cp + 1; + if (cp == pe->pe_name) + pe->pe_name = NULL; } #ifdef INET6 } #endif } - memset(&hints, 0, sizeof(hints)); - hints.ai_flags = AI_PASSIVE; - hints.ai_family = af; + hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; - error = getaddrinfo(bindhostname, bindservice, &hints, &res); + hints.ai_flags = AI_PASSIVE; + + dprintf("Try %s\n", pe->pe_name); + if (pe->pe_serv == NULL) + pe->pe_serv = "syslog"; + error = getaddrinfo(pe->pe_name, pe->pe_serv, &hints, &res0); if (error) { logerror(gai_strerror(error)); errno = 0; die(0); } - - /* Count max number of sockets we may open */ - for (maxs = 0, r = res; r; r = r->ai_next, maxs++); - socks = malloc((maxs+1) * sizeof(int)); - if (socks == NULL) { - logerror("couldn't allocate memory for sockets"); - die(0); - } - - *socks = 0; /* num of sockets counter at start of array */ - s = socks + 1; - for (r = res; r; r = r->ai_next) { + for (res = res0; res != NULL; res = res->ai_next) { + int s; int on = 1; - *s = socket(r->ai_family, r->ai_socktype, r->ai_protocol); - if (*s < 0) { + + if (res->ai_family == AF_LOCAL) + unlink(pe->pe_name); + else if (SecureMode > 1) { + /* Only AF_LOCAL in secure mode. */ + continue; + } + if (family != AF_UNSPEC && res->ai_family != family) + continue; + + s = socket(res->ai_family, res->ai_socktype, + res->ai_protocol); + if (s < 0) { logerror("socket"); + error++; continue; } #ifdef INET6 - if (r->ai_family == AF_INET6) { - if (setsockopt(*s, IPPROTO_IPV6, IPV6_V6ONLY, - (char *)&on, sizeof (on)) < 0) { - logerror("setsockopt"); - close(*s); + if (res->ai_family == AF_INET6) { + if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, + (char *)&on, sizeof(on)) < 0) { + logerror("setsockopt(IPV6_V6ONLY)"); + close(s); + error++; continue; } } #endif - if (setsockopt(*s, SOL_SOCKET, SO_REUSEADDR, - (char *)&on, sizeof (on)) < 0) { - logerror("setsockopt"); - close(*s); + if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, + (char *)&on, sizeof(on)) < 0) { + logerror("setsockopt(SO_REUSEADDR)"); + close(s); + error++; continue; } /* @@ -2878,33 +2824,49 @@ socksetup(int af, char *bindhostname) * this, we can skip the bind() step so that the * system will choose a port for us. */ - if (!NoBind) { - if (bind(*s, r->ai_addr, r->ai_addrlen) < 0) { + if (NoBind == 0) { + if (bind(s, res->ai_addr, res->ai_addrlen) < 0) { logerror("bind"); - close(*s); + close(s); + error++; continue; } - - if (!SecureMode) - increase_rcvbuf(*s); + if (SecureMode == 0) + increase_rcvbuf(s); } - - (*socks)++; - dprintf("socksetup: new socket fd is %d\n", *s); - s++; + if (res->ai_family == AF_LOCAL && + chmod(pe->pe_name, pe->pe_mode) < 0) { + dprintf("chmod %s: %s\n", pe->pe_name, + strerror(errno)); + close(s); + error++; + continue; + } + dprintf("new socket fd is %d\n", s); + listen(s, 5); + dprintf("shutdown\n"); + if (SecureMode) { + /* Forbid communication in secure mode. */ + if (shutdown(s, SHUT_RD) < 0 && + errno != ENOTCONN) { + logerror("shutdown"); + if (!Debug) + die(0); + } + dprintf("listening on inet socket\n"); + } else + dprintf("sending on inet socket\n"); + sl = calloc(1, sizeof(*sl)); + if (sl == NULL) + err(1, "malloc failed"); + sl->sl_socket = s; + memcpy(&sl->sl_ss, res->ai_addr, res->ai_addrlen); + sl->sl_peer = pe; + STAILQ_INSERT_TAIL(&shead, sl, next); } + freeaddrinfo(res0); - if (*socks == 0) { - free(socks); - if (Debug) - return (NULL); - else - die(0); - } - if (res) - freeaddrinfo(res); - - return (socks); + return (error); } static void From 71ef4d586ac7d29d2054ec6d4c68ca784c80332d Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 19:10:39 +0000 Subject: [PATCH 067/226] Now that these variables do not contain the --default-item flag itself, change the name of the variable from $def_item_... to $default_... --- usr.sbin/bsdinstall/scripts/wlanconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 34a3a6da0cb..22f68da22a5 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -81,8 +81,8 @@ dialog_country_select() { local input regdomains countries regdomain country local no_default="" - local def_item_regdomain="${1:-$no_default}" - local def_item_country="${2:-$no_default}" + local default_regdomain="${1:-$no_default}" + local default_country="${2:-$no_default}" # # Parse available countries/regdomains @@ -112,7 +112,7 @@ dialog_country_select() --backtitle \"$DIALOG_BACKTITLE\" \ --title \"Regdomain selection\" \ --cancel-label \"Skip\" \ - --default-item \"$def_item_regdomain\" \ + --default-item \"$default_regdomain\" \ --no-items \ --stdout \ --menu \"Select your regdomain.\" \ @@ -126,7 +126,7 @@ dialog_country_select() --backtitle \"$DIALOG_BACKTITLE\" \ --title \"Country selection\" \ --cancel-label \"Skip\" \ - --default-item \"$def_item_country\" \ + --default-item \"$default_country\" \ --stdout \ --menu \"Select your country.\" \ $height $width $rows $countries" From e3d4c4dcdecc057c1e53156d7513a9d88cca56ea Mon Sep 17 00:00:00 2001 From: Edward Tomasz Napierala Date: Mon, 12 Dec 2016 19:11:04 +0000 Subject: [PATCH 068/226] Undo r309891. Konstantin is right in that this condition normally cannot happen - the um_dev field is assigned at mount and never written to afterwards. --- sys/kern/kern_conf.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 381540574d3..ea68a6dea9a 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -1230,9 +1230,6 @@ const char * devtoname(struct cdev *dev) { - if (dev == NULL) - return (NULL); - return (dev->si_name); } From 0e638f57e6499160fe8c6b81791171339e1be5b7 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 19:12:31 +0000 Subject: [PATCH 069/226] If you're not going to make use of the products of a match() in awk (e.g., RSTART and RLENGTH variables) then use ~ instead of match() --- usr.sbin/bsdinstall/scripts/wlanconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 22f68da22a5..d4ab8a19c9b 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -95,8 +95,8 @@ dialog_country_select() sub(/Regulatory.*/, "") for (i = 1; i <= NF; i++) { printf "%s", $i - if (match($i, /[[:lower:]]/)) - if (match($(i+1), /[[:lower:]]/)) + if ($i ~ /[[:lower:]]/) + if ($(i+1) ~ /[[:lower:]]/) printf "\\\\\\ " else printf "\n" From 25e578de557c0af8622271415bbcf2ba6f0159f0 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Mon, 12 Dec 2016 19:16:35 +0000 Subject: [PATCH 070/226] vfs: use vrefact in getcwd and fchdir --- sys/kern/vfs_cache.c | 4 ++-- sys/kern/vfs_syscalls.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index cb37bc3c210..827a019b4ab 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -2066,9 +2066,9 @@ kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg, u_int buflen, fdp = td->td_proc->p_fd; FILEDESC_SLOCK(fdp); cdir = fdp->fd_cdir; - VREF(cdir); + vrefact(cdir); rdir = fdp->fd_rdir; - VREF(rdir); + vrefact(rdir); FILEDESC_SUNLOCK(fdp); error = vn_fullpath1(td, cdir, rdir, tmpbuf, &bp, buflen); vrele(rdir); diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 922ad88839a..0b4af64e2d1 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -754,7 +754,7 @@ sys_fchdir(td, uap) if (error != 0) return (error); vp = fp->f_vnode; - VREF(vp); + vrefact(vp); fdrop(fp, td); vn_lock(vp, LK_SHARED | LK_RETRY); AUDIT_ARG_VNODE1(vp); From 7bcf4508be42c7c5695a25264b1563c16637504c Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 19:24:32 +0000 Subject: [PATCH 071/226] Use ternary operator --- usr.sbin/bsdinstall/scripts/wlanconfig | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index d4ab8a19c9b..4f74d8d2eb2 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -96,10 +96,7 @@ dialog_country_select() for (i = 1; i <= NF; i++) { printf "%s", $i if ($i ~ /[[:lower:]]/) - if ($(i+1) ~ /[[:lower:]]/) - printf "\\\\\\ " - else - printf "\n" + printf $(i+1) ~ /[[:lower:]]/ ? "\\\\\\ " : "\n" else printf " " } From 8555a6e0a474dfe5439c10d9b1e241aaa1cd9936 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Mon, 12 Dec 2016 19:24:52 +0000 Subject: [PATCH 072/226] Temporarily backout the previous commit because it was totally broken due to unresolved merge conflicts. Pointy hat to: hrs --- usr.sbin/syslogd/Makefile | 3 - usr.sbin/syslogd/syslogd.c | 796 +++++++++++++++++++------------------ 2 files changed, 417 insertions(+), 382 deletions(-) diff --git a/usr.sbin/syslogd/Makefile b/usr.sbin/syslogd/Makefile index ac9acbfcea9..716efbe7d59 100644 --- a/usr.sbin/syslogd/Makefile +++ b/usr.sbin/syslogd/Makefile @@ -13,9 +13,6 @@ LIBADD= util WARNS?= 3 -.if ${MK_INET_SUPPORT} != "no" -CFLAGS+= -DINET -.endif .if ${MK_INET6_SUPPORT} != "no" CFLAGS+= -DINET6 .endif diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index b324fb2e383..50553d14206 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -88,6 +88,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -115,60 +116,43 @@ __FBSDID("$FreeBSD$"); #define SYSLOG_NAMES #include -static const char *ConfFile = _PATH_LOGCONF; -static const char *PidFile = _PATH_LOGPID; -static const char ctty[] = _PATH_CONSOLE; -static const char include_str[] = "include"; -static const char include_ext[] = ".conf"; +const char *ConfFile = _PATH_LOGCONF; +const char *PidFile = _PATH_LOGPID; +const char ctty[] = _PATH_CONSOLE; +static const char include_str[] = "include"; +static const char include_ext[] = ".conf"; #define dprintf if (Debug) printf #define MAXUNAMES 20 /* maximum number of user names */ -#define sstosa(ss) ((struct sockaddr *)(ss)) -#ifdef INET -#define satosin(sa) ((struct sockaddr_in *)(void *)(sa)) -#endif -#ifdef INET6 -#define satosin6(sa) ((struct sockaddr_in6 *)(void *)(sa)) -#define s6_addr32 __u6_addr.__u6_addr32 -#define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \ - (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \ - (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \ - (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \ - (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 ) -#endif /* - * List of peers and sockets for binding. + * List of hosts for binding. */ -struct peer { - const char *pe_name; - const char *pe_serv; - mode_t pe_mode; - STAILQ_ENTRY(peer) next; +static STAILQ_HEAD(, host) hqueue; +struct host { + char *name; + STAILQ_ENTRY(host) next; }; -struct socklist { - struct sockaddr_storage sl_ss; - int sl_socket; - struct peer *sl_peer; - STAILQ_ENTRY(socklist) next; -}; -static STAILQ_HEAD(, socklist) shead = STAILQ_HEAD_INITIALIZER(shead); -static struct peer funix_secure = { - .pe_name = _PATH_LOG_PRIV, - .pe_mode = S_IRUSR | S_IWUSR, - .next = {NULL}, -}; -static struct peer funix_default = { - .pe_name = _PATH_LOG, - .pe_mode = DEFFILEMODE, - .next = {&funix_secure}, -}; -static STAILQ_HEAD(, peer) pqueue = { - &funix_default, - &funix_secure.next.stqe_next, +/* + * Unix sockets. + * We have two default sockets, one with 666 permissions, + * and one for privileged programs. + */ +struct funix { + int s; + const char *name; + mode_t mode; + STAILQ_ENTRY(funix) next; }; +struct funix funix_secure = { -1, _PATH_LOG_PRIV, S_IRUSR | S_IWUSR, + { NULL } }; +struct funix funix_default = { -1, _PATH_LOG, DEFFILEMODE, + { &funix_secure } }; + +STAILQ_HEAD(, funix) funixes = { &funix_default, + &(funix_secure.next.stqe_next) }; /* * Flags to logmsg(). @@ -188,7 +172,7 @@ static STAILQ_HEAD(, peer) pqueue = { */ struct filed { - STAILQ_ENTRY(filed) next; /* next in linked list */ + struct filed *f_next; /* next in linked list */ short f_type; /* entry type, see below */ short f_file; /* file descriptor */ time_t f_time; /* time this was last written */ @@ -212,12 +196,6 @@ struct filed { pid_t f_pid; } f_pipe; } f_un; -#define fu_uname f_un.f_uname -#define fu_forw_hname f_un.f_forw.f_hname -#define fu_forw_addr f_un.f_forw.f_addr -#define fu_fname f_un.f_fname -#define fu_pipe_pname f_un.f_pipe.f_pname -#define fu_pipe_pid f_un.f_pipe.f_pid char f_prevline[MAXSVLINE]; /* last message logged */ char f_lasttime[16]; /* time of last occurrence */ char f_prevhost[MAXHOSTNAMELEN]; /* host from which recd. */ @@ -233,12 +211,15 @@ struct filed { /* * Queue of about-to-be dead processes we should watch out for. */ + +TAILQ_HEAD(stailhead, deadq_entry) deadq_head; +struct stailhead *deadq_headp; + struct deadq_entry { pid_t dq_pid; int dq_timeout; TAILQ_ENTRY(deadq_entry) dq_entries; }; -static TAILQ_HEAD(, deadq_entry) deadq_head; /* * The timeout to apply to processes waiting on the dead queue. Unit @@ -268,9 +249,7 @@ struct allowedpeer { #define a_addr u.numeric.addr #define a_mask u.numeric.mask #define a_name u.name - STAILQ_ENTRY(allowedpeer) next; }; -static STAILQ_HEAD(, allowedpeer) aphead = STAILQ_HEAD_INITIALIZER(aphead); /* @@ -278,7 +257,7 @@ static STAILQ_HEAD(, allowedpeer) aphead = STAILQ_HEAD_INITIALIZER(aphead); * in seconds after previous message is logged. After each flush, * we move to the next interval until we reach the largest. */ -static int repeatinterval[] = { 30, 120, 600 }; /* # of secs before flush */ +int repeatinterval[] = { 30, 120, 600 }; /* # of secs before flush */ #define MAXREPEAT ((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1) #define REPEATTIME(f) ((f)->f_time + repeatinterval[(f)->f_repeatcount]) #define BACKOFF(f) { if (++(f)->f_repeatcount > MAXREPEAT) \ @@ -295,13 +274,12 @@ static int repeatinterval[] = { 30, 120, 600 }; /* # of secs before flush */ #define F_WALL 6 /* everyone logged on */ #define F_PIPE 7 /* pipe to program */ -static const char *TypeNames[8] = { +const char *TypeNames[8] = { "UNUSED", "FILE", "TTY", "CONSOLE", "FORW", "USERS", "WALL", "PIPE" }; -static STAILQ_HEAD(, filed) fhead = - STAILQ_HEAD_INITIALIZER(fhead); /* Log files that we write to */ +static struct filed *Files; /* Log files that we write to */ static struct filed consfile; /* Console */ static int Debug; /* debug flag */ @@ -309,6 +287,7 @@ static int Foreground = 0; /* Run in foreground, instead of daemonizing */ static int resolve = 1; /* resolve hostname */ static char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */ static const char *LocalDomain; /* our local domain name */ +static int *finet; /* Internet datagram sockets */ static int fklog = -1; /* /dev/klog */ static int Initialized; /* set when we have initialized ourselves */ static int MarkInterval = 20 * 60; /* interval between marks in seconds */ @@ -328,6 +307,8 @@ static int logflags = O_WRONLY|O_APPEND; /* flags used to open log files */ static char bootfile[MAXLINE+1]; /* booted kernel file */ +struct allowedpeer *AllowedPeers; /* List of allowed peers */ +static int NumAllowed; /* Number of entries in AllowedPeers */ static int RemoteAddDate; /* Always set the date on remote messages */ static int UniquePriority; /* Only log specified priority? */ @@ -337,7 +318,7 @@ static int KeepKernFac; /* Keep remotely logged kernel facility */ static int needdofsync = 0; /* Are any file(s) waiting to be fsynced? */ static struct pidfh *pfh; -static volatile sig_atomic_t MarkSet, WantDie; +volatile sig_atomic_t MarkSet, WantDie; static int allowaddr(char *); static void cfline(const char *, struct filed *, @@ -351,7 +332,7 @@ static void dodie(int); static void dofsync(void); static void domark(int); static void fprintlog(struct filed *, int, const char *); -static int socksetup(struct peer *); +static int *socksetup(int, char *); static void init(int); static void logerror(const char *); static void logmsg(int, const char *, const char *, int); @@ -387,30 +368,31 @@ close_filed(struct filed *f) int main(int argc, char *argv[]) { - int ch, i, fdsrmax = 0; - struct sockaddr_storage ss; + int ch, i, fdsrmax = 0, l; + struct sockaddr_un sunx, fromunix; + struct sockaddr_storage frominet; fd_set *fdsr = NULL; char line[MAXLINE + 1]; const char *hname; struct timeval tv, *tvp; struct sigaction sact; - struct peer *pe; - struct socklist *sl; + struct host *host; + struct funix *fx, *fx1; sigset_t mask; pid_t ppid = 1, spid; - socklen_t sslen; + socklen_t len; if (madvise(NULL, 0, MADV_PROTECT) != 0) dprintf("madvise() failed: %s\n", strerror(errno)); + STAILQ_INIT(&hqueue); + while ((ch = getopt(argc, argv, "468Aa:b:cCdf:Fkl:m:nNop:P:sS:Tuv")) != -1) switch (ch) { -#ifdef INET case '4': family = PF_INET; break; -#endif #ifdef INET6 case '6': family = PF_INET6; @@ -427,12 +409,13 @@ main(int argc, char *argv[]) usage(); break; case 'b': - if ((pe = calloc(1, sizeof(*pe))) == NULL) + { + if ((host = malloc(sizeof(struct host))) == NULL) err(1, "malloc failed"); - pe->pe_name = optarg; - pe->pe_serv = NULL; - STAILQ_INSERT_TAIL(&pqueue, pe, next); + host->name = optarg; + STAILQ_INSERT_TAIL(&hqueue, host, next); break; + } case 'c': no_compress++; break; @@ -475,12 +458,17 @@ main(int argc, char *argv[]) } else errx(1, "invalid mode %s, exiting", optarg); - } - if ((pe = calloc(1, sizeof(*pe))) == NULL) + } else /* doesn't begin with '/', and no ':' */ + errx(1, "can't parse path %s", optarg); + + if (strlen(name) >= sizeof(sunx.sun_path)) + errx(1, "%s path too long, exiting", name); + if ((fx = malloc(sizeof(struct funix))) == NULL) err(1, "malloc failed"); - pe->pe_name = name; - pe->pe_mode = mode; - STAILQ_INSERT_TAIL(&pqueue, pe, next); + fx->s = -1; + fx->name = name; + fx->mode = mode; + STAILQ_INSERT_TAIL(&funixes, fx, next); break; } case 'm': /* mark interval */ @@ -497,7 +485,9 @@ main(int argc, char *argv[]) use_bootfile = 1; break; case 'p': /* path */ - funix_default.pe_name = optarg; + if (strlen(optarg) >= sizeof(sunx.sun_path)) + errx(1, "%s path too long, exiting", optarg); + funix_default.name = optarg; break; case 'P': /* path for alt. PID */ PidFile = optarg; @@ -506,7 +496,9 @@ main(int argc, char *argv[]) SecureMode++; break; case 'S': /* path for privileged originator */ - funix_secure.pe_name = optarg; + if (strlen(optarg) >= sizeof(sunx.sun_path)) + errx(1, "%s path too long, exiting", optarg); + funix_secure.name = optarg; break; case 'T': RemoteAddDate = 1; @@ -522,8 +514,6 @@ main(int argc, char *argv[]) } if ((argc -= optind) != 0) usage(); - STAILQ_FOREACH(pe, &pqueue, next) - socksetup(pe); pfh = pidfile_open(PidFile, 0600, &spid); if (pfh == NULL) { @@ -539,12 +529,16 @@ main(int argc, char *argv[]) pidfile_remove(pfh); exit(1); } - } else if (Debug) + } else if (Debug) { setlinebuf(stdout); + } + + if (NumAllowed) + endservent(); consfile.f_type = F_CONSOLE; - (void)strlcpy(consfile.fu_fname, ctty + sizeof _PATH_DEV - 1, - sizeof(consfile.fu_fname)); + (void)strlcpy(consfile.f_un.f_fname, ctty + sizeof _PATH_DEV - 1, + sizeof(consfile.f_un.f_fname)); (void)strlcpy(bootfile, getbootfile(), sizeof(bootfile)); (void)signal(SIGTERM, dodie); (void)signal(SIGINT, Debug ? dodie : SIG_IGN); @@ -567,6 +561,69 @@ main(int argc, char *argv[]) TAILQ_INIT(&deadq_head); +#ifndef SUN_LEN +#define SUN_LEN(unp) (strlen((unp)->sun_path) + 2) +#endif + STAILQ_FOREACH_SAFE(fx, &funixes, next, fx1) { + (void)unlink(fx->name); + memset(&sunx, 0, sizeof(sunx)); + sunx.sun_family = AF_LOCAL; + (void)strlcpy(sunx.sun_path, fx->name, sizeof(sunx.sun_path)); + fx->s = socket(PF_LOCAL, SOCK_DGRAM, 0); + if (fx->s < 0 || + bind(fx->s, (struct sockaddr *)&sunx, SUN_LEN(&sunx)) < 0 || + chmod(fx->name, fx->mode) < 0) { + (void)snprintf(line, sizeof line, + "cannot create %s", fx->name); + logerror(line); + dprintf("cannot create %s (%d)\n", fx->name, errno); + if (fx == &funix_default || fx == &funix_secure) + die(0); + else { + STAILQ_REMOVE(&funixes, fx, funix, next); + continue; + } + } + increase_rcvbuf(fx->s); + } + if (SecureMode <= 1) { + if (STAILQ_EMPTY(&hqueue)) + finet = socksetup(family, NULL); + STAILQ_FOREACH(host, &hqueue, next) { + int *finet0, total; + finet0 = socksetup(family, host->name); + if (finet0 && !finet) { + finet = finet0; + } else if (finet0 && finet) { + total = *finet0 + *finet + 1; + finet = realloc(finet, total * sizeof(int)); + if (finet == NULL) + err(1, "realloc failed"); + for (i = 1; i <= *finet0; i++) { + finet[(*finet)+i] = finet0[i]; + } + *finet = total - 1; + free(finet0); + } + } + } + + if (finet) { + if (SecureMode) { + for (i = 0; i < *finet; i++) { + if (shutdown(finet[i+1], SHUT_RD) < 0 && + errno != ENOTCONN) { + logerror("shutdown"); + if (!Debug) + die(0); + } + } + } else { + dprintf("listening on inet and/or inet6 socket\n"); + } + dprintf("sending on inet and/or inet6 socket\n"); + } + if ((fklog = open(_PATH_KLOG, O_RDONLY|O_NONBLOCK, 0)) < 0) dprintf("can't open %s (%d)\n", _PATH_KLOG, errno); @@ -589,10 +646,15 @@ main(int argc, char *argv[]) if (fklog != -1 && fklog > fdsrmax) fdsrmax = fklog; - STAILQ_FOREACH(sl, &shead, next) { - if (sl->sl_socket > fdsrmax) - fdsrmax = sl->sl_socket; + if (finet && !SecureMode) { + for (i = 0; i < *finet; i++) { + if (finet[i+1] != -1 && finet[i+1] > fdsrmax) + fdsrmax = finet[i+1]; + } } + STAILQ_FOREACH(fx, &funixes, next) + if (fx->s > fdsrmax) + fdsrmax = fx->s; fdsr = (fd_set *)calloc(howmany(fdsrmax+1, NFDBITS), sizeof(fd_mask)); @@ -610,11 +672,16 @@ main(int argc, char *argv[]) if (fklog != -1) FD_SET(fklog, fdsr); - STAILQ_FOREACH(sl, &shead, next) { - if (sl->sl_socket != -1) - FD_SET(sl->sl_socket, fdsr); + if (finet && !SecureMode) { + for (i = 0; i < *finet; i++) { + if (finet[i+1] != -1) + FD_SET(finet[i+1], fdsr); + } } - i = select(fdsrmax + 1, fdsr, NULL, NULL, + STAILQ_FOREACH(fx, &funixes, next) + FD_SET(fx->s, fdsr); + + i = select(fdsrmax+1, fdsr, NULL, NULL, needdofsync ? &tv : tvp); switch (i) { case 0: @@ -633,40 +700,34 @@ main(int argc, char *argv[]) } if (fklog != -1 && FD_ISSET(fklog, fdsr)) readklog(); - STAILQ_FOREACH(sl, &shead, next) { - int date, len; - - if (FD_ISSET(sl->sl_socket, fdsr)) { - sslen = sizeof(ss); - dprintf("sslen(1) = %d\n", sslen); - len = recvfrom(sl->sl_socket, line, - sizeof(line) - 1, 0, - sstosa(&ss), &sslen); - dprintf("sslen(2) = %d\n", sslen); - if (len == 0) - continue; - if (len < 0) { - if (errno != EINTR) - logerror("recvfrom"); - continue; + if (finet && !SecureMode) { + for (i = 0; i < *finet; i++) { + if (FD_ISSET(finet[i+1], fdsr)) { + len = sizeof(frominet); + l = recvfrom(finet[i+1], line, MAXLINE, + 0, (struct sockaddr *)&frominet, + &len); + if (l > 0) { + line[l] = '\0'; + hname = cvthname((struct sockaddr *)&frominet); + unmapped((struct sockaddr *)&frominet); + if (validate((struct sockaddr *)&frominet, hname)) + printline(hname, line, RemoteAddDate ? ADDDATE : 0); + } else if (l < 0 && errno != EINTR) + logerror("recvfrom inet"); } - /* Received valid data. */ - line[len] = '\0'; - if (sl->sl_ss.ss_family == AF_LOCAL) { - hname = LocalHostName; - date = 0; - } else { - hname = cvthname(sstosa(&ss)); - unmapped(sstosa(&ss)); - if (validate(sstosa(&ss), hname) == 0) - hname = NULL; - date = RemoteAddDate ? ADDDATE : 0; - } - if (hname != NULL) - printline(hname, line, date); - else - dprintf("Invalid msg from " - "%s was ignored.", hname); + } + } + STAILQ_FOREACH(fx, &funixes, next) { + if (FD_ISSET(fx->s, fdsr)) { + len = sizeof(fromunix); + l = recvfrom(fx->s, line, MAXLINE, 0, + (struct sockaddr *)&fromunix, &len); + if (l > 0) { + line[l] = '\0'; + printline(LocalHostName, line, 0); + } else if (l < 0 && errno != EINTR) + logerror("recvfrom unix"); } } } @@ -674,36 +735,30 @@ main(int argc, char *argv[]) free(fdsr); } -#ifdef INET6 static void unmapped(struct sockaddr *sa) { struct sockaddr_in6 *sin6; struct sockaddr_in sin4; - if (sa == NULL || - sa->sa_family != AF_INET6 || - sa->sa_len != sizeof(*sin6)) + if (sa->sa_family != AF_INET6) return; - sin6 = satosin6(sa); + if (sa->sa_len != sizeof(struct sockaddr_in6) || + sizeof(sin4) > sa->sa_len) + return; + sin6 = (struct sockaddr_in6 *)sa; if (!IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) return; memset(&sin4, 0, sizeof(sin4)); sin4.sin_family = AF_INET; - sin4.sin_len = sizeof(sin4); + sin4.sin_len = sizeof(struct sockaddr_in); memcpy(&sin4.sin_addr, &sin6->sin6_addr.s6_addr[12], sizeof(sin4.sin_addr)); sin4.sin_port = sin6->sin6_port; memcpy(sa, &sin4, sin4.sin_len); } -#else -static void -unmapped(struct sockaddr *sa __unused) -{ -} -#endif static void usage(void) @@ -988,7 +1043,7 @@ logmsg(int pri, const char *msg, const char *from, int flags) (void)sigsetmask(omask); return; } - STAILQ_FOREACH(f, &fhead, next) { + for (f = Files; f; f = f->f_next) { /* skip messages that are incorrect priority */ if (!(((f->f_pcmp[fac] & PRI_EQ) && (f->f_pmask[fac] == prilev)) ||((f->f_pcmp[fac] & PRI_LT) && (f->f_pmask[fac] < prilev)) @@ -1065,7 +1120,7 @@ dofsync(void) { struct filed *f; - STAILQ_FOREACH(f, &fhead, next) { + for (f = Files; f; f = f->f_next) { if ((f->f_type == F_FILE) && (f->f_flags & FFLAG_NEEDSYNC)) { f->f_flags &= ~FFLAG_NEEDSYNC; @@ -1081,7 +1136,7 @@ fprintlog(struct filed *f, int flags, const char *msg) struct iovec iov[IOV_SIZE]; struct iovec *v; struct addrinfo *r; - int l, lsent = 0; + int i, l, lsent = 0; char line[MAXLINE + 1], repbuf[80], greetings[200], *wmsg = NULL; char nul[] = "", space[] = " ", lf[] = "\n", crlf[] = "\r\n"; const char *msgret; @@ -1189,11 +1244,12 @@ fprintlog(struct filed *f, int flags, const char *msg) break; case F_FORW: - port = ntohs(satosin(f->fu_forw_addr->ai_addr)->sin_port); + port = (int)ntohs(((struct sockaddr_in *) + (f->f_un.f_forw.f_addr->ai_addr))->sin_port); if (port != 514) { - dprintf(" %s:%d\n", f->fu_forw_hname, port); + dprintf(" %s:%d\n", f->f_un.f_forw.f_hname, port); } else { - dprintf(" %s\n", f->fu_forw_hname); + dprintf(" %s\n", f->f_un.f_forw.f_hname); } /* check for local vs remote messages */ if (strcasecmp(f->f_prevhost, LocalHostName)) @@ -1210,51 +1266,57 @@ fprintlog(struct filed *f, int flags, const char *msg) else if (l > MAXLINE) l = MAXLINE; - for (r = f->fu_forw_addr; r; r = r->ai_next) { - struct socklist *sl; - - STAILQ_FOREACH(sl, &shead, next) { - if (sl->sl_ss.ss_family == AF_LOCAL) - continue; - lsent = sendto(sl->sl_socket, line, l, 0, - r->ai_addr, r->ai_addrlen); - if (lsent == l) + if (finet) { + for (r = f->f_un.f_forw.f_addr; r; r = r->ai_next) { + for (i = 0; i < *finet; i++) { +#if 0 + /* + * should we check AF first, or just + * trial and error? FWD + */ + if (r->ai_family == + address_family_of(finet[i+1])) +#endif + lsent = sendto(finet[i+1], line, l, 0, + r->ai_addr, r->ai_addrlen); + if (lsent == l) + break; + } + if (lsent == l && !send_to_all) break; } - if (lsent == l && !send_to_all) - break; - } - dprintf("lsent/l: %d/%d\n", lsent, l); - if (lsent != l) { - int e = errno; - logerror("sendto"); - errno = e; - switch (errno) { - case ENOBUFS: - case ENETDOWN: - case ENETUNREACH: - case EHOSTUNREACH: - case EHOSTDOWN: - case EADDRNOTAVAIL: - break; - /* case EBADF: */ - /* case EACCES: */ - /* case ENOTSOCK: */ - /* case EFAULT: */ - /* case EMSGSIZE: */ - /* case EAGAIN: */ - /* case ENOBUFS: */ - /* case ECONNREFUSED: */ - default: - dprintf("removing entry: errno=%d\n", e); - f->f_type = F_UNUSED; - break; + dprintf("lsent/l: %d/%d\n", lsent, l); + if (lsent != l) { + int e = errno; + logerror("sendto"); + errno = e; + switch (errno) { + case ENOBUFS: + case ENETDOWN: + case ENETUNREACH: + case EHOSTUNREACH: + case EHOSTDOWN: + case EADDRNOTAVAIL: + break; + /* case EBADF: */ + /* case EACCES: */ + /* case ENOTSOCK: */ + /* case EFAULT: */ + /* case EMSGSIZE: */ + /* case EAGAIN: */ + /* case ENOBUFS: */ + /* case ECONNREFUSED: */ + default: + dprintf("removing entry: errno=%d\n", e); + f->f_type = F_UNUSED; + break; + } } } break; case F_FILE: - dprintf(" %s\n", f->fu_fname); + dprintf(" %s\n", f->f_un.f_fname); v->iov_base = lf; v->iov_len = 1; if (writev(f->f_file, iov, IOV_SIZE) < 0) { @@ -1267,7 +1329,7 @@ fprintlog(struct filed *f, int flags, const char *msg) int e = errno; close_filed(f); errno = e; - logerror(f->fu_fname); + logerror(f->f_un.f_fname); } } else if ((flags & SYNC_FILE) && (f->f_flags & FFLAG_SYNC)) { f->f_flags |= FFLAG_NEEDSYNC; @@ -1276,26 +1338,26 @@ fprintlog(struct filed *f, int flags, const char *msg) break; case F_PIPE: - dprintf(" %s\n", f->fu_pipe_pname); + dprintf(" %s\n", f->f_un.f_pipe.f_pname); v->iov_base = lf; v->iov_len = 1; - if (f->fu_pipe_pid == 0) { - if ((f->f_file = p_open(f->fu_pipe_pname, - &f->fu_pipe_pid)) < 0) { + if (f->f_un.f_pipe.f_pid == 0) { + if ((f->f_file = p_open(f->f_un.f_pipe.f_pname, + &f->f_un.f_pipe.f_pid)) < 0) { f->f_type = F_UNUSED; - logerror(f->fu_pipe_pname); + logerror(f->f_un.f_pipe.f_pname); break; } } if (writev(f->f_file, iov, IOV_SIZE) < 0) { int e = errno; close_filed(f); - if (f->fu_pipe_pid > 0) - deadq_enter(f->fu_pipe_pid, - f->fu_pipe_pname); - f->fu_pipe_pid = 0; + if (f->f_un.f_pipe.f_pid > 0) + deadq_enter(f->f_un.f_pipe.f_pid, + f->f_un.f_pipe.f_pname); + f->f_un.f_pipe.f_pid = 0; errno = e; - logerror(f->fu_pipe_pname); + logerror(f->f_un.f_pipe.f_pname); } break; @@ -1307,12 +1369,12 @@ fprintlog(struct filed *f, int flags, const char *msg) /* FALLTHROUGH */ case F_TTY: - dprintf(" %s%s\n", _PATH_DEV, f->fu_fname); + dprintf(" %s%s\n", _PATH_DEV, f->f_un.f_fname); v->iov_base = crlf; v->iov_len = 2; errno = 0; /* ttymsg() only sometimes returns an errno */ - if ((msgret = ttymsg(iov, IOV_SIZE, f->fu_fname, 10))) { + if ((msgret = ttymsg(iov, IOV_SIZE, f->f_un.f_fname, 10))) { f->f_type = F_UNUSED; logerror(msgret); } @@ -1361,9 +1423,9 @@ wallmsg(struct filed *f, struct iovec *iov, const int iovlen) } /* should we send the message to this user? */ for (i = 0; i < MAXUNAMES; i++) { - if (!f->fu_uname[i][0]) + if (!f->f_un.f_uname[i][0]) break; - if (!strcmp(f->fu_uname[i], ut->ut_user)) { + if (!strcmp(f->f_un.f_uname[i], ut->ut_user)) { if ((p = ttymsg_check(iov, iovlen, ut->ut_line, TTYMSGTIME)) != NULL) { errno = 0; /* already in msg */ @@ -1414,18 +1476,20 @@ reapchild(int signo __unused) /* First, look if it's a process from the dead queue. */ if (deadq_remove(pid)) - continue; + goto oncemore; /* Now, look in list of active processes. */ - STAILQ_FOREACH(f, &fhead, next) { + for (f = Files; f; f = f->f_next) if (f->f_type == F_PIPE && - f->fu_pipe_pid == pid) { + f->f_un.f_pipe.f_pid == pid) { close_filed(f); - f->fu_pipe_pid = 0; - log_deadchild(pid, status, f->fu_pipe_pname); + f->f_un.f_pipe.f_pid = 0; + log_deadchild(pid, status, + f->f_un.f_pipe.f_pname); break; } - } + oncemore: + continue; } } @@ -1439,9 +1503,9 @@ cvthname(struct sockaddr *f) sigset_t omask, nmask; static char hname[NI_MAXHOST], ip[NI_MAXHOST]; - dprintf("cvthname(%d) len = %d, %zu\n", f->sa_family, f->sa_len, sizeof(struct sockaddr_in6)); - error = getnameinfo(f, f->sa_len, ip, sizeof(ip), NULL, 0, - NI_NUMERICHOST); + error = getnameinfo((struct sockaddr *)f, + ((struct sockaddr *)f)->sa_len, + ip, sizeof ip, NULL, 0, NI_NUMERICHOST); dprintf("cvthname(%s)\n", ip); if (error) { @@ -1511,19 +1575,19 @@ static void die(int signo) { struct filed *f; - struct socklist *sl; + struct funix *fx; int was_initialized; char buf[100]; was_initialized = Initialized; Initialized = 0; /* Don't log SIGCHLDs. */ - STAILQ_FOREACH(f, &fhead, next) { + for (f = Files; f != NULL; f = f->f_next) { /* flush any pending output */ if (f->f_prevcount) fprintlog(f, 0, (char *)NULL); - if (f->f_type == F_PIPE && f->fu_pipe_pid > 0) { + if (f->f_type == F_PIPE && f->f_un.f_pipe.f_pid > 0) { close_filed(f); - f->fu_pipe_pid = 0; + f->f_un.f_pipe.f_pid = 0; } } Initialized = was_initialized; @@ -1533,10 +1597,8 @@ die(int signo) errno = 0; logerror(buf); } - STAILQ_FOREACH(sl, &shead, next) { - if (sl->sl_ss.ss_family == AF_LOCAL) - unlink(sl->sl_peer->pe_name); - } + STAILQ_FOREACH(fx, &funixes, next) + (void)unlink(fx->name); pidfile_remove(pfh); exit(1); @@ -1564,7 +1626,7 @@ configfiles(const struct dirent *dp) } static void -readconfigfile(FILE *cf, int allow_includes) +readconfigfile(FILE *cf, struct filed **nextp, int allow_includes) { FILE *cf2; struct filed *f; @@ -1624,7 +1686,7 @@ readconfigfile(FILE *cf, int allow_includes) if (cf2 == NULL) continue; dprintf("reading %s\n", file); - readconfigfile(cf2, 0); + readconfigfile(cf2, nextp, 0); fclose(cf2); } free(ent); @@ -1687,7 +1749,8 @@ readconfigfile(FILE *cf, int allow_includes) logerror("calloc"); exit(1); } - STAILQ_INSERT_TAIL(&fhead, f, next); + *nextp = f; + nextp = &f->f_next; cfline(cline, f, prog, host); } } @@ -1700,7 +1763,7 @@ init(int signo) { int i; FILE *cf; - struct filed *f; + struct filed *f, *next, **nextp; char *p; char oldLocalHostName[MAXHOSTNAMELEN]; char hostMsg[2*MAXHOSTNAMELEN+40]; @@ -1745,7 +1808,7 @@ init(int signo) * Close all open log files. */ Initialized = 0; - STAILQ_FOREACH(f, &fhead, next) { + for (f = Files; f != NULL; f = next) { /* flush any pending output */ if (f->f_prevcount) fprintlog(f, 0, (char *)NULL); @@ -1758,48 +1821,42 @@ init(int signo) close_filed(f); break; case F_PIPE: - if (f->fu_pipe_pid > 0) { + if (f->f_un.f_pipe.f_pid > 0) { close_filed(f); - deadq_enter(f->fu_pipe_pid, - f->fu_pipe_pname); + deadq_enter(f->f_un.f_pipe.f_pid, + f->f_un.f_pipe.f_pname); } - f->fu_pipe_pid = 0; + f->f_un.f_pipe.f_pid = 0; break; } + next = f->f_next; + if (f->f_program) free(f->f_program); + if (f->f_host) free(f->f_host); + free((char *)f); } - while(!STAILQ_EMPTY(&fhead)) { - f = STAILQ_FIRST(&fhead); - STAILQ_REMOVE_HEAD(&fhead, next); - free(f->f_program); - free(f->f_host); - free(f); - } + Files = NULL; nextp = &Files; /* open the configuration file */ if ((cf = fopen(ConfFile, "r")) == NULL) { dprintf("cannot open %s\n", ConfFile); - f = calloc(1, sizeof(*f)); - if (f == NULL) { + *nextp = (struct filed *)calloc(1, sizeof(*f)); + if (*nextp == NULL) { logerror("calloc"); exit(1); } - cfline("*.ERR\t/dev/console", f, "*", "*"); - STAILQ_INSERT_TAIL(&fhead, f, next); - - f = calloc(1, sizeof(*f)); - if (f == NULL) { + cfline("*.ERR\t/dev/console", *nextp, "*", "*"); + (*nextp)->f_next = (struct filed *)calloc(1, sizeof(*f)); + if ((*nextp)->f_next == NULL) { logerror("calloc"); exit(1); } - cfline("*.PANIC\t*", f, "*", "*"); - STAILQ_INSERT_TAIL(&fhead, f, next); - + cfline("*.PANIC\t*", (*nextp)->f_next, "*", "*"); Initialized = 1; return; } - readconfigfile(cf, 1); + readconfigfile(cf, &Files, 1); /* close the configuration file */ (void)fclose(cf); @@ -1808,7 +1865,7 @@ init(int signo) if (Debug) { int port; - STAILQ_FOREACH(f, &fhead, next) { + for (f = Files; f; f = f->f_next) { for (i = 0; i <= LOG_NFACILITIES; i++) if (f->f_pmask[i] == INTERNAL_NOPRI) printf("X "); @@ -1817,31 +1874,32 @@ init(int signo) printf("%s: ", TypeNames[f->f_type]); switch (f->f_type) { case F_FILE: - printf("%s", f->fu_fname); + printf("%s", f->f_un.f_fname); break; case F_CONSOLE: case F_TTY: - printf("%s%s", _PATH_DEV, f->fu_fname); + printf("%s%s", _PATH_DEV, f->f_un.f_fname); break; case F_FORW: - port = ntohs(satosin(f->fu_forw_addr->ai_addr)->sin_port); + port = (int)ntohs(((struct sockaddr_in *) + (f->f_un.f_forw.f_addr->ai_addr))->sin_port); if (port != 514) { printf("%s:%d", - f->fu_forw_hname, port); + f->f_un.f_forw.f_hname, port); } else { - printf("%s", f->fu_forw_hname); + printf("%s", f->f_un.f_forw.f_hname); } break; case F_PIPE: - printf("%s", f->fu_pipe_pname); + printf("%s", f->f_un.f_pipe.f_pname); break; case F_USERS: - for (i = 0; i < MAXUNAMES && *f->fu_uname[i]; i++) - printf("%s, ", f->fu_uname[i]); + for (i = 0; i < MAXUNAMES && *f->f_un.f_uname[i]; i++) + printf("%s, ", f->f_un.f_uname[i]); break; } if (f->f_program) @@ -2046,8 +2104,8 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) * scan forward to see if there is a port defined. * so we can't use strlcpy.. */ - i = sizeof(f->fu_forw_hname); - tp = f->fu_forw_hname; + i = sizeof(f->f_un.f_forw.f_hname); + tp = f->f_un.f_forw.f_hname; p++; /* @@ -2074,13 +2132,13 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) memset(&hints, 0, sizeof(hints)); hints.ai_family = family; hints.ai_socktype = SOCK_DGRAM; - error = getaddrinfo(f->fu_forw_hname, + error = getaddrinfo(f->f_un.f_forw.f_hname, p ? p : "syslog", &hints, &res); if (error) { logerror(gai_strerror(error)); break; } - f->fu_forw_addr = res; + f->f_un.f_forw.f_addr = res; f->f_type = F_FORW; break; @@ -2097,18 +2155,18 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) f->f_type = F_CONSOLE; else f->f_type = F_TTY; - (void)strlcpy(f->fu_fname, p + sizeof(_PATH_DEV) - 1, - sizeof(f->fu_fname)); + (void)strlcpy(f->f_un.f_fname, p + sizeof(_PATH_DEV) - 1, + sizeof(f->f_un.f_fname)); } else { - (void)strlcpy(f->fu_fname, p, sizeof(f->fu_fname)); + (void)strlcpy(f->f_un.f_fname, p, sizeof(f->f_un.f_fname)); f->f_type = F_FILE; } break; case '|': - f->fu_pipe_pid = 0; - (void)strlcpy(f->fu_pipe_pname, p + 1, - sizeof(f->fu_pipe_pname)); + f->f_un.f_pipe.f_pid = 0; + (void)strlcpy(f->f_un.f_pipe.f_pname, p + 1, + sizeof(f->f_un.f_pipe.f_pname)); f->f_type = F_PIPE; break; @@ -2120,11 +2178,11 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) for (i = 0; i < MAXUNAMES && *p; i++) { for (q = p; *q && *q != ','; ) q++; - (void)strncpy(f->fu_uname[i], p, MAXLOGNAME - 1); + (void)strncpy(f->f_un.f_uname[i], p, MAXLOGNAME - 1); if ((q - p) >= MAXLOGNAME) - f->fu_uname[i][MAXLOGNAME - 1] = '\0'; + f->f_un.f_uname[i][MAXLOGNAME - 1] = '\0'; else - f->fu_uname[i][q - p] = '\0'; + f->f_un.f_uname[i][q - p] = '\0'; while (*q == ',' || *q == ' ') q++; p = q; @@ -2175,7 +2233,7 @@ markit(void) MarkSeq = 0; } - STAILQ_FOREACH(f, &fhead, next) { + for (f = Files; f; f = f->f_next) { if (f->f_prevcount && now >= REPEATTIME(f)) { dprintf("flush %s: repeated %d times, %d sec.\n", TypeNames[f->f_type], f->f_prevcount, @@ -2436,7 +2494,7 @@ allowaddr(char *s) } if (Debug) { - printf("allowaddr: rule "); + printf("allowaddr: rule %d: ", NumAllowed); if (ap.isnumeric) { printf("numeric, "); getnameinfo((struct sockaddr *)&ap.a_addr, @@ -2452,6 +2510,14 @@ allowaddr(char *s) } printf("port = %d\n", ap.port); } + + if ((AllowedPeers = realloc(AllowedPeers, + ++NumAllowed * sizeof(struct allowedpeer))) + == NULL) { + logerror("realloc"); + exit(1); + } + memcpy(&AllowedPeers[NumAllowed - 1], &ap, sizeof(struct allowedpeer)); return (0); } @@ -2467,17 +2533,13 @@ validate(struct sockaddr *sa, const char *hname) struct allowedpeer *ap; struct sockaddr_in *sin4, *a4p = NULL, *m4p = NULL; #ifdef INET6 - int reject; + int j, reject; struct sockaddr_in6 *sin6, *a6p = NULL, *m6p = NULL; #endif struct addrinfo hints, *res; u_short sport; - int num = 0; - STAILQ_FOREACH(ap, &aphead, next) - num++; - dprintf("# of validation rule: %d\n", num); - if (num == 0) + if (NumAllowed == 0) /* traditional behaviour, allow everything */ return (1); @@ -2492,7 +2554,7 @@ validate(struct sockaddr *sa, const char *hname) strlcat(name, ".", sizeof name); strlcat(name, LocalDomain, sizeof name); } - if (getnameinfo(sa, sa->sa_len, ip, sizeof(ip), port, sizeof(port), + if (getnameinfo(sa, sa->sa_len, ip, sizeof ip, port, sizeof port, NI_NUMERICHOST | NI_NUMERICSERV) != 0) return (0); /* for safety, should not occur */ dprintf("validate: dgram from IP %s, port %s, name %s;\n", @@ -2500,12 +2562,9 @@ validate(struct sockaddr *sa, const char *hname) sport = atoi(port); /* now, walk down the list */ - i = 0; - STAILQ_FOREACH(ap, &aphead, next) { - i++; + for (i = 0, ap = AllowedPeers; i < NumAllowed; i++, ap++) { if (ap->port != 0 && ap->port != sport) { - dprintf("rejected in rule %d due to port mismatch.\n", - i); + dprintf("rejected in rule %d due to port mismatch.\n", i); continue; } @@ -2515,9 +2574,9 @@ validate(struct sockaddr *sa, const char *hname) continue; } if (ap->a_addr.ss_family == AF_INET) { - sin4 = satosin(sa); - a4p = satosin(&ap->a_addr); - m4p = satosin(&ap->a_mask); + sin4 = (struct sockaddr_in *)sa; + a4p = (struct sockaddr_in *)&ap->a_addr; + m4p = (struct sockaddr_in *)&ap->a_mask; if ((sin4->sin_addr.s_addr & m4p->sin_addr.s_addr) != a4p->sin_addr.s_addr) { dprintf("rejected in rule %d due to IP mismatch.\n", i); @@ -2526,19 +2585,21 @@ validate(struct sockaddr *sa, const char *hname) } #ifdef INET6 else if (ap->a_addr.ss_family == AF_INET6) { - sin6 = satosin6(sa); - a6p = satosin6(&ap->a_addr); - m6p = satosin6(&ap->a_mask); + sin6 = (struct sockaddr_in6 *)sa; + a6p = (struct sockaddr_in6 *)&ap->a_addr; + m6p = (struct sockaddr_in6 *)&ap->a_mask; if (a6p->sin6_scope_id != 0 && sin6->sin6_scope_id != a6p->sin6_scope_id) { dprintf("rejected in rule %d due to scope mismatch.\n", i); continue; } reject = 0; - if (IN6_ARE_MASKED_ADDR_EQUAL(&sin6->sin6_addr, - &a6p->sin6_addr, &m6p->sin6_addr) != 0) { - ++reject; - break; + for (j = 0; j < 16; j += 4) { + if ((*(u_int32_t *)&sin6->sin6_addr.s6_addr[j] & *(u_int32_t *)&m6p->sin6_addr.s6_addr[j]) + != *(u_int32_t *)&a6p->sin6_addr.s6_addr[j]) { + ++reject; + break; + } } if (reject) { dprintf("rejected in rule %d due to IP mismatch.\n", i); @@ -2695,13 +2756,11 @@ deadq_remove(pid_t pid) dq_t q; TAILQ_FOREACH(q, &deadq_head, dq_entries) { - if (q->dq_pid == pid) - break; - } - if (q != NULL) { - TAILQ_REMOVE(&deadq_head, q, dq_entries); - free(q); - return (1); + if (q->dq_pid == pid) { + TAILQ_REMOVE(&deadq_head, q, dq_entries); + free(q); + return (1); + } } return (0); @@ -2730,90 +2789,85 @@ log_deadchild(pid_t pid, int status, const char *name) logerror(buf); } -static int -socksetup(struct peer *pe) +static int * +socksetup(int af, char *bindhostname) { - struct addrinfo hints, *res, *res0; - struct socklist *sl; - int error; + struct addrinfo hints, *res, *r; + const char *bindservice; char *cp; + int error, maxs, *s, *socks; + /* * We have to handle this case for backwards compatibility: * If there are two (or more) colons but no '[' and ']', * assume this is an inet6 address without a service. */ - if (pe->pe_name != NULL) { + bindservice = "syslog"; + if (bindhostname != NULL) { #ifdef INET6 - if (pe->pe_name[0] == '[' && - (cp = strchr(pe->pe_name + 1, ']')) != NULL) { - pe->pe_name = &pe->pe_name[1]; + if (*bindhostname == '[' && + (cp = strchr(bindhostname + 1, ']')) != NULL) { + ++bindhostname; *cp = '\0'; if (cp[1] == ':' && cp[2] != '\0') - pe->pe_serv = cp + 2; + bindservice = cp + 2; } else { #endif - cp = strchr(pe->pe_name, ':'); + cp = strchr(bindhostname, ':'); if (cp != NULL && strchr(cp + 1, ':') == NULL) { *cp = '\0'; if (cp[1] != '\0') - pe->pe_serv = cp + 1; - if (cp == pe->pe_name) - pe->pe_name = NULL; + bindservice = cp + 1; + if (cp == bindhostname) + bindhostname = NULL; } #ifdef INET6 } #endif } - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_DGRAM; - hints.ai_flags = AI_PASSIVE; - dprintf("Try %s\n", pe->pe_name); - if (pe->pe_serv == NULL) - pe->pe_serv = "syslog"; - error = getaddrinfo(pe->pe_name, pe->pe_serv, &hints, &res0); + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = AI_PASSIVE; + hints.ai_family = af; + hints.ai_socktype = SOCK_DGRAM; + error = getaddrinfo(bindhostname, bindservice, &hints, &res); if (error) { logerror(gai_strerror(error)); errno = 0; die(0); } - for (res = res0; res != NULL; res = res->ai_next) { - int s; + + /* Count max number of sockets we may open */ + for (maxs = 0, r = res; r; r = r->ai_next, maxs++); + socks = malloc((maxs+1) * sizeof(int)); + if (socks == NULL) { + logerror("couldn't allocate memory for sockets"); + die(0); + } + + *socks = 0; /* num of sockets counter at start of array */ + s = socks + 1; + for (r = res; r; r = r->ai_next) { int on = 1; - - if (res->ai_family == AF_LOCAL) - unlink(pe->pe_name); - else if (SecureMode > 1) { - /* Only AF_LOCAL in secure mode. */ - continue; - } - if (family != AF_UNSPEC && res->ai_family != family) - continue; - - s = socket(res->ai_family, res->ai_socktype, - res->ai_protocol); - if (s < 0) { + *s = socket(r->ai_family, r->ai_socktype, r->ai_protocol); + if (*s < 0) { logerror("socket"); - error++; continue; } #ifdef INET6 - if (res->ai_family == AF_INET6) { - if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, - (char *)&on, sizeof(on)) < 0) { - logerror("setsockopt(IPV6_V6ONLY)"); - close(s); - error++; + if (r->ai_family == AF_INET6) { + if (setsockopt(*s, IPPROTO_IPV6, IPV6_V6ONLY, + (char *)&on, sizeof (on)) < 0) { + logerror("setsockopt"); + close(*s); continue; } } #endif - if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, - (char *)&on, sizeof(on)) < 0) { - logerror("setsockopt(SO_REUSEADDR)"); - close(s); - error++; + if (setsockopt(*s, SOL_SOCKET, SO_REUSEADDR, + (char *)&on, sizeof (on)) < 0) { + logerror("setsockopt"); + close(*s); continue; } /* @@ -2824,49 +2878,33 @@ socksetup(struct peer *pe) * this, we can skip the bind() step so that the * system will choose a port for us. */ - if (NoBind == 0) { - if (bind(s, res->ai_addr, res->ai_addrlen) < 0) { + if (!NoBind) { + if (bind(*s, r->ai_addr, r->ai_addrlen) < 0) { logerror("bind"); - close(s); - error++; + close(*s); continue; } - if (SecureMode == 0) - increase_rcvbuf(s); - } - if (res->ai_family == AF_LOCAL && - chmod(pe->pe_name, pe->pe_mode) < 0) { - dprintf("chmod %s: %s\n", pe->pe_name, - strerror(errno)); - close(s); - error++; - continue; - } - dprintf("new socket fd is %d\n", s); - listen(s, 5); - dprintf("shutdown\n"); - if (SecureMode) { - /* Forbid communication in secure mode. */ - if (shutdown(s, SHUT_RD) < 0 && - errno != ENOTCONN) { - logerror("shutdown"); - if (!Debug) - die(0); - } - dprintf("listening on inet socket\n"); - } else - dprintf("sending on inet socket\n"); - sl = calloc(1, sizeof(*sl)); - if (sl == NULL) - err(1, "malloc failed"); - sl->sl_socket = s; - memcpy(&sl->sl_ss, res->ai_addr, res->ai_addrlen); - sl->sl_peer = pe; - STAILQ_INSERT_TAIL(&shead, sl, next); - } - freeaddrinfo(res0); - return (error); + if (!SecureMode) + increase_rcvbuf(*s); + } + + (*socks)++; + dprintf("socksetup: new socket fd is %d\n", *s); + s++; + } + + if (*socks == 0) { + free(socks); + if (Debug) + return (NULL); + else + die(0); + } + if (res) + freeaddrinfo(res); + + return (socks); } static void From 15fadc4858df936936a5d71b43ed4bbb3c8ef87a Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 19:26:55 +0000 Subject: [PATCH 073/226] Remove an unnecessary "return $?" at end of function --- usr.sbin/bsdinstall/scripts/wlanconfig | 2 -- 1 file changed, 2 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 4f74d8d2eb2..d4f0167fc91 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -130,8 +130,6 @@ dialog_country_select() ) country_set "$regdomain" "$country" - - return $? } ############################################################ MAIN From dc96a41b443340eed61473fe994402d63351c2c2 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Mon, 12 Dec 2016 19:33:40 +0000 Subject: [PATCH 074/226] - Refactor listening socket list. All of the listening sockets are now maintained in a single linked-list in a transport-independent manner. - Use queue.h for linked-list structure. - Use linked-list for AllowedPeers. - Use getaddrinfo(8) even for Unix Domain sockets. - Use macros to type-casting from/to struct sockaddr{,_in,_in6}. - Define fu_* macro for union f_un to shorten the member names. - Remove an extra #include . - Add "static" to non-exported symbols. - !INET support is still incomplete but will be fixed later. There is no functional change except for some minor debug messages. --- usr.sbin/syslogd/Makefile | 3 + usr.sbin/syslogd/syslogd.c | 791 ++++++++++++++++++------------------- 2 files changed, 379 insertions(+), 415 deletions(-) diff --git a/usr.sbin/syslogd/Makefile b/usr.sbin/syslogd/Makefile index 716efbe7d59..ac9acbfcea9 100644 --- a/usr.sbin/syslogd/Makefile +++ b/usr.sbin/syslogd/Makefile @@ -13,6 +13,9 @@ LIBADD= util WARNS?= 3 +.if ${MK_INET_SUPPORT} != "no" +CFLAGS+= -DINET +.endif .if ${MK_INET6_SUPPORT} != "no" CFLAGS+= -DINET6 .endif diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 50553d14206..53866382e3b 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -88,7 +88,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -116,43 +115,56 @@ __FBSDID("$FreeBSD$"); #define SYSLOG_NAMES #include -const char *ConfFile = _PATH_LOGCONF; -const char *PidFile = _PATH_LOGPID; -const char ctty[] = _PATH_CONSOLE; -static const char include_str[] = "include"; -static const char include_ext[] = ".conf"; +static const char *ConfFile = _PATH_LOGCONF; +static const char *PidFile = _PATH_LOGPID; +static const char ctty[] = _PATH_CONSOLE; +static const char include_str[] = "include"; +static const char include_ext[] = ".conf"; #define dprintf if (Debug) printf #define MAXUNAMES 20 /* maximum number of user names */ +#define sstosa(ss) ((struct sockaddr *)(ss)) +#define satosin6(sa) ((struct sockaddr_in6 *)(void *)(sa)) +#define satosin(sa) ((struct sockaddr_in *)(void *)(sa)) +#define s6_addr32 __u6_addr.__u6_addr32 +#define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \ + (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \ + (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \ + (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \ + (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 ) /* - * List of hosts for binding. + * List of peers and sockets for binding. */ -static STAILQ_HEAD(, host) hqueue; -struct host { - char *name; - STAILQ_ENTRY(host) next; +struct peer { + const char *pe_name; + const char *pe_serv; + mode_t pe_mode; + STAILQ_ENTRY(peer) next; }; - -/* - * Unix sockets. - * We have two default sockets, one with 666 permissions, - * and one for privileged programs. - */ -struct funix { - int s; - const char *name; - mode_t mode; - STAILQ_ENTRY(funix) next; +struct socklist { + struct sockaddr_storage sl_ss; + int sl_socket; + struct peer *sl_peer; + STAILQ_ENTRY(socklist) next; }; -struct funix funix_secure = { -1, _PATH_LOG_PRIV, S_IRUSR | S_IWUSR, - { NULL } }; -struct funix funix_default = { -1, _PATH_LOG, DEFFILEMODE, - { &funix_secure } }; +static STAILQ_HEAD(, socklist) shead = STAILQ_HEAD_INITIALIZER(shead); -STAILQ_HEAD(, funix) funixes = { &funix_default, - &(funix_secure.next.stqe_next) }; +static struct peer funix_secure = { + .pe_name = _PATH_LOG_PRIV, + .pe_mode = S_IRUSR | S_IWUSR, + .next = {NULL}, +}; +static struct peer funix_default = { + .pe_name = _PATH_LOG, + .pe_mode = DEFFILEMODE, + .next = {&funix_secure}, +}; +static STAILQ_HEAD(, peer) pqueue = { + &funix_default, + &funix_secure.next.stqe_next, +}; /* * Flags to logmsg(). @@ -172,7 +184,7 @@ STAILQ_HEAD(, funix) funixes = { &funix_default, */ struct filed { - struct filed *f_next; /* next in linked list */ + STAILQ_ENTRY(filed) next; /* next in linked list */ short f_type; /* entry type, see below */ short f_file; /* file descriptor */ time_t f_time; /* time this was last written */ @@ -196,6 +208,12 @@ struct filed { pid_t f_pid; } f_pipe; } f_un; +#define fu_uname f_un.f_uname +#define fu_forw_hname f_un.f_forw.f_hname +#define fu_forw_addr f_un.f_forw.f_addr +#define fu_fname f_un.f_fname +#define fu_pipe_pname f_un.f_pipe.f_pname +#define fu_pipe_pid f_un.f_pipe.f_pid char f_prevline[MAXSVLINE]; /* last message logged */ char f_lasttime[16]; /* time of last occurrence */ char f_prevhost[MAXHOSTNAMELEN]; /* host from which recd. */ @@ -211,15 +229,12 @@ struct filed { /* * Queue of about-to-be dead processes we should watch out for. */ - -TAILQ_HEAD(stailhead, deadq_entry) deadq_head; -struct stailhead *deadq_headp; - struct deadq_entry { pid_t dq_pid; int dq_timeout; TAILQ_ENTRY(deadq_entry) dq_entries; }; +static TAILQ_HEAD(, deadq_entry) deadq_head; /* * The timeout to apply to processes waiting on the dead queue. Unit @@ -249,7 +264,9 @@ struct allowedpeer { #define a_addr u.numeric.addr #define a_mask u.numeric.mask #define a_name u.name + STAILQ_ENTRY(allowedpeer) next; }; +static STAILQ_HEAD(, allowedpeer) aphead = STAILQ_HEAD_INITIALIZER(aphead); /* @@ -257,7 +274,7 @@ struct allowedpeer { * in seconds after previous message is logged. After each flush, * we move to the next interval until we reach the largest. */ -int repeatinterval[] = { 30, 120, 600 }; /* # of secs before flush */ +static int repeatinterval[] = { 30, 120, 600 }; /* # of secs before flush */ #define MAXREPEAT ((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1) #define REPEATTIME(f) ((f)->f_time + repeatinterval[(f)->f_repeatcount]) #define BACKOFF(f) { if (++(f)->f_repeatcount > MAXREPEAT) \ @@ -274,12 +291,13 @@ int repeatinterval[] = { 30, 120, 600 }; /* # of secs before flush */ #define F_WALL 6 /* everyone logged on */ #define F_PIPE 7 /* pipe to program */ -const char *TypeNames[8] = { +static const char *TypeNames[8] = { "UNUSED", "FILE", "TTY", "CONSOLE", "FORW", "USERS", "WALL", "PIPE" }; -static struct filed *Files; /* Log files that we write to */ +static STAILQ_HEAD(, filed) fhead = + STAILQ_HEAD_INITIALIZER(fhead); /* Log files that we write to */ static struct filed consfile; /* Console */ static int Debug; /* debug flag */ @@ -287,7 +305,6 @@ static int Foreground = 0; /* Run in foreground, instead of daemonizing */ static int resolve = 1; /* resolve hostname */ static char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */ static const char *LocalDomain; /* our local domain name */ -static int *finet; /* Internet datagram sockets */ static int fklog = -1; /* /dev/klog */ static int Initialized; /* set when we have initialized ourselves */ static int MarkInterval = 20 * 60; /* interval between marks in seconds */ @@ -307,8 +324,6 @@ static int logflags = O_WRONLY|O_APPEND; /* flags used to open log files */ static char bootfile[MAXLINE+1]; /* booted kernel file */ -struct allowedpeer *AllowedPeers; /* List of allowed peers */ -static int NumAllowed; /* Number of entries in AllowedPeers */ static int RemoteAddDate; /* Always set the date on remote messages */ static int UniquePriority; /* Only log specified priority? */ @@ -318,7 +333,7 @@ static int KeepKernFac; /* Keep remotely logged kernel facility */ static int needdofsync = 0; /* Are any file(s) waiting to be fsynced? */ static struct pidfh *pfh; -volatile sig_atomic_t MarkSet, WantDie; +static volatile sig_atomic_t MarkSet, WantDie; static int allowaddr(char *); static void cfline(const char *, struct filed *, @@ -332,12 +347,12 @@ static void dodie(int); static void dofsync(void); static void domark(int); static void fprintlog(struct filed *, int, const char *); -static int *socksetup(int, char *); static void init(int); static void logerror(const char *); static void logmsg(int, const char *, const char *, int); static void log_deadchild(pid_t, int, const char *); static void markit(void); +static int socksetup(struct peer *); static int skip_message(const char *, const char *, int); static void printline(const char *, char *, int); static void printsys(char *); @@ -368,31 +383,31 @@ close_filed(struct filed *f) int main(int argc, char *argv[]) { - int ch, i, fdsrmax = 0, l; - struct sockaddr_un sunx, fromunix; - struct sockaddr_storage frominet; + int ch, i, fdsrmax = 0; + struct sockaddr_storage ss; fd_set *fdsr = NULL; char line[MAXLINE + 1]; const char *hname; struct timeval tv, *tvp; struct sigaction sact; - struct host *host; - struct funix *fx, *fx1; + struct peer *pe; + struct socklist *sl; sigset_t mask; pid_t ppid = 1, spid; - socklen_t len; + socklen_t sslen; + char *p; if (madvise(NULL, 0, MADV_PROTECT) != 0) dprintf("madvise() failed: %s\n", strerror(errno)); - STAILQ_INIT(&hqueue); - while ((ch = getopt(argc, argv, "468Aa:b:cCdf:Fkl:m:nNop:P:sS:Tuv")) != -1) switch (ch) { +#ifdef INET case '4': family = PF_INET; break; +#endif #ifdef INET6 case '6': family = PF_INET6; @@ -409,13 +424,21 @@ main(int argc, char *argv[]) usage(); break; case 'b': - { - if ((host = malloc(sizeof(struct host))) == NULL) + if ((pe = calloc(1, sizeof(*pe))) == NULL) err(1, "malloc failed"); - host->name = optarg; - STAILQ_INSERT_TAIL(&hqueue, host, next); + if ((p = strchr(optarg, ':')) == NULL) { + /* A hostname or filename only. */ + pe->pe_name = optarg; + pe->pe_serv = "syslog"; + } else { + /* The case of "name:service". */ + *p++ = '\0'; + pe->pe_serv = p; + pe->pe_name = (strlen(optarg) == 0) ? + NULL : optarg; + } + STAILQ_INSERT_TAIL(&pqueue, pe, next); break; - } case 'c': no_compress++; break; @@ -458,17 +481,12 @@ main(int argc, char *argv[]) } else errx(1, "invalid mode %s, exiting", optarg); - } else /* doesn't begin with '/', and no ':' */ - errx(1, "can't parse path %s", optarg); - - if (strlen(name) >= sizeof(sunx.sun_path)) - errx(1, "%s path too long, exiting", name); - if ((fx = malloc(sizeof(struct funix))) == NULL) + } + if ((pe = calloc(1, sizeof(*pe))) == NULL) err(1, "malloc failed"); - fx->s = -1; - fx->name = name; - fx->mode = mode; - STAILQ_INSERT_TAIL(&funixes, fx, next); + pe->pe_name = name; + pe->pe_mode = mode; + STAILQ_INSERT_TAIL(&pqueue, pe, next); break; } case 'm': /* mark interval */ @@ -485,9 +503,7 @@ main(int argc, char *argv[]) use_bootfile = 1; break; case 'p': /* path */ - if (strlen(optarg) >= sizeof(sunx.sun_path)) - errx(1, "%s path too long, exiting", optarg); - funix_default.name = optarg; + funix_default.pe_name = optarg; break; case 'P': /* path for alt. PID */ PidFile = optarg; @@ -496,9 +512,7 @@ main(int argc, char *argv[]) SecureMode++; break; case 'S': /* path for privileged originator */ - if (strlen(optarg) >= sizeof(sunx.sun_path)) - errx(1, "%s path too long, exiting", optarg); - funix_secure.name = optarg; + funix_secure.pe_name = optarg; break; case 'T': RemoteAddDate = 1; @@ -514,6 +528,8 @@ main(int argc, char *argv[]) } if ((argc -= optind) != 0) usage(); + STAILQ_FOREACH(pe, &pqueue, next) + socksetup(pe); pfh = pidfile_open(PidFile, 0600, &spid); if (pfh == NULL) { @@ -529,16 +545,12 @@ main(int argc, char *argv[]) pidfile_remove(pfh); exit(1); } - } else if (Debug) { + } else if (Debug) setlinebuf(stdout); - } - - if (NumAllowed) - endservent(); consfile.f_type = F_CONSOLE; - (void)strlcpy(consfile.f_un.f_fname, ctty + sizeof _PATH_DEV - 1, - sizeof(consfile.f_un.f_fname)); + (void)strlcpy(consfile.fu_fname, ctty + sizeof _PATH_DEV - 1, + sizeof(consfile.fu_fname)); (void)strlcpy(bootfile, getbootfile(), sizeof(bootfile)); (void)signal(SIGTERM, dodie); (void)signal(SIGINT, Debug ? dodie : SIG_IGN); @@ -561,69 +573,6 @@ main(int argc, char *argv[]) TAILQ_INIT(&deadq_head); -#ifndef SUN_LEN -#define SUN_LEN(unp) (strlen((unp)->sun_path) + 2) -#endif - STAILQ_FOREACH_SAFE(fx, &funixes, next, fx1) { - (void)unlink(fx->name); - memset(&sunx, 0, sizeof(sunx)); - sunx.sun_family = AF_LOCAL; - (void)strlcpy(sunx.sun_path, fx->name, sizeof(sunx.sun_path)); - fx->s = socket(PF_LOCAL, SOCK_DGRAM, 0); - if (fx->s < 0 || - bind(fx->s, (struct sockaddr *)&sunx, SUN_LEN(&sunx)) < 0 || - chmod(fx->name, fx->mode) < 0) { - (void)snprintf(line, sizeof line, - "cannot create %s", fx->name); - logerror(line); - dprintf("cannot create %s (%d)\n", fx->name, errno); - if (fx == &funix_default || fx == &funix_secure) - die(0); - else { - STAILQ_REMOVE(&funixes, fx, funix, next); - continue; - } - } - increase_rcvbuf(fx->s); - } - if (SecureMode <= 1) { - if (STAILQ_EMPTY(&hqueue)) - finet = socksetup(family, NULL); - STAILQ_FOREACH(host, &hqueue, next) { - int *finet0, total; - finet0 = socksetup(family, host->name); - if (finet0 && !finet) { - finet = finet0; - } else if (finet0 && finet) { - total = *finet0 + *finet + 1; - finet = realloc(finet, total * sizeof(int)); - if (finet == NULL) - err(1, "realloc failed"); - for (i = 1; i <= *finet0; i++) { - finet[(*finet)+i] = finet0[i]; - } - *finet = total - 1; - free(finet0); - } - } - } - - if (finet) { - if (SecureMode) { - for (i = 0; i < *finet; i++) { - if (shutdown(finet[i+1], SHUT_RD) < 0 && - errno != ENOTCONN) { - logerror("shutdown"); - if (!Debug) - die(0); - } - } - } else { - dprintf("listening on inet and/or inet6 socket\n"); - } - dprintf("sending on inet and/or inet6 socket\n"); - } - if ((fklog = open(_PATH_KLOG, O_RDONLY|O_NONBLOCK, 0)) < 0) dprintf("can't open %s (%d)\n", _PATH_KLOG, errno); @@ -646,15 +595,10 @@ main(int argc, char *argv[]) if (fklog != -1 && fklog > fdsrmax) fdsrmax = fklog; - if (finet && !SecureMode) { - for (i = 0; i < *finet; i++) { - if (finet[i+1] != -1 && finet[i+1] > fdsrmax) - fdsrmax = finet[i+1]; - } + STAILQ_FOREACH(sl, &shead, next) { + if (sl->sl_socket > fdsrmax) + fdsrmax = sl->sl_socket; } - STAILQ_FOREACH(fx, &funixes, next) - if (fx->s > fdsrmax) - fdsrmax = fx->s; fdsr = (fd_set *)calloc(howmany(fdsrmax+1, NFDBITS), sizeof(fd_mask)); @@ -672,16 +616,11 @@ main(int argc, char *argv[]) if (fklog != -1) FD_SET(fklog, fdsr); - if (finet && !SecureMode) { - for (i = 0; i < *finet; i++) { - if (finet[i+1] != -1) - FD_SET(finet[i+1], fdsr); - } + STAILQ_FOREACH(sl, &shead, next) { + if (sl->sl_socket != -1) + FD_SET(sl->sl_socket, fdsr); } - STAILQ_FOREACH(fx, &funixes, next) - FD_SET(fx->s, fdsr); - - i = select(fdsrmax+1, fdsr, NULL, NULL, + i = select(fdsrmax + 1, fdsr, NULL, NULL, needdofsync ? &tv : tvp); switch (i) { case 0: @@ -700,34 +639,40 @@ main(int argc, char *argv[]) } if (fklog != -1 && FD_ISSET(fklog, fdsr)) readklog(); - if (finet && !SecureMode) { - for (i = 0; i < *finet; i++) { - if (FD_ISSET(finet[i+1], fdsr)) { - len = sizeof(frominet); - l = recvfrom(finet[i+1], line, MAXLINE, - 0, (struct sockaddr *)&frominet, - &len); - if (l > 0) { - line[l] = '\0'; - hname = cvthname((struct sockaddr *)&frominet); - unmapped((struct sockaddr *)&frominet); - if (validate((struct sockaddr *)&frominet, hname)) - printline(hname, line, RemoteAddDate ? ADDDATE : 0); - } else if (l < 0 && errno != EINTR) - logerror("recvfrom inet"); + STAILQ_FOREACH(sl, &shead, next) { + int date, len; + + if (FD_ISSET(sl->sl_socket, fdsr)) { + sslen = sizeof(ss); + dprintf("sslen(1) = %d\n", sslen); + len = recvfrom(sl->sl_socket, line, + sizeof(line) - 1, 0, + sstosa(&ss), &sslen); + dprintf("sslen(2) = %d\n", sslen); + if (len == 0) + continue; + if (len < 0) { + if (errno != EINTR) + logerror("recvfrom"); + continue; } - } - } - STAILQ_FOREACH(fx, &funixes, next) { - if (FD_ISSET(fx->s, fdsr)) { - len = sizeof(fromunix); - l = recvfrom(fx->s, line, MAXLINE, 0, - (struct sockaddr *)&fromunix, &len); - if (l > 0) { - line[l] = '\0'; - printline(LocalHostName, line, 0); - } else if (l < 0 && errno != EINTR) - logerror("recvfrom unix"); + /* Received valid data. */ + line[len] = '\0'; + if (sl->sl_ss.ss_family == AF_LOCAL) { + hname = LocalHostName; + date = 0; + } else { + hname = cvthname(sstosa(&ss)); + unmapped(sstosa(&ss)); + if (validate(sstosa(&ss), hname) == 0) + hname = NULL; + date = RemoteAddDate ? ADDDATE : 0; + } + if (hname != NULL) + printline(hname, line, date); + else + dprintf("Invalid msg from " + "%s was ignored.", hname); } } } @@ -741,18 +686,17 @@ unmapped(struct sockaddr *sa) struct sockaddr_in6 *sin6; struct sockaddr_in sin4; - if (sa->sa_family != AF_INET6) + if (sa == NULL || + sa->sa_family != AF_INET6 || + sa->sa_len != sizeof(*sin6)) return; - if (sa->sa_len != sizeof(struct sockaddr_in6) || - sizeof(sin4) > sa->sa_len) - return; - sin6 = (struct sockaddr_in6 *)sa; + sin6 = satosin6(sa); if (!IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) return; memset(&sin4, 0, sizeof(sin4)); sin4.sin_family = AF_INET; - sin4.sin_len = sizeof(struct sockaddr_in); + sin4.sin_len = sizeof(sin4); memcpy(&sin4.sin_addr, &sin6->sin6_addr.s6_addr[12], sizeof(sin4.sin_addr)); sin4.sin_port = sin6->sin6_port; @@ -1043,7 +987,7 @@ logmsg(int pri, const char *msg, const char *from, int flags) (void)sigsetmask(omask); return; } - for (f = Files; f; f = f->f_next) { + STAILQ_FOREACH(f, &fhead, next) { /* skip messages that are incorrect priority */ if (!(((f->f_pcmp[fac] & PRI_EQ) && (f->f_pmask[fac] == prilev)) ||((f->f_pcmp[fac] & PRI_LT) && (f->f_pmask[fac] < prilev)) @@ -1120,7 +1064,7 @@ dofsync(void) { struct filed *f; - for (f = Files; f; f = f->f_next) { + STAILQ_FOREACH(f, &fhead, next) { if ((f->f_type == F_FILE) && (f->f_flags & FFLAG_NEEDSYNC)) { f->f_flags &= ~FFLAG_NEEDSYNC; @@ -1136,7 +1080,7 @@ fprintlog(struct filed *f, int flags, const char *msg) struct iovec iov[IOV_SIZE]; struct iovec *v; struct addrinfo *r; - int i, l, lsent = 0; + int l, lsent = 0; char line[MAXLINE + 1], repbuf[80], greetings[200], *wmsg = NULL; char nul[] = "", space[] = " ", lf[] = "\n", crlf[] = "\r\n"; const char *msgret; @@ -1244,12 +1188,11 @@ fprintlog(struct filed *f, int flags, const char *msg) break; case F_FORW: - port = (int)ntohs(((struct sockaddr_in *) - (f->f_un.f_forw.f_addr->ai_addr))->sin_port); + port = ntohs(satosin(f->fu_forw_addr->ai_addr)->sin_port); if (port != 514) { - dprintf(" %s:%d\n", f->f_un.f_forw.f_hname, port); + dprintf(" %s:%d\n", f->fu_forw_hname, port); } else { - dprintf(" %s\n", f->f_un.f_forw.f_hname); + dprintf(" %s\n", f->fu_forw_hname); } /* check for local vs remote messages */ if (strcasecmp(f->f_prevhost, LocalHostName)) @@ -1266,57 +1209,51 @@ fprintlog(struct filed *f, int flags, const char *msg) else if (l > MAXLINE) l = MAXLINE; - if (finet) { - for (r = f->f_un.f_forw.f_addr; r; r = r->ai_next) { - for (i = 0; i < *finet; i++) { -#if 0 - /* - * should we check AF first, or just - * trial and error? FWD - */ - if (r->ai_family == - address_family_of(finet[i+1])) -#endif - lsent = sendto(finet[i+1], line, l, 0, - r->ai_addr, r->ai_addrlen); - if (lsent == l) - break; - } - if (lsent == l && !send_to_all) + for (r = f->fu_forw_addr; r; r = r->ai_next) { + struct socklist *sl; + + STAILQ_FOREACH(sl, &shead, next) { + if (sl->sl_ss.ss_family == AF_LOCAL) + continue; + lsent = sendto(sl->sl_socket, line, l, 0, + r->ai_addr, r->ai_addrlen); + if (lsent == l) break; } - dprintf("lsent/l: %d/%d\n", lsent, l); - if (lsent != l) { - int e = errno; - logerror("sendto"); - errno = e; - switch (errno) { - case ENOBUFS: - case ENETDOWN: - case ENETUNREACH: - case EHOSTUNREACH: - case EHOSTDOWN: - case EADDRNOTAVAIL: - break; - /* case EBADF: */ - /* case EACCES: */ - /* case ENOTSOCK: */ - /* case EFAULT: */ - /* case EMSGSIZE: */ - /* case EAGAIN: */ - /* case ENOBUFS: */ - /* case ECONNREFUSED: */ - default: - dprintf("removing entry: errno=%d\n", e); - f->f_type = F_UNUSED; - break; - } + if (lsent == l && !send_to_all) + break; + } + dprintf("lsent/l: %d/%d\n", lsent, l); + if (lsent != l) { + int e = errno; + logerror("sendto"); + errno = e; + switch (errno) { + case ENOBUFS: + case ENETDOWN: + case ENETUNREACH: + case EHOSTUNREACH: + case EHOSTDOWN: + case EADDRNOTAVAIL: + break; + /* case EBADF: */ + /* case EACCES: */ + /* case ENOTSOCK: */ + /* case EFAULT: */ + /* case EMSGSIZE: */ + /* case EAGAIN: */ + /* case ENOBUFS: */ + /* case ECONNREFUSED: */ + default: + dprintf("removing entry: errno=%d\n", e); + f->f_type = F_UNUSED; + break; } } break; case F_FILE: - dprintf(" %s\n", f->f_un.f_fname); + dprintf(" %s\n", f->fu_fname); v->iov_base = lf; v->iov_len = 1; if (writev(f->f_file, iov, IOV_SIZE) < 0) { @@ -1329,7 +1266,7 @@ fprintlog(struct filed *f, int flags, const char *msg) int e = errno; close_filed(f); errno = e; - logerror(f->f_un.f_fname); + logerror(f->fu_fname); } } else if ((flags & SYNC_FILE) && (f->f_flags & FFLAG_SYNC)) { f->f_flags |= FFLAG_NEEDSYNC; @@ -1338,26 +1275,26 @@ fprintlog(struct filed *f, int flags, const char *msg) break; case F_PIPE: - dprintf(" %s\n", f->f_un.f_pipe.f_pname); + dprintf(" %s\n", f->fu_pipe_pname); v->iov_base = lf; v->iov_len = 1; - if (f->f_un.f_pipe.f_pid == 0) { - if ((f->f_file = p_open(f->f_un.f_pipe.f_pname, - &f->f_un.f_pipe.f_pid)) < 0) { + if (f->fu_pipe_pid == 0) { + if ((f->f_file = p_open(f->fu_pipe_pname, + &f->fu_pipe_pid)) < 0) { f->f_type = F_UNUSED; - logerror(f->f_un.f_pipe.f_pname); + logerror(f->fu_pipe_pname); break; } } if (writev(f->f_file, iov, IOV_SIZE) < 0) { int e = errno; close_filed(f); - if (f->f_un.f_pipe.f_pid > 0) - deadq_enter(f->f_un.f_pipe.f_pid, - f->f_un.f_pipe.f_pname); - f->f_un.f_pipe.f_pid = 0; + if (f->fu_pipe_pid > 0) + deadq_enter(f->fu_pipe_pid, + f->fu_pipe_pname); + f->fu_pipe_pid = 0; errno = e; - logerror(f->f_un.f_pipe.f_pname); + logerror(f->fu_pipe_pname); } break; @@ -1369,12 +1306,12 @@ fprintlog(struct filed *f, int flags, const char *msg) /* FALLTHROUGH */ case F_TTY: - dprintf(" %s%s\n", _PATH_DEV, f->f_un.f_fname); + dprintf(" %s%s\n", _PATH_DEV, f->fu_fname); v->iov_base = crlf; v->iov_len = 2; errno = 0; /* ttymsg() only sometimes returns an errno */ - if ((msgret = ttymsg(iov, IOV_SIZE, f->f_un.f_fname, 10))) { + if ((msgret = ttymsg(iov, IOV_SIZE, f->fu_fname, 10))) { f->f_type = F_UNUSED; logerror(msgret); } @@ -1423,9 +1360,9 @@ wallmsg(struct filed *f, struct iovec *iov, const int iovlen) } /* should we send the message to this user? */ for (i = 0; i < MAXUNAMES; i++) { - if (!f->f_un.f_uname[i][0]) + if (!f->fu_uname[i][0]) break; - if (!strcmp(f->f_un.f_uname[i], ut->ut_user)) { + if (!strcmp(f->fu_uname[i], ut->ut_user)) { if ((p = ttymsg_check(iov, iovlen, ut->ut_line, TTYMSGTIME)) != NULL) { errno = 0; /* already in msg */ @@ -1476,20 +1413,18 @@ reapchild(int signo __unused) /* First, look if it's a process from the dead queue. */ if (deadq_remove(pid)) - goto oncemore; + continue; /* Now, look in list of active processes. */ - for (f = Files; f; f = f->f_next) + STAILQ_FOREACH(f, &fhead, next) { if (f->f_type == F_PIPE && - f->f_un.f_pipe.f_pid == pid) { + f->fu_pipe_pid == pid) { close_filed(f); - f->f_un.f_pipe.f_pid = 0; - log_deadchild(pid, status, - f->f_un.f_pipe.f_pname); + f->fu_pipe_pid = 0; + log_deadchild(pid, status, f->fu_pipe_pname); break; } - oncemore: - continue; + } } } @@ -1503,9 +1438,9 @@ cvthname(struct sockaddr *f) sigset_t omask, nmask; static char hname[NI_MAXHOST], ip[NI_MAXHOST]; - error = getnameinfo((struct sockaddr *)f, - ((struct sockaddr *)f)->sa_len, - ip, sizeof ip, NULL, 0, NI_NUMERICHOST); + dprintf("cvthname(%d) len = %d, %zu\n", f->sa_family, f->sa_len, sizeof(struct sockaddr_in6)); + error = getnameinfo(f, f->sa_len, ip, sizeof(ip), NULL, 0, + NI_NUMERICHOST); dprintf("cvthname(%s)\n", ip); if (error) { @@ -1575,19 +1510,19 @@ static void die(int signo) { struct filed *f; - struct funix *fx; + struct socklist *sl; int was_initialized; char buf[100]; was_initialized = Initialized; Initialized = 0; /* Don't log SIGCHLDs. */ - for (f = Files; f != NULL; f = f->f_next) { + STAILQ_FOREACH(f, &fhead, next) { /* flush any pending output */ if (f->f_prevcount) fprintlog(f, 0, (char *)NULL); - if (f->f_type == F_PIPE && f->f_un.f_pipe.f_pid > 0) { + if (f->f_type == F_PIPE && f->fu_pipe_pid > 0) { close_filed(f); - f->f_un.f_pipe.f_pid = 0; + f->fu_pipe_pid = 0; } } Initialized = was_initialized; @@ -1597,8 +1532,10 @@ die(int signo) errno = 0; logerror(buf); } - STAILQ_FOREACH(fx, &funixes, next) - (void)unlink(fx->name); + STAILQ_FOREACH(sl, &shead, next) { + if (sl->sl_ss.ss_family == AF_LOCAL) + unlink(sl->sl_peer->pe_name); + } pidfile_remove(pfh); exit(1); @@ -1626,7 +1563,7 @@ configfiles(const struct dirent *dp) } static void -readconfigfile(FILE *cf, struct filed **nextp, int allow_includes) +readconfigfile(FILE *cf, int allow_includes) { FILE *cf2; struct filed *f; @@ -1686,7 +1623,7 @@ readconfigfile(FILE *cf, struct filed **nextp, int allow_includes) if (cf2 == NULL) continue; dprintf("reading %s\n", file); - readconfigfile(cf2, nextp, 0); + readconfigfile(cf2, 0); fclose(cf2); } free(ent); @@ -1749,8 +1686,7 @@ readconfigfile(FILE *cf, struct filed **nextp, int allow_includes) logerror("calloc"); exit(1); } - *nextp = f; - nextp = &f->f_next; + STAILQ_INSERT_TAIL(&fhead, f, next); cfline(cline, f, prog, host); } } @@ -1763,7 +1699,7 @@ init(int signo) { int i; FILE *cf; - struct filed *f, *next, **nextp; + struct filed *f; char *p; char oldLocalHostName[MAXHOSTNAMELEN]; char hostMsg[2*MAXHOSTNAMELEN+40]; @@ -1808,7 +1744,7 @@ init(int signo) * Close all open log files. */ Initialized = 0; - for (f = Files; f != NULL; f = next) { + STAILQ_FOREACH(f, &fhead, next) { /* flush any pending output */ if (f->f_prevcount) fprintlog(f, 0, (char *)NULL); @@ -1821,42 +1757,47 @@ init(int signo) close_filed(f); break; case F_PIPE: - if (f->f_un.f_pipe.f_pid > 0) { + if (f->fu_pipe_pid > 0) { close_filed(f); - deadq_enter(f->f_un.f_pipe.f_pid, - f->f_un.f_pipe.f_pname); + deadq_enter(f->fu_pipe_pid, + f->fu_pipe_pname); } - f->f_un.f_pipe.f_pid = 0; + f->fu_pipe_pid = 0; break; } - next = f->f_next; - if (f->f_program) free(f->f_program); - if (f->f_host) free(f->f_host); - free((char *)f); } - Files = NULL; - nextp = &Files; + while(!STAILQ_EMPTY(&fhead)) { + f = STAILQ_FIRST(&fhead); + STAILQ_REMOVE_HEAD(&fhead, next); + free(f->f_program); + free(f->f_host); + free(f); + } /* open the configuration file */ if ((cf = fopen(ConfFile, "r")) == NULL) { dprintf("cannot open %s\n", ConfFile); - *nextp = (struct filed *)calloc(1, sizeof(*f)); - if (*nextp == NULL) { + f = calloc(1, sizeof(*f)); + if (f == NULL) { logerror("calloc"); exit(1); } - cfline("*.ERR\t/dev/console", *nextp, "*", "*"); - (*nextp)->f_next = (struct filed *)calloc(1, sizeof(*f)); - if ((*nextp)->f_next == NULL) { + cfline("*.ERR\t/dev/console", f, "*", "*"); + STAILQ_INSERT_TAIL(&fhead, f, next); + + f = calloc(1, sizeof(*f)); + if (f == NULL) { logerror("calloc"); exit(1); } - cfline("*.PANIC\t*", (*nextp)->f_next, "*", "*"); + cfline("*.PANIC\t*", f, "*", "*"); + STAILQ_INSERT_TAIL(&fhead, f, next); + Initialized = 1; return; } - readconfigfile(cf, &Files, 1); + readconfigfile(cf, 1); /* close the configuration file */ (void)fclose(cf); @@ -1865,7 +1806,7 @@ init(int signo) if (Debug) { int port; - for (f = Files; f; f = f->f_next) { + STAILQ_FOREACH(f, &fhead, next) { for (i = 0; i <= LOG_NFACILITIES; i++) if (f->f_pmask[i] == INTERNAL_NOPRI) printf("X "); @@ -1874,32 +1815,31 @@ init(int signo) printf("%s: ", TypeNames[f->f_type]); switch (f->f_type) { case F_FILE: - printf("%s", f->f_un.f_fname); + printf("%s", f->fu_fname); break; case F_CONSOLE: case F_TTY: - printf("%s%s", _PATH_DEV, f->f_un.f_fname); + printf("%s%s", _PATH_DEV, f->fu_fname); break; case F_FORW: - port = (int)ntohs(((struct sockaddr_in *) - (f->f_un.f_forw.f_addr->ai_addr))->sin_port); + port = ntohs(satosin(f->fu_forw_addr->ai_addr)->sin_port); if (port != 514) { printf("%s:%d", - f->f_un.f_forw.f_hname, port); + f->fu_forw_hname, port); } else { - printf("%s", f->f_un.f_forw.f_hname); + printf("%s", f->fu_forw_hname); } break; case F_PIPE: - printf("%s", f->f_un.f_pipe.f_pname); + printf("%s", f->fu_pipe_pname); break; case F_USERS: - for (i = 0; i < MAXUNAMES && *f->f_un.f_uname[i]; i++) - printf("%s, ", f->f_un.f_uname[i]); + for (i = 0; i < MAXUNAMES && *f->fu_uname[i]; i++) + printf("%s, ", f->fu_uname[i]); break; } if (f->f_program) @@ -2104,8 +2044,8 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) * scan forward to see if there is a port defined. * so we can't use strlcpy.. */ - i = sizeof(f->f_un.f_forw.f_hname); - tp = f->f_un.f_forw.f_hname; + i = sizeof(f->fu_forw_hname); + tp = f->fu_forw_hname; p++; /* @@ -2132,13 +2072,13 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) memset(&hints, 0, sizeof(hints)); hints.ai_family = family; hints.ai_socktype = SOCK_DGRAM; - error = getaddrinfo(f->f_un.f_forw.f_hname, + error = getaddrinfo(f->fu_forw_hname, p ? p : "syslog", &hints, &res); if (error) { logerror(gai_strerror(error)); break; } - f->f_un.f_forw.f_addr = res; + f->fu_forw_addr = res; f->f_type = F_FORW; break; @@ -2155,18 +2095,18 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) f->f_type = F_CONSOLE; else f->f_type = F_TTY; - (void)strlcpy(f->f_un.f_fname, p + sizeof(_PATH_DEV) - 1, - sizeof(f->f_un.f_fname)); + (void)strlcpy(f->fu_fname, p + sizeof(_PATH_DEV) - 1, + sizeof(f->fu_fname)); } else { - (void)strlcpy(f->f_un.f_fname, p, sizeof(f->f_un.f_fname)); + (void)strlcpy(f->fu_fname, p, sizeof(f->fu_fname)); f->f_type = F_FILE; } break; case '|': - f->f_un.f_pipe.f_pid = 0; - (void)strlcpy(f->f_un.f_pipe.f_pname, p + 1, - sizeof(f->f_un.f_pipe.f_pname)); + f->fu_pipe_pid = 0; + (void)strlcpy(f->fu_pipe_pname, p + 1, + sizeof(f->fu_pipe_pname)); f->f_type = F_PIPE; break; @@ -2178,11 +2118,11 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) for (i = 0; i < MAXUNAMES && *p; i++) { for (q = p; *q && *q != ','; ) q++; - (void)strncpy(f->f_un.f_uname[i], p, MAXLOGNAME - 1); + (void)strncpy(f->fu_uname[i], p, MAXLOGNAME - 1); if ((q - p) >= MAXLOGNAME) - f->f_un.f_uname[i][MAXLOGNAME - 1] = '\0'; + f->fu_uname[i][MAXLOGNAME - 1] = '\0'; else - f->f_un.f_uname[i][q - p] = '\0'; + f->fu_uname[i][q - p] = '\0'; while (*q == ',' || *q == ' ') q++; p = q; @@ -2233,7 +2173,7 @@ markit(void) MarkSeq = 0; } - for (f = Files; f; f = f->f_next) { + STAILQ_FOREACH(f, &fhead, next) { if (f->f_prevcount && now >= REPEATTIME(f)) { dprintf("flush %s: repeated %d times, %d sec.\n", TypeNames[f->f_type], f->f_prevcount, @@ -2494,7 +2434,7 @@ allowaddr(char *s) } if (Debug) { - printf("allowaddr: rule %d: ", NumAllowed); + printf("allowaddr: rule "); if (ap.isnumeric) { printf("numeric, "); getnameinfo((struct sockaddr *)&ap.a_addr, @@ -2510,14 +2450,6 @@ allowaddr(char *s) } printf("port = %d\n", ap.port); } - - if ((AllowedPeers = realloc(AllowedPeers, - ++NumAllowed * sizeof(struct allowedpeer))) - == NULL) { - logerror("realloc"); - exit(1); - } - memcpy(&AllowedPeers[NumAllowed - 1], &ap, sizeof(struct allowedpeer)); return (0); } @@ -2533,13 +2465,18 @@ validate(struct sockaddr *sa, const char *hname) struct allowedpeer *ap; struct sockaddr_in *sin4, *a4p = NULL, *m4p = NULL; #ifdef INET6 - int j, reject; + int reject; struct sockaddr_in6 *sin6, *a6p = NULL, *m6p = NULL; #endif struct addrinfo hints, *res; u_short sport; + int num = 0; - if (NumAllowed == 0) + STAILQ_FOREACH(ap, &aphead, next) { + num++; + } + dprintf("# of validation rule: %d\n", num); + if (num == 0) /* traditional behaviour, allow everything */ return (1); @@ -2554,7 +2491,7 @@ validate(struct sockaddr *sa, const char *hname) strlcat(name, ".", sizeof name); strlcat(name, LocalDomain, sizeof name); } - if (getnameinfo(sa, sa->sa_len, ip, sizeof ip, port, sizeof port, + if (getnameinfo(sa, sa->sa_len, ip, sizeof(ip), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV) != 0) return (0); /* for safety, should not occur */ dprintf("validate: dgram from IP %s, port %s, name %s;\n", @@ -2562,9 +2499,12 @@ validate(struct sockaddr *sa, const char *hname) sport = atoi(port); /* now, walk down the list */ - for (i = 0, ap = AllowedPeers; i < NumAllowed; i++, ap++) { + i = 0; + STAILQ_FOREACH(ap, &aphead, next) { + i++; if (ap->port != 0 && ap->port != sport) { - dprintf("rejected in rule %d due to port mismatch.\n", i); + dprintf("rejected in rule %d due to port mismatch.\n", + i); continue; } @@ -2574,9 +2514,9 @@ validate(struct sockaddr *sa, const char *hname) continue; } if (ap->a_addr.ss_family == AF_INET) { - sin4 = (struct sockaddr_in *)sa; - a4p = (struct sockaddr_in *)&ap->a_addr; - m4p = (struct sockaddr_in *)&ap->a_mask; + sin4 = satosin(sa); + a4p = satosin(&ap->a_addr); + m4p = satosin(&ap->a_mask); if ((sin4->sin_addr.s_addr & m4p->sin_addr.s_addr) != a4p->sin_addr.s_addr) { dprintf("rejected in rule %d due to IP mismatch.\n", i); @@ -2585,21 +2525,19 @@ validate(struct sockaddr *sa, const char *hname) } #ifdef INET6 else if (ap->a_addr.ss_family == AF_INET6) { - sin6 = (struct sockaddr_in6 *)sa; - a6p = (struct sockaddr_in6 *)&ap->a_addr; - m6p = (struct sockaddr_in6 *)&ap->a_mask; + sin6 = satosin6(sa); + a6p = satosin6(&ap->a_addr); + m6p = satosin6(&ap->a_mask); if (a6p->sin6_scope_id != 0 && sin6->sin6_scope_id != a6p->sin6_scope_id) { dprintf("rejected in rule %d due to scope mismatch.\n", i); continue; } reject = 0; - for (j = 0; j < 16; j += 4) { - if ((*(u_int32_t *)&sin6->sin6_addr.s6_addr[j] & *(u_int32_t *)&m6p->sin6_addr.s6_addr[j]) - != *(u_int32_t *)&a6p->sin6_addr.s6_addr[j]) { - ++reject; - break; - } + if (IN6_ARE_MASKED_ADDR_EQUAL(&sin6->sin6_addr, + &a6p->sin6_addr, &m6p->sin6_addr) != 0) { + ++reject; + break; } if (reject) { dprintf("rejected in rule %d due to IP mismatch.\n", i); @@ -2756,11 +2694,13 @@ deadq_remove(pid_t pid) dq_t q; TAILQ_FOREACH(q, &deadq_head, dq_entries) { - if (q->dq_pid == pid) { - TAILQ_REMOVE(&deadq_head, q, dq_entries); - free(q); - return (1); - } + if (q->dq_pid == pid) + break; + } + if (q != NULL) { + TAILQ_REMOVE(&deadq_head, q, dq_entries); + free(q); + return (1); } return (0); @@ -2789,85 +2729,90 @@ log_deadchild(pid_t pid, int status, const char *name) logerror(buf); } -static int * -socksetup(int af, char *bindhostname) +static int +socksetup(struct peer *pe) { - struct addrinfo hints, *res, *r; - const char *bindservice; + struct addrinfo hints, *res, *res0; + struct socklist *sl; + int error; char *cp; - int error, maxs, *s, *socks; - /* * We have to handle this case for backwards compatibility: * If there are two (or more) colons but no '[' and ']', * assume this is an inet6 address without a service. */ - bindservice = "syslog"; - if (bindhostname != NULL) { + if (pe->pe_name != NULL) { #ifdef INET6 - if (*bindhostname == '[' && - (cp = strchr(bindhostname + 1, ']')) != NULL) { - ++bindhostname; + if (pe->pe_name[0] == '[' && + (cp = strchr(pe->pe_name + 1, ']')) != NULL) { + pe->pe_name = &pe->pe_name[1]; *cp = '\0'; if (cp[1] == ':' && cp[2] != '\0') - bindservice = cp + 2; + pe->pe_serv = cp + 2; } else { #endif - cp = strchr(bindhostname, ':'); + cp = strchr(pe->pe_name, ':'); if (cp != NULL && strchr(cp + 1, ':') == NULL) { *cp = '\0'; if (cp[1] != '\0') - bindservice = cp + 1; - if (cp == bindhostname) - bindhostname = NULL; + pe->pe_serv = cp + 1; + if (cp == pe->pe_name) + pe->pe_name = NULL; } #ifdef INET6 } #endif } - memset(&hints, 0, sizeof(hints)); - hints.ai_flags = AI_PASSIVE; - hints.ai_family = af; + hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; - error = getaddrinfo(bindhostname, bindservice, &hints, &res); + hints.ai_flags = AI_PASSIVE; + + dprintf("Try %s\n", pe->pe_name); + if (pe->pe_serv == NULL) + pe->pe_serv = "syslog"; + error = getaddrinfo(pe->pe_name, pe->pe_serv, &hints, &res0); if (error) { logerror(gai_strerror(error)); errno = 0; die(0); } - - /* Count max number of sockets we may open */ - for (maxs = 0, r = res; r; r = r->ai_next, maxs++); - socks = malloc((maxs+1) * sizeof(int)); - if (socks == NULL) { - logerror("couldn't allocate memory for sockets"); - die(0); - } - - *socks = 0; /* num of sockets counter at start of array */ - s = socks + 1; - for (r = res; r; r = r->ai_next) { + for (res = res0; res != NULL; res = res->ai_next) { + int s; int on = 1; - *s = socket(r->ai_family, r->ai_socktype, r->ai_protocol); - if (*s < 0) { + + if (res->ai_family == AF_LOCAL) + unlink(pe->pe_name); + else if (SecureMode > 1) { + /* Only AF_LOCAL in secure mode. */ + continue; + } + if (family != AF_UNSPEC && res->ai_family != family) + continue; + + s = socket(res->ai_family, res->ai_socktype, + res->ai_protocol); + if (s < 0) { logerror("socket"); + error++; continue; } #ifdef INET6 - if (r->ai_family == AF_INET6) { - if (setsockopt(*s, IPPROTO_IPV6, IPV6_V6ONLY, - (char *)&on, sizeof (on)) < 0) { - logerror("setsockopt"); - close(*s); + if (res->ai_family == AF_INET6) { + if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, + (char *)&on, sizeof(on)) < 0) { + logerror("setsockopt(IPV6_V6ONLY)"); + close(s); + error++; continue; } } #endif - if (setsockopt(*s, SOL_SOCKET, SO_REUSEADDR, - (char *)&on, sizeof (on)) < 0) { - logerror("setsockopt"); - close(*s); + if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, + (char *)&on, sizeof(on)) < 0) { + logerror("setsockopt(SO_REUSEADDR)"); + close(s); + error++; continue; } /* @@ -2878,33 +2823,49 @@ socksetup(int af, char *bindhostname) * this, we can skip the bind() step so that the * system will choose a port for us. */ - if (!NoBind) { - if (bind(*s, r->ai_addr, r->ai_addrlen) < 0) { + if (NoBind == 0) { + if (bind(s, res->ai_addr, res->ai_addrlen) < 0) { logerror("bind"); - close(*s); + close(s); + error++; continue; } - - if (!SecureMode) - increase_rcvbuf(*s); + if (SecureMode == 0) + increase_rcvbuf(s); } - - (*socks)++; - dprintf("socksetup: new socket fd is %d\n", *s); - s++; + if (res->ai_family == AF_LOCAL && + chmod(pe->pe_name, pe->pe_mode) < 0) { + dprintf("chmod %s: %s\n", pe->pe_name, + strerror(errno)); + close(s); + error++; + continue; + } + dprintf("new socket fd is %d\n", s); + listen(s, 5); + dprintf("shutdown\n"); + if (SecureMode) { + /* Forbid communication in secure mode. */ + if (shutdown(s, SHUT_RD) < 0 && + errno != ENOTCONN) { + logerror("shutdown"); + if (!Debug) + die(0); + } + dprintf("listening on inet socket\n"); + } else + dprintf("sending on inet socket\n"); + sl = calloc(1, sizeof(*sl)); + if (sl == NULL) + err(1, "malloc failed"); + sl->sl_socket = s; + memcpy(&sl->sl_ss, res->ai_addr, res->ai_addrlen); + sl->sl_peer = pe; + STAILQ_INSERT_TAIL(&shead, sl, next); } + freeaddrinfo(res0); - if (*socks == 0) { - free(socks); - if (Debug) - return (NULL); - else - die(0); - } - if (res) - freeaddrinfo(res); - - return (socks); + return(error); } static void From b5938e7da308a733cdac834c31ad962b72c0d324 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 19:46:49 +0000 Subject: [PATCH 075/226] Consolidate redirects into here documents, with proper code indentation --- usr.sbin/bsdinstall/scripts/wlanconfig | 103 ++++++++++++++----------- 1 file changed, 60 insertions(+), 43 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index d4f0167fc91..5ab5bbf19fb 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -69,9 +69,10 @@ country_set() return $SUCCESS # Skip fi else - : > "$BSDINSTALL_TMPETC/rc.conf.net.wlan" - echo create_args_$WLAN_IFACE=\"$ifconfig_args\" >> \ - "$BSDINSTALL_TMPETC/rc.conf.net.wlan" + awk 'sub(/^\t\t/,"")||1' \ + > "$BSDINSTALL_TMPETC/rc.conf.net.wlan" <<-EOF + create_args_$WLAN_IFACE="$ifconfig_args" + EOF fi return $SUCCESS @@ -137,11 +138,13 @@ dialog_country_select() : > "$BSDINSTALL_TMPETC/wpa_supplicant.conf" chmod 0600 "$BSDINSTALL_TMPETC/wpa_supplicant.conf" -echo "ctrl_interface=/var/run/wpa_supplicant" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" -echo "eapol_version=2" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" -echo "ap_scan=1" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" -echo "fast_reauth=1" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" -echo >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" +cat >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" << EOF +ctrl_interface=/var/run/wpa_supplicant +eapol_version=2 +ap_scan=1 +fast_reauth=1 + +EOF # # Try to reach wpa_supplicant. If it isn't running and we can modify the @@ -246,12 +249,15 @@ if echo $ENCRYPTION | grep -q 'PSK'; then 2>&1 1>&3 ) \ || exec $0 $@ exec 3>&- -echo "network={ - ssid=\"$NETWORK\" - scan_ssid=$SCANSSID - psk=\"$PASS\" - priority=5 -}" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" + awk 'sub(/^\t/,"")||1' \ + >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF + network={ + ssid="$NETWORK" + scan_ssid=$SCANSSID + psk="$PASS" + priority=5 + } + EOF elif echo $ENCRYPTION | grep -q EAP; then exec 3>&1 USERPASS=$( dialog --insecure --backtitle "$DIALOG_BACKTITLE" \ @@ -262,20 +268,23 @@ elif echo $ENCRYPTION | grep -q EAP; then 2>&1 1>&3 ) \ || exec $0 $@ exec 3>&- -echo "network={ - ssid=\"$NETWORK\" - scan_ssid=$SCANSSID - key_mgmt=WPA-EAP" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" -echo "$USERPASS" | awk ' -{ - if (NR == 1) { - printf " identity=\"%s\"\n", $1; - } else if (NR == 2) { - printf " password=\"%s\"\n", $1; + awk 'sub(/^\t/,"")||1' \ + >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF + network={ + ssid="$NETWORK" + scan_ssid=$SCANSSID + key_mgmt=WPA-EAP$( + echo "$USERPASS" | awk ' + { + if (NR == 1) { + printf " identity=\"%s\"\n", $1; + } else if (NR == 2) { + printf " password=\"%s\"\n", $1; + } + }' ) + priority=5 } -}' >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" -echo " priority=5 -}" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" + EOF elif echo $ENCRYPTION | grep -q WEP; then exec 3>&1 WEPKEY=$( dialog --insecure --backtitle "$DIALOG_BACKTITLE" \ @@ -284,28 +293,36 @@ elif echo $ENCRYPTION | grep -q WEP; then "WEP Key 0" 2 0 "" 2 12 15 0 1 \ 2>&1 1>&3 ) \ || exec $0 $@ -echo "network={ - ssid=\"$NETWORK\" - scan_ssid=$SCANSSID - key_mgmt=NONE - wep_key0=\"$WEPKEY\" - wep_tx_keyidx=0 - priority=5 -}" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" + awk 'sub(/^\t/,"")||1' \ + >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF + network={ + ssid="$NETWORK" + scan_ssid=$SCANSSID + key_mgmt=NONE + wep_key0="$WEPKEY" + wep_tx_keyidx=0 + priority=5 + } + EOF else # Open -echo "network={ - ssid=\"$NETWORK\" - scan_ssid=$SCANSSID - key_mgmt=NONE - priority=5 -}" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" + awk 'sub(/^\t/,"")||1' \ + >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF + network={ + ssid="$NETWORK" + scan_ssid=$SCANSSID + key_mgmt=NONE + priority=5 + } + EOF fi # Connect to any open networks policy -echo "network={ +cat >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" << EOF +network={ priority=0 key_mgmt=NONE -}" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" +} +EOF # Bring up new network if [ "$BSDINSTALL_CONFIGCURRENT" ]; then From adff859ba29a4020ef33c7faf96e9ed5cf92e573 Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Mon, 12 Dec 2016 20:04:31 +0000 Subject: [PATCH 076/226] Use the spibus accessor when applicable. MFC after: 3 days --- sys/arm/lpc/lpc_spi.c | 8 +++++--- sys/mips/atheros/ar531x/ar5315_spi.c | 9 +++++---- sys/mips/atheros/ar71xx_spi.c | 12 +++++++----- sys/mips/mediatek/mtk_spi_v1.c | 6 ++++-- sys/mips/mediatek/mtk_spi_v2.c | 6 ++++-- sys/mips/rt305x/rt305x_spi.c | 6 ++++-- 6 files changed, 29 insertions(+), 18 deletions(-) diff --git a/sys/arm/lpc/lpc_spi.c b/sys/arm/lpc/lpc_spi.c index a3986da1227..c9accc8860b 100644 --- a/sys/arm/lpc/lpc_spi.c +++ b/sys/arm/lpc/lpc_spi.c @@ -141,12 +141,14 @@ static int lpc_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) { struct lpc_spi_softc *sc = device_get_softc(dev); - struct spibus_ivar *devi = SPIBUS_IVAR(child); + uint32_t cs; uint8_t *in_buf, *out_buf; int i; + spibus_get_cs(child, &cs); + /* Set CS active */ - lpc_gpio_set_state(child, devi->cs, 0); + lpc_gpio_set_state(child, cs, 0); /* Wait for FIFO to be ready */ while ((lpc_spi_read_4(sc, LPC_SSP_SR) & LPC_SSP_SR_TNF) == 0); @@ -168,7 +170,7 @@ lpc_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) } /* Set CS inactive */ - lpc_gpio_set_state(child, devi->cs, 1); + lpc_gpio_set_state(child, cs, 1); return (0); } diff --git a/sys/mips/atheros/ar531x/ar5315_spi.c b/sys/mips/atheros/ar531x/ar5315_spi.c index 5eee03c6c9f..a066b1d9018 100644 --- a/sys/mips/atheros/ar531x/ar5315_spi.c +++ b/sys/mips/atheros/ar531x/ar5315_spi.c @@ -155,9 +155,8 @@ ar5315_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) { struct ar5315_spi_softc *sc; uint8_t *buf_in, *buf_out; - struct spibus_ivar *devi = SPIBUS_IVAR(child); int lin, lout; - uint32_t ctl, cnt, op, rdat; + uint32_t ctl, cnt, op, rdat, cs; int i, j; sc = device_get_softc(dev); @@ -165,8 +164,10 @@ ar5315_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) if (sc->sc_debug & 0x8000) printf("ar5315_spi_transfer: CMD "); + spibus_get_cs(child, &cs); + /* Open SPI controller interface */ - ar5315_spi_chip_activate(sc, devi->cs); + ar5315_spi_chip_activate(sc, cs); do { ctl = SPI_READ(sc, ARSPI_REG_CTL); @@ -243,7 +244,7 @@ ar5315_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) } } - ar5315_spi_chip_deactivate(sc, devi->cs); + ar5315_spi_chip_deactivate(sc, cs); /* * Close SPI controller interface, restore flash memory mapped access. */ diff --git a/sys/mips/atheros/ar71xx_spi.c b/sys/mips/atheros/ar71xx_spi.c index 943a9d8ab9a..aa2cf21fa0d 100644 --- a/sys/mips/atheros/ar71xx_spi.c +++ b/sys/mips/atheros/ar71xx_spi.c @@ -204,13 +204,15 @@ static int ar71xx_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) { struct ar71xx_spi_softc *sc; + uint32_t cs; uint8_t *buf_in, *buf_out; - struct spibus_ivar *devi = SPIBUS_IVAR(child); int i; sc = device_get_softc(dev); - ar71xx_spi_chip_activate(sc, devi->cs); + spibus_get_cs(child, &cs); + + ar71xx_spi_chip_activate(sc, cs); KASSERT(cmd->tx_cmd_sz == cmd->rx_cmd_sz, ("TX/RX command sizes should be equal")); @@ -223,7 +225,7 @@ ar71xx_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) buf_out = (uint8_t *)cmd->tx_cmd; buf_in = (uint8_t *)cmd->rx_cmd; for (i = 0; i < cmd->tx_cmd_sz; i++) - buf_in[i] = ar71xx_spi_txrx(sc, devi->cs, buf_out[i]); + buf_in[i] = ar71xx_spi_txrx(sc, cs, buf_out[i]); /* * Receive/transmit data (depends on command) @@ -231,9 +233,9 @@ ar71xx_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) buf_out = (uint8_t *)cmd->tx_data; buf_in = (uint8_t *)cmd->rx_data; for (i = 0; i < cmd->tx_data_sz; i++) - buf_in[i] = ar71xx_spi_txrx(sc, devi->cs, buf_out[i]); + buf_in[i] = ar71xx_spi_txrx(sc, cs, buf_out[i]); - ar71xx_spi_chip_deactivate(sc, devi->cs); + ar71xx_spi_chip_deactivate(sc, cs); return (0); } diff --git a/sys/mips/mediatek/mtk_spi_v1.c b/sys/mips/mediatek/mtk_spi_v1.c index 9cf8faa9667..e50b025d6ff 100644 --- a/sys/mips/mediatek/mtk_spi_v1.c +++ b/sys/mips/mediatek/mtk_spi_v1.c @@ -224,12 +224,14 @@ mtk_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) { struct mtk_spi_softc *sc; uint8_t *buf, byte, *tx_buf; - struct spibus_ivar *devi = SPIBUS_IVAR(child); + uint32_t cs; int i, sz, error = 0, write = 0; sc = device_get_softc(dev); - if (devi->cs != 0) + spibus_get_cs(child, &cs); + + if (cs != 0) /* Only 1 CS */ return (ENXIO); diff --git a/sys/mips/mediatek/mtk_spi_v2.c b/sys/mips/mediatek/mtk_spi_v2.c index 1f85ca36893..ad55cb3f947 100644 --- a/sys/mips/mediatek/mtk_spi_v2.c +++ b/sys/mips/mediatek/mtk_spi_v2.c @@ -229,12 +229,14 @@ mtk_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) { struct mtk_spi_softc *sc; uint8_t *buf, byte, *tx_buf; - struct spibus_ivar *devi = SPIBUS_IVAR(child); + uint32_t cs; int i, sz, error, write = 0; sc = device_get_softc(dev); - if (devi->cs != 0) + spibus_get_cs(child, &cs); + + if (cs != 0) /* Only 1 CS */ return (ENXIO); diff --git a/sys/mips/rt305x/rt305x_spi.c b/sys/mips/rt305x/rt305x_spi.c index 6dd2d747cdf..17126d9aabb 100644 --- a/sys/mips/rt305x/rt305x_spi.c +++ b/sys/mips/rt305x/rt305x_spi.c @@ -218,13 +218,15 @@ static int rt305x_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) { struct rt305x_spi_softc *sc; + uint32_t cs; uint8_t *buf, byte, *tx_buf; - struct spibus_ivar *devi = SPIBUS_IVAR(child); int i, sz, error = 0, write = 0; sc = device_get_softc(dev); - if (devi->cs != 0) + spibus_get_cs(child, &cs); + + if (cs != 0) /* Only 1 CS */ return (ENXIO); From 8bd856de216d9f46e0b028e7479099fb9d56324e Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Mon, 12 Dec 2016 20:25:59 +0000 Subject: [PATCH 077/226] ed(1): Simplify some checks. The return type for both fread(3) and fwrite(3) cannot be negative, this renders some checks invalid and variable 'ct' unnecessary. Also bump 'len' to size_t to avoid signed/unsigned comparison warnings. --- bin/ed/buf.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/ed/buf.c b/bin/ed/buf.c index 6d8a6ed4f55..35b5d4d55dc 100644 --- a/bin/ed/buf.c +++ b/bin/ed/buf.c @@ -46,9 +46,9 @@ char * get_sbuf_line(line_t *lp) { static char *sfbuf = NULL; /* buffer */ - static int sfbufsz = 0; /* buffer size */ + static size_t sfbufsz; /* buffer size */ - int len, ct; + size_t len; if (lp == &buffer_head) return NULL; @@ -64,7 +64,7 @@ get_sbuf_line(line_t *lp) } len = lp->len; REALLOC(sfbuf, sfbufsz, len + 1, NULL); - if ((ct = fread(sfbuf, sizeof(char), len, sfp)) < 0 || ct != len) { + if ((fread(sfbuf, sizeof(char), len, sfp)) != len) { fprintf(stderr, "%s\n", strerror(errno)); errmsg = "cannot read temp file"; return NULL; @@ -81,7 +81,7 @@ const char * put_sbuf_line(const char *cs) { line_t *lp; - int len, ct; + size_t len; const char *s; if ((lp = (line_t *) malloc(sizeof(line_t))) == NULL) { @@ -110,7 +110,7 @@ put_sbuf_line(const char *cs) seek_write = 0; } /* assert: SPL1() */ - if ((ct = fwrite(cs, sizeof(char), len, sfp)) < 0 || ct != len) { + if ((fwrite(cs, sizeof(char), len, sfp)) != len) { sfseek = -1; fprintf(stderr, "%s\n", strerror(errno)); errmsg = "cannot write temp file"; From 2abc4c242ed9f2080db240098e793541b18c729c Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 20:41:27 +0000 Subject: [PATCH 078/226] Whitespace (dialog options separated to minimize diffs) --- usr.sbin/bsdinstall/scripts/wlanconfig | 121 +++++++++++++++++-------- 1 file changed, 81 insertions(+), 40 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 5ab5bbf19fb..c920d8c62bb 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -60,9 +60,14 @@ country_set() "$BSDINSTALL_TMPETC/wpa_supplicant.conf" fi if [ "$error_str" ]; then - dialog --backtitle "$DIALOG_BACKTITLE" --title "Error" \ - --yes-label Change --no-label Ignore --yesno \ - "Error while applying chosen settings ($error_str)" 0 0 + dialog \ + --backtitle "$DIALOG_BACKTITLE" \ + --title "Error" \ + --yes-label Change \ + --no-label Ignore \ + --yesno \ + "Error while applying chosen settings ($error_str)" \ + 0 0 if [ $? -eq $DIALOG_OK ]; then return $FAILURE # Restart else @@ -158,8 +163,11 @@ EOF # See if we succeeded wpa_cli ping >/dev/null 2>/dev/null if [ $? -ne 0 -a ! "$BSDINSTALL_CONFIGCURRENT" ]; then - dialog --backtitle "$DIALOG_BACKTITLE" --title "Error" --msgbox \ - "Wireless cannot be configured without making changes to the local system!" \ 0 0 + dialog \ + --backtitle "$DIALOG_BACKTITLE" \ + --title "Error" \ + --msgbox "Wireless cannot be configured without making changes to the local system!" \ + 0 0 exit 1 fi @@ -175,9 +183,11 @@ if [ "$BSDINSTALL_CONFIGCURRENT" ]; then DEF_COUNTRY=$( echo $INPUT | cut -w -f 4 ) [ "$DEF_REGDOMAIN" = 0 ] && DEF_REGDOMAIN="" [ "$DEF_COUNTRY" = 0 ] && DEF_COUNTRY="" - dialog --backtitle "$DIALOG_BACKTITLE" --title "Regdomain/country" \ - --yesno "Change regdomain/country (now \ - $DEF_REGDOMAIN/$DEF_COUNTRY)?" 0 0 + dialog \ + --backtitle "$DIALOG_BACKTITLE" \ + --title "Regdomain/country" \ + --yesno "Change regdomain/country (now $DEF_REGDOMAIN/$DEF_COUNTRY)?" \ + 0 0 if [ $? -eq 0 ]; then while : do @@ -193,28 +203,41 @@ while :; do SCANSSID=0 output=$( wpa_cli scan 2>&1 ) f_dprintf "%s" "$output" - dialog --backtitle "$DIALOG_BACKTITLE" --title "Scanning" \ - --ok-label "Skip" \ - --pause "Waiting 5 seconds to scan for wireless networks..." \ - 9 40 5 || exit 1 + dialog \ + --backtitle "$DIALOG_BACKTITLE" \ + --title "Scanning" \ + --ok-label "Skip" \ + --pause "Waiting 5 seconds to scan for wireless networks..." \ + 9 40 5 || exit 1 SCAN_RESULTS=$( wpa_cli scan_results ) - NETWORKS=$( echo "$SCAN_RESULTS" | awk -F '\t' \ - '/..:..:..:..:..:../ {if (length($5) > 0) \ - printf("\"%s\"\t%s\n", $5, $4);}' | sort | uniq ) + NETWORKS=$( echo "$SCAN_RESULTS" | awk -F '\t' ' + /..:..:..:..:..:../ { + if (length($5) > 0) + printf("\"%s\"\t%s\n", $5, $4); + } + ' | sort | uniq ) if [ ! "$NETWORKS" ]; then - dialog --backtitle "$DIALOG_BACKTITLE" --title "Error" \ - --yesno "No wireless networks were found. Rescan?" 0 0 && - continue + dialog \ + --backtitle "$DIALOG_BACKTITLE" \ + --title "Error" \ + --yesno "No wireless networks were found. Rescan?" \ + 0 0 && continue exit 1 fi exec 3>&1 - NETWORK=$( sh -c "dialog --extra-button --extra-label \"Rescan\" \ - --backtitle \"$DIALOG_BACKTITLE\" --title \"Network Selection\" \ - --menu \"Select a wireless network to connect to.\" 0 0 0 \ - $(echo $NETWORKS | tr '\n' ' ')" 2>&1 1>&3 ) + NETWORK=$( sh -c "dialog \ + --extra-button \ + --extra-label \"Rescan\" \ + --backtitle \"$DIALOG_BACKTITLE\" \ + --title \"Network Selection\" \ + --menu \"Select a wireless network to connect to.\" \ + 0 0 0 \ + $( echo $NETWORKS | tr '\n' ' ' )" \ + 2>&1 1>&3 + ) case $? in $DIALOG_OK) break @@ -224,9 +247,17 @@ while :; do f_dialog_title "Network Selection" f_dialog_yesno "Do you want to select the network manually?" || exit 1 f_dialog_input NETWORK "Enter SSID" || exit 1 - ENCRYPTION=$( dialog --backtitle "$DIALOG_BACKTITLE" --title \ - "$DIALOG_TITLE" --menu "Select encryption type" 0 0 0 \ - "1 WPA/WPA2 PSK" "" "2 WPA/WPA2 EAP" "" "3 WEP" "" "0 None" "" 2>&1 1>&3 ) || exit 1 + ENCRYPTION=$( dialog \ + --backtitle "$DIALOG_BACKTITLE" \ + --title "$DIALOG_TITLE" \ + --menu "Select encryption type" \ + 0 0 0 \ + "1 WPA/WPA2 PSK" "" \ + "2 WPA/WPA2 EAP" "" \ + "3 WEP" "" \ + "0 None" "" \ + 2>&1 1>&3 + ) || exit 1 SCANSSID=1 f_dialog_title_restore break @@ -237,17 +268,21 @@ while :; do exec 3>&- done -[ "$ENCRYPTION" ] || ENCRYPTION=$( echo "$NETWORKS" | awk -F '\t' \ - "/^\"$NETWORK\"\t/ {printf(\"%s\n\", \\\$2 );}" ) +[ "$ENCRYPTION" ] || ENCRYPTION=$( echo "$NETWORKS" | + awk -F '\t' "/^\"$NETWORK\"\t/ { printf(\"%s\n\", \\\$2 ); }" ) if echo $ENCRYPTION | grep -q 'PSK'; then exec 3>&1 - PASS=$( dialog --insecure --backtitle "$DIALOG_BACKTITLE" \ - --title "WPA Setup" --mixedform "" 0 0 0 \ + PASS=$( dialog \ + --insecure \ + --backtitle "$DIALOG_BACKTITLE" \ + --title "WPA Setup" \ + --mixedform "" \ + 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "Password" 2 0 "" 2 12 15 63 1 \ - 2>&1 1>&3 ) \ - || exec $0 $@ + 2>&1 1>&3 + ) || exec $0 $@ exec 3>&- awk 'sub(/^\t/,"")||1' \ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF @@ -260,13 +295,16 @@ if echo $ENCRYPTION | grep -q 'PSK'; then EOF elif echo $ENCRYPTION | grep -q EAP; then exec 3>&1 - USERPASS=$( dialog --insecure --backtitle "$DIALOG_BACKTITLE" \ - --title "WPA-Enterprise Setup" --mixedform "" 0 0 0 \ + USERPASS=$( dialog \ + --insecure \ + --backtitle "$DIALOG_BACKTITLE" \ + --title "WPA-Enterprise Setup" \ + --mixedform "" 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "Username" 2 0 "" 2 12 25 63 0 \ "Password" 3 0 "" 3 12 25 63 1 \ - 2>&1 1>&3 ) \ - || exec $0 $@ + 2>&1 1>&3 + ) || exec $0 $@ exec 3>&- awk 'sub(/^\t/,"")||1' \ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF @@ -287,12 +325,15 @@ elif echo $ENCRYPTION | grep -q EAP; then EOF elif echo $ENCRYPTION | grep -q WEP; then exec 3>&1 - WEPKEY=$( dialog --insecure --backtitle "$DIALOG_BACKTITLE" \ - --title "WEP Setup" --mixedform "" 0 0 0 \ + WEPKEY=$( dialog \ + --insecure \ + --backtitle "$DIALOG_BACKTITLE" \ + --title "WEP Setup" \ + --mixedform "" 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "WEP Key 0" 2 0 "" 2 12 15 0 1 \ - 2>&1 1>&3 ) \ - || exec $0 $@ + 2>&1 1>&3 + ) || exec $0 $@ awk 'sub(/^\t/,"")||1' \ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF network={ @@ -304,7 +345,7 @@ elif echo $ENCRYPTION | grep -q WEP; then priority=5 } EOF -else # Open +else # Open awk 'sub(/^\t/,"")||1' \ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF network={ From ea2e60b01cea6f2954cd3a3925c7e749185a87f4 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 20:43:09 +0000 Subject: [PATCH 079/226] Use provided API (change "dialog" to "$DIALOG") --- usr.sbin/bsdinstall/scripts/wlanconfig | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index c920d8c62bb..63121b5ca3d 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -60,7 +60,7 @@ country_set() "$BSDINSTALL_TMPETC/wpa_supplicant.conf" fi if [ "$error_str" ]; then - dialog \ + $DIALOG \ --backtitle "$DIALOG_BACKTITLE" \ --title "Error" \ --yes-label Change \ @@ -111,7 +111,7 @@ dialog_country_select() f_dialog_menu_size height width rows \"Regdomain selection\" \ \"$DIALOG_BACKTITLE\" \"Select your regdomain.\" \ \"\" $regdomains - regdomain=$( sh -c "dialog \ + regdomain=$( sh -c "$DIALOG \ --backtitle \"$DIALOG_BACKTITLE\" \ --title \"Regdomain selection\" \ --cancel-label \"Skip\" \ @@ -125,7 +125,7 @@ dialog_country_select() f_dialog_menu_size height width rows \"Country selection\" \ \"$DIALOG_BACKTITLE\" \"Select your country.\" \ \"\" $countries - country=$( sh -c "dialog \ + country=$( sh -c "$DIALOG \ --backtitle \"$DIALOG_BACKTITLE\" \ --title \"Country selection\" \ --cancel-label \"Skip\" \ @@ -157,13 +157,13 @@ EOF # (wpa_cli ping >/dev/null 2>/dev/null || ([ "$BSDINSTALL_CONFIGCURRENT" ] && wpa_supplicant -B -i $1 -c "$BSDINSTALL_TMPETC/wpa_supplicant.conf")) || - (dialog --backtitle "$DIALOG_BACKTITLE" --title "Error" --msgbox \ + ($DIALOG --backtitle "$DIALOG_BACKTITLE" --title "Error" --msgbox \ "Could not start wpa_supplicant!" 0 0; exit 1) || exit 1 # See if we succeeded wpa_cli ping >/dev/null 2>/dev/null if [ $? -ne 0 -a ! "$BSDINSTALL_CONFIGCURRENT" ]; then - dialog \ + $DIALOG \ --backtitle "$DIALOG_BACKTITLE" \ --title "Error" \ --msgbox "Wireless cannot be configured without making changes to the local system!" \ @@ -183,7 +183,7 @@ if [ "$BSDINSTALL_CONFIGCURRENT" ]; then DEF_COUNTRY=$( echo $INPUT | cut -w -f 4 ) [ "$DEF_REGDOMAIN" = 0 ] && DEF_REGDOMAIN="" [ "$DEF_COUNTRY" = 0 ] && DEF_COUNTRY="" - dialog \ + $DIALOG \ --backtitle "$DIALOG_BACKTITLE" \ --title "Regdomain/country" \ --yesno "Change regdomain/country (now $DEF_REGDOMAIN/$DEF_COUNTRY)?" \ @@ -203,7 +203,7 @@ while :; do SCANSSID=0 output=$( wpa_cli scan 2>&1 ) f_dprintf "%s" "$output" - dialog \ + $DIALOG \ --backtitle "$DIALOG_BACKTITLE" \ --title "Scanning" \ --ok-label "Skip" \ @@ -219,7 +219,7 @@ while :; do ' | sort | uniq ) if [ ! "$NETWORKS" ]; then - dialog \ + $DIALOG \ --backtitle "$DIALOG_BACKTITLE" \ --title "Error" \ --yesno "No wireless networks were found. Rescan?" \ @@ -228,7 +228,7 @@ while :; do fi exec 3>&1 - NETWORK=$( sh -c "dialog \ + NETWORK=$( sh -c "$DIALOG \ --extra-button \ --extra-label \"Rescan\" \ --backtitle \"$DIALOG_BACKTITLE\" \ @@ -247,7 +247,7 @@ while :; do f_dialog_title "Network Selection" f_dialog_yesno "Do you want to select the network manually?" || exit 1 f_dialog_input NETWORK "Enter SSID" || exit 1 - ENCRYPTION=$( dialog \ + ENCRYPTION=$( $DIALOG \ --backtitle "$DIALOG_BACKTITLE" \ --title "$DIALOG_TITLE" \ --menu "Select encryption type" \ @@ -273,7 +273,7 @@ done if echo $ENCRYPTION | grep -q 'PSK'; then exec 3>&1 - PASS=$( dialog \ + PASS=$( $DIALOG \ --insecure \ --backtitle "$DIALOG_BACKTITLE" \ --title "WPA Setup" \ @@ -295,7 +295,7 @@ if echo $ENCRYPTION | grep -q 'PSK'; then EOF elif echo $ENCRYPTION | grep -q EAP; then exec 3>&1 - USERPASS=$( dialog \ + USERPASS=$( $DIALOG \ --insecure \ --backtitle "$DIALOG_BACKTITLE" \ --title "WPA-Enterprise Setup" \ @@ -325,7 +325,7 @@ elif echo $ENCRYPTION | grep -q EAP; then EOF elif echo $ENCRYPTION | grep -q WEP; then exec 3>&1 - WEPKEY=$( dialog \ + WEPKEY=$( $DIALOG \ --insecure \ --backtitle "$DIALOG_BACKTITLE" \ --title "WEP Setup" \ From 6ea6e3fa7d11225ba57c288440baed1f8d76de9e Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 20:49:49 +0000 Subject: [PATCH 080/226] Fix incorrect use of provided API The result of which was incorrectly sized menu dialogs --- usr.sbin/bsdinstall/scripts/wlanconfig | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 63121b5ca3d..aa51a278533 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -108,9 +108,8 @@ dialog_country_select() } }' | sort -k 2 | tr '\n' ' ' ) - f_dialog_menu_size height width rows \"Regdomain selection\" \ - \"$DIALOG_BACKTITLE\" \"Select your regdomain.\" \ - \"\" $regdomains + f_dialog_menu_size height width rows "Regdomain selection" \ + "$DIALOG_BACKTITLE" "Select your regdomain." "" $regdomains regdomain=$( sh -c "$DIALOG \ --backtitle \"$DIALOG_BACKTITLE\" \ --title \"Regdomain selection\" \ @@ -122,9 +121,8 @@ dialog_country_select() $height $width $rows $regdomains" ) - f_dialog_menu_size height width rows \"Country selection\" \ - \"$DIALOG_BACKTITLE\" \"Select your country.\" \ - \"\" $countries + f_dialog_menu_size height width rows "Country selection" \ + "$DIALOG_BACKTITLE" "Select your country." "" $countries country=$( sh -c "$DIALOG \ --backtitle \"$DIALOG_BACKTITLE\" \ --title \"Country selection\" \ From 7797a5973f87f665febb4b8615ec26bb8d4c5991 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 20:54:20 +0000 Subject: [PATCH 081/226] Reorder dialog parameters based on commonality for readability --- usr.sbin/bsdinstall/scripts/wlanconfig | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index aa51a278533..a3af035f119 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -61,8 +61,8 @@ country_set() fi if [ "$error_str" ]; then $DIALOG \ - --backtitle "$DIALOG_BACKTITLE" \ --title "Error" \ + --backtitle "$DIALOG_BACKTITLE" \ --yes-label Change \ --no-label Ignore \ --yesno \ @@ -111,8 +111,8 @@ dialog_country_select() f_dialog_menu_size height width rows "Regdomain selection" \ "$DIALOG_BACKTITLE" "Select your regdomain." "" $regdomains regdomain=$( sh -c "$DIALOG \ - --backtitle \"$DIALOG_BACKTITLE\" \ --title \"Regdomain selection\" \ + --backtitle \"$DIALOG_BACKTITLE\" \ --cancel-label \"Skip\" \ --default-item \"$default_regdomain\" \ --no-items \ @@ -124,8 +124,8 @@ dialog_country_select() f_dialog_menu_size height width rows "Country selection" \ "$DIALOG_BACKTITLE" "Select your country." "" $countries country=$( sh -c "$DIALOG \ - --backtitle \"$DIALOG_BACKTITLE\" \ --title \"Country selection\" \ + --backtitle \"$DIALOG_BACKTITLE\" \ --cancel-label \"Skip\" \ --default-item \"$default_country\" \ --stdout \ @@ -162,8 +162,8 @@ EOF wpa_cli ping >/dev/null 2>/dev/null if [ $? -ne 0 -a ! "$BSDINSTALL_CONFIGCURRENT" ]; then $DIALOG \ - --backtitle "$DIALOG_BACKTITLE" \ --title "Error" \ + --backtitle "$DIALOG_BACKTITLE" \ --msgbox "Wireless cannot be configured without making changes to the local system!" \ 0 0 exit 1 @@ -182,8 +182,8 @@ if [ "$BSDINSTALL_CONFIGCURRENT" ]; then [ "$DEF_REGDOMAIN" = 0 ] && DEF_REGDOMAIN="" [ "$DEF_COUNTRY" = 0 ] && DEF_COUNTRY="" $DIALOG \ - --backtitle "$DIALOG_BACKTITLE" \ --title "Regdomain/country" \ + --backtitle "$DIALOG_BACKTITLE" \ --yesno "Change regdomain/country (now $DEF_REGDOMAIN/$DEF_COUNTRY)?" \ 0 0 if [ $? -eq 0 ]; then @@ -202,8 +202,8 @@ while :; do output=$( wpa_cli scan 2>&1 ) f_dprintf "%s" "$output" $DIALOG \ - --backtitle "$DIALOG_BACKTITLE" \ --title "Scanning" \ + --backtitle "$DIALOG_BACKTITLE" \ --ok-label "Skip" \ --pause "Waiting 5 seconds to scan for wireless networks..." \ 9 40 5 || exit 1 @@ -218,8 +218,8 @@ while :; do if [ ! "$NETWORKS" ]; then $DIALOG \ - --backtitle "$DIALOG_BACKTITLE" \ --title "Error" \ + --backtitle "$DIALOG_BACKTITLE" \ --yesno "No wireless networks were found. Rescan?" \ 0 0 && continue exit 1 @@ -227,10 +227,10 @@ while :; do exec 3>&1 NETWORK=$( sh -c "$DIALOG \ + --title \"Network Selection\" \ + --backtitle \"$DIALOG_BACKTITLE\" \ --extra-button \ --extra-label \"Rescan\" \ - --backtitle \"$DIALOG_BACKTITLE\" \ - --title \"Network Selection\" \ --menu \"Select a wireless network to connect to.\" \ 0 0 0 \ $( echo $NETWORKS | tr '\n' ' ' )" \ @@ -246,8 +246,8 @@ while :; do f_dialog_yesno "Do you want to select the network manually?" || exit 1 f_dialog_input NETWORK "Enter SSID" || exit 1 ENCRYPTION=$( $DIALOG \ - --backtitle "$DIALOG_BACKTITLE" \ --title "$DIALOG_TITLE" \ + --backtitle "$DIALOG_BACKTITLE" \ --menu "Select encryption type" \ 0 0 0 \ "1 WPA/WPA2 PSK" "" \ @@ -272,9 +272,9 @@ done if echo $ENCRYPTION | grep -q 'PSK'; then exec 3>&1 PASS=$( $DIALOG \ - --insecure \ - --backtitle "$DIALOG_BACKTITLE" \ --title "WPA Setup" \ + --backtitle "$DIALOG_BACKTITLE" \ + --insecure \ --mixedform "" \ 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ @@ -294,9 +294,9 @@ if echo $ENCRYPTION | grep -q 'PSK'; then elif echo $ENCRYPTION | grep -q EAP; then exec 3>&1 USERPASS=$( $DIALOG \ - --insecure \ - --backtitle "$DIALOG_BACKTITLE" \ --title "WPA-Enterprise Setup" \ + --backtitle "$DIALOG_BACKTITLE" \ + --insecure \ --mixedform "" 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "Username" 2 0 "" 2 12 25 63 0 \ @@ -324,9 +324,9 @@ elif echo $ENCRYPTION | grep -q EAP; then elif echo $ENCRYPTION | grep -q WEP; then exec 3>&1 WEPKEY=$( $DIALOG \ - --insecure \ - --backtitle "$DIALOG_BACKTITLE" \ --title "WEP Setup" \ + --backtitle "$DIALOG_BACKTITLE" \ + --insecure \ --mixedform "" 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "WEP Key 0" 2 0 "" 2 12 15 0 1 \ From 58ce2edc9809ab06ede00832dd28396cce577661 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 21:00:09 +0000 Subject: [PATCH 082/226] Use provided API to centralize dialog title strings --- usr.sbin/bsdinstall/scripts/wlanconfig | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index a3af035f119..2787215b767 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -108,10 +108,11 @@ dialog_country_select() } }' | sort -k 2 | tr '\n' ' ' ) - f_dialog_menu_size height width rows "Regdomain selection" \ + f_dialog_title "Regdomain selection" + f_dialog_menu_size height width rows "$DIALOG_TITLE" \ "$DIALOG_BACKTITLE" "Select your regdomain." "" $regdomains regdomain=$( sh -c "$DIALOG \ - --title \"Regdomain selection\" \ + --title \"$DIALOG_TITLE\" \ --backtitle \"$DIALOG_BACKTITLE\" \ --cancel-label \"Skip\" \ --default-item \"$default_regdomain\" \ @@ -121,10 +122,11 @@ dialog_country_select() $height $width $rows $regdomains" ) - f_dialog_menu_size height width rows "Country selection" \ + f_dialog_title "Country selection" + f_dialog_menu_size height width rows "$DIALOG_TITLE" \ "$DIALOG_BACKTITLE" "Select your country." "" $countries country=$( sh -c "$DIALOG \ - --title \"Country selection\" \ + --title \"$DIALOG_TITLE\" \ --backtitle \"$DIALOG_BACKTITLE\" \ --cancel-label \"Skip\" \ --default-item \"$default_country\" \ @@ -181,8 +183,9 @@ if [ "$BSDINSTALL_CONFIGCURRENT" ]; then DEF_COUNTRY=$( echo $INPUT | cut -w -f 4 ) [ "$DEF_REGDOMAIN" = 0 ] && DEF_REGDOMAIN="" [ "$DEF_COUNTRY" = 0 ] && DEF_COUNTRY="" + f_dialog_title "Regdomain/country" $DIALOG \ - --title "Regdomain/country" \ + --title "$DIALOG_TITLE" \ --backtitle "$DIALOG_BACKTITLE" \ --yesno "Change regdomain/country (now $DEF_REGDOMAIN/$DEF_COUNTRY)?" \ 0 0 @@ -201,8 +204,9 @@ while :; do SCANSSID=0 output=$( wpa_cli scan 2>&1 ) f_dprintf "%s" "$output" + f_dialog_title "Scanning" $DIALOG \ - --title "Scanning" \ + --title "$DIALOG_TITLE" \ --backtitle "$DIALOG_BACKTITLE" \ --ok-label "Skip" \ --pause "Waiting 5 seconds to scan for wireless networks..." \ @@ -217,17 +221,19 @@ while :; do ' | sort | uniq ) if [ ! "$NETWORKS" ]; then + f_dialog_title "Error" $DIALOG \ - --title "Error" \ + --title "$DIALOG_TITLE" \ --backtitle "$DIALOG_BACKTITLE" \ --yesno "No wireless networks were found. Rescan?" \ 0 0 && continue exit 1 fi + f_dialog_title "Network Selection" exec 3>&1 NETWORK=$( sh -c "$DIALOG \ - --title \"Network Selection\" \ + --title \"$DIALOG_TITLE\" \ --backtitle \"$DIALOG_BACKTITLE\" \ --extra-button \ --extra-label \"Rescan\" \ From 35c8d5eb1b2d387f411ddc77914c3a83103cb7f3 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 21:01:20 +0000 Subject: [PATCH 083/226] Allow the script path to contain whitespace and special characters --- usr.sbin/bsdinstall/scripts/wlanconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 2787215b767..67bd779cdd9 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -286,7 +286,7 @@ if echo $ENCRYPTION | grep -q 'PSK'; then "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "Password" 2 0 "" 2 12 15 63 1 \ 2>&1 1>&3 - ) || exec $0 $@ + ) || exec "$0" $@ exec 3>&- awk 'sub(/^\t/,"")||1' \ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF @@ -308,7 +308,7 @@ elif echo $ENCRYPTION | grep -q EAP; then "Username" 2 0 "" 2 12 25 63 0 \ "Password" 3 0 "" 3 12 25 63 1 \ 2>&1 1>&3 - ) || exec $0 $@ + ) || exec "$0" $@ exec 3>&- awk 'sub(/^\t/,"")||1' \ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF @@ -337,7 +337,7 @@ elif echo $ENCRYPTION | grep -q WEP; then "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "WEP Key 0" 2 0 "" 2 12 15 0 1 \ 2>&1 1>&3 - ) || exec $0 $@ + ) || exec "$0" $@ awk 'sub(/^\t/,"")||1' \ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF network={ From bef42d18c5702ce46a149783c1446b49bbcf0d79 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 21:04:11 +0000 Subject: [PATCH 084/226] Fix invalid parameter expansion (change $@ to "$@") Without quotes, $@ loses its special meanining (see below) % sh -c 'echo $@' /bin/sh " 1 " " 2 " 1 2 % sh -c 'echo "$@"' /bin/sh " 1 " " 2 " 1 2 The quotes are required to get ARGV to be unperterped --- usr.sbin/bsdinstall/scripts/wlanconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 67bd779cdd9..6247ff868c0 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -286,7 +286,7 @@ if echo $ENCRYPTION | grep -q 'PSK'; then "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "Password" 2 0 "" 2 12 15 63 1 \ 2>&1 1>&3 - ) || exec "$0" $@ + ) || exec "$0" "$@" exec 3>&- awk 'sub(/^\t/,"")||1' \ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF @@ -308,7 +308,7 @@ elif echo $ENCRYPTION | grep -q EAP; then "Username" 2 0 "" 2 12 25 63 0 \ "Password" 3 0 "" 3 12 25 63 1 \ 2>&1 1>&3 - ) || exec "$0" $@ + ) || exec "$0" "$@" exec 3>&- awk 'sub(/^\t/,"")||1' \ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF @@ -337,7 +337,7 @@ elif echo $ENCRYPTION | grep -q WEP; then "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "WEP Key 0" 2 0 "" 2 12 15 0 1 \ 2>&1 1>&3 - ) || exec "$0" $@ + ) || exec "$0" "$@" awk 'sub(/^\t/,"")||1' \ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF network={ From d9f83eb9f44f9b201731456eace9149347772261 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 21:11:55 +0000 Subject: [PATCH 085/226] 1 is the default descriptor for redirects without an fd prefix --- usr.sbin/bsdinstall/scripts/wlanconfig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 6247ff868c0..a42331a2bce 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -240,7 +240,7 @@ while :; do --menu \"Select a wireless network to connect to.\" \ 0 0 0 \ $( echo $NETWORKS | tr '\n' ' ' )" \ - 2>&1 1>&3 + 2>&1 >&3 ) case $? in $DIALOG_OK) @@ -260,7 +260,7 @@ while :; do "2 WPA/WPA2 EAP" "" \ "3 WEP" "" \ "0 None" "" \ - 2>&1 1>&3 + 2>&1 >&3 ) || exit 1 SCANSSID=1 f_dialog_title_restore @@ -285,7 +285,7 @@ if echo $ENCRYPTION | grep -q 'PSK'; then 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "Password" 2 0 "" 2 12 15 63 1 \ - 2>&1 1>&3 + 2>&1 >&3 ) || exec "$0" "$@" exec 3>&- awk 'sub(/^\t/,"")||1' \ @@ -307,7 +307,7 @@ elif echo $ENCRYPTION | grep -q EAP; then "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "Username" 2 0 "" 2 12 25 63 0 \ "Password" 3 0 "" 3 12 25 63 1 \ - 2>&1 1>&3 + 2>&1 >&3 ) || exec "$0" "$@" exec 3>&- awk 'sub(/^\t/,"")||1' \ @@ -336,7 +336,7 @@ elif echo $ENCRYPTION | grep -q WEP; then --mixedform "" 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "WEP Key 0" 2 0 "" 2 12 15 0 1 \ - 2>&1 1>&3 + 2>&1 >&3 ) || exec "$0" "$@" awk 'sub(/^\t/,"")||1' \ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF From 0b8f01fe99f501bc7ecdcf3209a029fc9cc52b81 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 21:16:37 +0000 Subject: [PATCH 086/226] Use awk the following (more succinct) awk syntax: condition1 { action1 } condition2 { action2 } instead of the following syntax: { if (condition1) { action1 } else if (condition2) { action2 } } --- usr.sbin/bsdinstall/scripts/wlanconfig | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index a42331a2bce..c0850d1224f 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -317,13 +317,9 @@ elif echo $ENCRYPTION | grep -q EAP; then scan_ssid=$SCANSSID key_mgmt=WPA-EAP$( echo "$USERPASS" | awk ' - { - if (NR == 1) { - printf " identity=\"%s\"\n", $1; - } else if (NR == 2) { - printf " password=\"%s\"\n", $1; - } - }' ) + NR == 1 { printf "\n\t\tidentity=\"%s\"", $1; } + NR == 2 { printf "\n\t\tpassword=\"%s\"", $1; } + ' ) priority=5 } EOF From 8bcf564644eb2c435e1cae3fa02ad693bc99195c Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 21:18:24 +0000 Subject: [PATCH 087/226] Remove unnecessary semi-colons --- usr.sbin/bsdinstall/scripts/wlanconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index c0850d1224f..ce48def187a 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -216,7 +216,7 @@ while :; do NETWORKS=$( echo "$SCAN_RESULTS" | awk -F '\t' ' /..:..:..:..:..:../ { if (length($5) > 0) - printf("\"%s\"\t%s\n", $5, $4); + printf("\"%s\"\t%s\n", $5, $4) } ' | sort | uniq ) @@ -273,7 +273,7 @@ while :; do done [ "$ENCRYPTION" ] || ENCRYPTION=$( echo "$NETWORKS" | - awk -F '\t' "/^\"$NETWORK\"\t/ { printf(\"%s\n\", \\\$2 ); }" ) + awk -F '\t' "/^\"$NETWORK\"\t/ { printf(\"%s\n\", \\\$2 ) }" ) if echo $ENCRYPTION | grep -q 'PSK'; then exec 3>&1 @@ -317,8 +317,8 @@ elif echo $ENCRYPTION | grep -q EAP; then scan_ssid=$SCANSSID key_mgmt=WPA-EAP$( echo "$USERPASS" | awk ' - NR == 1 { printf "\n\t\tidentity=\"%s\"", $1; } - NR == 2 { printf "\n\t\tpassword=\"%s\"", $1; } + NR == 1 { printf "\n\t\tidentity=\"%s\"", $1 } + NR == 2 { printf "\n\t\tpassword=\"%s\"", $1 } ' ) priority=5 } From 877ea0472189a40fb6de77c59a403b75ecda99bb Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 21:20:56 +0000 Subject: [PATCH 088/226] Remove incomplete and unnecessary creation of fd3 The provided API already provides a passthru descriptor and even gives you a varaible for referring to it. --- usr.sbin/bsdinstall/scripts/wlanconfig | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index ce48def187a..924590552b7 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -231,7 +231,6 @@ while :; do fi f_dialog_title "Network Selection" - exec 3>&1 NETWORK=$( sh -c "$DIALOG \ --title \"$DIALOG_TITLE\" \ --backtitle \"$DIALOG_BACKTITLE\" \ @@ -240,7 +239,7 @@ while :; do --menu \"Select a wireless network to connect to.\" \ 0 0 0 \ $( echo $NETWORKS | tr '\n' ' ' )" \ - 2>&1 >&3 + 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) case $? in $DIALOG_OK) @@ -260,7 +259,7 @@ while :; do "2 WPA/WPA2 EAP" "" \ "3 WEP" "" \ "0 None" "" \ - 2>&1 >&3 + 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) || exit 1 SCANSSID=1 f_dialog_title_restore @@ -269,14 +268,12 @@ while :; do $DIALOG_EXTRA) # Rescan ;; esac - exec 3>&- done [ "$ENCRYPTION" ] || ENCRYPTION=$( echo "$NETWORKS" | awk -F '\t' "/^\"$NETWORK\"\t/ { printf(\"%s\n\", \\\$2 ) }" ) if echo $ENCRYPTION | grep -q 'PSK'; then - exec 3>&1 PASS=$( $DIALOG \ --title "WPA Setup" \ --backtitle "$DIALOG_BACKTITLE" \ @@ -285,9 +282,8 @@ if echo $ENCRYPTION | grep -q 'PSK'; then 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "Password" 2 0 "" 2 12 15 63 1 \ - 2>&1 >&3 + 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) || exec "$0" "$@" - exec 3>&- awk 'sub(/^\t/,"")||1' \ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF network={ @@ -298,7 +294,6 @@ if echo $ENCRYPTION | grep -q 'PSK'; then } EOF elif echo $ENCRYPTION | grep -q EAP; then - exec 3>&1 USERPASS=$( $DIALOG \ --title "WPA-Enterprise Setup" \ --backtitle "$DIALOG_BACKTITLE" \ @@ -307,9 +302,8 @@ elif echo $ENCRYPTION | grep -q EAP; then "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "Username" 2 0 "" 2 12 25 63 0 \ "Password" 3 0 "" 3 12 25 63 1 \ - 2>&1 >&3 + 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) || exec "$0" "$@" - exec 3>&- awk 'sub(/^\t/,"")||1' \ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF network={ @@ -324,7 +318,6 @@ elif echo $ENCRYPTION | grep -q EAP; then } EOF elif echo $ENCRYPTION | grep -q WEP; then - exec 3>&1 WEPKEY=$( $DIALOG \ --title "WEP Setup" \ --backtitle "$DIALOG_BACKTITLE" \ @@ -332,7 +325,7 @@ elif echo $ENCRYPTION | grep -q WEP; then --mixedform "" 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "WEP Key 0" 2 0 "" 2 12 15 0 1 \ - 2>&1 >&3 + 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) || exec "$0" "$@" awk 'sub(/^\t/,"")||1' \ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF From d124dfc410ddd969f0a5a2d3fa61e8719304b1ea Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 21:23:47 +0000 Subject: [PATCH 089/226] Utilize provided i18n strings --- usr.sbin/bsdinstall/scripts/wlanconfig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 924590552b7..94c7f9b6688 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -61,7 +61,7 @@ country_set() fi if [ "$error_str" ]; then $DIALOG \ - --title "Error" \ + --title "$msg_error" \ --backtitle "$DIALOG_BACKTITLE" \ --yes-label Change \ --no-label Ignore \ @@ -114,7 +114,7 @@ dialog_country_select() regdomain=$( sh -c "$DIALOG \ --title \"$DIALOG_TITLE\" \ --backtitle \"$DIALOG_BACKTITLE\" \ - --cancel-label \"Skip\" \ + --cancel-label \"$msg_skip\" \ --default-item \"$default_regdomain\" \ --no-items \ --stdout \ @@ -128,7 +128,7 @@ dialog_country_select() country=$( sh -c "$DIALOG \ --title \"$DIALOG_TITLE\" \ --backtitle \"$DIALOG_BACKTITLE\" \ - --cancel-label \"Skip\" \ + --cancel-label \"$msg_skip\" \ --default-item \"$default_country\" \ --stdout \ --menu \"Select your country.\" \ @@ -157,14 +157,14 @@ EOF # (wpa_cli ping >/dev/null 2>/dev/null || ([ "$BSDINSTALL_CONFIGCURRENT" ] && wpa_supplicant -B -i $1 -c "$BSDINSTALL_TMPETC/wpa_supplicant.conf")) || - ($DIALOG --backtitle "$DIALOG_BACKTITLE" --title "Error" --msgbox \ + ($DIALOG --backtitle "$DIALOG_BACKTITLE" --title "$msg_error" --msgbox \ "Could not start wpa_supplicant!" 0 0; exit 1) || exit 1 # See if we succeeded wpa_cli ping >/dev/null 2>/dev/null if [ $? -ne 0 -a ! "$BSDINSTALL_CONFIGCURRENT" ]; then $DIALOG \ - --title "Error" \ + --title "$msg_error" \ --backtitle "$DIALOG_BACKTITLE" \ --msgbox "Wireless cannot be configured without making changes to the local system!" \ 0 0 @@ -208,7 +208,7 @@ while :; do $DIALOG \ --title "$DIALOG_TITLE" \ --backtitle "$DIALOG_BACKTITLE" \ - --ok-label "Skip" \ + --ok-label "$msg_skip" \ --pause "Waiting 5 seconds to scan for wireless networks..." \ 9 40 5 || exit 1 @@ -221,7 +221,7 @@ while :; do ' | sort | uniq ) if [ ! "$NETWORKS" ]; then - f_dialog_title "Error" + f_dialog_title "$msg_error" $DIALOG \ --title "$DIALOG_TITLE" \ --backtitle "$DIALOG_BACKTITLE" \ From 1045858386331041894ce047df03e7e53949593d Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 21:26:36 +0000 Subject: [PATCH 090/226] Whitespace --- usr.sbin/bsdinstall/scripts/wlanconfig | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 94c7f9b6688..9da6e732beb 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -190,8 +190,7 @@ if [ "$BSDINSTALL_CONFIGCURRENT" ]; then --yesno "Change regdomain/country (now $DEF_REGDOMAIN/$DEF_COUNTRY)?" \ 0 0 if [ $? -eq 0 ]; then - while : - do + while :; do dialog_country_select "$DEF_REGDOMAIN" "$DEF_COUNTRY" if [ $? -eq $SUCCESS ]; then break @@ -242,9 +241,7 @@ while :; do 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) case $? in - $DIALOG_OK) - break - ;; + $DIALOG_OK) break ;; $DIALOG_CANCEL) # here we ask if the user wants to select the network manually f_dialog_title "Network Selection" @@ -298,7 +295,8 @@ elif echo $ENCRYPTION | grep -q EAP; then --title "WPA-Enterprise Setup" \ --backtitle "$DIALOG_BACKTITLE" \ --insecure \ - --mixedform "" 0 0 0 \ + --mixedform "" \ + 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "Username" 2 0 "" 2 12 25 63 0 \ "Password" 3 0 "" 3 12 25 63 1 \ @@ -322,7 +320,8 @@ elif echo $ENCRYPTION | grep -q WEP; then --title "WEP Setup" \ --backtitle "$DIALOG_BACKTITLE" \ --insecure \ - --mixedform "" 0 0 0 \ + --mixedform "" \ + 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ "WEP Key 0" 2 0 "" 2 12 15 0 1 \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD From 275c0c07413075b80a69e08e35836ea4404f6133 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 21:27:29 +0000 Subject: [PATCH 091/226] Remove an unnecessary call to f_dialog_title_restore() --- usr.sbin/bsdinstall/scripts/wlanconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 9da6e732beb..2239388bcbf 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -259,7 +259,6 @@ while :; do 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) || exit 1 SCANSSID=1 - f_dialog_title_restore break ;; $DIALOG_EXTRA) # Rescan From 6c26775c2faa10b67337a2a6d77ec007e7910931 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 21:29:48 +0000 Subject: [PATCH 092/226] In awk, casting a variable as a boolean condition is the same as testing if the length of the variable contents is greater than zero This allows us to also move the secondary condition into the action clause --- usr.sbin/bsdinstall/scripts/wlanconfig | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 2239388bcbf..cde3c901bca 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -213,10 +213,7 @@ while :; do SCAN_RESULTS=$( wpa_cli scan_results ) NETWORKS=$( echo "$SCAN_RESULTS" | awk -F '\t' ' - /..:..:..:..:..:../ { - if (length($5) > 0) - printf("\"%s\"\t%s\n", $5, $4) - } + /..:..:..:..:..:../ && $5 { printf("\"%s\"\t%s\n", $5, $4) } ' | sort | uniq ) if [ ! "$NETWORKS" ]; then From fe56b177108edfcaafc53cf2acbd933d0bd1efc8 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Mon, 12 Dec 2016 22:51:29 +0000 Subject: [PATCH 093/226] Add tests for reaper receiving SIGCHLD (r309886). PR: 213928 MFC after: 2 weeks --- tests/sys/kern/reaper.c | 162 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) diff --git a/tests/sys/kern/reaper.c b/tests/sys/kern/reaper.c index 58e0261fb5c..d11ee704bdf 100644 --- a/tests/sys/kern/reaper.c +++ b/tests/sys/kern/reaper.c @@ -35,6 +35,11 @@ __FBSDID("$FreeBSD$"); #include #include +static void +dummy_sighandler(int sig __unused, siginfo_t *info __unused, void *ctx __unused) +{ +} + ATF_TC_WITHOUT_HEAD(reaper_wait_child_first); ATF_TC_BODY(reaper_wait_child_first, tc) { @@ -129,6 +134,161 @@ ATF_TC_BODY(reaper_wait_grandchild_first, tc) ATF_CHECK_EQ(2, r); } +ATF_TC(reaper_sigchld_child_first); +ATF_TC_HEAD(reaper_sigchld_child_first, tc) +{ + atf_tc_set_md_var(tc, "timeout", "2"); +} +ATF_TC_BODY(reaper_sigchld_child_first, tc) +{ + struct sigaction act; + sigset_t mask; + siginfo_t info; + pid_t parent, child, grandchild, pid; + int r; + int pip[2]; + + /* Be paranoid. */ + pid = waitpid(-1, NULL, WNOHANG); + ATF_REQUIRE(pid == -1 && errno == ECHILD); + + act.sa_sigaction = dummy_sighandler; + act.sa_flags = SA_SIGINFO | SA_RESTART; + r = sigemptyset(&act.sa_mask); + ATF_REQUIRE_EQ(0, r); + r = sigaction(SIGCHLD, &act, NULL); + ATF_REQUIRE_EQ(0, r); + + r = sigemptyset(&mask); + ATF_REQUIRE_EQ(0, r); + r = sigaddset(&mask, SIGCHLD); + ATF_REQUIRE_EQ(0, r); + r = sigprocmask(SIG_BLOCK, &mask, NULL); + ATF_REQUIRE_EQ(0, r); + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + r = pipe(pip); + ATF_REQUIRE_EQ(0, r); + + child = fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + if (close(pip[1]) != 0) + _exit(100); + grandchild = fork(); + if (grandchild == -1) + _exit(101); + else if (grandchild == 0) { + if (read(pip[0], &(uint8_t){ 0 }, 1) != 0) + _exit(102); + if (getppid() != parent) + _exit(103); + _exit(2); + } else + _exit(3); + } + + r = sigwaitinfo(&mask, &info); + ATF_REQUIRE_EQ(SIGCHLD, r); + ATF_CHECK_EQ(SIGCHLD, info.si_signo); + ATF_CHECK_EQ(CLD_EXITED, info.si_code); + ATF_CHECK_EQ(3, info.si_status); + ATF_CHECK_EQ(child, info.si_pid); + + pid = waitpid(child, NULL, 0); + ATF_REQUIRE_EQ(child, pid); + + r = close(pip[1]); + ATF_REQUIRE_EQ(0, r); + + r = sigwaitinfo(&mask, &info); + ATF_REQUIRE_EQ(SIGCHLD, r); + ATF_CHECK_EQ(SIGCHLD, info.si_signo); + ATF_CHECK_EQ(CLD_EXITED, info.si_code); + ATF_CHECK_EQ(2, info.si_status); + grandchild = info.si_pid; + ATF_REQUIRE(grandchild > 0); + ATF_REQUIRE(grandchild != parent); + ATF_REQUIRE(grandchild != child); + + pid = waitpid(-1, NULL, 0); + ATF_REQUIRE_EQ(grandchild, pid); + + r = close(pip[0]); + ATF_REQUIRE_EQ(0, r); +} + +ATF_TC(reaper_sigchld_grandchild_first); +ATF_TC_HEAD(reaper_sigchld_grandchild_first, tc) +{ + atf_tc_set_md_var(tc, "timeout", "2"); +} +ATF_TC_BODY(reaper_sigchld_grandchild_first, tc) +{ + struct sigaction act; + sigset_t mask; + siginfo_t info; + pid_t parent, child, grandchild, pid; + int r; + + /* Be paranoid. */ + pid = waitpid(-1, NULL, WNOHANG); + ATF_REQUIRE(pid == -1 && errno == ECHILD); + + act.sa_sigaction = dummy_sighandler; + act.sa_flags = SA_SIGINFO | SA_RESTART; + r = sigemptyset(&act.sa_mask); + ATF_REQUIRE_EQ(0, r); + r = sigaction(SIGCHLD, &act, NULL); + ATF_REQUIRE_EQ(0, r); + + r = sigemptyset(&mask); + ATF_REQUIRE_EQ(0, r); + r = sigaddset(&mask, SIGCHLD); + ATF_REQUIRE_EQ(0, r); + r = sigprocmask(SIG_BLOCK, &mask, NULL); + ATF_REQUIRE_EQ(0, r); + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + child = fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + grandchild = fork(); + if (grandchild == -1) + _exit(101); + else if (grandchild == 0) + _exit(2); + else { + if (waitid(P_PID, grandchild, NULL, + WNOWAIT | WEXITED) != 0) + _exit(102); + _exit(3); + } + } + + pid = waitpid(child, NULL, 0); + ATF_REQUIRE_EQ(child, pid); + + r = sigwaitinfo(&mask, &info); + ATF_REQUIRE_EQ(SIGCHLD, r); + ATF_CHECK_EQ(SIGCHLD, info.si_signo); + ATF_CHECK_EQ(CLD_EXITED, info.si_code); + ATF_CHECK_EQ(2, info.si_status); + grandchild = info.si_pid; + ATF_REQUIRE(grandchild > 0); + ATF_REQUIRE(grandchild != parent); + ATF_REQUIRE(grandchild != child); + + pid = waitpid(-1, NULL, 0); + ATF_REQUIRE_EQ(grandchild, pid); +} + ATF_TC_WITHOUT_HEAD(reaper_status); ATF_TC_BODY(reaper_status, tc) { @@ -484,6 +644,8 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, reaper_wait_child_first); ATF_TP_ADD_TC(tp, reaper_wait_grandchild_first); + ATF_TP_ADD_TC(tp, reaper_sigchld_child_first); + ATF_TP_ADD_TC(tp, reaper_sigchld_grandchild_first); ATF_TP_ADD_TC(tp, reaper_status); ATF_TP_ADD_TC(tp, reaper_getpids); ATF_TP_ADD_TC(tp, reaper_kill_badsig); From 49748e0a6d914c44733f9344926eee2e2fc85215 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Mon, 12 Dec 2016 22:57:07 +0000 Subject: [PATCH 094/226] Quote WLAN_IFACE (pedantic) --- usr.sbin/bsdinstall/scripts/wlanconfig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index cde3c901bca..f3ad78b6192 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -50,13 +50,13 @@ country_set() ifconfig_args="${ifconfig_args# }" # Regdomain/country cannot be applied while interface is running - iface_up=$( ifconfig -lu | grep -w $WLAN_IFACE ) - [ "$iface_up" ] && ifconfig $WLAN_IFACE down - error_str=$( ifconfig $WLAN_IFACE $ifconfig_args 2>&1 | + iface_up=$( ifconfig -lu | grep -w "$WLAN_IFACE" ) + [ "$iface_up" ] && ifconfig "$WLAN_IFACE" down + error_str=$( ifconfig "$WLAN_IFACE" $ifconfig_args 2>&1 | sed -e 's/ifconfig: //' ) if [ "$iface_up" ]; then # Restart wpa_supplicant(8) (should not fail). - wpa_supplicant -B -i $WLAN_IFACE -c \ + wpa_supplicant -B -i "$WLAN_IFACE" -c \ "$BSDINSTALL_TMPETC/wpa_supplicant.conf" fi if [ "$error_str" ]; then @@ -93,7 +93,7 @@ dialog_country_select() # # Parse available countries/regdomains # - input=$( ifconfig $WLAN_IFACE list countries | sed -e 's/DEBUG//gi' ) + input=$( ifconfig "$WLAN_IFACE" list countries | sed -e 's/DEBUG//gi' ) regdomains=$( echo $input | sed -e 's/.*domains://' | tr ' ' '\n' | sort | tr '\n' ' ' ) countries=$( echo $input | awk '{ @@ -178,7 +178,7 @@ fi if [ "$BSDINSTALL_CONFIGCURRENT" ]; then # Get current country/regdomain for selected interface WLAN_IFACE=$( wpa_cli ifname | tail -1 ) - INPUT=$( ifconfig $WLAN_IFACE list regdomain | head -1 ) + INPUT=$( ifconfig "$WLAN_IFACE" list regdomain | head -1 ) DEF_REGDOMAIN=$( echo $INPUT | cut -w -f 2 ) DEF_COUNTRY=$( echo $INPUT | cut -w -f 4 ) [ "$DEF_REGDOMAIN" = 0 ] && DEF_REGDOMAIN="" From e7f2eb12c2e1da17c24a5abbd7beb2ddcd76e4b1 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 00:02:59 +0000 Subject: [PATCH 095/226] Use the oft-neglected awk syntax "startcondition, stopcondition { ... }" to process the range of country labels which appear as columnar list from the "ifconfig DEV list countries" command. Not only improving maintainability, but also properly encapsulating arguments in single-quotes instead of trying to escape whitespace. It is also completely unnecessary to collapse newlines into whitespace (shell will do this for you automatically upon expansion of the contents where necessary). NB: This also changes the sorting algorithm to sort on the country code, not the country name. The type-ahead feature of dialog is destroyed if the tags are not sorted properly. --- usr.sbin/bsdinstall/scripts/wlanconfig | 40 ++++++++++++++------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index f3ad78b6192..0c1d9a6cf6c 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -96,17 +96,19 @@ dialog_country_select() input=$( ifconfig "$WLAN_IFACE" list countries | sed -e 's/DEBUG//gi' ) regdomains=$( echo $input | sed -e 's/.*domains://' | tr ' ' '\n' | sort | tr '\n' ' ' ) - countries=$( echo $input | awk '{ - sub(/Country codes:/, "") - sub(/Regulatory.*/, "") - for (i = 1; i <= NF; i++) { - printf "%s", $i - if ($i ~ /[[:lower:]]/) - printf $(i+1) ~ /[[:lower:]]/ ? "\\\\\\ " : "\n" - else - printf " " + countries=$( echo "$input" | awk ' + sub(/Country codes:/, ""), sub(/Regulatory.*/, "") { + while (match($0, /[[:upper:]][[:upper:][:digit:]] /)) { + country = substr($0, RSTART) + sub(/ [[:upper:]][[:upper:][:digit:]].*/, "", country) + code = substr(country, 1, 2) + desc = substr(country, 4) + sub(/[[:space:]]*$/, "", desc) + printf "'\''%s'\'' '\''%s'\''\n", code, desc + $0 = substr($0, RSTART + RLENGTH) + } } - }' | sort -k 2 | tr '\n' ' ' ) + ' | sort ) f_dialog_title "Regdomain selection" f_dialog_menu_size height width rows "$DIALOG_TITLE" \ @@ -123,16 +125,18 @@ dialog_country_select() ) f_dialog_title "Country selection" - f_dialog_menu_size height width rows "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" "Select your country." "" $countries - country=$( sh -c "$DIALOG \ - --title \"$DIALOG_TITLE\" \ - --backtitle \"$DIALOG_BACKTITLE\" \ - --cancel-label \"$msg_skip\" \ + eval f_dialog_menu_size height width rows \ + \"\$DIALOG_TITLE\" \"\$DIALOG_BACKTITLE\" \ + \"Select your country.\" \"\" $countries + country=$( eval $DIALOG \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --cancel-label \"\$msg_skip\" \ --default-item \"$default_country\" \ - --stdout \ --menu \"Select your country.\" \ - $height $width $rows $countries" + $height $width $rows \ + $countries \ + 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) country_set "$regdomain" "$country" From e2577019ed8163a92f7bd13de6bd8570b1a3468e Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 00:18:51 +0000 Subject: [PATCH 096/226] Add missing backslash (no real effect; it's pedantic and correct for the interpolation level) --- usr.sbin/bsdinstall/scripts/wlanconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 0c1d9a6cf6c..2850e1a80b4 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -132,7 +132,7 @@ dialog_country_select() --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --cancel-label \"\$msg_skip\" \ - --default-item \"$default_country\" \ + --default-item \"\$default_country\" \ --menu \"Select your country.\" \ $height $width $rows \ $countries \ From 1c61211223c7ab71c6189422ccb467a577544f98 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 00:22:01 +0000 Subject: [PATCH 097/226] Stop repeating strings (centralize prompt string) NB: Changes to strings now only affect a single line --- usr.sbin/bsdinstall/scripts/wlanconfig | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 2850e1a80b4..b81be8d0091 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -85,7 +85,7 @@ country_set() dialog_country_select() { - local input regdomains countries regdomain country + local input regdomains countries regdomain country prompt local no_default="" local default_regdomain="${1:-$no_default}" local default_country="${2:-$no_default}" @@ -111,8 +111,9 @@ dialog_country_select() ' | sort ) f_dialog_title "Regdomain selection" + prompt="Select your regdomain." f_dialog_menu_size height width rows "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" "Select your regdomain." "" $regdomains + "$DIALOG_BACKTITLE" "$prompt" "" $regdomains regdomain=$( sh -c "$DIALOG \ --title \"$DIALOG_TITLE\" \ --backtitle \"$DIALOG_BACKTITLE\" \ @@ -120,20 +121,21 @@ dialog_country_select() --default-item \"$default_regdomain\" \ --no-items \ --stdout \ - --menu \"Select your regdomain.\" \ + --menu \"$prompt\" \ $height $width $rows $regdomains" ) f_dialog_title "Country selection" + prompt="Select your country." eval f_dialog_menu_size height width rows \ \"\$DIALOG_TITLE\" \"\$DIALOG_BACKTITLE\" \ - \"Select your country.\" \"\" $countries + \"\$prompt\" \"\" $countries country=$( eval $DIALOG \ --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --cancel-label \"\$msg_skip\" \ --default-item \"\$default_country\" \ - --menu \"Select your country.\" \ + --menu \"\$prompt\" \ $height $width $rows \ $countries \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD From 6e038cc2eb64e08811751362676aa9edb9991543 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 00:27:56 +0000 Subject: [PATCH 098/226] More efficiently make use of the exit status --- usr.sbin/bsdinstall/scripts/wlanconfig | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index b81be8d0091..b9202044f50 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -67,12 +67,8 @@ country_set() --no-label Ignore \ --yesno \ "Error while applying chosen settings ($error_str)" \ - 0 0 - if [ $? -eq $DIALOG_OK ]; then - return $FAILURE # Restart - else - return $SUCCESS # Skip - fi + 0 0 || return $SUCCESS # Skip + return $FAILURE # Restart else awk 'sub(/^\t\t/,"")||1' \ > "$BSDINSTALL_TMPETC/rc.conf.net.wlan" <<-EOF From 95ee591e83a91fa01aac15b40b8f2aa9badeb28a Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 01:35:26 +0000 Subject: [PATCH 099/226] The --no-items and --stdout options are non-standard and should be avoided From the dialog(1) manual: using [--stdout] in portable scripts is not recommended --- usr.sbin/bsdinstall/scripts/wlanconfig | 32 +++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index b9202044f50..9b8d27c7ba0 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -90,8 +90,13 @@ dialog_country_select() # Parse available countries/regdomains # input=$( ifconfig "$WLAN_IFACE" list countries | sed -e 's/DEBUG//gi' ) - regdomains=$( echo $input | sed -e 's/.*domains://' | tr ' ' '\n' | - sort | tr '\n' ' ' ) + regdomains=$( echo "$input" | awk ' + sub(/.*domains:/, ""), /[^[:alnum:][[:space:]]/ { + n = split($0, domains) + for (i = 1; i <= n; i++) + printf "'\''%s'\'' '\'\''", domains[i] + } + ' ) countries=$( echo "$input" | awk ' sub(/Country codes:/, ""), sub(/Regulatory.*/, "") { while (match($0, /[[:upper:]][[:upper:][:digit:]] /)) { @@ -108,17 +113,18 @@ dialog_country_select() f_dialog_title "Regdomain selection" prompt="Select your regdomain." - f_dialog_menu_size height width rows "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" "$prompt" "" $regdomains - regdomain=$( sh -c "$DIALOG \ - --title \"$DIALOG_TITLE\" \ - --backtitle \"$DIALOG_BACKTITLE\" \ - --cancel-label \"$msg_skip\" \ - --default-item \"$default_regdomain\" \ - --no-items \ - --stdout \ - --menu \"$prompt\" \ - $height $width $rows $regdomains" + eval f_dialog_menu_size height width rows \ + \"\$DIALOG_TITLE\" \"\$DIALOG_BACKTITLE\" \ + \"\$prompt\" \"\" $regdomains + regdomain=$( eval $DIALOG \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --cancel-label \"\$msg_skip\" \ + --default-item \"\$default_regdomain\" \ + --menu \"\$prompt\" \ + $height $width $rows \ + $regdomains \ + 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) f_dialog_title "Country selection" From d401d36c04ce49c9725db37913b9e3e9e9cb381b Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 01:36:46 +0000 Subject: [PATCH 100/226] Sort the domains --- usr.sbin/bsdinstall/scripts/wlanconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 9b8d27c7ba0..11c80fbc44d 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -96,7 +96,7 @@ dialog_country_select() for (i = 1; i <= n; i++) printf "'\''%s'\'' '\'\''", domains[i] } - ' ) + ' | sort ) countries=$( echo "$input" | awk ' sub(/Country codes:/, ""), sub(/Regulatory.*/, "") { while (match($0, /[[:upper:]][[:upper:][:digit:]] /)) { From f20b7768fcdf572dca998d3745fad71c187596bc Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 01:39:09 +0000 Subject: [PATCH 101/226] Whitespace alignment --- usr.sbin/bsdinstall/scripts/wlanconfig | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 11c80fbc44d..f892d28d7fc 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -117,13 +117,13 @@ dialog_country_select() \"\$DIALOG_TITLE\" \"\$DIALOG_BACKTITLE\" \ \"\$prompt\" \"\" $regdomains regdomain=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --cancel-label \"\$msg_skip\" \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --cancel-label \"\$msg_skip\" \ --default-item \"\$default_regdomain\" \ - --menu \"\$prompt\" \ - $height $width $rows \ - $regdomains \ + --menu \"\$prompt\" \ + $height $width $rows \ + $regdomains \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) @@ -133,13 +133,13 @@ dialog_country_select() \"\$DIALOG_TITLE\" \"\$DIALOG_BACKTITLE\" \ \"\$prompt\" \"\" $countries country=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --cancel-label \"\$msg_skip\" \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --cancel-label \"\$msg_skip\" \ --default-item \"\$default_country\" \ - --menu \"\$prompt\" \ - $height $width $rows \ - $countries \ + --menu \"\$prompt\" \ + $height $width $rows \ + $countries \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) From f52733d46e1712169d71ee67d56b88201c47d656 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 01:41:06 +0000 Subject: [PATCH 102/226] The output of dialog needs to be sanitized for portability/compatibility requirements --- usr.sbin/bsdinstall/scripts/wlanconfig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index f892d28d7fc..d2b307f88c7 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -126,6 +126,7 @@ dialog_country_select() $regdomains \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) + f_dialog_data_sanitize regdomain f_dialog_title "Country selection" prompt="Select your country." @@ -142,6 +143,7 @@ dialog_country_select() $countries \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) + f_dialog_data_sanitize country country_set "$regdomain" "$country" } @@ -245,7 +247,9 @@ while :; do $( echo $NETWORKS | tr '\n' ' ' )" \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) - case $? in + retval=$? + f_dialog_data_sanitize NETWORK + case $retval in $DIALOG_OK) break ;; $DIALOG_CANCEL) # here we ask if the user wants to select the network manually From a51195769ae7fba19bf006f639058adadb30b615 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 01:42:13 +0000 Subject: [PATCH 103/226] Use more generic f_yesno() from provided API --- usr.sbin/bsdinstall/scripts/wlanconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index d2b307f88c7..4b7f559e93d 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -254,7 +254,7 @@ while :; do $DIALOG_CANCEL) # here we ask if the user wants to select the network manually f_dialog_title "Network Selection" - f_dialog_yesno "Do you want to select the network manually?" || exit 1 + f_yesno "Do you want to select the network manually?" || exit 1 f_dialog_input NETWORK "Enter SSID" || exit 1 ENCRYPTION=$( $DIALOG \ --title "$DIALOG_TITLE" \ From 66ef7d945511306681f75b863ccc3412c2950e82 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 01:44:18 +0000 Subject: [PATCH 104/226] Properly quote variable --- usr.sbin/bsdinstall/scripts/wlanconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 4b7f559e93d..e247e2d3bd7 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -189,8 +189,8 @@ if [ "$BSDINSTALL_CONFIGCURRENT" ]; then # Get current country/regdomain for selected interface WLAN_IFACE=$( wpa_cli ifname | tail -1 ) INPUT=$( ifconfig "$WLAN_IFACE" list regdomain | head -1 ) - DEF_REGDOMAIN=$( echo $INPUT | cut -w -f 2 ) - DEF_COUNTRY=$( echo $INPUT | cut -w -f 4 ) + DEF_REGDOMAIN=$( echo "$INPUT" | cut -w -f 2 ) + DEF_COUNTRY=$( echo "$INPUT" | cut -w -f 4 ) [ "$DEF_REGDOMAIN" = 0 ] && DEF_REGDOMAIN="" [ "$DEF_COUNTRY" = 0 ] && DEF_COUNTRY="" f_dialog_title "Regdomain/country" From 751993945a9dfa3fa7d0658376691b3c354b3a75 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 01:50:22 +0000 Subject: [PATCH 105/226] Why repeat yourself when you can send stderr to the same place as stdout? --- usr.sbin/bsdinstall/scripts/wlanconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index e247e2d3bd7..96a0de1c0ec 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -165,13 +165,13 @@ EOF # Try to reach wpa_supplicant. If it isn't running and we can modify the # existing system, start it. Otherwise, fail. # -(wpa_cli ping >/dev/null 2>/dev/null || ([ "$BSDINSTALL_CONFIGCURRENT" ] && +(wpa_cli ping > /dev/null 2>&1 || ([ "$BSDINSTALL_CONFIGCURRENT" ] && wpa_supplicant -B -i $1 -c "$BSDINSTALL_TMPETC/wpa_supplicant.conf")) || ($DIALOG --backtitle "$DIALOG_BACKTITLE" --title "$msg_error" --msgbox \ "Could not start wpa_supplicant!" 0 0; exit 1) || exit 1 # See if we succeeded -wpa_cli ping >/dev/null 2>/dev/null +wpa_cli ping > /dev/null 2>&1 if [ $? -ne 0 -a ! "$BSDINSTALL_CONFIGCURRENT" ]; then $DIALOG \ --title "$msg_error" \ From 19cae84e23ad845f1b3f4970413effc8784f0fce Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 01:52:10 +0000 Subject: [PATCH 106/226] Remove completely unnecesary parentheses --- usr.sbin/bsdinstall/scripts/wlanconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 96a0de1c0ec..fe55f6a626b 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -165,10 +165,10 @@ EOF # Try to reach wpa_supplicant. If it isn't running and we can modify the # existing system, start it. Otherwise, fail. # -(wpa_cli ping > /dev/null 2>&1 || ([ "$BSDINSTALL_CONFIGCURRENT" ] && - wpa_supplicant -B -i $1 -c "$BSDINSTALL_TMPETC/wpa_supplicant.conf")) || - ($DIALOG --backtitle "$DIALOG_BACKTITLE" --title "$msg_error" --msgbox \ - "Could not start wpa_supplicant!" 0 0; exit 1) || exit 1 +wpa_cli ping > /dev/null 2>&1 || ([ "$BSDINSTALL_CONFIGCURRENT" ] && + wpa_supplicant -B -i $1 -c "$BSDINSTALL_TMPETC/wpa_supplicant.conf") || + $DIALOG --backtitle "$DIALOG_BACKTITLE" --title "$msg_error" --msgbox \ + "Could not start wpa_supplicant!" 0 0; exit 1 || exit 1 # See if we succeeded wpa_cli ping > /dev/null 2>&1 From a1a6fec1c709622930c7a26b86259e45791259ad Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 01:54:44 +0000 Subject: [PATCH 107/226] Start deconstructing a conveluted hunk of code --- usr.sbin/bsdinstall/scripts/wlanconfig | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index fe55f6a626b..834090e0db3 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -165,10 +165,12 @@ EOF # Try to reach wpa_supplicant. If it isn't running and we can modify the # existing system, start it. Otherwise, fail. # -wpa_cli ping > /dev/null 2>&1 || ([ "$BSDINSTALL_CONFIGCURRENT" ] && - wpa_supplicant -B -i $1 -c "$BSDINSTALL_TMPETC/wpa_supplicant.conf") || - $DIALOG --backtitle "$DIALOG_BACKTITLE" --title "$msg_error" --msgbox \ - "Could not start wpa_supplicant!" 0 0; exit 1 || exit 1 +if ! wpa_cli ping > /dev/null 2>&1; then + ([ "$BSDINSTALL_CONFIGCURRENT" ] && + wpa_supplicant -B -i $1 -c "$BSDINSTALL_TMPETC/wpa_supplicant.conf") || + $DIALOG --backtitle "$DIALOG_BACKTITLE" --title "$msg_error" --msgbox \ + "Could not start wpa_supplicant!" 0 0; exit 1 || exit 1 +fi # See if we succeeded wpa_cli ping > /dev/null 2>&1 From 6b77f63e5dfb448c025813badcc8e0509725167b Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 01:56:28 +0000 Subject: [PATCH 108/226] If the first ping succeeded, why on Earth should we ping it again? --- usr.sbin/bsdinstall/scripts/wlanconfig | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 834090e0db3..32b83299ebf 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -170,18 +170,18 @@ if ! wpa_cli ping > /dev/null 2>&1; then wpa_supplicant -B -i $1 -c "$BSDINSTALL_TMPETC/wpa_supplicant.conf") || $DIALOG --backtitle "$DIALOG_BACKTITLE" --title "$msg_error" --msgbox \ "Could not start wpa_supplicant!" 0 0; exit 1 || exit 1 + + wpa_cli ping > /dev/null 2>&1 + if [ $? -ne 0 -a ! "$BSDINSTALL_CONFIGCURRENT" ]; then + $DIALOG \ + --title "$msg_error" \ + --backtitle "$DIALOG_BACKTITLE" \ + --msgbox "Wireless cannot be configured without making changes to the local system!" \ + 0 0 + exit 1 + fi fi -# See if we succeeded -wpa_cli ping > /dev/null 2>&1 -if [ $? -ne 0 -a ! "$BSDINSTALL_CONFIGCURRENT" ]; then - $DIALOG \ - --title "$msg_error" \ - --backtitle "$DIALOG_BACKTITLE" \ - --msgbox "Wireless cannot be configured without making changes to the local system!" \ - 0 0 - exit 1 -fi # # There is no way to check country/regdomain without (possible) From 7f513d3675e6136e2905fa9f4504143f5b8336b2 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 01:59:35 +0000 Subject: [PATCH 109/226] Why use $? when you can use the command itself --- usr.sbin/bsdinstall/scripts/wlanconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 32b83299ebf..9c5422eafe0 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -171,8 +171,7 @@ if ! wpa_cli ping > /dev/null 2>&1; then $DIALOG --backtitle "$DIALOG_BACKTITLE" --title "$msg_error" --msgbox \ "Could not start wpa_supplicant!" 0 0; exit 1 || exit 1 - wpa_cli ping > /dev/null 2>&1 - if [ $? -ne 0 -a ! "$BSDINSTALL_CONFIGCURRENT" ]; then + if ! wpa_cli ping > /dev/null 2>&1 && [ ! "$BSDINSTALL_CONFIGCURRENT" ]; then $DIALOG \ --title "$msg_error" \ --backtitle "$DIALOG_BACKTITLE" \ From 32c34b0361cb9c8087b6d51f177fb725d8e4b3af Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:02:14 +0000 Subject: [PATCH 110/226] These two error messages have always been backwards since inception --- usr.sbin/bsdinstall/scripts/wlanconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 9c5422eafe0..a904546b4cb 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -169,13 +169,13 @@ if ! wpa_cli ping > /dev/null 2>&1; then ([ "$BSDINSTALL_CONFIGCURRENT" ] && wpa_supplicant -B -i $1 -c "$BSDINSTALL_TMPETC/wpa_supplicant.conf") || $DIALOG --backtitle "$DIALOG_BACKTITLE" --title "$msg_error" --msgbox \ - "Could not start wpa_supplicant!" 0 0; exit 1 || exit 1 + "Wireless cannot be configured without making changes to the local system!" 0 0; exit 1 || exit 1 if ! wpa_cli ping > /dev/null 2>&1 && [ ! "$BSDINSTALL_CONFIGCURRENT" ]; then $DIALOG \ --title "$msg_error" \ --backtitle "$DIALOG_BACKTITLE" \ - --msgbox "Wireless cannot be configured without making changes to the local system!" \ + --msgbox "Could not start wpa_supplicant!" \ 0 0 exit 1 fi From 0724c87c959013839986da5054efe6a58e0ec99f Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:04:50 +0000 Subject: [PATCH 111/226] Continued resolution of conveluted statement We shouldn't be coding things like "x || (x && x) || x || x || x ..." --- usr.sbin/bsdinstall/scripts/wlanconfig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index a904546b4cb..8887491bd5c 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -166,10 +166,12 @@ EOF # existing system, start it. Otherwise, fail. # if ! wpa_cli ping > /dev/null 2>&1; then - ([ "$BSDINSTALL_CONFIGCURRENT" ] && - wpa_supplicant -B -i $1 -c "$BSDINSTALL_TMPETC/wpa_supplicant.conf") || + if [ ! "$BSDINSTALL_CONFIGCURRENT" ]; then $DIALOG --backtitle "$DIALOG_BACKTITLE" --title "$msg_error" --msgbox \ - "Wireless cannot be configured without making changes to the local system!" 0 0; exit 1 || exit 1 + "Wireless cannot be configured without making changes to the local system!" 0 0 + exit 1 + fi + wpa_supplicant -B -i $1 -c "$BSDINSTALL_TMPETC/wpa_supplicant.conf") || exit 1 if ! wpa_cli ping > /dev/null 2>&1 && [ ! "$BSDINSTALL_CONFIGCURRENT" ]; then $DIALOG \ From 191441eed8d58efba8e61200aa46abe48ee73918 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:07:12 +0000 Subject: [PATCH 112/226] You don't need parentheses for awk's printf --- usr.sbin/bsdinstall/scripts/wlanconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 8887491bd5c..1d2f6060a82 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -226,7 +226,7 @@ while :; do SCAN_RESULTS=$( wpa_cli scan_results ) NETWORKS=$( echo "$SCAN_RESULTS" | awk -F '\t' ' - /..:..:..:..:..:../ && $5 { printf("\"%s\"\t%s\n", $5, $4) } + /..:..:..:..:..:../ && $5 { printf "\"%s\"\t%s\n", $5, $4 } ' | sort | uniq ) if [ ! "$NETWORKS" ]; then From 5943bcd19f8450210c072fbd0cfbac1aff7e2426 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:11:09 +0000 Subject: [PATCH 113/226] Whitespace and alignment --- usr.sbin/bsdinstall/scripts/wlanconfig | 39 +++++++++++++------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 1d2f6060a82..9b26196d551 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -183,7 +183,6 @@ if ! wpa_cli ping > /dev/null 2>&1; then fi fi - # # There is no way to check country/regdomain without (possible) # interface state modification @@ -283,13 +282,13 @@ done if echo $ENCRYPTION | grep -q 'PSK'; then PASS=$( $DIALOG \ - --title "WPA Setup" \ - --backtitle "$DIALOG_BACKTITLE" \ - --insecure \ - --mixedform "" \ - 0 0 0 \ + --title "WPA Setup" \ + --backtitle "$DIALOG_BACKTITLE" \ + --insecure \ + --mixedform "" \ + 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ - "Password" 2 0 "" 2 12 15 63 1 \ + "Password" 2 0 "" 2 12 15 63 1 \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) || exec "$0" "$@" awk 'sub(/^\t/,"")||1' \ @@ -303,14 +302,14 @@ if echo $ENCRYPTION | grep -q 'PSK'; then EOF elif echo $ENCRYPTION | grep -q EAP; then USERPASS=$( $DIALOG \ - --title "WPA-Enterprise Setup" \ - --backtitle "$DIALOG_BACKTITLE" \ - --insecure \ - --mixedform "" \ - 0 0 0 \ + --title "WPA-Enterprise Setup" \ + --backtitle "$DIALOG_BACKTITLE" \ + --insecure \ + --mixedform "" \ + 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ - "Username" 2 0 "" 2 12 25 63 0 \ - "Password" 3 0 "" 3 12 25 63 1 \ + "Username" 2 0 "" 2 12 25 63 0 \ + "Password" 3 0 "" 3 12 25 63 1 \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) || exec "$0" "$@" awk 'sub(/^\t/,"")||1' \ @@ -328,13 +327,13 @@ elif echo $ENCRYPTION | grep -q EAP; then EOF elif echo $ENCRYPTION | grep -q WEP; then WEPKEY=$( $DIALOG \ - --title "WEP Setup" \ - --backtitle "$DIALOG_BACKTITLE" \ - --insecure \ - --mixedform "" \ - 0 0 0 \ + --title "WEP Setup" \ + --backtitle "$DIALOG_BACKTITLE" \ + --insecure \ + --mixedform "" \ + 0 0 0 \ "SSID" 1 0 "$NETWORK" 1 12 0 0 2 \ - "WEP Key 0" 2 0 "" 2 12 15 0 1 \ + "WEP Key 0" 2 0 "" 2 12 15 0 1 \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) || exec "$0" "$@" awk 'sub(/^\t/,"")||1' \ From be34885e2a7f72ac497d63fa935541b3efbd35af Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:12:00 +0000 Subject: [PATCH 114/226] Neither printf (and as is commonly known) nor print need parens in awk --- usr.sbin/bsdinstall/scripts/wlanconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 9b26196d551..eecee25529b 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -278,7 +278,7 @@ while :; do done [ "$ENCRYPTION" ] || ENCRYPTION=$( echo "$NETWORKS" | - awk -F '\t' "/^\"$NETWORK\"\t/ { printf(\"%s\n\", \\\$2 ) }" ) + awk -F '\t' "/^\"$NETWORK\"\t/ { printf \"%s\n\", \\\$2 }" ) if echo $ENCRYPTION | grep -q 'PSK'; then PASS=$( $DIALOG \ From dba958af5db6eb2a900125b36c302faba307fcba Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:13:20 +0000 Subject: [PATCH 115/226] This statement has too many backslashes --- usr.sbin/bsdinstall/scripts/wlanconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index eecee25529b..fe2cea6d299 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -278,7 +278,7 @@ while :; do done [ "$ENCRYPTION" ] || ENCRYPTION=$( echo "$NETWORKS" | - awk -F '\t' "/^\"$NETWORK\"\t/ { printf \"%s\n\", \\\$2 }" ) + awk -F '\t' "/^\"$NETWORK\"\t/ { printf \"%s\n\", \$2 }" ) if echo $ENCRYPTION | grep -q 'PSK'; then PASS=$( $DIALOG \ From 01a2404c350898ed9e293927a03b4e33198da460 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:14:40 +0000 Subject: [PATCH 116/226] In awk, if you're going to append a newline to your printf AND you're going to print only the argument, just use print --- usr.sbin/bsdinstall/scripts/wlanconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index fe2cea6d299..9f1cb16c01d 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -278,7 +278,7 @@ while :; do done [ "$ENCRYPTION" ] || ENCRYPTION=$( echo "$NETWORKS" | - awk -F '\t' "/^\"$NETWORK\"\t/ { printf \"%s\n\", \$2 }" ) + awk -F '\t' "/^\"$NETWORK\"\t/ { print \$2 }" ) if echo $ENCRYPTION | grep -q 'PSK'; then PASS=$( $DIALOG \ From 1095816ec3c9883ae3814fe91039531473c1806a Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:15:36 +0000 Subject: [PATCH 117/226] Add missing quotes --- usr.sbin/bsdinstall/scripts/wlanconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 9f1cb16c01d..5589424cb8e 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -280,7 +280,7 @@ done [ "$ENCRYPTION" ] || ENCRYPTION=$( echo "$NETWORKS" | awk -F '\t' "/^\"$NETWORK\"\t/ { print \$2 }" ) -if echo $ENCRYPTION | grep -q 'PSK'; then +if echo "$ENCRYPTION" | grep -q 'PSK'; then PASS=$( $DIALOG \ --title "WPA Setup" \ --backtitle "$DIALOG_BACKTITLE" \ @@ -300,7 +300,7 @@ if echo $ENCRYPTION | grep -q 'PSK'; then priority=5 } EOF -elif echo $ENCRYPTION | grep -q EAP; then +elif echo "$ENCRYPTION" | grep -q EAP; then USERPASS=$( $DIALOG \ --title "WPA-Enterprise Setup" \ --backtitle "$DIALOG_BACKTITLE" \ @@ -325,7 +325,7 @@ elif echo $ENCRYPTION | grep -q EAP; then priority=5 } EOF -elif echo $ENCRYPTION | grep -q WEP; then +elif echo "$ENCRYPTION" | grep -q WEP; then WEPKEY=$( $DIALOG \ --title "WEP Setup" \ --backtitle "$DIALOG_BACKTITLE" \ From 7599c85424bf1c4c8dbe9a1b8b1150871588960b Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:16:00 +0000 Subject: [PATCH 118/226] Remove unnecessary quotes --- usr.sbin/bsdinstall/scripts/wlanconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 5589424cb8e..5093146612d 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -280,7 +280,7 @@ done [ "$ENCRYPTION" ] || ENCRYPTION=$( echo "$NETWORKS" | awk -F '\t' "/^\"$NETWORK\"\t/ { print \$2 }" ) -if echo "$ENCRYPTION" | grep -q 'PSK'; then +if echo "$ENCRYPTION" | grep -q PSK; then PASS=$( $DIALOG \ --title "WPA Setup" \ --backtitle "$DIALOG_BACKTITLE" \ From d5fddc4dcbe6a33b4203fa7570f846cd1044fa6a Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:22:21 +0000 Subject: [PATCH 119/226] Relying on dialog auto-sizing (width/height/rows = 0) is a mistake Use the provided API for calculating the appropriate size of menus --- usr.sbin/bsdinstall/scripts/wlanconfig | 38 ++++++++++++++++---------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 5093146612d..618ce9d910b 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -239,14 +239,16 @@ while :; do fi f_dialog_title "Network Selection" - NETWORK=$( sh -c "$DIALOG \ - --title \"$DIALOG_TITLE\" \ - --backtitle \"$DIALOG_BACKTITLE\" \ + prompt="Select a wireless network to connect to." + menu_list=$( echo $NETWORKS | tr '\n' ' ' ) + NETWORK=$( eval $DIALOG \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ --extra-button \ --extra-label \"Rescan\" \ - --menu \"Select a wireless network to connect to.\" \ - 0 0 0 \ - $( echo $NETWORKS | tr '\n' ' ' )" \ + --menu \"\$prompt\" \ + $height $width $rows \ + $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) retval=$? @@ -258,15 +260,21 @@ while :; do f_dialog_title "Network Selection" f_yesno "Do you want to select the network manually?" || exit 1 f_dialog_input NETWORK "Enter SSID" || exit 1 - ENCRYPTION=$( $DIALOG \ - --title "$DIALOG_TITLE" \ - --backtitle "$DIALOG_BACKTITLE" \ - --menu "Select encryption type" \ - 0 0 0 \ - "1 WPA/WPA2 PSK" "" \ - "2 WPA/WPA2 EAP" "" \ - "3 WEP" "" \ - "0 None" "" \ + prompt="Select encryption type" + menu_list=" + '1 WPA/WPA2 PSK' '' + '2 WPA/WPA2 EAP' '' + '3 WEP' '' + '0 None' '' + " # END-QUOTE + eval f_dialog_menu_size height width rows \"\$DIALOG_TITLE\" \ + \"\$DIALOG_BACKTITLE\" \"\$prompt\" \"\" $menu_list + ENCRYPTION=$( eval $DIALOG \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --menu \"\$prompt\" \ + $height $width $rows \ + $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) || exit 1 SCANSSID=1 From b45548a80ed8303dcba6d4e9b458c79ff9cc9d06 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:23:48 +0000 Subject: [PATCH 120/226] Whitespace alignment --- usr.sbin/bsdinstall/scripts/wlanconfig | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 618ce9d910b..e36b81e6e39 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -242,13 +242,13 @@ while :; do prompt="Select a wireless network to connect to." menu_list=$( echo $NETWORKS | tr '\n' ' ' ) NETWORK=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ - --extra-button \ - --extra-label \"Rescan\" \ - --menu \"\$prompt\" \ - $height $width $rows \ - $menu_list \ + --extra-button \ + --extra-label \"Rescan\" \ + --menu \"\$prompt\" \ + $height $width $rows \ + $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) retval=$? @@ -270,11 +270,11 @@ while :; do eval f_dialog_menu_size height width rows \"\$DIALOG_TITLE\" \ \"\$DIALOG_BACKTITLE\" \"\$prompt\" \"\" $menu_list ENCRYPTION=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ - --menu \"\$prompt\" \ - $height $width $rows \ - $menu_list \ + --menu \"\$prompt\" \ + $height $width $rows \ + $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) || exit 1 SCANSSID=1 From 35af83c188b5ee52e80313541a48c23a131b1b85 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:25:23 +0000 Subject: [PATCH 121/226] Comment --- usr.sbin/bsdinstall/scripts/wlanconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index e36b81e6e39..3eb501815fa 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -256,7 +256,7 @@ while :; do case $retval in $DIALOG_OK) break ;; $DIALOG_CANCEL) - # here we ask if the user wants to select the network manually + # Ask if the user wants to select network manually f_dialog_title "Network Selection" f_yesno "Do you want to select the network manually?" || exit 1 f_dialog_input NETWORK "Enter SSID" || exit 1 From 1d92999c48dcfbe8d13681ee3721a199a2201555 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:27:38 +0000 Subject: [PATCH 122/226] There's an API function for displaying errors --- usr.sbin/bsdinstall/scripts/wlanconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 3eb501815fa..08800faa5b4 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -167,8 +167,8 @@ EOF # if ! wpa_cli ping > /dev/null 2>&1; then if [ ! "$BSDINSTALL_CONFIGCURRENT" ]; then - $DIALOG --backtitle "$DIALOG_BACKTITLE" --title "$msg_error" --msgbox \ - "Wireless cannot be configured without making changes to the local system!" 0 0 + f_show_err "Wireless cannot be configured without %s" \ + "making changes to the local system!" exit 1 fi wpa_supplicant -B -i $1 -c "$BSDINSTALL_TMPETC/wpa_supplicant.conf") || exit 1 From d79a1355788e61705813e4204940780a573f84d8 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:29:20 +0000 Subject: [PATCH 123/226] There's an API function for displaying yes/no dialogs --- usr.sbin/bsdinstall/scripts/wlanconfig | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 08800faa5b4..1eed3f0cdba 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -196,11 +196,7 @@ if [ "$BSDINSTALL_CONFIGCURRENT" ]; then [ "$DEF_REGDOMAIN" = 0 ] && DEF_REGDOMAIN="" [ "$DEF_COUNTRY" = 0 ] && DEF_COUNTRY="" f_dialog_title "Regdomain/country" - $DIALOG \ - --title "$DIALOG_TITLE" \ - --backtitle "$DIALOG_BACKTITLE" \ - --yesno "Change regdomain/country (now $DEF_REGDOMAIN/$DEF_COUNTRY)?" \ - 0 0 + f_yesno "Change regdomain/country (now $DEF_REGDOMAIN/$DEF_COUNTRY)?" if [ $? -eq 0 ]; then while :; do dialog_country_select "$DEF_REGDOMAIN" "$DEF_COUNTRY" @@ -230,11 +226,7 @@ while :; do if [ ! "$NETWORKS" ]; then f_dialog_title "$msg_error" - $DIALOG \ - --title "$DIALOG_TITLE" \ - --backtitle "$DIALOG_BACKTITLE" \ - --yesno "No wireless networks were found. Rescan?" \ - 0 0 && continue + f_yesno "No wireless networks were found. Rescan?" && continue exit 1 fi From 7e1166de96347feced115be9304a42a28c17d5d4 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:30:24 +0000 Subject: [PATCH 124/226] There's an API function for displaying pauses --- usr.sbin/bsdinstall/scripts/wlanconfig | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 1eed3f0cdba..76a16f9be36 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -212,12 +212,8 @@ while :; do output=$( wpa_cli scan 2>&1 ) f_dprintf "%s" "$output" f_dialog_title "Scanning" - $DIALOG \ - --title "$DIALOG_TITLE" \ - --backtitle "$DIALOG_BACKTITLE" \ - --ok-label "$msg_skip" \ - --pause "Waiting 5 seconds to scan for wireless networks..." \ - 9 40 5 || exit 1 + f_dialog_pause "Waiting 5 seconds to scan for wireless networks..." 5 || + exit 1 SCAN_RESULTS=$( wpa_cli scan_results ) NETWORKS=$( echo "$SCAN_RESULTS" | awk -F '\t' ' From 9a46c67aedddd1b93b27e53893796c866e77ceee Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:40:54 +0000 Subject: [PATCH 125/226] There's an API function for catching errors and displaying them or logging them to debug output --- usr.sbin/bsdinstall/scripts/wlanconfig | 28 ++++++++++---------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 76a16f9be36..03b30cd4caa 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -52,8 +52,9 @@ country_set() # Regdomain/country cannot be applied while interface is running iface_up=$( ifconfig -lu | grep -w "$WLAN_IFACE" ) [ "$iface_up" ] && ifconfig "$WLAN_IFACE" down - error_str=$( ifconfig "$WLAN_IFACE" $ifconfig_args 2>&1 | - sed -e 's/ifconfig: //' ) + f_eval_catch -dk error_str wlanconfig ifconfig "ifconfig %s %s" \ + "$WLAN_IFACE" "$ifconfig_args" + error_str="${error_str#ifconfig: }" if [ "$iface_up" ]; then # Restart wpa_supplicant(8) (should not fail). wpa_supplicant -B -i "$WLAN_IFACE" -c \ @@ -165,22 +166,17 @@ EOF # Try to reach wpa_supplicant. If it isn't running and we can modify the # existing system, start it. Otherwise, fail. # -if ! wpa_cli ping > /dev/null 2>&1; then +if ! f_eval_catch -d wlanconfig wpa_cli "wpa_cli ping"; then if [ ! "$BSDINSTALL_CONFIGCURRENT" ]; then f_show_err "Wireless cannot be configured without %s" \ "making changes to the local system!" exit 1 fi - wpa_supplicant -B -i $1 -c "$BSDINSTALL_TMPETC/wpa_supplicant.conf") || exit 1 + f_eval_catch wlanconfig wpa_supplicant \ + 'wpa_supplicant -B -i "%s" -c "%s/wpa_supplicant.conf"' \ + "$1" "$BSDINSTALL_TMPETC" || exit 1 - if ! wpa_cli ping > /dev/null 2>&1 && [ ! "$BSDINSTALL_CONFIGCURRENT" ]; then - $DIALOG \ - --title "$msg_error" \ - --backtitle "$DIALOG_BACKTITLE" \ - --msgbox "Could not start wpa_supplicant!" \ - 0 0 - exit 1 - fi + f_eval_catch wlanconfig wpa_cli "wpa_cli ping" || exit 1 fi # @@ -209,13 +205,12 @@ fi while :; do SCANSSID=0 - output=$( wpa_cli scan 2>&1 ) - f_dprintf "%s" "$output" + f_eval_catch -d wlanconfig wpa_cli "wpa_cli scan" f_dialog_title "Scanning" f_dialog_pause "Waiting 5 seconds to scan for wireless networks..." 5 || exit 1 - SCAN_RESULTS=$( wpa_cli scan_results ) + f_eval_catch -dk SCAN_RESULTS wlanconfig wpa_cli "wpa_cli scan_results" NETWORKS=$( echo "$SCAN_RESULTS" | awk -F '\t' ' /..:..:..:..:..:../ && $5 { printf "\"%s\"\t%s\n", $5, $4 } ' | sort | uniq ) @@ -365,8 +360,7 @@ EOF # Bring up new network if [ "$BSDINSTALL_CONFIGCURRENT" ]; then - output=$( wpa_cli reconfigure 2>&1 ) - f_dprintf "%s" "$output" + f_eval_catch -d wlanconfig wpa_cli "wpa_cli reconfigure" fi exit $SUCCESS From b9f60aba8be6344309f61891d910106f2b01539b Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:42:10 +0000 Subject: [PATCH 126/226] Calculate proper size of menu list dialog --- usr.sbin/bsdinstall/scripts/wlanconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 03b30cd4caa..f2829d7d935 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -224,6 +224,8 @@ while :; do f_dialog_title "Network Selection" prompt="Select a wireless network to connect to." menu_list=$( echo $NETWORKS | tr '\n' ' ' ) + f_dialog_menu_size height width rows "$DIALOG_TITLE" \ + "$DIALOG_BACKTITLE" "$prompt" "" $menu_list NETWORK=$( eval $DIALOG \ --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ From 94f5aec600ef939b56ba3cb422d1e84405b00d55 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:44:33 +0000 Subject: [PATCH 127/226] Both simplify bringup of interface after changes and catch errors in debug --- usr.sbin/bsdinstall/scripts/wlanconfig | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index f2829d7d935..25d0b31377f 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -55,11 +55,10 @@ country_set() f_eval_catch -dk error_str wlanconfig ifconfig "ifconfig %s %s" \ "$WLAN_IFACE" "$ifconfig_args" error_str="${error_str#ifconfig: }" - if [ "$iface_up" ]; then - # Restart wpa_supplicant(8) (should not fail). - wpa_supplicant -B -i "$WLAN_IFACE" -c \ - "$BSDINSTALL_TMPETC/wpa_supplicant.conf" - fi + # Restart wpa_supplicant(8) (should not fail). + [ "$iface_up" ] && f_eval_catch -d wlanconfig wpa_supplicant \ + 'wpa_supplicant -B -i "%s" -c "%s/wpa_supplicant.conf"' \ + "$WLAN_IFACE" "$BSDINSTALL_TMPETC" if [ "$error_str" ]; then $DIALOG \ --title "$msg_error" \ From 6ef8ca674fad4750777e805beaf353617cf4b471 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:45:07 +0000 Subject: [PATCH 128/226] Restore previous comment --- usr.sbin/bsdinstall/scripts/wlanconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 25d0b31377f..603aeb02972 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -175,6 +175,7 @@ if ! f_eval_catch -d wlanconfig wpa_cli "wpa_cli ping"; then 'wpa_supplicant -B -i "%s" -c "%s/wpa_supplicant.conf"' \ "$1" "$BSDINSTALL_TMPETC" || exit 1 + # See if we succeeded f_eval_catch wlanconfig wpa_cli "wpa_cli ping" || exit 1 fi From a9d334210fb66e8a578ed1f67fc6ba924356727d Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:45:52 +0000 Subject: [PATCH 129/226] Why test $? when you can test the command --- usr.sbin/bsdinstall/scripts/wlanconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 603aeb02972..6e7aa12ef7d 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -192,8 +192,8 @@ if [ "$BSDINSTALL_CONFIGCURRENT" ]; then [ "$DEF_REGDOMAIN" = 0 ] && DEF_REGDOMAIN="" [ "$DEF_COUNTRY" = 0 ] && DEF_COUNTRY="" f_dialog_title "Regdomain/country" - f_yesno "Change regdomain/country (now $DEF_REGDOMAIN/$DEF_COUNTRY)?" - if [ $? -eq 0 ]; then + if f_yesno "Change regdomain/country (now $DEF_REGDOMAIN/$DEF_COUNTRY)?" + then while :; do dialog_country_select "$DEF_REGDOMAIN" "$DEF_COUNTRY" if [ $? -eq $SUCCESS ]; then From b46ca7cefe40fbb91e3ed6ebb6d8401a48873e44 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:46:36 +0000 Subject: [PATCH 130/226] Wordsmithing --- usr.sbin/bsdinstall/scripts/wlanconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 6e7aa12ef7d..356290a7fa9 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -192,7 +192,7 @@ if [ "$BSDINSTALL_CONFIGCURRENT" ]; then [ "$DEF_REGDOMAIN" = 0 ] && DEF_REGDOMAIN="" [ "$DEF_COUNTRY" = 0 ] && DEF_COUNTRY="" f_dialog_title "Regdomain/country" - if f_yesno "Change regdomain/country (now $DEF_REGDOMAIN/$DEF_COUNTRY)?" + if f_yesno "Change regdomain/country ($DEF_REGDOMAIN/$DEF_COUNTRY)?" then while :; do dialog_country_select "$DEF_REGDOMAIN" "$DEF_COUNTRY" From afcce2f52d911f17e303e1294564aaf2d30eecf9 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:47:39 +0000 Subject: [PATCH 131/226] Simplify loop by moving predicate to clause --- usr.sbin/bsdinstall/scripts/wlanconfig | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 356290a7fa9..08481ea3cb3 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -194,12 +194,8 @@ if [ "$BSDINSTALL_CONFIGCURRENT" ]; then f_dialog_title "Regdomain/country" if f_yesno "Change regdomain/country ($DEF_REGDOMAIN/$DEF_COUNTRY)?" then - while :; do - dialog_country_select "$DEF_REGDOMAIN" "$DEF_COUNTRY" - if [ $? -eq $SUCCESS ]; then - break - fi - done + while ! dialog_country_select "$DEF_REGDOMAIN" "$DEF_COUNTRY" + do :; done fi fi From 19dbb0ba18ad36e19a579451bf70545020118d39 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:48:14 +0000 Subject: [PATCH 132/226] Simplify single-line if statements --- usr.sbin/bsdinstall/scripts/wlanconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 08481ea3cb3..1218d279100 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -357,9 +357,8 @@ network={ EOF # Bring up new network -if [ "$BSDINSTALL_CONFIGCURRENT" ]; then +[ "$BSDINSTALL_CONFIGCURRENT" ] && f_eval_catch -d wlanconfig wpa_cli "wpa_cli reconfigure" -fi exit $SUCCESS From be094a32047221d7d024da4f168dff0567eca8b0 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:54:44 +0000 Subject: [PATCH 133/226] The flags of a WLAN need to be quoted (they contain things like brackets) --- usr.sbin/bsdinstall/scripts/wlanconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index 1218d279100..dc87dbd5ef0 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -208,7 +208,7 @@ while :; do f_eval_catch -dk SCAN_RESULTS wlanconfig wpa_cli "wpa_cli scan_results" NETWORKS=$( echo "$SCAN_RESULTS" | awk -F '\t' ' - /..:..:..:..:..:../ && $5 { printf "\"%s\"\t%s\n", $5, $4 } + /..:..:..:..:..:../ && $5 { printf "\"%s\"\t\"%s\"\n", $5, $4 } ' | sort | uniq ) if [ ! "$NETWORKS" ]; then From f3a8471e5fe5447a35d5e430fe0b49de829ef190 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 02:56:52 +0000 Subject: [PATCH 134/226] It's completely pointless to replace newlines with space (this is done automatically for you upon shell expansion) --- usr.sbin/bsdinstall/scripts/wlanconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index dc87dbd5ef0..b7b150bd75f 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -219,7 +219,6 @@ while :; do f_dialog_title "Network Selection" prompt="Select a wireless network to connect to." - menu_list=$( echo $NETWORKS | tr '\n' ' ' ) f_dialog_menu_size height width rows "$DIALOG_TITLE" \ "$DIALOG_BACKTITLE" "$prompt" "" $menu_list NETWORK=$( eval $DIALOG \ @@ -229,7 +228,7 @@ while :; do --extra-label \"Rescan\" \ --menu \"\$prompt\" \ $height $width $rows \ - $menu_list \ + $NETWORKS \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) retval=$? From ec0a42e59cd7e0b466fcf94d60b31a4b84bf57e9 Mon Sep 17 00:00:00 2001 From: Oleksandr Tymoshenko Date: Tue, 13 Dec 2016 03:26:12 +0000 Subject: [PATCH 135/226] [iMX6] Fix platform compatibility string for i.MX6 Dual i.MX6 Dual boot was broken since r308533 because ofw_bus_node_is_compatible is more strict than fdt_is_compatible and does not accept partial matches --- sys/arm/freescale/imx/imx6_machdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/arm/freescale/imx/imx6_machdep.c b/sys/arm/freescale/imx/imx6_machdep.c index ad826787a1a..4fa4523adab 100644 --- a/sys/arm/freescale/imx/imx6_machdep.c +++ b/sys/arm/freescale/imx/imx6_machdep.c @@ -352,5 +352,5 @@ static platform_method_t imx6_methods[] = { }; FDT_PLATFORM_DEF2(imx6, imx6s, "i.MX6 Solo", 0, "fsl,imx6s", 0); -FDT_PLATFORM_DEF2(imx6, imx6d, "i.MX6 Dual", 0, "fsl,imx6d", 0); +FDT_PLATFORM_DEF2(imx6, imx6d, "i.MX6 Dual", 0, "fsl,imx6dl", 0); FDT_PLATFORM_DEF2(imx6, imx6q, "i.MX6 Quad", 0, "fsl,imx6q", 0); From a9a7fbcc58ff2424f2539881a6f1c5c170231654 Mon Sep 17 00:00:00 2001 From: Luiz Otavio O Souza Date: Tue, 13 Dec 2016 03:36:41 +0000 Subject: [PATCH 136/226] Remove a too strict test and instead, just filter the passed flags with the supported capabilities. Spotted by: yamori813@yahoo.co.jp (Hiroki Mori) MFC after: 2 weeks --- sys/dev/gpio/gpiobus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/gpio/gpiobus.c b/sys/dev/gpio/gpiobus.c index 056dd3193d4..90e447d065d 100644 --- a/sys/dev/gpio/gpiobus.c +++ b/sys/dev/gpio/gpiobus.c @@ -120,9 +120,9 @@ int gpio_check_flags(uint32_t caps, uint32_t flags) { - /* Check for unwanted flags. */ - if ((flags & caps) == 0 || (flags & caps) != flags) - return (EINVAL); + /* Filter unwanted flags. */ + flags &= caps; + /* Cannot mix input/output together. */ if (flags & GPIO_PIN_INPUT && flags & GPIO_PIN_OUTPUT) return (EINVAL); From c85d45a5bbbbd8398ed9b09f971cdda9d1a4525a Mon Sep 17 00:00:00 2001 From: Oleksandr Tymoshenko Date: Tue, 13 Dec 2016 05:09:49 +0000 Subject: [PATCH 137/226] [iMX6] Add compatibility string for GPT timer on i.MX6 Dual Up until r295436 GPT timer in i.MX6 Dual dts used the same compatiblity string as i.MX6 Quad. After the sync up with Linux in r295436, GPT timer stopped getting attached on the i.MX6 Dual MFC after: 3 days --- sys/arm/freescale/imx/imx_gpt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/arm/freescale/imx/imx_gpt.c b/sys/arm/freescale/imx/imx_gpt.c index f0eb7665dc0..117c9298e09 100644 --- a/sys/arm/freescale/imx/imx_gpt.c +++ b/sys/arm/freescale/imx/imx_gpt.c @@ -106,6 +106,7 @@ static struct resource_spec imx_gpt_spec[] = { }; static struct ofw_compat_data compat_data[] = { + {"fsl,imx6dl-gpt", 1}, {"fsl,imx6q-gpt", 1}, {"fsl,imx53-gpt", 1}, {"fsl,imx51-gpt", 1}, From 93954c2da374f8fff6376fbf1f2e1c60a22453ed Mon Sep 17 00:00:00 2001 From: Colin Percival Date: Tue, 13 Dec 2016 06:54:13 +0000 Subject: [PATCH 138/226] Check that blkfront devices have a non-zero number of sectors and a non-zero sector size. Such a device would be a virtual disk of zero bytes; clearly not useful, and not something we should try to attach. As a fortuitous side effect, checking that these values are non-zero here results in them not *becoming* zero later on the function. This odd behaviour began with r309124 (clang 3.9.0) but is challenging to debug; making any changes to this function whatsoever seems to affect the llvm optimizer behaviour enough to make the unexpected zeroing of the sector_size variable cease. PR: 215209 Security: The potential for variables to unexpectedly become zero has worrying consequences for security in general, but not so much in this particular context. --- sys/dev/xen/blkfront/blkfront.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/dev/xen/blkfront/blkfront.c b/sys/dev/xen/blkfront/blkfront.c index 4de58840341..2e09c2eb409 100644 --- a/sys/dev/xen/blkfront/blkfront.c +++ b/sys/dev/xen/blkfront/blkfront.c @@ -1245,6 +1245,14 @@ xbd_connect(struct xbd_softc *sc) xenbus_get_otherend_path(dev)); return; } + if ((sectors == 0) || (sector_size == 0)) { + xenbus_dev_fatal(dev, 0, + "invalid parameters from %s:" + " sectors = %lu, sector_size = %lu", + xenbus_get_otherend_path(dev), + sectors, sector_size); + return; + } err = xs_gather(XST_NIL, xenbus_get_otherend_path(dev), "physical-sector-size", "%lu", &phys_sector_size, NULL); From d6d7df8aa091d06fa4564344c30199466fc59ce6 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Tue, 13 Dec 2016 07:58:30 +0000 Subject: [PATCH 139/226] Remove the only user of sysctl_add_oid(). My plan is to change this function's prototype at some point in the future to add a new label argument, which can be used to export all of sysctl as metrics that can be scraped by Prometheus. Switch over this caller to use the macro wrapper counterpart. --- sys/compat/linuxkpi/common/include/linux/sysfs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/sysfs.h b/sys/compat/linuxkpi/common/include/linux/sysfs.h index 68c6e9224d9..f16c38b90ef 100644 --- a/sys/compat/linuxkpi/common/include/linux/sysfs.h +++ b/sys/compat/linuxkpi/common/include/linux/sysfs.h @@ -126,7 +126,7 @@ static inline int sysfs_create_file(struct kobject *kobj, const struct attribute *attr) { - sysctl_add_oid(NULL, SYSCTL_CHILDREN(kobj->oidp), OID_AUTO, + SYSCTL_ADD_OID(NULL, SYSCTL_CHILDREN(kobj->oidp), OID_AUTO, attr->name, CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_MPSAFE, kobj, (uintptr_t)attr, sysctl_handle_attr, "A", ""); @@ -158,7 +158,7 @@ sysfs_create_group(struct kobject *kobj, const struct attribute_group *grp) oidp = SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(kobj->oidp), OID_AUTO, grp->name, CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, grp->name); for (attr = grp->attrs; *attr != NULL; attr++) { - sysctl_add_oid(NULL, SYSCTL_CHILDREN(oidp), OID_AUTO, + SYSCTL_ADD_OID(NULL, SYSCTL_CHILDREN(oidp), OID_AUTO, (*attr)->name, CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_MPSAFE, kobj, (uintptr_t)*attr, sysctl_handle_attr, "A", ""); } From 167a228d792e30f4575d14eded58d5991d5a0858 Mon Sep 17 00:00:00 2001 From: Michael Zhilin Date: Tue, 13 Dec 2016 09:53:43 +0000 Subject: [PATCH 140/226] [spi] reformat message and ar5315_spi minor fix This commit corrects print of nomatch (newline was too early) and fix unit number for new child in ar5315_spi (was 0, now is -1 to calculate it according to actual system state) Submitted by: Hiroki Mori Reviewed by: ray, loos, mizhka MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D8749 --- sys/dev/spibus/spibus.c | 4 ++-- sys/mips/atheros/ar531x/ar5315_spi.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/spibus/spibus.c b/sys/dev/spibus/spibus.c index a773b6767a5..6ef5014a93a 100644 --- a/sys/dev/spibus/spibus.c +++ b/sys/dev/spibus/spibus.c @@ -117,8 +117,8 @@ spibus_probe_nomatch(device_t bus, device_t child) struct spibus_ivar *devi = SPIBUS_IVAR(child); device_printf(bus, ""); - printf(" at cs %d\n", devi->cs); - printf(" mode %d", devi->mode); + printf(" at cs %d", devi->cs); + printf(" mode %d\n", devi->mode); return; } diff --git a/sys/mips/atheros/ar531x/ar5315_spi.c b/sys/mips/atheros/ar531x/ar5315_spi.c index a066b1d9018..75546697ed1 100644 --- a/sys/mips/atheros/ar531x/ar5315_spi.c +++ b/sys/mips/atheros/ar531x/ar5315_spi.c @@ -122,7 +122,7 @@ ar5315_spi_attach(device_t dev) return (ENXIO); } - device_add_child(dev, "spibus", 0); + device_add_child(dev, "spibus", -1); ar5315_spi_attach_sysctl(dev); return (bus_generic_attach(dev)); From d1c38239e827488bf91641e1afdb551a06d2702e Mon Sep 17 00:00:00 2001 From: Michael Zhilin Date: Tue, 13 Dec 2016 10:03:29 +0000 Subject: [PATCH 141/226] [gpiospi] add clock delay to avoid smashing of bits Submitted by: Hiroki Mori Reviewed by: loos, ray, mizhka MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D8749 --- sys/dev/gpio/gpiospi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/dev/gpio/gpiospi.c b/sys/dev/gpio/gpiospi.c index ea867eb605c..840241385bf 100644 --- a/sys/dev/gpio/gpiospi.c +++ b/sys/dev/gpio/gpiospi.c @@ -293,6 +293,7 @@ gpio_spi_txrx(struct gpio_spi_softc *sc, int cs, int mode, uint8_t data) gpio_delay(sc); GPIOBUS_PIN_SET(sc->sc_busdev, sc->sc_dev, sc->sc_sclk, 1); + gpio_delay(sc); } else { /* If mode 0 or 3 */ @@ -312,6 +313,7 @@ gpio_spi_txrx(struct gpio_spi_softc *sc, int cs, int mode, uint8_t data) gpio_delay(sc); GPIOBUS_PIN_SET(sc->sc_busdev, sc->sc_dev, sc->sc_sclk, 0); + gpio_delay(sc); } } From a89938019a014370830f97890918046f12cb2ace Mon Sep 17 00:00:00 2001 From: Ganbold Tsagaankhuu Date: Tue, 13 Dec 2016 11:43:46 +0000 Subject: [PATCH 142/226] Switch Rockchip RK3188 SoC to use the platform code. Reviewed by: andrew, manu Differential Revision: https://reviews.freebsd.org/D8769 --- sys/arm/conf/RK3188 | 5 ++++ sys/arm/rockchip/rk30xx_machdep.c | 50 ++++++++++++++++++------------- sys/arm/rockchip/rk30xx_mp.c | 8 +++-- sys/arm/rockchip/rk30xx_mp.h | 38 +++++++++++++++++++++++ sys/conf/options.arm | 1 + 5 files changed, 79 insertions(+), 23 deletions(-) create mode 100644 sys/arm/rockchip/rk30xx_mp.h diff --git a/sys/arm/conf/RK3188 b/sys/arm/conf/RK3188 index 7f771593c75..15b98cfbef8 100644 --- a/sys/arm/conf/RK3188 +++ b/sys/arm/conf/RK3188 @@ -23,8 +23,13 @@ ident RK3188 include "std.armv6" include "../rockchip/std.rk30xx" +options SOC_ROCKCHIP_RK3188 + options SCHED_ULE # ULE scheduler options SMP # Enable multiple cores +options PLATFORM +options PLATFORM_SMP +options MULTIDELAY # Root mount from MMC/SD card options ROOTDEVNAME=\"ufs:/dev/mmcsd0\" diff --git a/sys/arm/rockchip/rk30xx_machdep.c b/sys/arm/rockchip/rk30xx_machdep.c index d45ef8d4c04..f86d71605d4 100644 --- a/sys/arm/rockchip/rk30xx_machdep.c +++ b/sys/arm/rockchip/rk30xx_machdep.c @@ -42,33 +42,25 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include -#include +#include +#include #include +#include -vm_offset_t -platform_lastaddr(void) +#include "platform_if.h" + +static vm_offset_t +rk30xx_lastaddr(platform_t plat) { return (devmap_lastaddr()); } -void -platform_probe_and_attach(void) -{ - -} - -void -platform_gpio_init(void) -{ -} - -void -platform_late_init(void) +static void +rk30xx_late_init(platform_t plat) { /* Enable cache */ @@ -79,8 +71,8 @@ platform_late_init(void) /* * Set up static device mappings. */ -int -platform_devmap_init(void) +static int +rk30xx_devmap_init(platform_t plat) { devmap_add_entry(0x10000000, 0x00200000); @@ -89,11 +81,27 @@ platform_devmap_init(void) return (0); } -void -cpu_reset() +static void +rk30xx_cpu_reset() { rk30_wd_watchdog_reset(); printf("Reset failed!\n"); while (1); } + +#if defined(SOC_ROCKCHIP_RK3188) +static platform_method_t rk30xx_methods[] = { + PLATFORMMETHOD(platform_lastaddr, rk30xx_lastaddr), + PLATFORMMETHOD(platform_devmap_init, rk30xx_devmap_init), + PLATFORMMETHOD(platform_late_init, rk30xx_late_init), + PLATFORMMETHOD(platform_cpu_reset, rk30xx_cpu_reset), + +#ifdef SMP + PLATFORMMETHOD(platform_mp_start_ap, rk30xx_mp_start_ap), + PLATFORMMETHOD(platform_mp_setmaxid, rk30xx_mp_setmaxid), +#endif + PLATFORMMETHOD_END, +}; +FDT_PLATFORM_DEF(rk30xx, "RK3188", 0, "rockchip,rk3188", 200); +#endif diff --git a/sys/arm/rockchip/rk30xx_mp.c b/sys/arm/rockchip/rk30xx_mp.c index 571989b5cd9..bb01d09499e 100644 --- a/sys/arm/rockchip/rk30xx_mp.c +++ b/sys/arm/rockchip/rk30xx_mp.c @@ -37,9 +37,13 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include +#include + +#include #define SCU_PHYSBASE 0x1013c000 #define SCU_SIZE 0x100 @@ -80,7 +84,7 @@ rk30xx_boot2(void) } void -platform_mp_setmaxid(void) +rk30xx_mp_setmaxid(platform_t plat) { bus_space_handle_t scu; int ncpu; @@ -101,7 +105,7 @@ platform_mp_setmaxid(void) } void -platform_mp_start_ap(void) +rk30xx_mp_start_ap(platform_t plat) { bus_space_handle_t scu; bus_space_handle_t imem; diff --git a/sys/arm/rockchip/rk30xx_mp.h b/sys/arm/rockchip/rk30xx_mp.h new file mode 100644 index 00000000000..01b1176ed71 --- /dev/null +++ b/sys/arm/rockchip/rk30xx_mp.h @@ -0,0 +1,38 @@ +/*- + * Copyright (C) 2016 Ganbold Tsagaankhuu + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _RK30XX_MP_H_ +#define _RK30XX_MP_H_ + +void rk30xx_mp_setmaxid(platform_t plat); +void rk30xx_mp_start_ap(platform_t plat); + +#endif /* _RK30XX_MP_H_ */ diff --git a/sys/conf/options.arm b/sys/conf/options.arm index 614741a94d3..cb94196eab0 100644 --- a/sys/conf/options.arm +++ b/sys/conf/options.arm @@ -64,6 +64,7 @@ SOC_MV_LOKIPLUS opt_global.h SOC_MV_ORION opt_global.h SOC_OMAP3 opt_global.h SOC_OMAP4 opt_global.h +SOC_ROCKCHIP_RK3188 opt_global.h SOC_TI_AM335X opt_global.h SOC_TEGRA2 opt_global.h XSCALE_CACHE_READ_WRITE_ALLOCATE opt_global.h From 3f31908a97e7d0390548f3f510b14959721edbd1 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Tue, 13 Dec 2016 13:07:17 +0000 Subject: [PATCH 143/226] Use platform_*_t to check the platform function signatures are correct in the Rockchip platform code and correct the one place they differ. Sponsored by: ABT Systems Ltd --- sys/arm/rockchip/rk30xx_machdep.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/arm/rockchip/rk30xx_machdep.c b/sys/arm/rockchip/rk30xx_machdep.c index f86d71605d4..92c98bb6813 100644 --- a/sys/arm/rockchip/rk30xx_machdep.c +++ b/sys/arm/rockchip/rk30xx_machdep.c @@ -52,6 +52,11 @@ __FBSDID("$FreeBSD$"); #include "platform_if.h" +static platform_lastaddr_t rk30xx_lastaddr; +static platform_devmap_init_t rk30xx_devmap_init; +static platform_late_init_t rk30xx_late_init; +static platform_cpu_reset_t rk30xx_cpu_reset; + static vm_offset_t rk30xx_lastaddr(platform_t plat) { @@ -82,7 +87,7 @@ rk30xx_devmap_init(platform_t plat) } static void -rk30xx_cpu_reset() +rk30xx_cpu_reset(platform_t plat) { rk30_wd_watchdog_reset(); From 59249a516a69e3a4055393f0975cdd8a848f5ce8 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Tue, 13 Dec 2016 13:43:22 +0000 Subject: [PATCH 144/226] Add the missing void to function signatures in much of the arm code. Sponsored by: ABT Systems Ltd --- sys/arm/allwinner/aw_wdog.c | 2 +- sys/arm/amlogic/aml8726/aml8726_identsoc.c | 2 +- sys/arm/amlogic/aml8726/aml8726_machdep.c | 2 +- sys/arm/amlogic/aml8726/aml8726_wdt.c | 2 +- sys/arm/arm/cpufunc.c | 4 ++-- sys/arm/arm/db_trace.c | 2 +- sys/arm/arm/physmem.c | 2 +- sys/arm/arm/undefined.c | 2 +- sys/arm/broadcom/bcm2835/bcm2835_wdog.c | 2 +- sys/arm/freescale/imx/imx6_anatop.c | 2 +- sys/arm/freescale/imx/imx6_src.c | 2 +- sys/arm/lpc/lpc_gpio.c | 2 +- sys/arm/nvidia/tegra_efuse.c | 2 +- sys/arm/rockchip/rk30xx_wdog.c | 2 +- sys/arm/ti/am335x/am335x_dmtpps.c | 6 +++--- sys/arm/versatile/versatile_machdep.c | 2 +- sys/arm/xilinx/zy7_machdep.c | 2 +- sys/arm/xilinx/zy7_slcr.c | 6 +++--- sys/arm/xscale/pxa/pxa_gpio.c | 2 +- sys/arm/xscale/pxa/pxa_icu.c | 14 +++++++------- sys/arm/xscale/pxa/pxa_space.c | 2 +- sys/arm/xscale/pxa/pxa_timer.c | 8 ++++---- 22 files changed, 36 insertions(+), 36 deletions(-) diff --git a/sys/arm/allwinner/aw_wdog.c b/sys/arm/allwinner/aw_wdog.c index ca1ac0d98a7..8ca9b7d3415 100644 --- a/sys/arm/allwinner/aw_wdog.c +++ b/sys/arm/allwinner/aw_wdog.c @@ -237,7 +237,7 @@ aw_wdog_shutdown_fn(void *private, int howto) } void -aw_wdog_watchdog_reset() +aw_wdog_watchdog_reset(void) { if (aw_wdog_sc == NULL) { diff --git a/sys/arm/amlogic/aml8726/aml8726_identsoc.c b/sys/arm/amlogic/aml8726/aml8726_identsoc.c index b10ad163676..64c668793d4 100644 --- a/sys/arm/amlogic/aml8726/aml8726_identsoc.c +++ b/sys/arm/amlogic/aml8726/aml8726_identsoc.c @@ -87,7 +87,7 @@ static const struct { }; void -aml8726_identify_soc() +aml8726_identify_soc(void) { int err; struct resource res; diff --git a/sys/arm/amlogic/aml8726/aml8726_machdep.c b/sys/arm/amlogic/aml8726/aml8726_machdep.c index 68fef27a3d5..0929528e1f9 100644 --- a/sys/arm/amlogic/aml8726/aml8726_machdep.c +++ b/sys/arm/amlogic/aml8726/aml8726_machdep.c @@ -56,7 +56,7 @@ vm_offset_t aml8726_aobus_kva_base; #endif static void -aml8726_fixup_busfreq() +aml8726_fixup_busfreq(void) { phandle_t node; pcell_t freq, prop; diff --git a/sys/arm/amlogic/aml8726/aml8726_wdt.c b/sys/arm/amlogic/aml8726/aml8726_wdt.c index 46bafccab95..45f1e6fe6bc 100644 --- a/sys/arm/amlogic/aml8726/aml8726_wdt.c +++ b/sys/arm/amlogic/aml8726/aml8726_wdt.c @@ -289,7 +289,7 @@ EARLY_DRIVER_MODULE(wdt, simplebus, aml8726_wdt_driver, aml8726_wdt_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); void -cpu_reset() +cpu_reset(void) { /* Watchdog has not yet been initialized */ diff --git a/sys/arm/arm/cpufunc.c b/sys/arm/arm/cpufunc.c index c8f6ed591c2..bdb67b3f93b 100644 --- a/sys/arm/arm/cpufunc.c +++ b/sys/arm/arm/cpufunc.c @@ -485,7 +485,7 @@ static int arm_dcache_l2_assoc; static int arm_dcache_l2_linesize; static void -get_cachetype_cp15() +get_cachetype_cp15(void) { u_int ctype, isize, dsize, cpuid; u_int clevel, csize, i, sel; @@ -600,7 +600,7 @@ get_cachetype_cp15() */ int -set_cpufuncs() +set_cpufuncs(void) { cputype = cpu_ident(); cputype &= CPU_ID_CPU_MASK; diff --git a/sys/arm/arm/db_trace.c b/sys/arm/arm/db_trace.c index 846ad4e9915..c2b1ed2d63d 100644 --- a/sys/arm/arm/db_trace.c +++ b/sys/arm/arm/db_trace.c @@ -130,7 +130,7 @@ db_stack_trace_cmd(struct unwind_state *state) } void -db_md_list_watchpoints() +db_md_list_watchpoints(void) { dbg_show_watchpoint(); diff --git a/sys/arm/arm/physmem.c b/sys/arm/arm/physmem.c index f6222c39611..ec68c3619a5 100644 --- a/sys/arm/arm/physmem.c +++ b/sys/arm/arm/physmem.c @@ -145,7 +145,7 @@ physmem_dump_tables(int (*prfunc)(const char *, ...)) * Print the contents of the static mapping table. Used for bootverbose. */ void -arm_physmem_print_tables() +arm_physmem_print_tables(void) { physmem_dump_tables(printf); diff --git a/sys/arm/arm/undefined.c b/sys/arm/arm/undefined.c index fec194e6625..5dfa0d454bd 100644 --- a/sys/arm/arm/undefined.c +++ b/sys/arm/arm/undefined.c @@ -165,7 +165,7 @@ gdb_trapper(u_int addr, u_int insn, struct trapframe *frame, int code) static struct undefined_handler gdb_uh; void -undefined_init() +undefined_init(void) { int loop; diff --git a/sys/arm/broadcom/bcm2835/bcm2835_wdog.c b/sys/arm/broadcom/bcm2835/bcm2835_wdog.c index 7a11b660a4e..45dbdf25827 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_wdog.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_wdog.c @@ -190,7 +190,7 @@ bcmwd_watchdog_fn(void *private, u_int cmd, int *error) } void -bcmwd_watchdog_reset() +bcmwd_watchdog_reset(void) { if (bcmwd_lsc == NULL) diff --git a/sys/arm/freescale/imx/imx6_anatop.c b/sys/arm/freescale/imx/imx6_anatop.c index 62c5a64d5a8..689df94623c 100644 --- a/sys/arm/freescale/imx/imx6_anatop.c +++ b/sys/arm/freescale/imx/imx6_anatop.c @@ -776,7 +776,7 @@ imx6_anatop_probe(device_t dev) } uint32_t -imx6_get_cpu_clock() +imx6_get_cpu_clock(void) { uint32_t corediv, plldiv; diff --git a/sys/arm/freescale/imx/imx6_src.c b/sys/arm/freescale/imx/imx6_src.c index 400357a5e1a..325c8befabc 100644 --- a/sys/arm/freescale/imx/imx6_src.c +++ b/sys/arm/freescale/imx/imx6_src.c @@ -70,7 +70,7 @@ WR4(struct src_softc *sc, bus_size_t off, uint32_t val) } int -src_reset_ipu() +src_reset_ipu(void) { uint32_t reg; int timeout = 10000; diff --git a/sys/arm/lpc/lpc_gpio.c b/sys/arm/lpc/lpc_gpio.c index 798469d3c85..b062792c55b 100644 --- a/sys/arm/lpc/lpc_gpio.c +++ b/sys/arm/lpc/lpc_gpio.c @@ -518,7 +518,7 @@ lpc_gpio_get_state(device_t dev, int pin, int *state) } void -lpc_gpio_init() +lpc_gpio_init(void) { bus_space_tag_t bst; bus_space_handle_t bsh; diff --git a/sys/arm/nvidia/tegra_efuse.c b/sys/arm/nvidia/tegra_efuse.c index 13d97abd033..96bb12e3228 100644 --- a/sys/arm/nvidia/tegra_efuse.c +++ b/sys/arm/nvidia/tegra_efuse.c @@ -236,7 +236,7 @@ tegra_fuse_read_4(int addr) { static void -tegra_efuse_dump_sku() +tegra_efuse_dump_sku(void) { printf(" TEGRA SKU Info:\n"); printf(" chip_id: %u\n", tegra_sku_info.chip_id); diff --git a/sys/arm/rockchip/rk30xx_wdog.c b/sys/arm/rockchip/rk30xx_wdog.c index 612b793fcbe..a24230e03ef 100644 --- a/sys/arm/rockchip/rk30xx_wdog.c +++ b/sys/arm/rockchip/rk30xx_wdog.c @@ -170,7 +170,7 @@ rk30_wd_watchdog_fn(void *private, u_int cmd, int *error) } void -rk30_wd_watchdog_reset() +rk30_wd_watchdog_reset(void) { bus_space_handle_t bsh; diff --git a/sys/arm/ti/am335x/am335x_dmtpps.c b/sys/arm/ti/am335x/am335x_dmtpps.c index 6ed9bd5b21f..b05437a26fd 100644 --- a/sys/arm/ti/am335x/am335x_dmtpps.c +++ b/sys/arm/ti/am335x/am335x_dmtpps.c @@ -163,7 +163,7 @@ dmtpps_translate_nickname(const char *nick) * fails that IS an error, return -1. */ static int -dmtpps_find_tmr_num_by_tunable() +dmtpps_find_tmr_num_by_tunable(void) { struct padinfo *pi; char iname[20]; @@ -201,7 +201,7 @@ dmtpps_find_tmr_num_by_tunable() * input pin. If so, return the timer number, if not return 0. */ static int -dmtpps_find_tmr_num_by_padconf() +dmtpps_find_tmr_num_by_padconf(void) { int err; unsigned int padstate; @@ -225,7 +225,7 @@ dmtpps_find_tmr_num_by_padconf() * configuration. This is done just once, the first time probe() runs. */ static int -dmtpps_find_tmr_num() +dmtpps_find_tmr_num(void) { int tmr_num; diff --git a/sys/arm/versatile/versatile_machdep.c b/sys/arm/versatile/versatile_machdep.c index 2ce2faf969d..22cf82b2e1b 100644 --- a/sys/arm/versatile/versatile_machdep.c +++ b/sys/arm/versatile/versatile_machdep.c @@ -100,7 +100,7 @@ platform_devmap_init(void) } void -cpu_reset() +cpu_reset(void) { printf("cpu_reset\n"); while (1); diff --git a/sys/arm/xilinx/zy7_machdep.c b/sys/arm/xilinx/zy7_machdep.c index 472f70c6473..3349dd1cb81 100644 --- a/sys/arm/xilinx/zy7_machdep.c +++ b/sys/arm/xilinx/zy7_machdep.c @@ -91,7 +91,7 @@ platform_devmap_init(void) } void -cpu_reset() +cpu_reset(void) { if (zynq7_cpu_reset != NULL) (*zynq7_cpu_reset)(); diff --git a/sys/arm/xilinx/zy7_slcr.c b/sys/arm/xilinx/zy7_slcr.c index bd0311c3320..c630fe6f7ce 100644 --- a/sys/arm/xilinx/zy7_slcr.c +++ b/sys/arm/xilinx/zy7_slcr.c @@ -496,7 +496,7 @@ zy7_pl_fclk_enabled(int unit) } int -zy7_pl_level_shifters_enabled() +zy7_pl_level_shifters_enabled(void) { struct zy7_slcr_softc *sc = zy7_slcr_softc_p; @@ -513,7 +513,7 @@ zy7_pl_level_shifters_enabled() } void -zy7_pl_level_shifters_enable() +zy7_pl_level_shifters_enable(void) { struct zy7_slcr_softc *sc = zy7_slcr_softc_p; @@ -528,7 +528,7 @@ zy7_pl_level_shifters_enable() } void -zy7_pl_level_shifters_disable() +zy7_pl_level_shifters_disable(void) { struct zy7_slcr_softc *sc = zy7_slcr_softc_p; diff --git a/sys/arm/xscale/pxa/pxa_gpio.c b/sys/arm/xscale/pxa/pxa_gpio.c index ecc220ae55d..a3ad33d98a8 100644 --- a/sys/arm/xscale/pxa/pxa_gpio.c +++ b/sys/arm/xscale/pxa/pxa_gpio.c @@ -331,7 +331,7 @@ pxa_gpio_unmask_irq(int irq) } int -pxa_gpio_get_next_irq() +pxa_gpio_get_next_irq(void) { struct pxa_gpio_softc *sc; int gpio; diff --git a/sys/arm/xscale/pxa/pxa_icu.c b/sys/arm/xscale/pxa/pxa_icu.c index 4194da3c036..c375ccba48b 100644 --- a/sys/arm/xscale/pxa/pxa_icu.c +++ b/sys/arm/xscale/pxa/pxa_icu.c @@ -171,7 +171,7 @@ arm_unmask_irq(uintptr_t nb) } uint32_t -pxa_icu_get_icip() +pxa_icu_get_icip(void) { return (bus_space_read_4(pxa_icu_softc->pi_bst, @@ -187,7 +187,7 @@ pxa_icu_clear_icip(int irq) } uint32_t -pxa_icu_get_icfp() +pxa_icu_get_icfp(void) { return (bus_space_read_4(pxa_icu_softc->pi_bst, @@ -203,7 +203,7 @@ pxa_icu_clear_icfp(int irq) } uint32_t -pxa_icu_get_icmr() +pxa_icu_get_icmr(void) { return (bus_space_read_4(pxa_icu_softc->pi_bst, @@ -219,7 +219,7 @@ pxa_icu_set_icmr(uint32_t val) } uint32_t -pxa_icu_get_iclr() +pxa_icu_get_iclr(void) { return (bus_space_read_4(pxa_icu_softc->pi_bst, @@ -235,7 +235,7 @@ pxa_icu_set_iclr(uint32_t val) } uint32_t -pxa_icu_get_icpr() +pxa_icu_get_icpr(void) { return (bus_space_read_4(pxa_icu_softc->pi_bst, @@ -243,7 +243,7 @@ pxa_icu_get_icpr() } void -pxa_icu_idle_enable() +pxa_icu_idle_enable(void) { bus_space_write_4(pxa_icu_softc->pi_bst, @@ -251,7 +251,7 @@ pxa_icu_idle_enable() } void -pxa_icu_idle_disable() +pxa_icu_idle_disable(void) { bus_space_write_4(pxa_icu_softc->pi_bst, diff --git a/sys/arm/xscale/pxa/pxa_space.c b/sys/arm/xscale/pxa/pxa_space.c index eb8314aeb8e..26c8d576cec 100644 --- a/sys/arm/xscale/pxa/pxa_space.c +++ b/sys/arm/xscale/pxa/pxa_space.c @@ -176,7 +176,7 @@ bus_space_tag_t base_tag = &_base_tag; bus_space_tag_t obio_tag = NULL; void -pxa_obio_tag_init() +pxa_obio_tag_init(void) { bcopy(&_base_tag, &_obio_tag, sizeof(struct bus_space)); diff --git a/sys/arm/xscale/pxa/pxa_timer.c b/sys/arm/xscale/pxa/pxa_timer.c index d62c1e1edbc..e13793de678 100644 --- a/sys/arm/xscale/pxa/pxa_timer.c +++ b/sys/arm/xscale/pxa/pxa_timer.c @@ -235,7 +235,7 @@ pxa_timer_set_osmr(int which, uint32_t val) } uint32_t -pxa_timer_get_oscr() +pxa_timer_get_oscr(void) { return (bus_space_read_4(timer_softc->pt_bst, @@ -251,7 +251,7 @@ pxa_timer_set_oscr(uint32_t val) } uint32_t -pxa_timer_get_ossr() +pxa_timer_get_ossr(void) { return (bus_space_read_4(timer_softc->pt_bst, @@ -267,7 +267,7 @@ pxa_timer_clear_ossr(uint32_t val) } void -pxa_timer_watchdog_enable() +pxa_timer_watchdog_enable(void) { bus_space_write_4(timer_softc->pt_bst, @@ -275,7 +275,7 @@ pxa_timer_watchdog_enable() } void -pxa_timer_watchdog_disable() +pxa_timer_watchdog_disable(void) { bus_space_write_4(timer_softc->pt_bst, From ba9f40ca3b693f16eb36ff24ff5534e5562b4149 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Tue, 13 Dec 2016 13:46:09 +0000 Subject: [PATCH 145/226] Use the platform_*_t typedefs to help check the platform function types are correct. Sponsored by: ABT Systems Ltd --- sys/arm/allwinner/aw_machdep.c | 11 +++++++++++ sys/arm/broadcom/bcm2835/bcm2835_machdep.c | 10 ++++++++++ sys/arm/freescale/imx/imx51_machdep.c | 8 +++++++- sys/arm/freescale/imx/imx53_machdep.c | 8 +++++++- sys/arm/freescale/imx/imx6_machdep.c | 9 ++++++++- sys/arm/nvidia/tegra124/tegra124_machdep.c | 6 ++++++ sys/arm/ti/ti_machdep.c | 11 +++++++++++ 7 files changed, 60 insertions(+), 3 deletions(-) diff --git a/sys/arm/allwinner/aw_machdep.c b/sys/arm/allwinner/aw_machdep.c index d9effb8eec9..2c34475656e 100644 --- a/sys/arm/allwinner/aw_machdep.c +++ b/sys/arm/allwinner/aw_machdep.c @@ -54,6 +54,17 @@ __FBSDID("$FreeBSD$"); #include "platform_if.h" +static platform_attach_t a10_attach; +static platform_attach_t a13_attach; +static platform_attach_t a20_attach; +static platform_attach_t a31_attach; +static platform_attach_t a31s_attach; +static platform_attach_t a83t_attach; +static platform_attach_t h3_attach; +static platform_lastaddr_t allwinner_lastaddr; +static platform_devmap_init_t allwinner_devmap_init; +static platform_cpu_reset_t allwinner_cpu_reset; + static u_int soc_type; static u_int soc_family; diff --git a/sys/arm/broadcom/bcm2835/bcm2835_machdep.c b/sys/arm/broadcom/bcm2835/bcm2835_machdep.c index bd1762f8896..5101f62c3d4 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_machdep.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_machdep.c @@ -62,6 +62,16 @@ __FBSDID("$FreeBSD$"); #include "platform_if.h" +#ifdef SOC_BCM2835 +static platform_devmap_init_t bcm2835_devmap_init; +#endif +#ifdef SOC_BCM2836 +static platform_devmap_init_t bcm2836_devmap_init; +#endif +static platform_lastaddr_t bcm2835_lastaddr; +static platform_late_init_t bcm2835_late_init; +static platform_cpu_reset_t bcm2835_cpu_reset; + static vm_offset_t bcm2835_lastaddr(platform_t plat) { diff --git a/sys/arm/freescale/imx/imx51_machdep.c b/sys/arm/freescale/imx/imx51_machdep.c index 645d2810b3d..3d208768b98 100644 --- a/sys/arm/freescale/imx/imx51_machdep.c +++ b/sys/arm/freescale/imx/imx51_machdep.c @@ -45,6 +45,11 @@ __FBSDID("$FreeBSD$"); #include "platform_if.h" +static platform_attach_t imx51_attach; +static platform_devmap_init_t imx51_devmap_init; +static platform_lastaddr_t imx51_lastaddr; +static platform_cpu_reset_t imx51_cpu_reset; + static vm_offset_t imx51_lastaddr(platform_t plat) { @@ -88,7 +93,8 @@ imx51_cpu_reset(platform_t plat) imx_wdog_cpu_reset(0x73F98000); } -u_int imx_soc_type() +u_int +imx_soc_type(void) { return (IMXSOC_51); } diff --git a/sys/arm/freescale/imx/imx53_machdep.c b/sys/arm/freescale/imx/imx53_machdep.c index 7596a2082f5..81a5486a1a1 100644 --- a/sys/arm/freescale/imx/imx53_machdep.c +++ b/sys/arm/freescale/imx/imx53_machdep.c @@ -45,6 +45,11 @@ __FBSDID("$FreeBSD$"); #include "platform_if.h" +static platform_attach_t imx53_attach; +static platform_devmap_init_t imx53_devmap_init; +static platform_lastaddr_t imx53_lastaddr; +static platform_cpu_reset_t imx53_cpu_reset; + static vm_offset_t imx53_lastaddr(platform_t plat) { @@ -88,7 +93,8 @@ imx53_cpu_reset(platform_t plat) imx_wdog_cpu_reset(0x53F98000); } -u_int imx_soc_type() +u_int +imx_soc_type(void) { return (IMXSOC_53); } diff --git a/sys/arm/freescale/imx/imx6_machdep.c b/sys/arm/freescale/imx/imx6_machdep.c index 4fa4523adab..a2c5fd8d51e 100644 --- a/sys/arm/freescale/imx/imx6_machdep.c +++ b/sys/arm/freescale/imx/imx6_machdep.c @@ -54,6 +54,12 @@ __FBSDID("$FreeBSD$"); static uint32_t gpio1_node; +static platform_attach_t imx6_attach; +static platform_devmap_init_t imx6_devmap_init; +static platform_lastaddr_t imx6_lastaddr; +static platform_late_init_t imx6_late_init; +static platform_cpu_reset_t imx6_cpu_reset; + #ifndef INTRNG /* * Work around the linux workaround for imx6 erratum 006687, in which some @@ -259,7 +265,8 @@ imx6_cpu_reset(platform_t plat) * hwsoc = 0x00000063 * scu config = 0x00005503 */ -u_int imx_soc_type() +u_int +imx_soc_type(void) { uint32_t digprog, hwsoc; uint32_t *pcr; diff --git a/sys/arm/nvidia/tegra124/tegra124_machdep.c b/sys/arm/nvidia/tegra124/tegra124_machdep.c index b874b5abd0f..3ef47a16abb 100644 --- a/sys/arm/nvidia/tegra124/tegra124_machdep.c +++ b/sys/arm/nvidia/tegra124/tegra124_machdep.c @@ -60,6 +60,12 @@ __FBSDID("$FreeBSD$"); PMC_SCRATCH0_MODE_BOOTLOADER | \ PMC_SCRATCH0_MODE_RCM) +static platform_attach_t tegra124_attach; +static platform_lastaddr_t tegra124_lastaddr; +static platform_devmap_init_t tegra124_devmap_init; +static platform_late_init_t tegra124_late_init; +static platform_cpu_reset_t tegra124_cpu_reset; + static vm_offset_t tegra124_lastaddr(platform_t plat) { diff --git a/sys/arm/ti/ti_machdep.c b/sys/arm/ti/ti_machdep.c index 23cfea021da..7963e225696 100644 --- a/sys/arm/ti/ti_machdep.c +++ b/sys/arm/ti/ti_machdep.c @@ -58,6 +58,17 @@ __FBSDID("$FreeBSD$"); #include "platform_if.h" +#if defined(SOC_OMAP4) +static platform_attach_t omap4_attach; +static platform_devmap_init_t ti_omap4_devmap_init; +#endif +#if defined(SOC_TI_AM335X) +static platform_attach_t ti_am335x_attach; +static platform_devmap_init_t ti_am335x_devmap_init; +#endif +static platform_lastaddr_t ti_lastaddr; +static platform_cpu_reset_t ti_plat_cpu_reset; + void (*ti_cpu_reset)(void) = NULL; int _ti_chip = -1; From d686b0713255b66f0b8c7eb371df6cf91daf7aa2 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 13 Dec 2016 16:20:10 +0000 Subject: [PATCH 146/226] Reduce diff from Illumos by better variables mapping. --- sys/cddl/compat/opensolaris/sys/kmem.h | 7 +++++-- .../opensolaris/uts/common/fs/zfs/arc.c | 20 ++----------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/sys/cddl/compat/opensolaris/sys/kmem.h b/sys/cddl/compat/opensolaris/sys/kmem.h index c0e9760d57b..0b7e16c6766 100644 --- a/sys/cddl/compat/opensolaris/sys/kmem.h +++ b/sys/cddl/compat/opensolaris/sys/kmem.h @@ -37,6 +37,7 @@ #include #include #include +#include MALLOC_DECLARE(M_SOLARIS); @@ -77,8 +78,10 @@ void kmem_reap(void); int kmem_debugging(void); void *calloc(size_t n, size_t s); -#define freemem vm_cnt.v_free_count -#define minfree vm_cnt.v_free_min +#define freemem (long)vm_cnt.v_free_count +#define desfree (long)vm_cnt.v_free_target +#define minfree (long)vm_cnt.v_free_min +#define needfree (long)vm_pageout_deficit #define heap_arena kmem_arena #define kmem_alloc(size, kmflags) zfs_kmem_alloc((size), (kmflags)) #define kmem_zalloc(size, kmflags) zfs_kmem_alloc((size), (kmflags) | M_ZERO) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c index b41b746d368..49c52ed3e6d 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c @@ -357,6 +357,7 @@ int zfs_arc_shrink_shift = 0; int zfs_arc_p_min_shift = 0; uint64_t zfs_arc_average_blocksize = 8 * 1024; /* 8KB */ u_int zfs_arc_free_target = 0; +#define lotsfree zfs_arc_free_target /* Absolute min for arc min / max is 16MB. */ static uint64_t arc_abs_min = 16 << 20; @@ -3827,8 +3828,6 @@ arc_shrink(int64_t to_free) } } -static long needfree = 0; - typedef enum free_memory_reason_t { FMR_UNKNOWN, FMR_NEEDFREE, @@ -3874,17 +3873,6 @@ arc_available_memory(void) } } - /* - * Cooperate with pagedaemon when it's time for it to scan - * and reclaim some pages. - */ - n = PAGESIZE * ((int64_t)freemem - zfs_arc_free_target); - if (n < lowest) { - lowest = n; - r = FMR_LOTSFREE; - } - -#ifdef illumos /* * check that we're out of range of the pageout scanner. It starts to * schedule paging if freemem is less than lotsfree and needfree. @@ -3898,6 +3886,7 @@ arc_available_memory(void) r = FMR_LOTSFREE; } +#ifdef illumos /* * check to make sure that swapfs has enough space so that anon * reservations can still succeed. anon_resvmem() checks that the @@ -4154,9 +4143,6 @@ arc_reclaim_thread(void *dummy __unused) * infinite loop. */ if (arc_size <= arc_c || evicted == 0) { -#ifdef _KERNEL - needfree = 0; -#endif /* * We're either no longer overflowing, or we * can't evict anything more, so we should wake @@ -5883,8 +5869,6 @@ arc_lowmem(void *arg __unused, int howto __unused) { mutex_enter(&arc_reclaim_lock); - /* XXX: Memory deficit should be passed as argument. */ - needfree = btoc(arc_c >> arc_shrink_shift); DTRACE_PROBE(arc__needfree); cv_signal(&arc_reclaim_thread_cv); From 37472174e03c5d89b5b788a8b8f8a0b9b78728f5 Mon Sep 17 00:00:00 2001 From: Nikolai Lifanov Date: Tue, 13 Dec 2016 16:53:58 +0000 Subject: [PATCH 147/226] add myself as a ports committer and update mentor/mentee relationship Reviewed by: matthew Approved by: matthew (mentor) Differential Revision: https://reviews.freebsd.org/D8774 --- share/misc/committers-ports.dot | 3 +++ 1 file changed, 3 insertions(+) diff --git a/share/misc/committers-ports.dot b/share/misc/committers-ports.dot index 33560cbe91e..3da0e274a68 100644 --- a/share/misc/committers-ports.dot +++ b/share/misc/committers-ports.dot @@ -145,6 +145,7 @@ lawrance [label="Sam Lawrance\nlawrance@FreeBSD.org\n2005/04/11\n2007/02/21"] lbr [label="Lars Balker Rasmussen\nlbr@FreeBSD.org\n2006/04/30"] leeym [label="Yen-Ming Lee\nleeym@FreeBSD.org\n2002/08/14"] lev [label="Lev Serebryakov\nlev@FreeBSD.org\n2003/06/17"] +lifanov [label="Nikolai Lifanov\nlifanov@FreeBSD.org\n2016/12/11"] linimon [label="Mark Linimon\nlinimon@FreeBSD.org\n2003/10/23"] lioux [label="Mario Sergio Fujikawa Ferriera\nlioux@FreeBSD.org\n2000/10/14"] lippe [label="Felippe de Meirelles Motta\nlippe@FreeBSD.org\n2008/03/08"] @@ -475,6 +476,8 @@ mat -> tcberner mat -> thierry mat -> woodsb02 +matthew -> lifanov + mezz -> tmclaugh miwi -> amdmi3 From 9d9b69b3732314d3900c104cd1d1bc54c2d057a7 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Tue, 13 Dec 2016 18:05:14 +0000 Subject: [PATCH 148/226] Take write lock for rtld_bind before modifying obj_list in dl_iterate_phdr(). This avoids a race with readers such as dladdr(3)/dlinfo(3)/dlsym(3) and the atexit(3) handler. This race was introduced in r294373. Reviewed by: markj, kib, kan MFC after: 2 weeks Sponsored by: Dell EMC Isilon --- libexec/rtld-elf/rtld.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index ce152f8157f..ec33d87888d 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -3549,7 +3549,7 @@ dl_iterate_phdr(__dl_iterate_hdr_callback callback, void *param) error = 0; wlock_acquire(rtld_phdr_lock, &phdr_lockstate); - rlock_acquire(rtld_bind_lock, &bind_lockstate); + wlock_acquire(rtld_bind_lock, &bind_lockstate); for (obj = globallist_curr(TAILQ_FIRST(&obj_list)); obj != NULL;) { TAILQ_INSERT_AFTER(&obj_list, obj, &marker, next); rtld_fill_dl_phdr_info(obj, &phdr_info); @@ -3557,7 +3557,7 @@ dl_iterate_phdr(__dl_iterate_hdr_callback callback, void *param) error = callback(&phdr_info, sizeof phdr_info, param); - rlock_acquire(rtld_bind_lock, &bind_lockstate); + wlock_acquire(rtld_bind_lock, &bind_lockstate); obj = globallist_next(&marker); TAILQ_REMOVE(&obj_list, &marker, next); if (error != 0) { From c519c3c3089ef65c72566084ec02a1d7f45f8127 Mon Sep 17 00:00:00 2001 From: Christian Brueffer Date: Tue, 13 Dec 2016 18:15:11 +0000 Subject: [PATCH 149/226] Language and mdoc cleanup. --- sbin/decryptcore/decryptcore.8 | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/sbin/decryptcore/decryptcore.8 b/sbin/decryptcore/decryptcore.8 index d21667c0784..c1c910a5936 100644 --- a/sbin/decryptcore/decryptcore.8 +++ b/sbin/decryptcore/decryptcore.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 10, 2016 +.Dd December 13, 2016 .Dt DECRYPTCORE 8 .Os .Sh NAME @@ -45,7 +45,7 @@ .Sh DESCRIPTION The .Nm -first decrypts +utility first decrypts .Ar keyfile using .Ar privatekeyfile @@ -53,7 +53,7 @@ and then uses the resulting key to decrypt .Ar encryptedcore saved by .Xr savecore 8 . -Result is saved in +The result is saved in .Ar core . .Pp Alternatively a user can decrypt a core dump numbered @@ -91,24 +91,22 @@ Specify location of an encrypted core. .It Fl c Ar core Specify location of a resulting decrypted core dump. .It Fl d Ar crashdir -Specify an alternative crash dump directory. The default crash dump directory is +Specify an alternative crash dump directory. +The default crash dump directory is .Pa /var/crash . .It Fl n Ar dumpnr Specify a number of a crash dump to be decrypted. .El .Sh EXIT STATUS -The -.Nm -utility exits 0 on success, and >0 if an error occurs. +.Ex -std .Sh SEE ALSO +.Xr kgdb 1 , .Xr capsicum 4 , .Xr dumpon 8 , -.Xr kgdb 1 , .Xr savecore 8 , .Xr syslogd 8 .Sh AUTHORS The .Nm -was implemented by -.An -nosplit +utility was implemented by .An Konrad Witaszczyk Aq Mt def@FreeBSD.org . From 826673702320356317092f45f371858fbbecb599 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Tue, 13 Dec 2016 19:04:05 +0000 Subject: [PATCH 150/226] Fix bug in r309712, do not leak gem object pin count in case of error or retry. Reported and tested by: Michael Butler Sponsored by: The FreeBSD Foundation MFC after: 16 days --- sys/dev/drm2/i915/i915_gem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/dev/drm2/i915/i915_gem.c b/sys/dev/drm2/i915/i915_gem.c index 2a53ae8f8ed..0fa5249e553 100644 --- a/sys/dev/drm2/i915/i915_gem.c +++ b/sys/dev/drm2/i915/i915_gem.c @@ -1521,7 +1521,7 @@ i915_gem_pager_populate(vm_object_t vm_obj, vm_pindex_t pidx, int fault_type, /* Now bind it into the GTT if needed */ ret = i915_gem_object_pin(obj, 0, true, false); if (ret) - goto unpin; + goto unlock; pinned = 1; ret = i915_gem_object_set_to_gtt_domain(obj, write); @@ -1580,6 +1580,8 @@ i915_gem_pager_populate(vm_object_t vm_obj, vm_pindex_t pidx, int fault_type, return (VM_PAGER_OK); unpin: + i915_gem_object_unpin(obj); +unlock: DRM_UNLOCK(dev); out: KASSERT(ret != 0, ("i915_gem_pager_fault: wrong return")); From a9546a6b174e4336e4e45e916038247dd618b9cd Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 13 Dec 2016 19:22:43 +0000 Subject: [PATCH 151/226] Use db_lookup_proc() in the DDB 'show procvm' command. This allows processes to be identified by PID as well as a pointer address. MFC after: 2 weeks Sponsored by: DARPA / AFRL --- sys/vm/vm_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 8b72128b9be..2cb1affcc28 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -4309,7 +4309,7 @@ DB_SHOW_COMMAND(procvm, procvm) struct proc *p; if (have_addr) { - p = (struct proc *) addr; + p = db_lookup_proc(addr); } else { p = curproc; } From 6c941e4724b6a83b3c6d4ab90033402139354342 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 13 Dec 2016 19:27:31 +0000 Subject: [PATCH 152/226] Fix remove_userlocal_code() for n32. n32 kernels use a 64-bit store to the TLS register rather than a 32-bit store. Sponsored by: DARPA / AFRL --- sys/mips/mips/cpu.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/mips/mips/cpu.c b/sys/mips/mips/cpu.c index fa68fd32e74..149bec32f92 100644 --- a/sys/mips/mips/cpu.c +++ b/sys/mips/mips/cpu.c @@ -78,9 +78,6 @@ struct mips_cpuinfo cpuinfo; # define _ADDU_V0_T0_T1 \ _ENCODE_INSN(0, T0, T1, V0, OP_DADDU) -# define _MTC0_V0_USERLOCAL \ - _ENCODE_INSN(OP_COP0, OP_DMT, V0, 4, 2) - #else /* mips 32 */ # define _LOAD_T0_MDTLS_A1 \ @@ -93,10 +90,19 @@ struct mips_cpuinfo cpuinfo; # define _ADDU_V0_T0_T1 \ _ENCODE_INSN(0, T0, T1, V0, OP_ADDU) +#endif /* ! __mips_n64 */ + +#if defined(__mips_n64) || defined(__mips_n32) + +# define _MTC0_V0_USERLOCAL \ + _ENCODE_INSN(OP_COP0, OP_DMT, V0, 4, 2) + +#else /* mips o32 */ + # define _MTC0_V0_USERLOCAL \ _ENCODE_INSN(OP_COP0, OP_MT, V0, 4, 2) -#endif /* ! __mips_n64 */ +#endif /* ! (__mips_n64 || __mipsn32) */ #define _JR_RA _ENCODE_INSN(OP_SPECIAL, RA, 0, 0, OP_JR) #define _NOP 0 From ca311cf72b5fb5121c12790e6fb551c445d713b8 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 13 Dec 2016 19:36:05 +0000 Subject: [PATCH 153/226] Use register_t instead of uintptr_t for register values in backtraces. This fixes backtraces from DDB in n32 kernels as uintptr_t is only a uint32_t. In particular, the upper 32-bits of each register value were treated as the register's value breaking both the output of register values, but also the values of 'ra' and 'sp' required to walk up to the previous frame. Sponsored by: DARPA / AFRL --- sys/mips/mips/db_trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/mips/mips/db_trace.c b/sys/mips/mips/db_trace.c index 215ec0fc152..74d05b92617 100644 --- a/sys/mips/mips/db_trace.c +++ b/sys/mips/mips/db_trace.c @@ -139,8 +139,8 @@ stacktrace_subr(register_t pc, register_t sp, register_t ra, * of these registers is valid, e.g. obtained from the stack */ int valid_args[4]; - uintptr_t args[4]; - uintptr_t va, subr; + register_t args[4]; + register_t va, subr; unsigned instr, mask; unsigned int frames = 0; int more, stksize, j; @@ -379,7 +379,7 @@ stacktrace_subr(register_t pc, register_t sp, register_t ra, if (j > 0) (*printfn)(","); if (valid_args[j]) - (*printfn)("%x", args[j]); + (*printfn)("%jx", (uintmax_t)(u_register_t)args[j]); else (*printfn)("?"); } From 2f02a9e15af40c69782ff392a3d031d8e6108ff7 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Tue, 13 Dec 2016 19:58:21 +0000 Subject: [PATCH 154/226] linuxkpi: Fix not-found case of linux_pci_find_irq_dev Linux list_for_each_entry() does not neccessarily end with the iterator NULL (it may be an offset from NULL if the list member is not the first element of the member struct). Reported by: Coverity CID: 1366940 Reviewed by: hselasky@ Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8780 --- sys/compat/linuxkpi/common/include/linux/pci.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 305fa6f312a..a7fcb04c480 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -220,18 +220,19 @@ static inline struct device * linux_pci_find_irq_dev(unsigned int irq) { struct pci_dev *pdev; + struct device *found; + found = NULL; spin_lock(&pci_lock); list_for_each_entry(pdev, &pci_devices, links) { - if (irq == pdev->dev.irq) - break; - if (irq >= pdev->dev.msix && irq < pdev->dev.msix_max) + if (irq == pdev->dev.irq || + (irq >= pdev->dev.msix && irq < pdev->dev.msix_max)) { + found = &pdev->dev; break; + } } spin_unlock(&pci_lock); - if (pdev) - return &pdev->dev; - return (NULL); + return (found); } static inline unsigned long From 1276a8363c0fc4991032a3c627e283bfefdf3373 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Tue, 13 Dec 2016 20:11:45 +0000 Subject: [PATCH 155/226] Zero return value when counter_rate() switches over to next second and value is positive, but below the limit. --- sys/kern/subr_counter.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/kern/subr_counter.c b/sys/kern/subr_counter.c index 08f55d0f1f1..f0727f31d78 100644 --- a/sys/kern/subr_counter.c +++ b/sys/kern/subr_counter.c @@ -154,6 +154,8 @@ counter_ratecheck(struct counter_rate *cr, int64_t limit) counter_u64_zero(cr->cr_rate); cr->cr_over = 0; cr->cr_ticks = now; + if (val <= limit) + val = 0; } atomic_store_rel_int(&cr->cr_lock, 0); } else From 1521ca71d38bedcb4e17f61867d435868aaf96d9 Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Tue, 13 Dec 2016 20:35:57 +0000 Subject: [PATCH 156/226] cxgbe(4): Retire t4_bus_space_read_8 and t4_bus_space_write_8. MFC after: 3 days Sponsored by: Chelsio Communications --- sys/dev/cxgbe/adapter.h | 54 ++++++++++------------------------------- 1 file changed, 13 insertions(+), 41 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 1666bc781dd..29af300d393 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -84,45 +84,6 @@ prefetch(void *x) #define SBUF_DRAIN 1 #endif -#ifdef __amd64__ -/* XXX: need systemwide bus_space_read_8/bus_space_write_8 */ -static __inline uint64_t -t4_bus_space_read_8(bus_space_tag_t tag, bus_space_handle_t handle, - bus_size_t offset) -{ - KASSERT(tag == X86_BUS_SPACE_MEM, - ("%s: can only handle mem space", __func__)); - - return (*(volatile uint64_t *)(handle + offset)); -} - -static __inline void -t4_bus_space_write_8(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, uint64_t value) -{ - KASSERT(tag == X86_BUS_SPACE_MEM, - ("%s: can only handle mem space", __func__)); - - *(volatile uint64_t *)(bsh + offset) = value; -} -#else -static __inline uint64_t -t4_bus_space_read_8(bus_space_tag_t tag, bus_space_handle_t handle, - bus_size_t offset) -{ - return (uint64_t)bus_space_read_4(tag, handle, offset) + - ((uint64_t)bus_space_read_4(tag, handle, offset + 4) << 32); -} - -static __inline void -t4_bus_space_write_8(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, uint64_t value) -{ - bus_space_write_4(tag, bsh, offset, value); - bus_space_write_4(tag, bsh, offset + 4, value >> 32); -} -#endif - struct adapter; typedef struct adapter adapter_t; @@ -977,14 +938,25 @@ static inline uint64_t t4_read_reg64(struct adapter *sc, uint32_t reg) { - return t4_bus_space_read_8(sc->bt, sc->bh, reg); +#ifdef __LP64__ + return bus_space_read_8(sc->bt, sc->bh, reg); +#else + return (uint64_t)bus_space_read_4(sc->bt, sc->bh, reg) + + ((uint64_t)bus_space_read_4(sc->bt, sc->bh, reg + 4) << 32); + +#endif } static inline void t4_write_reg64(struct adapter *sc, uint32_t reg, uint64_t val) { - t4_bus_space_write_8(sc->bt, sc->bh, reg, val); +#ifdef __LP64__ + bus_space_write_8(sc->bt, sc->bh, reg, val); +#else + bus_space_write_4(sc->bt, sc->bh, reg, val); + bus_space_write_4(sc->bt, sc->bh, reg + 4, val>> 32); +#endif } static inline void From 442f3ba311a4f01835953feb59ae1ea41c44fdf8 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Tue, 13 Dec 2016 20:55:46 +0000 Subject: [PATCH 157/226] Remove an extra "break" which could incorrectly terminate an STAILQ_FOREACH() loop when an AF_INET6 rule matched. Spotted by: cem --- usr.sbin/syslogd/syslogd.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 53866382e3b..a198b5f8e3b 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -2465,7 +2465,6 @@ validate(struct sockaddr *sa, const char *hname) struct allowedpeer *ap; struct sockaddr_in *sin4, *a4p = NULL, *m4p = NULL; #ifdef INET6 - int reject; struct sockaddr_in6 *sin6, *a6p = NULL, *m6p = NULL; #endif struct addrinfo hints, *res; @@ -2533,13 +2532,8 @@ validate(struct sockaddr *sa, const char *hname) dprintf("rejected in rule %d due to scope mismatch.\n", i); continue; } - reject = 0; if (IN6_ARE_MASKED_ADDR_EQUAL(&sin6->sin6_addr, &a6p->sin6_addr, &m6p->sin6_addr) != 0) { - ++reject; - break; - } - if (reject) { dprintf("rejected in rule %d due to IP mismatch.\n", i); continue; } From 2aa82aeacc0d6c91415e090497a63f58cb747288 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 13 Dec 2016 22:30:48 +0000 Subject: [PATCH 158/226] Fix stack traces in DDB for the debugger thread. When the kernel debugger is entered, makectx() is called to store appropriate state from the trapframe for the debugger into a global kdb_pcb used as the thread context of the thread entering the debugger. Stack unwinders for DDB called via db_trace_thread() are supposed to then use this saved context so that the stack trace for the current thread starts at the location of the event that triggered debugger entry. MIPS was instead starting the stack trace of the current thread from the context of db_trace_thread itself and unwinding back out through the debugger to the original frame. Fix a couple of things to bring MIPS inline with other platforms: - Fix makectx() to store the PC, SP, and RA in the right portion of the PCB used by db_trace_thread(). - Fix db_trace_thread() to always use kdb_thr_ctx() (and thus kdb_pcb for the debugger thread). - Move the logic for tracing curthread from within the current function into db_trace_self() to match other architectures. Sponsored by: DARPA / AFRL --- sys/mips/mips/db_trace.c | 42 +++++++++++++++++--------------------- sys/mips/mips/pm_machdep.c | 6 +++--- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/sys/mips/mips/db_trace.c b/sys/mips/mips/db_trace.c index 74d05b92617..8126febc144 100644 --- a/sys/mips/mips/db_trace.c +++ b/sys/mips/mips/db_trace.c @@ -432,7 +432,20 @@ db_md_list_watchpoints() void db_trace_self(void) { - db_trace_thread (curthread, -1); + register_t pc, ra, sp; + + sp = (register_t)(intptr_t)__builtin_frame_address(0); + ra = (register_t)(intptr_t)__builtin_return_address(0); + + __asm __volatile( + "jal 99f\n" + "nop\n" + "99:\n" + "move %0, $31\n" /* get ra */ + "move $31, %1\n" /* restore ra */ + : "=r" (pc) + : "r" (ra)); + stacktrace_subr(pc, sp, ra, db_printf); return; } @@ -442,28 +455,11 @@ db_trace_thread(struct thread *thr, int count) register_t pc, ra, sp; struct pcb *ctx; - if (thr == curthread) { - sp = (register_t)(intptr_t)__builtin_frame_address(0); - ra = (register_t)(intptr_t)__builtin_return_address(0); - - __asm __volatile( - "jal 99f\n" - "nop\n" - "99:\n" - "move %0, $31\n" /* get ra */ - "move $31, %1\n" /* restore ra */ - : "=r" (pc) - : "r" (ra)); - - } else { - ctx = kdb_thr_ctx(thr); - sp = (register_t)ctx->pcb_context[PCB_REG_SP]; - pc = (register_t)ctx->pcb_context[PCB_REG_PC]; - ra = (register_t)ctx->pcb_context[PCB_REG_RA]; - } - - stacktrace_subr(pc, sp, ra, - (int (*) (const char *, ...))db_printf); + ctx = kdb_thr_ctx(thr); + sp = (register_t)ctx->pcb_context[PCB_REG_SP]; + pc = (register_t)ctx->pcb_context[PCB_REG_PC]; + ra = (register_t)ctx->pcb_context[PCB_REG_RA]; + stacktrace_subr(pc, sp, ra, db_printf); return (0); } diff --git a/sys/mips/mips/pm_machdep.c b/sys/mips/mips/pm_machdep.c index 577d1104690..167706335c8 100644 --- a/sys/mips/mips/pm_machdep.c +++ b/sys/mips/mips/pm_machdep.c @@ -292,9 +292,9 @@ void makectx(struct trapframe *tf, struct pcb *pcb) { - pcb->pcb_regs.ra = tf->ra; - pcb->pcb_regs.pc = tf->pc; - pcb->pcb_regs.sp = tf->sp; + pcb->pcb_context[PCB_REG_RA] = tf->ra; + pcb->pcb_context[PCB_REG_PC] = tf->pc; + pcb->pcb_context[PCB_REG_SP] = tf->sp; } int From a7cc56803c92ca843a28621f3a9808e72b7c10f4 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 13 Dec 2016 22:31:49 +0000 Subject: [PATCH 159/226] Revert r309918 -- modern POSIX has deprecated -<#>/+<#> syntax Special thanks to: jilles --- usr.sbin/bsdinstall/scripts/wlanconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig index b7b150bd75f..130f1e06419 100755 --- a/usr.sbin/bsdinstall/scripts/wlanconfig +++ b/usr.sbin/bsdinstall/scripts/wlanconfig @@ -185,8 +185,8 @@ fi # if [ "$BSDINSTALL_CONFIGCURRENT" ]; then # Get current country/regdomain for selected interface - WLAN_IFACE=$( wpa_cli ifname | tail -1 ) - INPUT=$( ifconfig "$WLAN_IFACE" list regdomain | head -1 ) + WLAN_IFACE=$( wpa_cli ifname | tail -n 1 ) + INPUT=$( ifconfig "$WLAN_IFACE" list regdomain | head -n 1 ) DEF_REGDOMAIN=$( echo "$INPUT" | cut -w -f 2 ) DEF_COUNTRY=$( echo "$INPUT" | cut -w -f 4 ) [ "$DEF_REGDOMAIN" = 0 ] && DEF_REGDOMAIN="" From ecb65f66c6308aa025ee0e31b2e8025c7de808e6 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Wed, 14 Dec 2016 00:18:12 +0000 Subject: [PATCH 160/226] Use casts to force an unsigned comparison in db_search_symbol(). On all of our platforms, db_expr_t is a signed integer while db_addr_t is an unsigned integer value. db_search_symbol used variables of type db_expr_t to hold the current offset of the requested address from the "best" symbol found so far. This value was initialized to '~0'. When a new symbol is found from a symbol table, the associated diff for the new symbol is compared against the existing value as 'if (newdiff < diff)' to determine if the new symbol had a smaller diff and was thus a closer match. On 64-bit MIPS, the '~0' was treated as a negative value (-1). A lookup that found a perfect match of an address against a symbol returned a diff of 0. However, in signed comparisons, 0 is not less than -1. As a result, DDB on 64-bit MIPS never resolved any addresses to symbols. Workaround this by using casts to force an unsigned comparison. Probably the diff returned from db_search_symbol() and X_db_search_symbol() should be changed to a db_addr_t instead of a db_expr_t as it is an unsigned value (and is an offset of an address, so should fit in the same size as an address). Sponsored by: DARPA / AFRL --- sys/ddb/db_sym.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/ddb/db_sym.c b/sys/ddb/db_sym.c index 25ae4bcaa97..12e98b112db 100644 --- a/sys/ddb/db_sym.c +++ b/sys/ddb/db_sym.c @@ -373,10 +373,10 @@ db_search_symbol(db_addr_t val, db_strategy_t strategy, db_expr_t *offp) register int i; c_db_sym_t ret = C_DB_SYM_NULL, sym; - newdiff = diff = ~0; + newdiff = diff = val; for (i = 0; i < db_nsymtab; i++) { sym = X_db_search_symbol(&db_symtabs[i], val, strategy, &newdiff); - if (newdiff < diff) { + if ((uintmax_t)newdiff < (uintmax_t)diff) { db_last_symtab = &db_symtabs[i]; diff = newdiff; ret = sym; From a24563566aa8d1e7c9ad3d9fdde2eb772fa18104 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Wed, 14 Dec 2016 00:21:06 +0000 Subject: [PATCH 161/226] Add 'const' to fn_name's return type to remove a cast. --- sys/mips/mips/db_trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/mips/mips/db_trace.c b/sys/mips/mips/db_trace.c index 8126febc144..357436a578b 100644 --- a/sys/mips/mips/db_trace.c +++ b/sys/mips/mips/db_trace.c @@ -105,7 +105,7 @@ static struct { /* * Map a function address to a string name, if known; or a hex string. */ -static char * +static const char * fn_name(uintptr_t addr) { static char buf[17]; @@ -113,12 +113,12 @@ fn_name(uintptr_t addr) db_expr_t diff; c_db_sym_t sym; - char *symname; + const char *symname; diff = 0; symname = NULL; sym = db_search_symbol((db_addr_t)addr, DB_STGY_ANY, &diff); - db_symbol_values(sym, (const char **)&symname, (db_expr_t *)0); + db_symbol_values(sym, &symname, NULL); if (symname && diff == 0) return (symname); From 82fe834050f2d9dc91309f6c0d2d2129f698e703 Mon Sep 17 00:00:00 2001 From: Glen Barber Date: Wed, 14 Dec 2016 03:01:15 +0000 Subject: [PATCH 162/226] - Resize FreeBSD to the size of the OpenStack flavor (growfs). - Speeds up the boot process by disabling sendmail. - Allows an user to ssh as root with a public key. - Make ssh(1) respond faster by disabling DNS lookups. - Enable DHCP on the vtnet(4) interface. Note: The CLOUDWARE list has not yet been changed to include the OpenStack target by default yet. Submitted by: Diego Casati PR: 215258 MFC after: 1 week Sponsored by: The FreeBSD Foundation --- release/tools/openstack.conf | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/release/tools/openstack.conf b/release/tools/openstack.conf index 5d188bba1e8..df5b378d882 100644 --- a/release/tools/openstack.conf +++ b/release/tools/openstack.conf @@ -11,8 +11,25 @@ export VM_EXTRA_PACKAGES="net/cloud-init devel/py-pbr devel/py-iso8601 \ # Set to a list of third-party software to enable in rc.conf(5). export VM_RC_LIST="cloudinit" +export NOSWAP=YES + vm_extra_pre_umount() { + #Enable sshd by default echo 'sshd_enable="YES"' >> ${DESTDIR}/etc/rc.conf + + # Disable DNS lookups by default to make SSH connect quickly + echo 'UseDNS no' >> ${DESTDIR}/etc/ssh/sshd_config + + # Allow root to ssh using keys + echo 'PermitRootLogin without-password' >> ${DESTDIR}/etc/ssh/sshd_config + + # Disable sendmail + echo 'sendmail_enable="NO"' >> ${DESTDIR}/etc/rc.conf + echo 'sendmail_submit_enable="NO"' >> ${DESTDIR}/etc/rc.conf + echo 'sendmail_outbound_enable="NO"' >> ${DESTDIR}/etc/rc.conf + echo 'sendmail_msp_queue_enable="NO"' >> ${DESTDIR}/etc/rc.conf + + # Enable DHCP for the OpenStack instance echo 'ifconfig_DEFAULT="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf # Openstack wants sudo(8) usable by default without a password. @@ -21,5 +38,15 @@ vm_extra_pre_umount() { rm -f ${DESTDIR}/etc/resolv.conf + # The console is not interactive, so we might as well boot quickly. + echo 'autoboot_delay="-1"' >> ${DESTDIR}/boot/loader.conf + echo 'beastie_disable="YES"' >> ${DESTDIR}/boot/loader.conf + + # Reboot quickly, Don't wait at the panic screen + echo 'debug.trace_on_panic=1' >> ${DESTDIR}/etc/sysctl.conf + echo 'debug.debugger_on_panic=0' >> ${DESTDIR}/etc/sysctl.conf + echo 'kern.panic_reboot_wait_time=0' >> ${DESTDIR}/etc/sysctl.conf + + touch ${DESTDIR}/firstboot return 0 } From de69dfbbbc46b23ca5c379d3673d09ca41f330c2 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Wed, 14 Dec 2016 03:20:57 +0000 Subject: [PATCH 163/226] hyperv: Implement "enlightened" time counter, which is rdtsc based. Reviewed by: kib MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8763 --- sys/dev/hyperv/include/hyperv.h | 1 + sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c | 112 ++++++++++++++++++++ sys/dev/hyperv/vmbus/hyperv_reg.h | 16 +++ 3 files changed, 129 insertions(+) diff --git a/sys/dev/hyperv/include/hyperv.h b/sys/dev/hyperv/include/hyperv.h index c5e7dec1f68..44851444d26 100644 --- a/sys/dev/hyperv/include/hyperv.h +++ b/sys/dev/hyperv/include/hyperv.h @@ -45,6 +45,7 @@ #define CPUID_HV_MSR_HYPERCALL 0x0020 /* MSR_HV_GUEST_OS_ID * MSR_HV_HYPERCALL */ #define CPUID_HV_MSR_VP_INDEX 0x0040 /* MSR_HV_VP_INDEX */ +#define CPUID_HV_MSR_REFERENCE_TSC 0x0200 /* MSR_HV_REFERENCE_TSC */ #define CPUID_HV_MSR_GUEST_IDLE 0x0400 /* MSR_HV_GUEST_IDLE */ #ifndef NANOSEC diff --git a/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c b/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c index 5b5f205f333..712a6e22994 100644 --- a/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c +++ b/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c @@ -28,7 +28,37 @@ __FBSDID("$FreeBSD$"); #include +#include +#include +#include + +#include +#include +#include + +#include +#include #include +#include +#include + +struct hyperv_reftsc_ctx { + struct hyperv_reftsc *tsc_ref; + struct hyperv_dma tsc_ref_dma; +}; + +static struct timecounter hyperv_tsc_timecounter = { + .tc_get_timecount = NULL, /* based on CPU vendor. */ + .tc_poll_pps = NULL, + .tc_counter_mask = 0xffffffff, + .tc_frequency = HYPERV_TIMER_FREQ, + .tc_name = "Hyper-V-TSC", + .tc_quality = 3000, + .tc_flags = 0, + .tc_priv = NULL +}; + +static struct hyperv_reftsc_ctx hyperv_ref_tsc; uint64_t hypercall_md(volatile void *hc_addr, uint64_t in_val, @@ -41,3 +71,85 @@ hypercall_md(volatile void *hc_addr, uint64_t in_val, "c" (in_val), "d" (in_paddr), "m" (hc_addr)); return (status); } + +#define HYPERV_TSC_TIMECOUNT(fence) \ +static u_int \ +hyperv_tsc_timecount_##fence(struct timecounter *tc) \ +{ \ + struct hyperv_reftsc *tsc_ref = hyperv_ref_tsc.tsc_ref; \ + uint32_t seq; \ + \ + while ((seq = atomic_load_acq_int(&tsc_ref->tsc_seq)) != 0) { \ + uint64_t disc, ret, tsc; \ + uint64_t scale = tsc_ref->tsc_scale; \ + int64_t ofs = tsc_ref->tsc_ofs; \ + \ + fence(); \ + tsc = rdtsc(); \ + \ + /* ret = ((tsc * scale) >> 64) + ofs */ \ + __asm__ __volatile__ ("mulq %3" : \ + "=d" (ret), "=a" (disc) : \ + "a" (tsc), "r" (scale)); \ + ret += ofs; \ + \ + atomic_thread_fence_acq(); \ + if (tsc_ref->tsc_seq == seq) \ + return (ret); \ + \ + /* Sequence changed; re-sync. */ \ + } \ + /* Fallback to the generic timecounter, i.e. rdmsr. */ \ + return (rdmsr(MSR_HV_TIME_REF_COUNT)); \ +} \ +struct __hack + +HYPERV_TSC_TIMECOUNT(lfence); +HYPERV_TSC_TIMECOUNT(mfence); + +static void +hyperv_tsc_tcinit(void *dummy __unused) +{ + uint64_t val, orig; + + if ((hyperv_features & + (CPUID_HV_MSR_TIME_REFCNT | CPUID_HV_MSR_REFERENCE_TSC)) != + (CPUID_HV_MSR_TIME_REFCNT | CPUID_HV_MSR_REFERENCE_TSC) || + (cpu_feature & CPUID_SSE2) == 0) /* SSE2 for mfence/lfence */ + return; + + switch (cpu_vendor_id) { + case CPU_VENDOR_AMD: + hyperv_tsc_timecounter.tc_get_timecount = + hyperv_tsc_timecount_mfence; + break; + + case CPU_VENDOR_INTEL: + hyperv_tsc_timecounter.tc_get_timecount = + hyperv_tsc_timecount_lfence; + break; + + default: + /* Unsupport CPU vendors. */ + return; + } + + hyperv_ref_tsc.tsc_ref = hyperv_dmamem_alloc(NULL, PAGE_SIZE, 0, + sizeof(struct hyperv_reftsc), &hyperv_ref_tsc.tsc_ref_dma, + BUS_DMA_WAITOK | BUS_DMA_ZERO); + if (hyperv_ref_tsc.tsc_ref == NULL) { + printf("hyperv: reftsc page allocation failed\n"); + return; + } + + orig = rdmsr(MSR_HV_REFERENCE_TSC); + val = MSR_HV_REFTSC_ENABLE | (orig & MSR_HV_REFTSC_RSVD_MASK) | + ((hyperv_ref_tsc.tsc_ref_dma.hv_paddr >> PAGE_SHIFT) << + MSR_HV_REFTSC_PGSHIFT); + wrmsr(MSR_HV_REFERENCE_TSC, val); + + /* Register "enlightened" timecounter. */ + tc_init(&hyperv_tsc_timecounter); +} +SYSINIT(hyperv_tsc_init, SI_SUB_DRIVERS, SI_ORDER_FIRST, hyperv_tsc_tcinit, + NULL); diff --git a/sys/dev/hyperv/vmbus/hyperv_reg.h b/sys/dev/hyperv/vmbus/hyperv_reg.h index 4fb12286be2..263a191fec2 100644 --- a/sys/dev/hyperv/vmbus/hyperv_reg.h +++ b/sys/dev/hyperv/vmbus/hyperv_reg.h @@ -57,6 +57,11 @@ #define MSR_HV_VP_INDEX 0x40000002 +#define MSR_HV_REFERENCE_TSC 0x40000021 +#define MSR_HV_REFTSC_ENABLE 0x0001ULL +#define MSR_HV_REFTSC_RSVD_MASK 0x0ffeULL +#define MSR_HV_REFTSC_PGSHIFT 12 + #define MSR_HV_SCONTROL 0x40000080 #define MSR_HV_SCTRL_ENABLE 0x0001ULL #define MSR_HV_SCTRL_RSVD_MASK 0xfffffffffffffffeULL @@ -123,6 +128,17 @@ #define CPUID_LEAF_HV_LIMITS 0x40000005 #define CPUID_LEAF_HV_HWFEATURES 0x40000006 +/* + * Hyper-V Reference TSC + */ +struct hyperv_reftsc { + volatile uint32_t tsc_seq; + volatile uint32_t tsc_rsvd1; + volatile uint64_t tsc_scale; + volatile int64_t tsc_ofs; +} __packed __aligned(PAGE_SIZE); +CTASSERT(sizeof(struct hyperv_reftsc) == PAGE_SIZE); + /* * Hyper-V Monitor Notification Facility */ From ca276276f13bf614c107adea892a75fd3cdeeba5 Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Wed, 14 Dec 2016 07:36:36 +0000 Subject: [PATCH 164/226] cxgbe(4): Fix the tid range shown for T6 cards in misc.tids. MFC after: 3 days --- sys/dev/cxgbe/t4_main.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 76e0b545f9c..d2429936404 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -7219,25 +7219,23 @@ sysctl_tids(SYSCTL_HANDLER_ARGS) } if (t->ntids) { + sbuf_printf(sb, "TID range: "); if (t4_read_reg(sc, A_LE_DB_CONFIG) & F_HASHEN) { - uint32_t b; + uint32_t b, hb; - if (chip_id(sc) <= CHELSIO_T5) + if (chip_id(sc) <= CHELSIO_T5) { b = t4_read_reg(sc, A_LE_DB_SERVER_INDEX) / 4; - else - b = t4_read_reg(sc, A_LE_DB_SRVR_START_INDEX); - - if (b) { - sbuf_printf(sb, "TID range: 0-%u, %u-%u", b - 1, - t4_read_reg(sc, A_LE_DB_TID_HASHBASE) / 4, - t->ntids - 1); + hb = t4_read_reg(sc, A_LE_DB_TID_HASHBASE) / 4; } else { - sbuf_printf(sb, "TID range: %u-%u", - t4_read_reg(sc, A_LE_DB_TID_HASHBASE) / 4, - t->ntids - 1); + b = t4_read_reg(sc, A_LE_DB_SRVR_START_INDEX); + hb = t4_read_reg(sc, A_T6_LE_DB_HASH_TID_BASE); } + + if (b) + sbuf_printf(sb, "0-%u, ", b - 1); + sbuf_printf(sb, "%u-%u", hb, t->ntids - 1); } else - sbuf_printf(sb, "TID range: 0-%u", t->ntids - 1); + sbuf_printf(sb, "0-%u", t->ntids - 1); sbuf_printf(sb, ", in use: %u\n", atomic_load_acq_int(&t->tids_in_use)); } From 396a688bd91e69f16448750bc9a8a97ae954d255 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Wed, 14 Dec 2016 11:40:31 +0000 Subject: [PATCH 165/226] Provide non-final but valid PCB pointer for thread0 for duration of hammer_time(). This makes assembler exception handlers not fault itself when setting PCB flags, and allow normal kernel trap handler to get control. The pointer is reset after FPU parameters are obtained. Set thread0.td_critnest to 1 for duration of hammer_time() as well. In particular, page faults at that early stage panic immediately instead of trying to call not yet operational VM to resolve it. As result, faults during second half of the hammer_time() execution have a chance to be reported instead of silent machine reboot or hang. Sponsored by: The FreeBSD Foundation MFC after: 2 weeks --- sys/amd64/amd64/machdep.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index b2283339405..682307f5fe4 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -1672,6 +1672,16 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) wrmsr(MSR_STAR, msr); wrmsr(MSR_SF_MASK, PSL_NT|PSL_T|PSL_I|PSL_C|PSL_D); + /* + * Temporary forge some valid pointer to PCB, for exception + * handlers. It is reinitialized properly below after FPU is + * set up. Also set up td_critnest to short-cut the page + * fault handler. + */ + cpu_max_ext_state_size = sizeof(struct savefpu); + thread0.td_pcb = get_pcb_td(&thread0); + thread0.td_critnest = 1; + /* * The console and kdb should be initialized even earlier than here, * but some console drivers don't work until after getmemsize(). @@ -1762,6 +1772,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) #ifdef FDT x86_init_fdt(); #endif + thread0.td_critnest = 0; /* Location of kernel stack for locore */ return ((u_int64_t)thread0.td_pcb); From 1e1f3941e4071048c0bbdc4238d221842d818188 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Wed, 14 Dec 2016 12:47:34 +0000 Subject: [PATCH 166/226] Add support for attaching aggregation labels to sysctl objects. I'm currently working on writing a metrics exporter for the Prometheus monitoring system to provide access to sysctl metrics. Prometheus and sysctl have some structural differences: - sysctl is a tree of string component names. - Prometheus uses a flat namespace for its metrics, but allows you to attach labels with values to them, so that you can do aggregation. An initial version of my exporter simply translated hw.acpi.thermal.tz1.temperature to sysctl_hw_acpi_thermal_tz1_temperature_celcius while we should ideally have sysctl_hw_acpi_thermal_temperature_celcius{thermal_zone="tz1"} allowing you to graph all thermal zones on a system in one go. The change presented in this commit adds support for accomplishing this, by providing the ability to attach labels to nodes. In the example I gave above, the label "thermal_zone" would be attached to "tz1". As this is a feature that will only be used very rarely, I decided to not change the KPI too aggressively. Discussed on: hackers@ Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D8775 --- share/man/man9/Makefile | 3 + share/man/man9/sysctl.9 | 33 +++++++++- share/man/man9/sysctl_add_oid.9 | 3 +- sys/kern/kern_sysctl.c | 33 +++++++++- sys/sys/sysctl.h | 109 +++++++++++++++++++------------- 5 files changed, 134 insertions(+), 47 deletions(-) diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index c27540db685..d11500ba48d 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1712,6 +1712,7 @@ MLINKS+=sysctl.9 SYSCTL_DECL.9 \ sysctl.9 SYSCTL_ADD_INT.9 \ sysctl.9 SYSCTL_ADD_LONG.9 \ sysctl.9 SYSCTL_ADD_NODE.9 \ + sysctl.9 SYSCTL_ADD_NODE_WITH_LABEL.9 \ sysctl.9 SYSCTL_ADD_OPAQUE.9 \ sysctl.9 SYSCTL_ADD_PROC.9 \ sysctl.9 SYSCTL_ADD_QUAD.9 \ @@ -1735,8 +1736,10 @@ MLINKS+=sysctl.9 SYSCTL_DECL.9 \ sysctl.9 SYSCTL_NODE_CHILDREN.9 \ sysctl.9 SYSCTL_PARENT.9 \ sysctl.9 SYSCTL_INT.9 \ + sysctl.9 SYSCTL_INT_WITH_LABEL.9 \ sysctl.9 SYSCTL_LONG.9 \ sysctl.9 SYSCTL_NODE.9 \ + sysctl.9 SYSCTL_NODE_WITH_LABEL.9 \ sysctl.9 SYSCTL_OPAQUE.9 \ sysctl.9 SYSCTL_PROC.9 \ sysctl.9 SYSCTL_QUAD.9 \ diff --git a/share/man/man9/sysctl.9 b/share/man/man9/sysctl.9 index 916ffa1f2fd..dbb61f59f2c 100644 --- a/share/man/man9/sysctl.9 +++ b/share/man/man9/sysctl.9 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 23, 2015 +.Dd December 13, 2016 .Dt SYSCTL 9 .Os .Sh NAME @@ -33,6 +33,7 @@ .Nm SYSCTL_ADD_INT , .Nm SYSCTL_ADD_LONG , .Nm SYSCTL_ADD_NODE , +.Nm SYSCTL_ADD_NODE_WITH_LABEL , .Nm SYSCTL_ADD_OPAQUE , .Nm SYSCTL_ADD_PROC , .Nm SYSCTL_ADD_QUAD , @@ -56,8 +57,10 @@ .Nm SYSCTL_NODE_CHILDREN , .Nm SYSCTL_PARENT , .Nm SYSCTL_INT , +.Nm SYSCTL_INT_WITH_LABEL , .Nm SYSCTL_LONG , .Nm SYSCTL_NODE , +.Nm SYSCTL_NODE_WITH_LABEL , .Nm SYSCTL_OPAQUE , .Nm SYSCTL_PROC , .Nm SYSCTL_QUAD , @@ -112,6 +115,17 @@ .Fa "const char *descr" .Fc .Ft struct sysctl_oid * +.Fo SYSCTL_ADD_NODE_WITH_LABEL +.Fa "struct sysctl_ctx_list *ctx" +.Fa "struct sysctl_oid_list *parent" +.Fa "int number" +.Fa "const char *name" +.Fa "int ctlflags" +.Fa "int (*handler)(SYSCTL_HANDLER_ARGS)" +.Fa "const char *descr" +.Fa "const char *label" +.Fc +.Ft struct sysctl_oid * .Fo SYSCTL_ADD_OPAQUE .Fa "struct sysctl_ctx_list *ctx" .Fa "struct sysctl_oid_list *parent" @@ -324,8 +338,10 @@ .Fa "struct sysctl_oid *oid" .Fc .Fn SYSCTL_INT parent number name ctlflags ptr val descr +.Fn SYSCTL_INT_WITH_LABEL parent number name ctlflags ptr val descr label .Fn SYSCTL_LONG parent number name ctlflags ptr val descr .Fn SYSCTL_NODE parent number name ctlflags handler descr +.Fn SYSCTL_NODE_WITH_LABEL parent number name ctlflags handler descr label .Fn SYSCTL_OPAQUE parent number name ctlflags ptr len format descr .Fn SYSCTL_PROC parent number name ctlflags arg1 arg2 handler format descr .Fn SYSCTL_QUAD parent number name ctlflags ptr val descr @@ -459,6 +475,18 @@ structures .El .It Fa descr A pointer to a textual description of the OID. +.It Fa label +A pointer to an aggregation label for this component of the OID. +To make it easier to export sysctl data to monitoring systems that +support aggregations through labels (e.g., Prometheus), +this argument can be used to attach a label name to an OID. +The label acts as a hint that this component's name should not be part +of the metric's name, +but attached to the metric as a label instead. +.Pp +Labels should only be applied to siblings that are structurally similar +and encode the same type of value, +as aggregation is of no use otherwise. .El .Sh CREATING ROOT NODES Sysctl MIBs or OIDs are created in a hierarchical tree. @@ -517,8 +545,10 @@ accessible, or needs to be processed before exporting. .Sh CREATING A STATIC SYSCTL Static sysctls are declared using one of the .Fn SYSCTL_INT , +.Fn SYSCTL_INT_WITH_LABEL , .Fn SYSCTL_LONG , .Fn SYSCTL_NODE , +.Fn SYSCTL_NODE_WITH_LABEL , .Fn SYSCTL_OPAQUE , .Fn SYSCTL_PROC , .Fn SYSCTL_QUAD , @@ -543,6 +573,7 @@ Dynamic nodes are created using one of the .Fn SYSCTL_ADD_INT , .Fn SYSCTL_ADD_LONG , .Fn SYSCTL_ADD_NODE , +.Fn SYSCTL_ADD_NODE_WITH_LABEL , .Fn SYSCTL_ADD_OPAQUE , .Fn SYSCTL_ADD_PROC , .Fn SYSCTL_ADD_QUAD , diff --git a/share/man/man9/sysctl_add_oid.9 b/share/man/man9/sysctl_add_oid.9 index e309f6529fd..d28aa799be8 100644 --- a/share/man/man9/sysctl_add_oid.9 +++ b/share/man/man9/sysctl_add_oid.9 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 6, 2015 +.Dd December 13, 2016 .Dt SYSCTL_ADD_OID 9 .Os .Sh NAME @@ -51,6 +51,7 @@ .Fa "int (*handler) (SYSCTL_HANDLER_ARGS)" .Fa "const char *format" .Fa "const char *descr" +.Fa "const char *label" .Fc .Ft int .Fo sysctl_move_oid diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 2f4085a1a58..6d9980d65c1 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -678,6 +678,9 @@ sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, int recurse) if (oidp->oid_descr) free(__DECONST(char *, oidp->oid_descr), M_SYSCTLOID); + if (oidp->oid_label) + free(__DECONST(char *, oidp->oid_label), + M_SYSCTLOID); free(__DECONST(char *, oidp->oid_name), M_SYSCTLOID); free(oidp, M_SYSCTLOID); } @@ -691,7 +694,8 @@ sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, int recurse) struct sysctl_oid * sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent, int number, const char *name, int kind, void *arg1, intmax_t arg2, - int (*handler)(SYSCTL_HANDLER_ARGS), const char *fmt, const char *descr) + int (*handler)(SYSCTL_HANDLER_ARGS), const char *fmt, const char *descr, + const char *label) { struct sysctl_oid *oidp; @@ -728,6 +732,8 @@ sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent, oidp->oid_fmt = fmt; if (descr != NULL) oidp->oid_descr = strdup(descr, M_SYSCTLOID); + if (label != NULL) + oidp->oid_label = strdup(label, M_SYSCTLOID); /* Update the context, if used */ if (clist != NULL) sysctl_ctx_entry_add(clist, oidp); @@ -1176,6 +1182,31 @@ sysctl_sysctl_oiddescr(SYSCTL_HANDLER_ARGS) static SYSCTL_NODE(_sysctl, 5, oiddescr, CTLFLAG_RD|CTLFLAG_MPSAFE|CTLFLAG_CAPRD, sysctl_sysctl_oiddescr, ""); +static int +sysctl_sysctl_oidlabel(SYSCTL_HANDLER_ARGS) +{ + struct sysctl_oid *oid; + struct rm_priotracker tracker; + int error; + + SYSCTL_RLOCK(&tracker); + error = sysctl_find_oid(arg1, arg2, &oid, NULL, req); + if (error) + goto out; + + if (oid->oid_label == NULL) { + error = ENOENT; + goto out; + } + error = SYSCTL_OUT(req, oid->oid_label, strlen(oid->oid_label) + 1); + out: + SYSCTL_RUNLOCK(&tracker); + return (error); +} + +static SYSCTL_NODE(_sysctl, 6, oidlabel, + CTLFLAG_RD | CTLFLAG_MPSAFE | CTLFLAG_CAPRD, sysctl_sysctl_oidlabel, ""); + /* * Default "handler" functions. */ diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index bc6c542f956..5f949f5a40c 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -188,6 +188,7 @@ struct sysctl_oid { int oid_refcnt; u_int oid_running; const char *oid_descr; + const char *oid_label; }; #define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l) @@ -252,7 +253,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); #endif /* This macro is only for internal use */ -#define SYSCTL_OID_RAW(id, parent_child_head, nbr, name, kind, a1, a2, handler, fmt, descr) \ +#define SYSCTL_OID_RAW(id, parent_child_head, nbr, name, kind, a1, a2, handler, fmt, descr, label) \ struct sysctl_oid id = { \ .oid_parent = (parent_child_head), \ .oid_children = SLIST_HEAD_INITIALIZER(&id.oid_children), \ @@ -263,46 +264,58 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); .oid_name = (name), \ .oid_handler = (handler), \ .oid_fmt = (fmt), \ - .oid_descr = __DESCR(descr) \ + .oid_descr = __DESCR(descr), \ + .oid_label = (label), \ }; \ DATA_SET(sysctl_set, id) /* This constructs a static "raw" MIB oid. */ #define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ - static SYSCTL_OID_RAW(sysctl__##parent##_##name, \ - SYSCTL_CHILDREN(&sysctl__##parent), \ - nbr, #name, kind, a1, a2, handler, fmt, descr) + SYSCTL_OID_WITH_LABEL(parent, nbr, name, kind, a1, a2, \ + handler, fmt, descr, NULL) + +#define SYSCTL_OID_WITH_LABEL(parent, nbr, name, kind, a1, a2, handler, fmt, descr, label) \ + static SYSCTL_OID_RAW(sysctl__##parent##_##name, \ + SYSCTL_CHILDREN(&sysctl__##parent), \ + nbr, #name, kind, a1, a2, handler, fmt, descr, label) /* This constructs a global "raw" MIB oid. */ -#define SYSCTL_OID_GLOBAL(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ +#define SYSCTL_OID_GLOBAL(parent, nbr, name, kind, a1, a2, handler, fmt, descr, label) \ SYSCTL_OID_RAW(sysctl__##parent##_##name, \ SYSCTL_CHILDREN(&sysctl__##parent), \ - nbr, #name, kind, a1, a2, handler, fmt, descr) + nbr, #name, kind, a1, a2, handler, fmt, descr, label) #define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, __DESCR(descr)) + sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, __DESCR(descr), NULL) /* This constructs a root node from which other nodes can hang. */ #define SYSCTL_ROOT_NODE(nbr, name, access, handler, descr) \ SYSCTL_OID_RAW(sysctl___##name, &sysctl__children, \ nbr, #name, CTLTYPE_NODE|(access), NULL, 0, \ - handler, "N", descr); \ + handler, "N", descr, NULL); \ CTASSERT(((access) & CTLTYPE) == 0 || \ ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE) /* This constructs a node from which other oids can hang. */ -#define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \ +#define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \ + SYSCTL_NODE_WITH_LABEL(parent, nbr, name, access, handler, descr, NULL) + +#define SYSCTL_NODE_WITH_LABEL(parent, nbr, name, access, handler, descr, label) \ SYSCTL_OID_GLOBAL(parent, nbr, name, CTLTYPE_NODE|(access), \ - NULL, 0, handler, "N", descr); \ + NULL, 0, handler, "N", descr, label); \ CTASSERT(((access) & CTLTYPE) == 0 || \ ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE) #define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \ + SYSCTL_ADD_NODE_WITH_LABEL(ctx, parent, nbr, name, access, \ + handler, descr, NULL) + +#define SYSCTL_ADD_NODE_WITH_LABEL(ctx, parent, nbr, name, access, handler, descr, label) \ ({ \ CTASSERT(((access) & CTLTYPE) == 0 || \ ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE); \ sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access), \ - NULL, 0, handler, "N", __DESCR(descr)); \ + NULL, 0, handler, "N", __DESCR(descr), label); \ }) #define SYSCTL_ADD_ROOT_NODE(ctx, nbr, name, access, handler, descr) \ @@ -311,7 +324,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE); \ sysctl_add_oid(ctx, &sysctl__children, nbr, name, \ CTLTYPE_NODE|(access), \ - NULL, 0, handler, "N", __DESCR(descr)); \ + NULL, 0, handler, "N", __DESCR(descr), NULL); \ }) /* Oid for a string. len can be 0 to indicate '\0' termination. */ @@ -327,7 +340,8 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); CTASSERT(((access) & CTLTYPE) == 0 || \ ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING); \ sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access), \ - __arg, len, sysctl_handle_string, "A", __DESCR(descr)); \ + __arg, len, sysctl_handle_string, "A", __DESCR(descr), \ + NULL); \ }) /* Oid for a bool. If ptr is NULL, val is returned. */ @@ -345,7 +359,8 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); CTASSERT(((access) & CTLTYPE) == 0); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_U8 | CTLFLAG_MPSAFE | (access), \ - __ptr, val, sysctl_handle_bool, "CU", __DESCR(descr)); \ + __ptr, val, sysctl_handle_bool, "CU", __DESCR(descr), \ + NULL); \ }) /* Oid for a signed 8-bit int. If ptr is NULL, val is returned. */ @@ -365,7 +380,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S8); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_S8 | CTLFLAG_MPSAFE | (access), \ - __ptr, val, sysctl_handle_8, "C", __DESCR(descr)); \ + __ptr, val, sysctl_handle_8, "C", __DESCR(descr), NULL); \ }) /* Oid for an unsigned 8-bit int. If ptr is NULL, val is returned. */ @@ -385,7 +400,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U8); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_U8 | CTLFLAG_MPSAFE | (access), \ - __ptr, val, sysctl_handle_8, "CU", __DESCR(descr)); \ + __ptr, val, sysctl_handle_8, "CU", __DESCR(descr), NULL); \ }) /* Oid for a signed 16-bit int. If ptr is NULL, val is returned. */ @@ -405,7 +420,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S16); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_S16 | CTLFLAG_MPSAFE | (access), \ - __ptr, val, sysctl_handle_16, "S", __DESCR(descr)); \ + __ptr, val, sysctl_handle_16, "S", __DESCR(descr), NULL); \ }) /* Oid for an unsigned 16-bit int. If ptr is NULL, val is returned. */ @@ -425,7 +440,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U16); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_U16 | CTLFLAG_MPSAFE | (access), \ - __ptr, val, sysctl_handle_16, "SU", __DESCR(descr)); \ + __ptr, val, sysctl_handle_16, "SU", __DESCR(descr), NULL); \ }) /* Oid for a signed 32-bit int. If ptr is NULL, val is returned. */ @@ -445,7 +460,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S32); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_S32 | CTLFLAG_MPSAFE | (access), \ - __ptr, val, sysctl_handle_32, "I", __DESCR(descr)); \ + __ptr, val, sysctl_handle_32, "I", __DESCR(descr), NULL); \ }) /* Oid for an unsigned 32-bit int. If ptr is NULL, val is returned. */ @@ -465,7 +480,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U32); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_U32 | CTLFLAG_MPSAFE | (access), \ - __ptr, val, sysctl_handle_32, "IU", __DESCR(descr)); \ + __ptr, val, sysctl_handle_32, "IU", __DESCR(descr), NULL); \ }) /* Oid for a signed 64-bit int. If ptr is NULL, val is returned. */ @@ -485,7 +500,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_S64 | CTLFLAG_MPSAFE | (access), \ - __ptr, val, sysctl_handle_64, "Q", __DESCR(descr)); \ + __ptr, val, sysctl_handle_64, "Q", __DESCR(descr), NULL); \ }) /* Oid for an unsigned 64-bit int. If ptr is NULL, val is returned. */ @@ -505,16 +520,19 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ - __ptr, val, sysctl_handle_64, "QU", __DESCR(descr)); \ + __ptr, val, sysctl_handle_64, "QU", __DESCR(descr), NULL); \ }) /* Oid for an int. If ptr is SYSCTL_NULL_INT_PTR, val is returned. */ #define SYSCTL_NULL_INT_PTR ((int *)NULL) -#define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, \ - CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ - ptr, val, sysctl_handle_int, "I", descr); \ - CTASSERT((((access) & CTLTYPE) == 0 || \ +#define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \ + SYSCTL_INT_WITH_LABEL(parent, nbr, name, access, ptr, val, descr, NULL) + +#define SYSCTL_INT_WITH_LABEL(parent, nbr, name, access, ptr, val, descr, label) \ + SYSCTL_OID_WITH_LABEL(parent, nbr, name, \ + CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ + ptr, val, sysctl_handle_int, "I", descr, label); \ + CTASSERT((((access) & CTLTYPE) == 0 || \ ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT) && \ sizeof(int) == sizeof(*(ptr))) @@ -525,7 +543,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ - __ptr, val, sysctl_handle_int, "I", __DESCR(descr)); \ + __ptr, val, sysctl_handle_int, "I", __DESCR(descr), NULL); \ }) /* Oid for an unsigned int. If ptr is NULL, val is returned. */ @@ -545,7 +563,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_UINT); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_UINT | CTLFLAG_MPSAFE | (access), \ - __ptr, val, sysctl_handle_int, "IU", __DESCR(descr)); \ + __ptr, val, sysctl_handle_int, "IU", __DESCR(descr), NULL); \ }) /* Oid for a long. The pointer must be non NULL. */ @@ -565,7 +583,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_LONG); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_LONG | CTLFLAG_MPSAFE | (access), \ - __ptr, 0, sysctl_handle_long, "L", __DESCR(descr)); \ + __ptr, 0, sysctl_handle_long, "L", __DESCR(descr), NULL); \ }) /* Oid for an unsigned long. The pointer must be non NULL. */ @@ -585,7 +603,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_ULONG); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_ULONG | CTLFLAG_MPSAFE | (access), \ - __ptr, 0, sysctl_handle_long, "LU", __DESCR(descr)); \ + __ptr, 0, sysctl_handle_long, "LU", __DESCR(descr), NULL); \ }) /* Oid for a quad. The pointer must be non NULL. */ @@ -605,7 +623,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_S64 | CTLFLAG_MPSAFE | (access), \ - __ptr, 0, sysctl_handle_64, "Q", __DESCR(descr)); \ + __ptr, 0, sysctl_handle_64, "Q", __DESCR(descr), NULL); \ }) #define SYSCTL_NULL_UQUAD_PTR ((uint64_t *)NULL) @@ -624,7 +642,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ - __ptr, 0, sysctl_handle_64, "QU", __DESCR(descr)); \ + __ptr, 0, sysctl_handle_64, "QU", __DESCR(descr), NULL); \ }) /* Oid for a CPU dependent variable */ @@ -638,12 +656,12 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); __ret = sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ (ptr), 0, sysctl_handle_64, "QU", \ - __DESCR(descr)); \ + __DESCR(descr), NULL); \ } else { \ __ret = sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_UINT | CTLFLAG_MPSAFE | (access), \ (ptr), 0, sysctl_handle_int, "IU", \ - __DESCR(descr)); \ + __DESCR(descr), NULL); \ } \ __ret; \ }) @@ -665,7 +683,8 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ - __ptr, 0, sysctl_handle_counter_u64, "QU", __DESCR(descr)); \ + __ptr, 0, sysctl_handle_counter_u64, "QU", __DESCR(descr), \ + NULL); \ }) /* Oid for an array of counter(9)s. The pointer and length must be non zero. */ @@ -687,7 +706,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | (access), \ __ptr, len, sysctl_handle_counter_u64_array, "S", \ - __DESCR(descr)); \ + __DESCR(descr), NULL); \ }) /* Oid for an opaque object. Specified by a pointer and a length. */ @@ -702,7 +721,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); CTASSERT(((access) & CTLTYPE) == 0 || \ ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \ sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \ - ptr, len, sysctl_handle_opaque, fmt, __DESCR(descr)); \ + ptr, len, sysctl_handle_opaque, fmt, __DESCR(descr), NULL); \ }) /* Oid for a struct. Specified by a pointer and a type. */ @@ -719,7 +738,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \ sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \ (ptr), sizeof(struct type), \ - sysctl_handle_opaque, "S," #type, __DESCR(descr)); \ + sysctl_handle_opaque, "S," #type, __DESCR(descr), NULL); \ }) /* Oid for a procedure. Specified by a pointer and an arg. */ @@ -732,7 +751,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ({ \ CTASSERT(((access) & CTLTYPE) != 0); \ sysctl_add_oid(ctx, parent, nbr, name, (access), \ - (ptr), (arg), (handler), (fmt), __DESCR(descr)); \ + (ptr), (arg), (handler), (fmt), __DESCR(descr), NULL); \ }) /* Oid to handle limits on uma(9) zone specified by pointer. */ @@ -750,7 +769,8 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ - __ptr, 0, sysctl_handle_uma_zone_max, "I", __DESCR(descr)); \ + __ptr, 0, sysctl_handle_uma_zone_max, "I", __DESCR(descr), \ + NULL); \ }) /* Oid to obtain current use of uma(9) zone specified by pointer. */ @@ -768,7 +788,8 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \ sysctl_add_oid(ctx, parent, nbr, name, \ CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ - __ptr, 0, sysctl_handle_uma_zone_cur, "I", __DESCR(descr)); \ + __ptr, 0, sysctl_handle_uma_zone_cur, "I", __DESCR(descr), \ + NULL); \ }) /* @@ -993,7 +1014,7 @@ extern char kern_ident[]; struct sysctl_oid *sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent, int nbr, const char *name, int kind, void *arg1, intmax_t arg2, int (*handler)(SYSCTL_HANDLER_ARGS), - const char *fmt, const char *descr); + const char *fmt, const char *descr, const char *label); int sysctl_remove_name(struct sysctl_oid *parent, const char *name, int del, int recurse); void sysctl_rename_oid(struct sysctl_oid *oidp, const char *name); From 4c484fd216d5aa5d1ef40578d6373229dc6abf9c Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Wed, 14 Dec 2016 12:53:33 +0000 Subject: [PATCH 167/226] Add label annotations to CAM sysctls. Under kern.cam we have certain sysctls that are per-device, such as the ones under kern.cam.ada.[0-9]+.*. Add a "device_index" label annotation to such sysctls, so that the Prometheus metrics exporter will give all of those metrics the same name. The device number will be added to the metric name as the "device_index" label. Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D8775 --- sys/cam/ata/ata_da.c | 4 ++-- sys/cam/ata/ata_pmp.c | 4 ++-- sys/cam/nvme/nvme_da.c | 4 ++-- sys/cam/scsi/scsi_cd.c | 4 ++-- sys/cam/scsi/scsi_da.c | 4 ++-- sys/cam/scsi/scsi_sa.c | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index 808dc72afcb..45a27e281cf 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -1394,9 +1394,9 @@ adasysctlinit(void *context, int pending) sysctl_ctx_init(&softc->sysctl_ctx); softc->flags |= ADA_FLAG_SCTX_INIT; - softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx, + softc->sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&softc->sysctl_ctx, SYSCTL_STATIC_CHILDREN(_kern_cam_ada), OID_AUTO, tmpstr2, - CTLFLAG_RD, 0, tmpstr); + CTLFLAG_RD, 0, tmpstr, "device_index"); if (softc->sysctl_tree == NULL) { printf("adasysctlinit: unable to allocate sysctl tree\n"); cam_periph_release(periph); diff --git a/sys/cam/ata/ata_pmp.c b/sys/cam/ata/ata_pmp.c index aa37de2270f..1b28fdd0338 100644 --- a/sys/cam/ata/ata_pmp.c +++ b/sys/cam/ata/ata_pmp.c @@ -350,9 +350,9 @@ pmpsysctlinit(void *context, int pending) sysctl_ctx_init(&softc->sysctl_ctx); softc->flags |= PMP_FLAG_SCTX_INIT; - softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx, + softc->sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&softc->sysctl_ctx, SYSCTL_STATIC_CHILDREN(_kern_cam_pmp), OID_AUTO, tmpstr2, - CTLFLAG_RD, 0, tmpstr); + CTLFLAG_RD, 0, tmpstr, "device_index"); if (softc->sysctl_tree == NULL) { printf("pmpsysctlinit: unable to allocate sysctl tree\n"); cam_periph_release(periph); diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c index 9628530edb2..5e316c36529 100644 --- a/sys/cam/nvme/nvme_da.c +++ b/sys/cam/nvme/nvme_da.c @@ -608,9 +608,9 @@ ndasysctlinit(void *context, int pending) sysctl_ctx_init(&softc->sysctl_ctx); softc->flags |= NDA_FLAG_SCTX_INIT; - softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx, + softc->sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&softc->sysctl_ctx, SYSCTL_STATIC_CHILDREN(_kern_cam_nda), OID_AUTO, tmpstr2, - CTLFLAG_RD, 0, tmpstr); + CTLFLAG_RD, 0, tmpstr, "device_index"); if (softc->sysctl_tree == NULL) { printf("ndasysctlinit: unable to allocate sysctl tree\n"); cam_periph_release(periph); diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index 42dd491f86d..4a9f44cd728 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -481,9 +481,9 @@ cdsysctlinit(void *context, int pending) sysctl_ctx_init(&softc->sysctl_ctx); softc->flags |= CD_FLAG_SCTX_INIT; - softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx, + softc->sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&softc->sysctl_ctx, SYSCTL_STATIC_CHILDREN(_kern_cam_cd), OID_AUTO, - tmpstr2, CTLFLAG_RD, 0, tmpstr); + tmpstr2, CTLFLAG_RD, 0, tmpstr, "device_index"); if (softc->sysctl_tree == NULL) { printf("cdsysctlinit: unable to allocate sysctl tree\n"); diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index ffceb23a7c6..cad8f01a11c 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -1924,9 +1924,9 @@ dasysctlinit(void *context, int pending) sysctl_ctx_init(&softc->sysctl_ctx); softc->flags |= DA_FLAG_SCTX_INIT; - softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx, + softc->sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&softc->sysctl_ctx, SYSCTL_STATIC_CHILDREN(_kern_cam_da), OID_AUTO, tmpstr2, - CTLFLAG_RD, 0, tmpstr); + CTLFLAG_RD, 0, tmpstr, "device_index"); if (softc->sysctl_tree == NULL) { printf("dasysctlinit: unable to allocate sysctl tree\n"); cam_periph_release(periph); diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c index 3166b8a44c5..2ed06abb820 100644 --- a/sys/cam/scsi/scsi_sa.c +++ b/sys/cam/scsi/scsi_sa.c @@ -2308,9 +2308,9 @@ sasysctlinit(void *context, int pending) sysctl_ctx_init(&softc->sysctl_ctx); softc->flags |= SA_FLAG_SCTX_INIT; - softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx, + softc->sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&softc->sysctl_ctx, SYSCTL_STATIC_CHILDREN(_kern_cam_sa), OID_AUTO, tmpstr2, - CTLFLAG_RD, 0, tmpstr); + CTLFLAG_RD, 0, tmpstr, "device_index"); if (softc->sysctl_tree == NULL) goto bailout; From fd0f59709dbe4b065ac021c7516260741df2a6e9 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Wed, 14 Dec 2016 12:56:58 +0000 Subject: [PATCH 168/226] Add labels to sysctls related to clocks. Sysctls like kern.eventtimer.et.*.quality currently embed the name of the clock device. This is problematic for the Prometheus metrics exporter for two reasons: - Some of those clocks have dashes in their names, which Prometheus doesn't allow to be used in metric names. - It doesn't allow for extracting the same property of all clocks on the system from within a single query. Attach these nodes to have a label, so that the Prometheus metrics exporter gives these metric a uniform name with the name of the clock attached as a label. Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D8775 --- sys/kern/kern_et.c | 4 ++-- sys/kern/kern_tc.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_et.c b/sys/kern/kern_et.c index 979e0c5cf24..3d25d697ccc 100644 --- a/sys/kern/kern_et.c +++ b/sys/kern/kern_et.c @@ -66,9 +66,9 @@ et_register(struct eventtimer *et) } } KASSERT(et->et_start, ("et_register: timer has no start function")); - et->et_sysctl = SYSCTL_ADD_NODE(NULL, + et->et_sysctl = SYSCTL_ADD_NODE_WITH_LABEL(NULL, SYSCTL_STATIC_CHILDREN(_kern_eventtimer_et), OID_AUTO, et->et_name, - CTLFLAG_RW, 0, "event timer description"); + CTLFLAG_RW, 0, "event timer description", "eventtimer"); SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(et->et_sysctl), OID_AUTO, "flags", CTLFLAG_RD, &(et->et_flags), 0, "Event timer capabilities"); diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index b69bff526f9..e81e33f5f27 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -1218,9 +1218,9 @@ tc_init(struct timecounter *tc) /* * Set up sysctl tree for this counter. */ - tc_root = SYSCTL_ADD_NODE(NULL, + tc_root = SYSCTL_ADD_NODE_WITH_LABEL(NULL, SYSCTL_STATIC_CHILDREN(_kern_timecounter_tc), OID_AUTO, tc->tc_name, - CTLFLAG_RW, 0, "timecounter description"); + CTLFLAG_RW, 0, "timecounter description", "timecounter"); SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(tc_root), OID_AUTO, "mask", CTLFLAG_RD, &(tc->tc_counter_mask), 0, "mask for implemented bits"); From 3fd335bcc7d546414f6871fe9d864ac8551b9716 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Wed, 14 Dec 2016 13:00:27 +0000 Subject: [PATCH 169/226] Attach a "thermal_zone" label to the ACPI thermal zone sysctls. In order to make Prometheus do graphing/alerting on thermal sensors in a generic fashion, we should attach the name of the thermal zone device as a label. That way there is only a single metric for the temperature of a thermal zone, with its name attached as a label. Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D8775 --- sys/dev/acpica/acpi_thermal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/acpica/acpi_thermal.c b/sys/dev/acpica/acpi_thermal.c index fa1c2e81cc2..b2b2a13aa88 100644 --- a/sys/dev/acpica/acpi_thermal.c +++ b/sys/dev/acpica/acpi_thermal.c @@ -258,9 +258,9 @@ acpi_tz_attach(device_t dev) } sysctl_ctx_init(&sc->tz_sysctl_ctx); sprintf(oidname, "tz%d", device_get_unit(dev)); - sc->tz_sysctl_tree = SYSCTL_ADD_NODE(&sc->tz_sysctl_ctx, - SYSCTL_CHILDREN(acpi_tz_sysctl_tree), - OID_AUTO, oidname, CTLFLAG_RD, 0, ""); + sc->tz_sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&sc->tz_sysctl_ctx, + SYSCTL_CHILDREN(acpi_tz_sysctl_tree), + OID_AUTO, oidname, CTLFLAG_RD, 0, "", "thermal_zone"); SYSCTL_ADD_PROC(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree), OID_AUTO, "temperature", CTLTYPE_INT | CTLFLAG_RD, &sc->tz_temperature, 0, sysctl_handle_int, From ae1571536003b29f527ab7aedc0c61d783ecbd65 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Wed, 14 Dec 2016 13:03:01 +0000 Subject: [PATCH 170/226] Add a "device_index" label to all sysctls under dev.$driver.$index. This way it becomes possible to graph a property for all instances of a single driver. For example, graphing the number of packets across all USB controllers, the amount of dropped packets on all NICs, etc. Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D8775 --- sys/kern/subr_bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 91dc30b9109..cf3cd47fe9c 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -288,10 +288,10 @@ device_sysctl_init(device_t dev) return; devclass_sysctl_init(dc); sysctl_ctx_init(&dev->sysctl_ctx); - dev->sysctl_tree = SYSCTL_ADD_NODE(&dev->sysctl_ctx, + dev->sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&dev->sysctl_ctx, SYSCTL_CHILDREN(dc->sysctl_tree), OID_AUTO, dev->nameunit + strlen(dc->name), - CTLFLAG_RD, NULL, ""); + CTLFLAG_RD, NULL, "", "device_index"); SYSCTL_ADD_PROC(&dev->sysctl_ctx, SYSCTL_CHILDREN(dev->sysctl_tree), OID_AUTO, "%desc", CTLTYPE_STRING | CTLFLAG_RD, dev, DEVICE_SYSCTL_DESC, device_sysctl_handler, "A", From 977ffc4c2aefdeb70cee048cfae190f508d63997 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Wed, 14 Dec 2016 13:05:04 +0000 Subject: [PATCH 171/226] Let all FEATURE()s use the same Prometheus metric. Without this change, every individual FEATURE() declaration would have an individual metric in Prometheus. Though this wouldn't be harmful, it would look very cluttered. By letting it use a single metric with the name of the feature attached as a label, it also becomes easier to search, as you can apply regex matching, etc. Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D8775 --- sys/sys/sysctl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 5f949f5a40c..799e69ed6a7 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -796,9 +796,9 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); * A macro to generate a read-only sysctl to indicate the presence of optional * kernel features. */ -#define FEATURE(name, desc) \ - SYSCTL_INT(_kern_features, OID_AUTO, name, CTLFLAG_RD | CTLFLAG_CAPRD, \ - SYSCTL_NULL_INT_PTR, 1, desc) +#define FEATURE(name, desc, label) \ + SYSCTL_INT_WITH_LABEL(_kern_features, OID_AUTO, name, \ + CTLFLAG_RD | CTLFLAG_CAPRD, SYSCTL_NULL_INT_PTR, 1, desc, "feature") #endif /* _KERNEL */ From 13a83707bc4c69a793a6fbcf8de570d135612617 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Wed, 14 Dec 2016 13:35:33 +0000 Subject: [PATCH 172/226] Revert accidental change made in r310056. Because I had to cherry-pick some of my changes in r310051, I accidentally made a typo when manually applying the rest in r310056. --- sys/sys/sysctl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 799e69ed6a7..ae323aae1ae 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -796,7 +796,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); * A macro to generate a read-only sysctl to indicate the presence of optional * kernel features. */ -#define FEATURE(name, desc, label) \ +#define FEATURE(name, desc) \ SYSCTL_INT_WITH_LABEL(_kern_features, OID_AUTO, name, \ CTLFLAG_RD | CTLFLAG_CAPRD, SYSCTL_NULL_INT_PTR, 1, desc, "feature") From d3e8d4784dce2a3247c33120b9ae80fb932ac355 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Wed, 14 Dec 2016 14:13:44 +0000 Subject: [PATCH 173/226] Fix initialisation of mlx4_pci_table's .driver_data fields. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D8791 Sponsored by: Mellanox Technologies Submitted by: Dexuan Cui --- sys/dev/mlx4/mlx4_core/mlx4_main.c | 68 ++++++++++++++++++------------ 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/sys/dev/mlx4/mlx4_core/mlx4_main.c b/sys/dev/mlx4/mlx4_core/mlx4_main.c index 797da7f511c..0754ab3d0e4 100644 --- a/sys/dev/mlx4/mlx4_core/mlx4_main.c +++ b/sys/dev/mlx4/mlx4_core/mlx4_main.c @@ -3635,47 +3635,61 @@ int mlx4_restart_one(struct pci_dev *pdev) static DEFINE_PCI_DEVICE_TABLE(mlx4_pci_table) = { /* MT25408 "Hermon" SDR */ - { PCI_VDEVICE(MELLANOX, 0x6340), MLX4_PCI_DEV_FORCE_SENSE_PORT }, + { PCI_VDEVICE(MELLANOX, 0x6340), + .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT }, /* MT25408 "Hermon" DDR */ - { PCI_VDEVICE(MELLANOX, 0x634a), MLX4_PCI_DEV_FORCE_SENSE_PORT }, + { PCI_VDEVICE(MELLANOX, 0x634a), + .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT }, /* MT25408 "Hermon" QDR */ - { PCI_VDEVICE(MELLANOX, 0x6354), MLX4_PCI_DEV_FORCE_SENSE_PORT }, + { PCI_VDEVICE(MELLANOX, 0x6354), + .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT }, /* MT25408 "Hermon" DDR PCIe gen2 */ - { PCI_VDEVICE(MELLANOX, 0x6732), MLX4_PCI_DEV_FORCE_SENSE_PORT }, + { PCI_VDEVICE(MELLANOX, 0x6732), + .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT }, /* MT25408 "Hermon" QDR PCIe gen2 */ - { PCI_VDEVICE(MELLANOX, 0x673c), MLX4_PCI_DEV_FORCE_SENSE_PORT }, + { PCI_VDEVICE(MELLANOX, 0x673c), + .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT }, /* MT25408 "Hermon" EN 10GigE */ - { PCI_VDEVICE(MELLANOX, 0x6368), MLX4_PCI_DEV_FORCE_SENSE_PORT }, + { PCI_VDEVICE(MELLANOX, 0x6368), + .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT }, /* MT25408 "Hermon" EN 10GigE PCIe gen2 */ - { PCI_VDEVICE(MELLANOX, 0x6750), MLX4_PCI_DEV_FORCE_SENSE_PORT }, + { PCI_VDEVICE(MELLANOX, 0x6750), + .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT }, /* MT25458 ConnectX EN 10GBASE-T 10GigE */ - { PCI_VDEVICE(MELLANOX, 0x6372), MLX4_PCI_DEV_FORCE_SENSE_PORT }, + { PCI_VDEVICE(MELLANOX, 0x6372), + .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT }, /* MT25458 ConnectX EN 10GBASE-T+Gen2 10GigE */ - { PCI_VDEVICE(MELLANOX, 0x675a), MLX4_PCI_DEV_FORCE_SENSE_PORT }, + { PCI_VDEVICE(MELLANOX, 0x675a), + .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT }, /* MT26468 ConnectX EN 10GigE PCIe gen2*/ - { PCI_VDEVICE(MELLANOX, 0x6764), MLX4_PCI_DEV_FORCE_SENSE_PORT }, + { PCI_VDEVICE(MELLANOX, 0x6764), + .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT }, /* MT26438 ConnectX EN 40GigE PCIe gen2 5GT/s */ - { PCI_VDEVICE(MELLANOX, 0x6746), MLX4_PCI_DEV_FORCE_SENSE_PORT }, + { PCI_VDEVICE(MELLANOX, 0x6746), + .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT }, /* MT26478 ConnectX2 40GigE PCIe gen2 */ - { PCI_VDEVICE(MELLANOX, 0x676e), MLX4_PCI_DEV_FORCE_SENSE_PORT }, + { PCI_VDEVICE(MELLANOX, 0x676e), + .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT }, /* MT25400 Family [ConnectX-2 Virtual Function] */ - { PCI_VDEVICE(MELLANOX, 0x1002), MLX4_PCI_DEV_IS_VF }, + { PCI_VDEVICE(MELLANOX, 0x1002), + .driver_data = MLX4_PCI_DEV_IS_VF }, /* MT27500 Family [ConnectX-3] */ - { PCI_VDEVICE(MELLANOX, 0x1003), 0 }, + { PCI_VDEVICE(MELLANOX, 0x1003) }, /* MT27500 Family [ConnectX-3 Virtual Function] */ - { PCI_VDEVICE(MELLANOX, 0x1004), MLX4_PCI_DEV_IS_VF }, - { PCI_VDEVICE(MELLANOX, 0x1005), 0 }, /* MT27510 Family */ - { PCI_VDEVICE(MELLANOX, 0x1006), 0 }, /* MT27511 Family */ - { PCI_VDEVICE(MELLANOX, 0x1007), 0 }, /* MT27520 Family */ - { PCI_VDEVICE(MELLANOX, 0x1008), 0 }, /* MT27521 Family */ - { PCI_VDEVICE(MELLANOX, 0x1009), 0 }, /* MT27530 Family */ - { PCI_VDEVICE(MELLANOX, 0x100a), 0 }, /* MT27531 Family */ - { PCI_VDEVICE(MELLANOX, 0x100b), 0 }, /* MT27540 Family */ - { PCI_VDEVICE(MELLANOX, 0x100c), 0 }, /* MT27541 Family */ - { PCI_VDEVICE(MELLANOX, 0x100d), 0 }, /* MT27550 Family */ - { PCI_VDEVICE(MELLANOX, 0x100e), 0 }, /* MT27551 Family */ - { PCI_VDEVICE(MELLANOX, 0x100f), 0 }, /* MT27560 Family */ - { PCI_VDEVICE(MELLANOX, 0x1010), 0 }, /* MT27561 Family */ + { PCI_VDEVICE(MELLANOX, 0x1004), + .driver_data = MLX4_PCI_DEV_IS_VF }, + { PCI_VDEVICE(MELLANOX, 0x1005) }, /* MT27510 Family */ + { PCI_VDEVICE(MELLANOX, 0x1006) }, /* MT27511 Family */ + { PCI_VDEVICE(MELLANOX, 0x1007) }, /* MT27520 Family */ + { PCI_VDEVICE(MELLANOX, 0x1008) }, /* MT27521 Family */ + { PCI_VDEVICE(MELLANOX, 0x1009) }, /* MT27530 Family */ + { PCI_VDEVICE(MELLANOX, 0x100a) }, /* MT27531 Family */ + { PCI_VDEVICE(MELLANOX, 0x100b) }, /* MT27540 Family */ + { PCI_VDEVICE(MELLANOX, 0x100c) }, /* MT27541 Family */ + { PCI_VDEVICE(MELLANOX, 0x100d) }, /* MT27550 Family */ + { PCI_VDEVICE(MELLANOX, 0x100e) }, /* MT27551 Family */ + { PCI_VDEVICE(MELLANOX, 0x100f) }, /* MT27560 Family */ + { PCI_VDEVICE(MELLANOX, 0x1010) }, /* MT27561 Family */ { 0, } }; From 2b0f0faeb6f2d5cafe8b378b50dc16833486a904 Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Wed, 14 Dec 2016 15:00:24 +0000 Subject: [PATCH 174/226] Add new compatible string "allwinner,sun7i-a20-mmc". New upstream DTS is using this now for A20 SoC. MFC after: 3 days --- sys/arm/allwinner/a10_mmc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/arm/allwinner/a10_mmc.c b/sys/arm/allwinner/a10_mmc.c index 3c94bba9f12..cfbd74b798b 100644 --- a/sys/arm/allwinner/a10_mmc.c +++ b/sys/arm/allwinner/a10_mmc.c @@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$"); static struct ofw_compat_data compat_data[] = { {"allwinner,sun4i-a10-mmc", 1}, {"allwinner,sun5i-a13-mmc", 1}, + {"allwinner,sun7i-a20-mmc", 1}, {NULL, 0} }; From 3d026d871fd2fad2ce5b980750fd47757e548a4a Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Wed, 14 Dec 2016 17:28:55 +0000 Subject: [PATCH 175/226] Tidy up. Mostly, remove or replace stale comments. Most of the comments in this file actually described the operation of the swap pager, not the default pager. Given that this is the wrong place to discuss the implementation of the swap pager, it shouldn't come as a surprise that as the swap pager evolved these comments became increasingly stale. In addition, apply some style fixes, like modernizing a few remaining old- style function definitions. Reviewed by: kib, markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D8781 --- sys/vm/default_pager.c | 80 ++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 50 deletions(-) diff --git a/sys/vm/default_pager.c b/sys/vm/default_pager.c index f334cd72d80..7fc4f6c49e0 100644 --- a/sys/vm/default_pager.c +++ b/sys/vm/default_pager.c @@ -27,14 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * The default pager is responsible for supplying backing store to unbacked - * storage. The backing store is usually swap so we just fall through to - * the swap routines. However, since swap metadata has not been assigned, - * the swap routines assign and manage the swap backing store through the - * vm_page->swapblk field. The object is only converted when the page is - * physically freed after having been cleaned and even then vm_page->swapblk - * is maintained whenever a resident page also has swap backing store. */ #include @@ -53,14 +45,16 @@ __FBSDID("$FreeBSD$"); #include #include -static vm_object_t default_pager_alloc(void *, vm_ooffset_t, vm_prot_t, - vm_ooffset_t, struct ucred *); -static void default_pager_dealloc(vm_object_t); -static int default_pager_getpages(vm_object_t, vm_page_t *, int, int *, int *); -static void default_pager_putpages(vm_object_t, vm_page_t *, int, - boolean_t, int *); -static boolean_t default_pager_haspage(vm_object_t, vm_pindex_t, int *, - int *); +static vm_object_t default_pager_alloc(void *, vm_ooffset_t, vm_prot_t, + vm_ooffset_t, struct ucred *); +static void default_pager_dealloc(vm_object_t); +static int default_pager_getpages(vm_object_t, vm_page_t *, int, + int *, int *); +static void default_pager_putpages(vm_object_t, vm_page_t *, int, + boolean_t, int *); +static boolean_t default_pager_haspage(vm_object_t, vm_pindex_t, int *, + int *); + /* * pagerops for OBJT_DEFAULT - "default pager". */ @@ -73,7 +67,7 @@ struct pagerops defaultpagerops = { }; /* - * no_pager_alloc just returns an initialized object. + * Return an initialized object. */ static vm_object_t default_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, @@ -100,68 +94,54 @@ default_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, } /* - * deallocate resources associated with default objects. The default objects - * have no special resources allocated to them, but the vm_page's being used - * in this object might. Still, we do not have to do anything - we will free - * the swapblk in the underlying vm_page's when we free the vm_page or - * garbage collect the vm_page cache list. + * Deallocate resources associated with the object. */ static void -default_pager_dealloc(object) - vm_object_t object; +default_pager_dealloc(vm_object_t object) { - /* - * OBJT_DEFAULT objects have no special resources allocated to them. - */ + + /* Reserved swap is released by vm_object_destroy(). */ object->type = OBJT_DEAD; } /* - * Load pages from backing store. Since OBJT_DEFAULT is converted to - * OBJT_SWAP at the time a swap-backed vm_page_t is freed, we will never - * see a vm_page with assigned swap here. + * Load pages from backing store. */ static int default_pager_getpages(vm_object_t object, vm_page_t *m, int count, int *rbehind, int *rahead) { + /* + * Since an OBJT_DEFAULT object is converted to OBJT_SWAP by the first + * call to the putpages method, this function will never be called on + * a vm_page with assigned swap. + */ return (VM_PAGER_FAIL); } /* - * Store pages to backing store. We should assign swap and initiate - * I/O. We do not actually convert the object to OBJT_SWAP here. The - * object will be converted when the written-out vm_page_t is moved from the - * cache to the free list. + * Store pages to backing store. */ static void default_pager_putpages(vm_object_t object, vm_page_t *m, int count, int flags, int *rtvals) { + /* The swap pager will convert the object to OBJT_SWAP. */ swappagerops.pgo_putpages(object, m, count, flags, rtvals); } /* - * Tell us whether the backing store for the requested (object,index) is - * synchronized. i.e. tell us whether we can throw the page away and - * reload it later. So, for example, if we are in the process of writing - * the page to its backing store, or if no backing store has been assigned, - * it is not yet synchronized. - * - * It is possible to have fully-synchronized swap assigned without the - * object having been converted. We just call swap_pager_haspage() to - * deal with it since it must already deal with it plus deal with swap - * meta-data structures. + * Tell us whether the requested (object,index) is available from the object's + * backing store. */ static boolean_t -default_pager_haspage(object, pindex, before, after) - vm_object_t object; - vm_pindex_t pindex; - int *before; - int *after; +default_pager_haspage(vm_object_t object, vm_pindex_t pindex, int *before, + int *after) { - return FALSE; + + /* An OBJT_DEFAULT object has no backing store. */ + return (FALSE); } From f85ea63d69bfc774dd52b26291029e1fb182c53a Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Wed, 14 Dec 2016 19:00:08 +0000 Subject: [PATCH 176/226] Don't run the MCA record refill task during boot. The MCA taskqueue is not initialized until some time after CMCIs are enabled on the BSP. Reviewed by: cem, jhb MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8783 --- sys/x86/x86/mca.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/x86/x86/mca.c b/sys/x86/x86/mca.c index d005180415b..1d99efc74ed 100644 --- a/sys/x86/x86/mca.c +++ b/sys/x86/x86/mca.c @@ -508,7 +508,7 @@ mca_record_entry(enum scan_mode mode, const struct mca_record *record) STAILQ_INSERT_TAIL(&mca_records, rec, link); mca_count++; mtx_unlock_spin(&mca_lock); - if (mode == CMCI) + if (mode == CMCI && !cold) taskqueue_enqueue(mca_tq, &mca_refill_task); } @@ -714,6 +714,9 @@ mca_createtq(void *dummy) mca_tq = taskqueue_create_fast("mca", M_WAITOK, taskqueue_thread_enqueue, &mca_tq); taskqueue_start_threads(&mca_tq, 1, PI_SWI(SWI_TQ), "mca taskq"); + + /* CMCIs during boot may have claimed items from the freelist. */ + mca_fill_freelist(); } SYSINIT(mca_createtq, SI_SUB_CONFIGURE, SI_ORDER_ANY, mca_createtq, NULL); From 90556839e944ac790db07bc9b041d742ba762801 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Wed, 14 Dec 2016 19:01:43 +0000 Subject: [PATCH 177/226] Skip a ustack test that triggers an assertion on INVARIANTS kernels. Reported by: ngie Sponsored by: Dell EMC Isilon X-MFC-With: r309698 --- cddl/usr.sbin/dtrace/tests/tools/exclude.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cddl/usr.sbin/dtrace/tests/tools/exclude.sh b/cddl/usr.sbin/dtrace/tests/tools/exclude.sh index 59cd693f50d..e7902423a7f 100755 --- a/cddl/usr.sbin/dtrace/tests/tools/exclude.sh +++ b/cddl/usr.sbin/dtrace/tests/tools/exclude.sh @@ -188,3 +188,6 @@ exclude EXFAIL common/usdt/tst.static2.ksh # Uses the Solaris-specific ppriv(1). exclude EXFAIL common/usdt/tst.user.ksh + +# Triggers a lock assertion by using the raise() action from a profile probe. +exclude SKIP common/ustack/tst.spin.ksh From 085def3f0a66da5c5a538d9b02df9e2e8b9dd8d6 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 14 Dec 2016 19:28:19 +0000 Subject: [PATCH 178/226] In xbd_connect(), use correct scanf conversion specifiers for the feature_barrier and feature_flush variables. Otherwise, adjacent variables on the stack, such as sector_size, may be overwritten, with disastrous results. Note that I did not see a good reason to revert the addition of zero checks introduced in r310013. Better safe than sorry. PR: 215209 Tested by: royger MFC after: 3 days --- sys/dev/xen/blkfront/blkfront.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/xen/blkfront/blkfront.c b/sys/dev/xen/blkfront/blkfront.c index 2e09c2eb409..9eca2201f89 100644 --- a/sys/dev/xen/blkfront/blkfront.c +++ b/sys/dev/xen/blkfront/blkfront.c @@ -1259,13 +1259,13 @@ xbd_connect(struct xbd_softc *sc) if (err || phys_sector_size <= sector_size) phys_sector_size = 0; err = xs_gather(XST_NIL, xenbus_get_otherend_path(dev), - "feature-barrier", "%lu", &feature_barrier, + "feature-barrier", "%d", &feature_barrier, NULL); if (err == 0 && feature_barrier != 0) sc->xbd_flags |= XBDF_BARRIER; err = xs_gather(XST_NIL, xenbus_get_otherend_path(dev), - "feature-flush-cache", "%lu", &feature_flush, + "feature-flush-cache", "%d", &feature_flush, NULL); if (err == 0 && feature_flush != 0) sc->xbd_flags |= XBDF_FLUSH; From e61e40a204c61ae698e92478135a61e44301305c Mon Sep 17 00:00:00 2001 From: Rene Ladan Date: Wed, 14 Dec 2016 20:53:46 +0000 Subject: [PATCH 179/226] Add adamw, feld and rene to the portmgr organization --- share/misc/organization.dot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/misc/organization.dot b/share/misc/organization.dot index 5877593347d..17568e3d82e 100644 --- a/share/misc/organization.dot +++ b/share/misc/organization.dot @@ -30,7 +30,7 @@ coresecretary [label="Core Team Secretary\ncore-secretary@FreeBSD.org\nmatthew"] doccommitters [label="Doc/www Committers\ndoc-committers@FreeBSD.org"] doceng [label="Documentation Engineering Team\ndoceng@FreeBSD.org\ngjb, blackend,\ngabor, hrs"] portscommitters [label="Ports Committers\nports-committers@FreeBSD.org"] -portmgr [label="Port Management Team\nportmgr@FreeBSD.org\nantoine, bdrewery,\nmat, swills"] +portmgr [label="Port Management Team\nportmgr@FreeBSD.org\nadamw, antoine, bdrewery, feld\nmat, rene, swills"] portmgrsecretary [label="Port Management Team Secretary\nportmgr-secretary@FreeBSD.org\nrene"] re [label="Primary Release Engineering Team\nre@FreeBSD.org\nkib, blackend, jpaetzel, hrs, kensmith"] secteam [label="Security Team\nsecteam@FreeBSD.org\ndelphij,\ndes, gavin, gjb,\nglebius, remko"] From 176d3efd2b8fb2824b75a95036bec4d543d548b6 Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Wed, 14 Dec 2016 21:11:42 +0000 Subject: [PATCH 180/226] Put the undocumented df feature of mounting filesystems from device nodes under an ifdef. Leave enabled. Reviewed by: cem MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D8513 --- bin/df/Makefile | 1 + bin/df/df.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/df/Makefile b/bin/df/Makefile index 8f9f5284d94..c0f2f07b73e 100644 --- a/bin/df/Makefile +++ b/bin/df/Makefile @@ -9,6 +9,7 @@ PROG= df SRCS= df.c vfslist.c CFLAGS+= -I${MOUNT} +CFLAGS+= -DMOUNT_CHAR_DEVS LIBADD= xo util diff --git a/bin/df/df.c b/bin/df/df.c index 1bcf40d2111..e07df327035 100644 --- a/bin/df/df.c +++ b/bin/df/df.c @@ -50,7 +50,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef MOUNT_CHAR_DEVS #include +#endif #include #include #include @@ -98,7 +100,9 @@ imax(int a, int b) static int aflag = 0, cflag, hflag, iflag, kflag, lflag = 0, nflag, Tflag; static int thousands; +#ifdef MOUNT_CHAR_DEVS static struct ufs_args mdev; +#endif int main(int argc, char *argv[]) @@ -108,7 +112,10 @@ main(int argc, char *argv[]) struct maxwidths maxwidths; struct statfs *mntbuf; const char *fstype; - char *mntpath, *mntpt; +#ifdef MOUNT_CHAR_DEVS + char *mntpath; +#endif + char *mntpt; const char **vfslist; int i, mntsize; int ch, rv; @@ -227,6 +234,7 @@ main(int argc, char *argv[]) rv = 1; continue; } +#ifdef MOUNT_CHAR_DEVS } else if (S_ISCHR(stbuf.st_mode)) { if ((mntpt = getmntpt(*argv)) == NULL) { mdev.fspec = *argv; @@ -264,6 +272,7 @@ main(int argc, char *argv[]) free(mntpath); continue; } +#endif } else mntpt = *argv; From bdad1bcea4fdce96a2ce4a17afd3881fd7eb62cc Mon Sep 17 00:00:00 2001 From: Andriy Voskoboinyk Date: Wed, 14 Dec 2016 21:12:43 +0000 Subject: [PATCH 181/226] ifconfig: do not truncate SSID in verbose mode. Fix 32-character SSID abbreviation for 'ifconfig -v wlan0 scan' command. PR: 215301 Submitted by: MFC after: 4 days --- sbin/ifconfig/ifieee80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c index c7017f074b0..5b1a79c6fb7 100644 --- a/sbin/ifconfig/ifieee80211.c +++ b/sbin/ifconfig/ifieee80211.c @@ -3305,7 +3305,7 @@ list_scan(int s) getchaninfo(s); - ssidmax = verbose ? IEEE80211_NWID_LEN - 1 : 14; + ssidmax = verbose ? IEEE80211_NWID_LEN : 14; printf("%-*.*s %-17.17s %4s %4s %-7s %3s %4s\n" , ssidmax, ssidmax, "SSID/MESH ID" , "BSSID" From 9dad1250d735a8ec06a52d7512ad0a0b2f513645 Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Wed, 14 Dec 2016 21:13:10 +0000 Subject: [PATCH 182/226] Mount filesystems without executable permissions since they should never be used. Reviewed by: cem MFC after: 1 week Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D8513 --- bin/df/df.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/df/df.c b/bin/df/df.c index e07df327035..3ed7c1e8f49 100644 --- a/bin/df/df.c +++ b/bin/df/df.c @@ -251,7 +251,7 @@ main(int argc, char *argv[]) free(mntpath); continue; } - if (mount(fstype, mntpt, MNT_RDONLY, + if (mount(fstype, mntpt, MNT_RDONLY|MNT_NOEXEC, &mdev) != 0) { xo_warn("%s", *argv); rv = 1; From f50fae318d6dd4028b6aca25436053c28b07b0ea Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Wed, 14 Dec 2016 21:14:43 +0000 Subject: [PATCH 183/226] ed(1): drop redundant parenthesis. These were Left-over from the cleanup in r309936. --- bin/ed/buf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ed/buf.c b/bin/ed/buf.c index 35b5d4d55dc..68594a8ebb2 100644 --- a/bin/ed/buf.c +++ b/bin/ed/buf.c @@ -64,7 +64,7 @@ get_sbuf_line(line_t *lp) } len = lp->len; REALLOC(sfbuf, sfbufsz, len + 1, NULL); - if ((fread(sfbuf, sizeof(char), len, sfp)) != len) { + if (fread(sfbuf, sizeof(char), len, sfp) != len) { fprintf(stderr, "%s\n", strerror(errno)); errmsg = "cannot read temp file"; return NULL; @@ -110,7 +110,7 @@ put_sbuf_line(const char *cs) seek_write = 0; } /* assert: SPL1() */ - if ((fwrite(cs, sizeof(char), len, sfp)) != len) { + if (fwrite(cs, sizeof(char), len, sfp) != len) { sfseek = -1; fprintf(stderr, "%s\n", strerror(errno)); errmsg = "cannot write temp file"; From b32720888a5e55bb2d38a7494071bea228dcd644 Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Wed, 14 Dec 2016 21:26:43 +0000 Subject: [PATCH 184/226] Add a free_iovec() function to reset iovec's. The primary purpose is to call nmount() in a loop with new iovec's so free_iovec takes arguments by reference and resets their values. Reviewed by: cem MFC after: 1 week Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D8513 --- sbin/mount/getmntopts.c | 14 ++++++++++++++ sbin/mount/mntopts.h | 1 + 2 files changed, 15 insertions(+) diff --git a/sbin/mount/getmntopts.c b/sbin/mount/getmntopts.c index f8a34530c5d..59a383ebe5f 100644 --- a/sbin/mount/getmntopts.c +++ b/sbin/mount/getmntopts.c @@ -181,3 +181,17 @@ build_iovec_argf(struct iovec **iov, int *iovlen, const char *name, va_end(ap); build_iovec(iov, iovlen, name, strdup(val), (size_t)-1); } + +/* + * Free the iovec and reset to NULL with zero length. Useful for calling + * nmount in a loop. + */ +void +free_iovec(struct iovec **iov, int *iovlen) +{ + int i; + + for (i = 0; i < *iovlen; i++) + free((*iov)[i].iov_base); + free(*iov); +} diff --git a/sbin/mount/mntopts.h b/sbin/mount/mntopts.h index d273dde9f1d..4cb83f15e6e 100644 --- a/sbin/mount/mntopts.h +++ b/sbin/mount/mntopts.h @@ -99,3 +99,4 @@ int checkpath(const char *, char resolved_path[]); extern int getmnt_silent; void build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val, size_t len); void build_iovec_argf(struct iovec **iov, int *iovlen, const char *name, const char *fmt, ...); +void free_iovec(struct iovec **iovec, int *iovlen); From facc3cb0ff89079cca9ce320be9954ee349ad979 Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Wed, 14 Dec 2016 21:30:44 +0000 Subject: [PATCH 185/226] Use nmount(2) rather than the obsolete mount(2). Reviewed by: cem MFC after: 1 week Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D8513 --- bin/df/Makefile | 2 ++ bin/df/df.c | 30 +++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/bin/df/Makefile b/bin/df/Makefile index c0f2f07b73e..c054d29a27e 100644 --- a/bin/df/Makefile +++ b/bin/df/Makefile @@ -9,7 +9,9 @@ PROG= df SRCS= df.c vfslist.c CFLAGS+= -I${MOUNT} + CFLAGS+= -DMOUNT_CHAR_DEVS +SRCS+= getmntopts.c LIBADD= xo util diff --git a/bin/df/df.c b/bin/df/df.c index 3ed7c1e8f49..9ecff3586eb 100644 --- a/bin/df/df.c +++ b/bin/df/df.c @@ -56,6 +56,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef MOUNT_CHAR_DEVS +#include +#endif #include #include #include @@ -111,14 +114,21 @@ main(int argc, char *argv[]) struct statfs statfsbuf, totalbuf; struct maxwidths maxwidths; struct statfs *mntbuf; +#ifdef MOUNT_CHAR_DEVS + struct iovec *iov = NULL; +#endif const char *fstype; #ifdef MOUNT_CHAR_DEVS char *mntpath; + char errmsg[255] = {0}; #endif char *mntpt; const char **vfslist; int i, mntsize; int ch, rv; +#ifdef MOUNT_CHAR_DEVS + int iovlen = 0; +#endif fstype = "ufs"; (void)setlocale(LC_ALL, ""); @@ -251,9 +261,23 @@ main(int argc, char *argv[]) free(mntpath); continue; } - if (mount(fstype, mntpt, MNT_RDONLY|MNT_NOEXEC, - &mdev) != 0) { - xo_warn("%s", *argv); + if (iov != NULL) + free_iovec(&iov, &iovlen); + build_iovec_argf(&iov, &iovlen, "fstype", "%s", + fstype); + build_iovec_argf(&iov, &iovlen, "fspath", "%s", + mntpath); + build_iovec_argf(&iov, &iovlen, "from", "%s", + *argv); + build_iovec(&iov, &iovlen, "errmsg", errmsg, + sizeof(errmsg)); + if (nmount(iov, iovlen, + MNT_RDONLY|MNT_NOEXEC) < 0) { + if (errmsg[0]) + xo_warn("%s: %s", *argv, + errmsg); + else + xo_warn("%s", *argv); rv = 1; (void)rmdir(mntpt); free(mntpath); From b9a6fb934370a36a3067edbdbf2cc85357ec4b26 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Wed, 14 Dec 2016 22:49:20 +0000 Subject: [PATCH 186/226] reaper: Make REAPER_KILL_SUBTREE actually work. MFC after: 2 weeks --- sys/kern/kern_procctl.c | 2 +- tests/sys/kern/reaper.c | 102 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_procctl.c b/sys/kern/kern_procctl.c index c3d290ae984..e8751701363 100644 --- a/sys/kern/kern_procctl.c +++ b/sys/kern/kern_procctl.c @@ -243,7 +243,7 @@ reap_kill(struct thread *td, struct proc *p, struct procctl_reaper_kill *rk) return (ECAPMODE); if (rk->rk_sig <= 0 || rk->rk_sig > _SIG_MAXSIG) return (EINVAL); - if ((rk->rk_flags & ~REAPER_KILL_CHILDREN) != 0) + if ((rk->rk_flags & ~(REAPER_KILL_CHILDREN | REAPER_KILL_SUBTREE)) != 0) return (EINVAL); PROC_UNLOCK(p); reap = (p->p_treeflag & P_TREE_REAPER) == 0 ? p->p_reaper : p; diff --git a/tests/sys/kern/reaper.c b/tests/sys/kern/reaper.c index d11ee704bdf..60317133443 100644 --- a/tests/sys/kern/reaper.c +++ b/tests/sys/kern/reaper.c @@ -639,6 +639,107 @@ ATF_TC_BODY(reaper_kill_normal, tc) ATF_REQUIRE_EQ(0, r); } +ATF_TC_WITHOUT_HEAD(reaper_kill_subtree); +ATF_TC_BODY(reaper_kill_subtree, tc) +{ + struct procctl_reaper_kill params; + ssize_t sr; + pid_t parent, child1, child2, grandchild1, grandchild2, pid; + int r, status; + int pip[2]; + + parent = getpid(); + r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL); + ATF_REQUIRE_EQ(0, r); + + r = pipe(pip); + ATF_REQUIRE_EQ(0, r); + child1 = fork(); + ATF_REQUIRE(child1 != -1); + if (child1 == 0) { + if (close(pip[0]) != 0) + _exit(100); + grandchild1 = fork(); + if (grandchild1 == -1) + _exit(101); + if (grandchild1 == 0) { + if (write(pip[1], &(uint8_t){ 0 }, 1) != 1) + _exit(102); + for (;;) + pause(); + } + for (;;) + pause(); + } + child2 = fork(); + ATF_REQUIRE(child2 != -1); + if (child2 == 0) { + if (close(pip[0]) != 0) + _exit(100); + grandchild2 = fork(); + if (grandchild2 == -1) + _exit(101); + if (grandchild2 == 0) { + if (write(pip[1], &(uint8_t){ 0 }, 1) != 1) + _exit(102); + for (;;) + pause(); + } + for (;;) + pause(); + } + r = close(pip[1]); + ATF_REQUIRE_EQ(0, r); + + sr = read(pip[0], &(uint8_t){ 0 }, 1); + ATF_REQUIRE_EQ(1, sr); + sr = read(pip[0], &(uint8_t){ 0 }, 1); + ATF_REQUIRE_EQ(1, sr); + + params.rk_sig = SIGUSR1; + params.rk_flags = REAPER_KILL_SUBTREE; + params.rk_subtree = child1; + params.rk_killed = 77; + r = procctl(P_PID, parent, PROC_REAP_KILL, ¶ms); + ATF_REQUIRE_EQ(0, r); + ATF_REQUIRE_EQ(2, params.rk_killed); + ATF_CHECK_EQ(-1, params.rk_fpid); + + pid = waitpid(child1, &status, 0); + ATF_REQUIRE_EQ(child1, pid); + ATF_CHECK(WIFSIGNALED(status) && WTERMSIG(status) == SIGUSR1); + + pid = waitpid(-1, &status, 0); + ATF_REQUIRE(pid > 0); + ATF_CHECK(pid != parent); + ATF_CHECK(pid != child1); + ATF_CHECK(pid != child2); + ATF_CHECK(WIFSIGNALED(status) && WTERMSIG(status) == SIGUSR1); + + params.rk_sig = SIGUSR2; + params.rk_flags = REAPER_KILL_SUBTREE; + params.rk_subtree = child2; + params.rk_killed = 77; + r = procctl(P_PID, parent, PROC_REAP_KILL, ¶ms); + ATF_REQUIRE_EQ(0, r); + ATF_REQUIRE_EQ(2, params.rk_killed); + ATF_CHECK_EQ(-1, params.rk_fpid); + + pid = waitpid(child2, &status, 0); + ATF_REQUIRE_EQ(child2, pid); + ATF_CHECK(WIFSIGNALED(status) && WTERMSIG(status) == SIGUSR2); + + pid = waitpid(-1, &status, 0); + ATF_REQUIRE(pid > 0); + ATF_CHECK(pid != parent); + ATF_CHECK(pid != child1); + ATF_CHECK(pid != child2); + ATF_CHECK(WIFSIGNALED(status) && WTERMSIG(status) == SIGUSR2); + + r = close(pip[0]); + ATF_REQUIRE_EQ(0, r); +} + ATF_TP_ADD_TCS(tp) { @@ -652,5 +753,6 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, reaper_kill_sigzero); ATF_TP_ADD_TC(tp, reaper_kill_empty); ATF_TP_ADD_TC(tp, reaper_kill_normal); + ATF_TP_ADD_TC(tp, reaper_kill_subtree); return (atf_no_error()); } From a41ece084017f53d5e5709c2d7ce82368aef04b6 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Wed, 14 Dec 2016 23:34:25 +0000 Subject: [PATCH 187/226] Remove locking around accounting initialization of the default object. The object is not yet fully constructed and must not be available to other threads. This makes default_pager_alloc() almost identical to swap_pager_alloc_init(). Reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/vm/default_pager.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/vm/default_pager.c b/sys/vm/default_pager.c index 7fc4f6c49e0..d08e5f54a31 100644 --- a/sys/vm/default_pager.c +++ b/sys/vm/default_pager.c @@ -85,10 +85,8 @@ default_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, object = vm_object_allocate(OBJT_DEFAULT, OFF_TO_IDX(round_page(offset + size))); if (cred != NULL) { - VM_OBJECT_WLOCK(object); object->cred = cred; object->charge = size; - VM_OBJECT_WUNLOCK(object); } return (object); } From a1e9a3bba3fce73f004b59717130417b3faccb23 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Wed, 14 Dec 2016 23:36:32 +0000 Subject: [PATCH 188/226] Provide introductory description of the default pager. Reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/vm/default_pager.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sys/vm/default_pager.c b/sys/vm/default_pager.c index d08e5f54a31..8887e95f1e9 100644 --- a/sys/vm/default_pager.c +++ b/sys/vm/default_pager.c @@ -57,6 +57,16 @@ static boolean_t default_pager_haspage(vm_object_t, vm_pindex_t, int *, /* * pagerops for OBJT_DEFAULT - "default pager". + * + * This pager handles anonymous (no handle) swap-backed memory, just + * like the swap pager. It allows several optimizations based on the + * fact that no pages of a default object can be swapped out. The + * most important optimization is in vm_fault(), where the pager is + * never asked for a non-resident page. Instead, a freshly allocated + * zeroed page is used. + * + * On the first request to page out a page from a default object, the + * object is converted to swap pager type. */ struct pagerops defaultpagerops = { .pgo_alloc = default_pager_alloc, From 1de8c69de77368f9b17cd8a94e8fafcb0cfd776f Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Thu, 15 Dec 2016 02:05:29 +0000 Subject: [PATCH 189/226] cxgbe(4): Deal with compressed error vectors. MFC after: 3 days Sponsored by: Chelsio Communications --- sys/dev/cxgbe/common/common.h | 2 +- sys/dev/cxgbe/common/t4_hw.c | 11 ++++++++--- sys/dev/cxgbe/common/t4_msg.h | 2 +- sys/dev/cxgbe/t4_sge.c | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sys/dev/cxgbe/common/common.h b/sys/dev/cxgbe/common/common.h index f2901f5e422..2e1f8a98fca 100644 --- a/sys/dev/cxgbe/common/common.h +++ b/sys/dev/cxgbe/common/common.h @@ -227,7 +227,7 @@ struct tp_params { uint32_t vlan_pri_map; uint32_t ingress_config; - uint32_t rx_pkt_encap; + __be16 err_vec_mask; int8_t fcoe_shift; int8_t port_shift; diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c index 381ca2a3a70..3f49460a798 100644 --- a/sys/dev/cxgbe/common/t4_hw.c +++ b/sys/dev/cxgbe/common/t4_hw.c @@ -8020,12 +8020,17 @@ int t4_init_tp_params(struct adapter *adap) read_filter_mode_and_ingress_config(adap); /* - * For T6, cache the adapter's compressed error vector - * and passing outer header info for encapsulated packets. + * Cache a mask of the bits that represent the error vector portion of + * rx_pkt.err_vec. T6+ can use a compressed error vector to make room + * for information about outer encapsulation (GENEVE/VXLAN/NVGRE). */ + tpp->err_vec_mask = htobe16(0xffff); if (chip_id(adap) > CHELSIO_T5) { v = t4_read_reg(adap, A_TP_OUT_CONFIG); - tpp->rx_pkt_encap = (v & F_CRXPKTENC) ? 1 : 0; + if (v & F_CRXPKTENC) { + tpp->err_vec_mask = + htobe16(V_T6_COMPR_RXERR_VEC(M_T6_COMPR_RXERR_VEC)); + } } return 0; diff --git a/sys/dev/cxgbe/common/t4_msg.h b/sys/dev/cxgbe/common/t4_msg.h index ea48fc6dde9..3264bac65a8 100644 --- a/sys/dev/cxgbe/common/t4_msg.h +++ b/sys/dev/cxgbe/common/t4_msg.h @@ -2014,7 +2014,7 @@ struct cpl_rx_pkt { #define S_T6_COMPR_RXERR_VEC 0 #define M_T6_COMPR_RXERR_VEC 0x3F -#define V_T6_COMPR_RXERR_VEC(x) ((x) << S_T6_COMPR_RXERR_LEN) +#define V_T6_COMPR_RXERR_VEC(x) ((x) << S_T6_COMPR_RXERR_VEC) #define G_T6_COMPR_RXERR_VEC(x) \ (((x) >> S_T6_COMPR_RXERR_VEC) & M_T6_COMPR_RXERR_VEC) diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 88c2e91bc7a..bdfaa4db2b0 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -1808,7 +1808,7 @@ t4_eth_rx(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m0) M_HASHTYPE_SET(m0, sw_hashtype[rss->hash_type][rss->ipv6]); m0->m_pkthdr.flowid = be32toh(rss->hash_val); - if (cpl->csum_calc && !cpl->err_vec) { + if (cpl->csum_calc && !(cpl->err_vec & sc->params.tp.err_vec_mask)) { if (ifp->if_capenable & IFCAP_RXCSUM && cpl->l2info & htobe32(F_RXF_IP)) { m0->m_pkthdr.csum_flags = (CSUM_IP_CHECKED | From 9622c93ae8fdd7956de3f0a65baede8cffd3cb86 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Thu, 15 Dec 2016 03:32:24 +0000 Subject: [PATCH 190/226] hyperv: Allow userland to ro-mmap reference TSC page This paves way to implement VDSO for the enlightened time counter. Reviewed by: kib MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8768 --- include/Makefile | 8 ++++ sys/dev/hyperv/include/hyperv.h | 31 ++++++++++--- sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c | 49 +++++++++++++++++++++ sys/dev/hyperv/vmbus/hyperv_reg.h | 11 ----- 4 files changed, 83 insertions(+), 16 deletions(-) diff --git a/include/Makefile b/include/Makefile index af291fa24b0..3032785e254 100644 --- a/include/Makefile +++ b/include/Makefile @@ -185,6 +185,9 @@ copies: .PHONY .META ${DESTDIR}${INCLUDEDIR}/dev/evdev; \ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 uinput.h \ ${DESTDIR}${INCLUDEDIR}/dev/evdev + cd ${.CURDIR}/../sys/dev/hyperv/include; \ + ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 hyperv.h \ + ${DESTDIR}${INCLUDEDIR}/dev/hyperv cd ${.CURDIR}/../sys/dev/hyperv/utilities; \ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 hv_snapshot.h \ ${DESTDIR}${INCLUDEDIR}/dev/hyperv @@ -293,6 +296,11 @@ symlinks: .PHONY .META ln -fs ../../../../sys/dev/evdev/$$h \ ${DESTDIR}${INCLUDEDIR}/dev/evdev; \ done + cd ${.CURDIR}/../sys/dev/hyperv/include; \ + for h in hyperv.h; do \ + ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/hyperv/include/$$h \ + ${DESTDIR}${INCLUDEDIR}/dev/hyperv; \ + done cd ${.CURDIR}/../sys/dev/hyperv/utilities; \ for h in hv_snapshot.h; do \ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/hyperv/utilities/$$h \ diff --git a/sys/dev/hyperv/include/hyperv.h b/sys/dev/hyperv/include/hyperv.h index 44851444d26..0eda9f0691a 100644 --- a/sys/dev/hyperv/include/hyperv.h +++ b/sys/dev/hyperv/include/hyperv.h @@ -31,10 +31,10 @@ #ifndef _HYPERV_H_ #define _HYPERV_H_ -#include +#ifdef _KERNEL -#include -#include +#include +#include #define MSR_HV_TIME_REF_COUNT 0x40000020 @@ -54,14 +54,35 @@ #define HYPERV_TIMER_NS_FACTOR 100ULL #define HYPERV_TIMER_FREQ (NANOSEC / HYPERV_TIMER_NS_FACTOR) +#endif /* _KERNEL */ + +#define HYPERV_REFTSC_DEVNAME "hv_tsc" + +/* + * Hyper-V Reference TSC + */ +struct hyperv_reftsc { + volatile uint32_t tsc_seq; + volatile uint32_t tsc_rsvd1; + volatile uint64_t tsc_scale; + volatile int64_t tsc_ofs; +} __packed __aligned(PAGE_SIZE); +#ifdef CTASSERT +CTASSERT(sizeof(struct hyperv_reftsc) == PAGE_SIZE); +#endif + +#ifdef _KERNEL + struct hyperv_guid { - uint8_t hv_guid[16]; + uint8_t hv_guid[16]; } __packed; -#define HYPERV_GUID_STRLEN 40 +#define HYPERV_GUID_STRLEN 40 int hyperv_guid2str(const struct hyperv_guid *, char *, size_t); extern u_int hyperv_features; /* CPUID_HV_MSR_ */ +#endif /* _KERNEL */ + #endif /* _HYPERV_H_ */ diff --git a/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c b/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c index 712a6e22994..abf0372bb31 100644 --- a/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c +++ b/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c @@ -28,6 +28,8 @@ __FBSDID("$FreeBSD$"); #include +#include +#include #include #include #include @@ -35,6 +37,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include + +#include #include #include @@ -47,6 +52,9 @@ struct hyperv_reftsc_ctx { struct hyperv_dma tsc_ref_dma; }; +static d_open_t hyperv_tsc_open; +static d_mmap_t hyperv_tsc_mmap; + static struct timecounter hyperv_tsc_timecounter = { .tc_get_timecount = NULL, /* based on CPU vendor. */ .tc_poll_pps = NULL, @@ -58,6 +66,13 @@ static struct timecounter hyperv_tsc_timecounter = { .tc_priv = NULL }; +static struct cdevsw hyperv_tsc_cdevsw = { + .d_version = D_VERSION, + .d_open = hyperv_tsc_open, + .d_mmap = hyperv_tsc_mmap, + .d_name = HYPERV_REFTSC_DEVNAME +}; + static struct hyperv_reftsc_ctx hyperv_ref_tsc; uint64_t @@ -72,6 +87,36 @@ hypercall_md(volatile void *hc_addr, uint64_t in_val, return (status); } +static int +hyperv_tsc_open(struct cdev *dev __unused, int oflags, int devtype __unused, + struct thread *td __unused) +{ + + if (oflags & FWRITE) + return (EPERM); + return (0); +} + +static int +hyperv_tsc_mmap(struct cdev *dev __unused, vm_ooffset_t offset, + vm_paddr_t *paddr, int nprot __unused, vm_memattr_t *memattr __unused) +{ + + KASSERT(hyperv_ref_tsc.tsc_ref != NULL, ("reftsc has not been setup")); + + /* + * NOTE: + * 'nprot' does not contain information interested to us; + * WR-open is blocked by d_open. + */ + + if (offset != 0) + return (EOPNOTSUPP); + + *paddr = hyperv_ref_tsc.tsc_ref_dma.hv_paddr; + return (0); +} + #define HYPERV_TSC_TIMECOUNT(fence) \ static u_int \ hyperv_tsc_timecount_##fence(struct timecounter *tc) \ @@ -150,6 +195,10 @@ hyperv_tsc_tcinit(void *dummy __unused) /* Register "enlightened" timecounter. */ tc_init(&hyperv_tsc_timecounter); + + /* Add device for mmap(2). */ + make_dev(&hyperv_tsc_cdevsw, 0, UID_ROOT, GID_WHEEL, 0444, + HYPERV_REFTSC_DEVNAME); } SYSINIT(hyperv_tsc_init, SI_SUB_DRIVERS, SI_ORDER_FIRST, hyperv_tsc_tcinit, NULL); diff --git a/sys/dev/hyperv/vmbus/hyperv_reg.h b/sys/dev/hyperv/vmbus/hyperv_reg.h index 263a191fec2..b3b133c8488 100644 --- a/sys/dev/hyperv/vmbus/hyperv_reg.h +++ b/sys/dev/hyperv/vmbus/hyperv_reg.h @@ -128,17 +128,6 @@ #define CPUID_LEAF_HV_LIMITS 0x40000005 #define CPUID_LEAF_HV_HWFEATURES 0x40000006 -/* - * Hyper-V Reference TSC - */ -struct hyperv_reftsc { - volatile uint32_t tsc_seq; - volatile uint32_t tsc_rsvd1; - volatile uint64_t tsc_scale; - volatile int64_t tsc_ofs; -} __packed __aligned(PAGE_SIZE); -CTASSERT(sizeof(struct hyperv_reftsc) == PAGE_SIZE); - /* * Hyper-V Monitor Notification Facility */ From c5f74c48734b78cbc442cdf0891d2418f548cba8 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Thu, 15 Dec 2016 08:03:16 +0000 Subject: [PATCH 191/226] Revert r310023 for now. After another look my new variable mapping was not exactly right. --- sys/cddl/compat/opensolaris/sys/kmem.h | 7 ++----- .../opensolaris/uts/common/fs/zfs/arc.c | 20 +++++++++++++++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/sys/cddl/compat/opensolaris/sys/kmem.h b/sys/cddl/compat/opensolaris/sys/kmem.h index 0b7e16c6766..c0e9760d57b 100644 --- a/sys/cddl/compat/opensolaris/sys/kmem.h +++ b/sys/cddl/compat/opensolaris/sys/kmem.h @@ -37,7 +37,6 @@ #include #include #include -#include MALLOC_DECLARE(M_SOLARIS); @@ -78,10 +77,8 @@ void kmem_reap(void); int kmem_debugging(void); void *calloc(size_t n, size_t s); -#define freemem (long)vm_cnt.v_free_count -#define desfree (long)vm_cnt.v_free_target -#define minfree (long)vm_cnt.v_free_min -#define needfree (long)vm_pageout_deficit +#define freemem vm_cnt.v_free_count +#define minfree vm_cnt.v_free_min #define heap_arena kmem_arena #define kmem_alloc(size, kmflags) zfs_kmem_alloc((size), (kmflags)) #define kmem_zalloc(size, kmflags) zfs_kmem_alloc((size), (kmflags) | M_ZERO) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c index 49c52ed3e6d..b41b746d368 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c @@ -357,7 +357,6 @@ int zfs_arc_shrink_shift = 0; int zfs_arc_p_min_shift = 0; uint64_t zfs_arc_average_blocksize = 8 * 1024; /* 8KB */ u_int zfs_arc_free_target = 0; -#define lotsfree zfs_arc_free_target /* Absolute min for arc min / max is 16MB. */ static uint64_t arc_abs_min = 16 << 20; @@ -3828,6 +3827,8 @@ arc_shrink(int64_t to_free) } } +static long needfree = 0; + typedef enum free_memory_reason_t { FMR_UNKNOWN, FMR_NEEDFREE, @@ -3873,6 +3874,17 @@ arc_available_memory(void) } } + /* + * Cooperate with pagedaemon when it's time for it to scan + * and reclaim some pages. + */ + n = PAGESIZE * ((int64_t)freemem - zfs_arc_free_target); + if (n < lowest) { + lowest = n; + r = FMR_LOTSFREE; + } + +#ifdef illumos /* * check that we're out of range of the pageout scanner. It starts to * schedule paging if freemem is less than lotsfree and needfree. @@ -3886,7 +3898,6 @@ arc_available_memory(void) r = FMR_LOTSFREE; } -#ifdef illumos /* * check to make sure that swapfs has enough space so that anon * reservations can still succeed. anon_resvmem() checks that the @@ -4143,6 +4154,9 @@ arc_reclaim_thread(void *dummy __unused) * infinite loop. */ if (arc_size <= arc_c || evicted == 0) { +#ifdef _KERNEL + needfree = 0; +#endif /* * We're either no longer overflowing, or we * can't evict anything more, so we should wake @@ -5869,6 +5883,8 @@ arc_lowmem(void *arg __unused, int howto __unused) { mutex_enter(&arc_reclaim_lock); + /* XXX: Memory deficit should be passed as argument. */ + needfree = btoc(arc_c >> arc_shrink_shift); DTRACE_PROBE(arc__needfree); cv_signal(&arc_reclaim_thread_cv); From 7e9de36c3a524b63e0d21a8cc634b40404bb3200 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Thu, 15 Dec 2016 12:57:03 +0000 Subject: [PATCH 192/226] newvers.sh: add option to eliminate kernel build metadata Build metadata (username, hostname, etc.) prevents the FreeBSD kernel from building reproducibly. Add an option to disable inclusion of that metadata but retain the release information and SVN/git VCS details. See https://reproducible-builds.org/ for additional background. Reviewed by: bapt Obtained from: NetBSD MFC after: 1 month Sponsored by: Reproducible Builds World Summit 2, Berlin Differential Revision: https://reviews.freebsd.org/D4347 --- sys/conf/newvers.sh | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 72e9ae60610..9e018f769f0 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -30,6 +30,14 @@ # @(#)newvers.sh 8.1 (Berkeley) 4/20/94 # $FreeBSD$ +# Command line options: +# +# -r Reproducible build. Do not embed directory names, user +# names, time stamps or other dynamic information into +# the outuput file. This is intended to allow two builds +# done at different times and even by different people on +# different hosts to produce identical output. + TYPE="FreeBSD" REVISION="12.0" BRANCH="CURRENT" @@ -250,10 +258,28 @@ if [ -n "$hg_cmd" ] ; then fi fi +include_metadata=true +while getopts r opt; do + case "$opt" in + r) + include_metadata= + ;; + esac +done +shift $((OPTIND - 1)) + +if [ -z "${include_metadata}" ]; then + VERINFO="${VERSION} ${svn}${git}${hg}${p4version}" + VERSTR="${VERINFO}\\n" +else + VERINFO="${VERSION} #${v}${svn}${git}${hg}${p4version}: ${t}" + VERSTR="${VERINFO}\\n ${u}@${h}:${d}\\n" +fi + cat << EOF > vers.c $COPYRIGHT -#define SCCSSTR "@(#)${VERSION} #${v}${svn}${git}${hg}${p4version}: ${t}" -#define VERSTR "${VERSION} #${v}${svn}${git}${hg}${p4version}: ${t}\\n ${u}@${h}:${d}\\n" +#define SCCSSTR "@(#)${VERINFO}" +#define VERSTR "${VERSTR}" #define RELSTR "${RELEASE}" char sccs[sizeof(SCCSSTR) > 128 ? sizeof(SCCSSTR) : 128] = SCCSSTR; From cf1db37a45f4f7e4877ed3d2e3f1aac1f174494a Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Thu, 15 Dec 2016 13:31:44 +0000 Subject: [PATCH 193/226] Directly include openfirm.h rather than through fdt_common.h as none of the latter file is needed. Sponsored by: ABT Systems Ltd --- sys/arm/broadcom/bcm2835/bcm2835_machdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/arm/broadcom/bcm2835/bcm2835_machdep.c b/sys/arm/broadcom/bcm2835/bcm2835_machdep.c index 5101f62c3d4..5d0507998b3 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_machdep.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_machdep.c @@ -55,7 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include #include From e77cf5967abbcf9ea09d54b98c9fd53a57e1cf54 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Thu, 15 Dec 2016 15:14:02 +0000 Subject: [PATCH 194/226] newvers.sh: correct typo in comment Submitted by: lidl --- sys/conf/newvers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 9e018f769f0..a8fbac566cc 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -34,7 +34,7 @@ # # -r Reproducible build. Do not embed directory names, user # names, time stamps or other dynamic information into -# the outuput file. This is intended to allow two builds +# the output file. This is intended to allow two builds # done at different times and even by different people on # different hosts to produce identical output. From 669a25b50dc9b305e213a50f9a03f47094f3e91c Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Thu, 15 Dec 2016 15:45:11 +0000 Subject: [PATCH 195/226] Document the existence of the {0, 6, ...} sysctl. --- sys/kern/kern_sysctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 6d9980d65c1..d0be3623d2e 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -821,7 +821,8 @@ SYSINIT(sysctl, SI_SUB_KMEM, SI_ORDER_FIRST, sysctl_register_all, 0); * {0,2,...} return the next OID. * {0,3} return the OID of the name in "new" * {0,4,...} return the kind & format info for the "..." OID. - * {0,5,...} return the description the "..." OID. + * {0,5,...} return the description of the "..." OID. + * {0,6,...} return the aggregation label of the "..." OID. */ #ifdef SYSCTL_DEBUG From 15b2342cf3e3f888366b01cd801ffead330bbb84 Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Thu, 15 Dec 2016 15:52:13 +0000 Subject: [PATCH 196/226] Add information about interrupts in the Allwinner padconf files and correct some pin numbering. While here switch to my freebsd mail address in the copyright. MFC after: 3 days --- sys/arm/allwinner/a10/a10_padconf.c | 66 +++++------ sys/arm/allwinner/a13/a13_padconf.c | 30 ++--- sys/arm/allwinner/a20/a20_padconf.c | 54 ++++----- sys/arm/allwinner/a31/a31_padconf.c | 152 +++++++++++++------------- sys/arm/allwinner/a31/a31_r_padconf.c | 26 ++--- sys/arm/allwinner/a31/a31s_padconf.c | 150 ++++++++++++------------- sys/arm/allwinner/a64/a64_padconf.c | 72 ++++++------ sys/arm/allwinner/a64/a64_r_padconf.c | 26 ++--- sys/arm/allwinner/allwinner_pinctrl.h | 2 + sys/arm/allwinner/h3/h3_padconf.c | 72 ++++++------ sys/arm/allwinner/h3/h3_r_padconf.c | 24 ++-- 11 files changed, 338 insertions(+), 336 deletions(-) diff --git a/sys/arm/allwinner/a10/a10_padconf.c b/sys/arm/allwinner/a10/a10_padconf.c index f77f5e68f61..b08a1d71e1a 100644 --- a/sys/arm/allwinner/a10/a10_padconf.c +++ b/sys/arm/allwinner/a10/a10_padconf.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Emmanuel Vadot + * Copyright (c) 2016 Emmanuel Vadot * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -170,28 +170,28 @@ const static struct allwinner_pins a10_pins[] = { {"PG10", 6, 10, {"gpio_in", "gpio_out", "ts1", "csi1", "uart4", "csi0", NULL, NULL}}, {"PG11", 6, 11, {"gpio_in", "gpio_out", "ts1", "csi1", "uart4", "csi0", NULL, NULL}}, - {"PH0", 7, 0, {"gpio_in", "gpio_out", "lcd1", "pata", "uart3", NULL, "eint", "csi1"}}, - {"PH1", 7, 1, {"gpio_in", "gpio_out", "lcd1", "pata", "uart3", NULL, "eint", "csi1"}}, - {"PH2", 7, 2, {"gpio_in", "gpio_out", "lcd1", "pata", "uart3", NULL, "eint", "csi1"}}, - {"PH3", 7, 3, {"gpio_in", "gpio_out", "lcd1", "pata", "uart3", NULL, "eint", "csi1"}}, - {"PH4", 7, 4, {"gpio_in", "gpio_out", "lcd1", "pata", "uart4", NULL, "eint", "csi1"}}, - {"PH5", 7, 5, {"gpio_in", "gpio_out", "lcd1", "pata", "uart4", NULL, "eint", "csi1"}}, - {"PH6", 7, 6, {"gpio_in", "gpio_out", "lcd1", "pata", "uart5", "ms", "eint", "csi1"}}, - {"PH7", 7, 7, {"gpio_in", "gpio_out", "lcd1", "pata", "uart5", "ms", "eint", "csi1"}}, - {"PH8", 7, 8, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "ms", "eint", "csi1"}}, - {"PH9", 7, 9, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "ms", "eint", "csi1"}}, - {"PH10", 7, 10, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "ms", "eint", "csi1"}}, - {"PH11", 7, 11, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "ms", "eint", "csi1"}}, - {"PH12", 7, 12, {"gpio_in", "gpio_out", "lcd1", "pata", "ps2", NULL, "eint", "csi1"}}, - {"PH13", 7, 13, {"gpio_in", "gpio_out", "lcd1", "pata", "ps2", "sim", "eint", "csi1"}}, - {"PH14", 7, 14, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "sim", "eint", "csi1"}}, - {"PH15", 7, 15, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "sim", "eint", "csi1"}}, - {"PH16", 7, 16, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", NULL, "eint", "csi1"}}, - {"PH17", 7, 17, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "sim", "eint", "csi1"}}, - {"PH18", 7, 18, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "sim", "eint", "csi1"}}, - {"PH19", 7, 19, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "sim", "eint", "csi1"}}, - {"PH20", 7, 20, {"gpio_in", "gpio_out", "lcd1", "pata", "can", NULL, "eint", "csi1"}}, - {"PH21", 7, 21, {"gpio_in", "gpio_out", "lcd1", "pata", "can", NULL, "eint", "csi1"}}, + {"PH0", 7, 0, {"gpio_in", "gpio_out", "lcd1", "pata", "uart3", NULL, "eint0", "csi1"}, 6, 0}, + {"PH1", 7, 1, {"gpio_in", "gpio_out", "lcd1", "pata", "uart3", NULL, "eint1", "csi1"}, 6, 1}, + {"PH2", 7, 2, {"gpio_in", "gpio_out", "lcd1", "pata", "uart3", NULL, "eint2", "csi1"}, 6, 2}, + {"PH3", 7, 3, {"gpio_in", "gpio_out", "lcd1", "pata", "uart3", NULL, "eint3", "csi1"}, 6, 3}, + {"PH4", 7, 4, {"gpio_in", "gpio_out", "lcd1", "pata", "uart4", NULL, "eint4", "csi1"}, 6, 4}, + {"PH5", 7, 5, {"gpio_in", "gpio_out", "lcd1", "pata", "uart4", NULL, "eint5", "csi1"}, 6, 5}, + {"PH6", 7, 6, {"gpio_in", "gpio_out", "lcd1", "pata", "uart5", "ms", "eint6", "csi1"}, 6, 6}, + {"PH7", 7, 7, {"gpio_in", "gpio_out", "lcd1", "pata", "uart5", "ms", "eint7", "csi1"}, 6, 7}, + {"PH8", 7, 8, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "ms", "eint8", "csi1"}, 6, 8}, + {"PH9", 7, 9, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "ms", "eint9", "csi1"}, 6, 9}, + {"PH10", 7, 10, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "ms", "eint10", "csi1"}, 6, 10}, + {"PH11", 7, 11, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "ms", "eint11", "csi1"}, 6, 11}, + {"PH12", 7, 12, {"gpio_in", "gpio_out", "lcd1", "pata", "ps2", NULL, "eint12", "csi1"}, 6, 12}, + {"PH13", 7, 13, {"gpio_in", "gpio_out", "lcd1", "pata", "ps2", "sim", "eint13", "csi1"}, 6, 13}, + {"PH14", 7, 14, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "sim", "eint14", "csi1"}, 6, 14}, + {"PH15", 7, 15, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "sim", "eint15", "csi1"}, 6, 15}, + {"PH16", 7, 16, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", NULL, "eint16", "csi1"}, 6, 16}, + {"PH17", 7, 17, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "sim", "eint17", "csi1"}, 6, 17}, + {"PH18", 7, 18, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "sim", "eint18", "csi1"}, 6, 18}, + {"PH19", 7, 19, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "sim", "eint19", "csi1"}, 6, 19}, + {"PH20", 7, 20, {"gpio_in", "gpio_out", "lcd1", "pata", "can", NULL, "eint20", "csi1"}, 6, 20}, + {"PH21", 7, 21, {"gpio_in", "gpio_out", "lcd1", "pata", "can", NULL, "eint21", "csi1"}, 6, 21}, {"PH22", 7, 22, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "mmc1", NULL, "csi1"}}, {"PH23", 7, 23, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "mmc1", NULL, "csi1"}}, {"PH24", 7, 24, {"gpio_in", "gpio_out", "lcd1", "pata", "keypad", "mmc1", NULL, "csi1"}}, @@ -209,16 +209,16 @@ const static struct allwinner_pins a10_pins[] = { {"PI7", 8, 7, {"gpio_in", "gpio_out", "mmc3", NULL, NULL, NULL, NULL, NULL}}, {"PI8", 8, 8, {"gpio_in", "gpio_out", "mmc3", NULL, NULL, NULL, NULL, NULL}}, {"PI9", 8, 9, {"gpio_in", "gpio_out", "mmc3", NULL, NULL, NULL, NULL, NULL}}, - {"PI10", 8, 10, {"gpio_in", "gpio_out", "spi0", "uart5", NULL, NULL, "eint", NULL}}, - {"PI11", 8, 11, {"gpio_in", "gpio_out", "spi0", "uart5", NULL, NULL, "eint", NULL}}, - {"PI12", 8, 12, {"gpio_in", "gpio_out", "spi0", "uart6", NULL, NULL, "eint", NULL}}, - {"PI13", 8, 13, {"gpio_in", "gpio_out", "spi0", "uart6", NULL, NULL, "eint", NULL}}, - {"PI14", 8, 14, {"gpio_in", "gpio_out", "spi0", "ps2", "timer4", NULL, "eint", NULL}}, - {"PI15", 8, 15, {"gpio_in", "gpio_out", "spi1", "ps2", "timer5", NULL, "eint", NULL}}, - {"PI16", 8, 16, {"gpio_in", "gpio_out", "spi1", "uart2", NULL, NULL, "eint", NULL}}, - {"PI17", 8, 17, {"gpio_in", "gpio_out", "spi1", "uart2", NULL, NULL, "eint", NULL}}, - {"PI18", 8, 18, {"gpio_in", "gpio_out", "spi1", "uart2", NULL, NULL, "eint", NULL}}, - {"PI19", 8, 19, {"gpio_in", "gpio_out", "spi1", "uart2", NULL, NULL, "eint", NULL}}, + {"PI10", 8, 10, {"gpio_in", "gpio_out", "spi0", "uart5", NULL, NULL, "eint22", NULL}, 6, 22}, + {"PI11", 8, 11, {"gpio_in", "gpio_out", "spi0", "uart5", NULL, NULL, "eint23", NULL}, 6, 23}, + {"PI12", 8, 12, {"gpio_in", "gpio_out", "spi0", "uart6", NULL, NULL, "eint24", NULL}, 6, 24}, + {"PI13", 8, 13, {"gpio_in", "gpio_out", "spi0", "uart6", NULL, NULL, "eint25", NULL}, 6, 25}, + {"PI14", 8, 14, {"gpio_in", "gpio_out", "spi0", "ps2", "timer4", NULL, "eint26", NULL}, 6, 26}, + {"PI15", 8, 15, {"gpio_in", "gpio_out", "spi1", "ps2", "timer5", NULL, "eint27", NULL}, 6, 27}, + {"PI16", 8, 16, {"gpio_in", "gpio_out", "spi1", "uart2", NULL, NULL, "eint28", NULL}, 6, 28}, + {"PI17", 8, 17, {"gpio_in", "gpio_out", "spi1", "uart2", NULL, NULL, "eint29", NULL}, 6, 29}, + {"PI18", 8, 18, {"gpio_in", "gpio_out", "spi1", "uart2", NULL, NULL, "eint30", NULL}, 6, 30}, + {"PI19", 8, 19, {"gpio_in", "gpio_out", "spi1", "uart2", NULL, NULL, "eint31", NULL}, 6, 31}, {"PI20", 8, 20, {"gpio_in", "gpio_out", "ps2", "uart7", "hdmi", NULL, NULL, NULL}}, {"PI21", 8, 21, {"gpio_in", "gpio_out", "ps2", "uart7", "hdmi", NULL, NULL, NULL}}, }; diff --git a/sys/arm/allwinner/a13/a13_padconf.c b/sys/arm/allwinner/a13/a13_padconf.c index 3966b602f9d..104f56d764f 100644 --- a/sys/arm/allwinner/a13/a13_padconf.c +++ b/sys/arm/allwinner/a13/a13_padconf.c @@ -40,10 +40,10 @@ __FBSDID("$FreeBSD$"); const static struct allwinner_pins a13_pins[] = { {"PB0", 1, 0, {"gpio_in", "gpio_out", "i2c0", NULL, NULL, NULL, NULL, NULL}}, {"PB1", 1, 1, {"gpio_in", "gpio_out", "i2c0", NULL, NULL, NULL, NULL, NULL}}, - {"PB2", 1, 2, {"gpio_in", "gpio_out", "pwm", NULL, NULL, "eint", NULL, NULL}}, - {"PB3", 1, 3, {"gpio_in", "gpio_out", "ir0", NULL, NULL, "eint", NULL, NULL}}, - {"PB4", 1, 4, {"gpio_in", "gpio_out", "ir0", NULL, NULL, "eint", NULL, NULL}}, - {"PB10", 1, 10, {"gpio_in", "gpio_out", "spi2", NULL, NULL, "eint", NULL, NULL}}, + {"PB2", 1, 2, {"gpio_in", "gpio_out", "pwm", NULL, NULL, NULL, "eint16", NULL}, 6, 16}, + {"PB3", 1, 3, {"gpio_in", "gpio_out", "ir0", NULL, NULL, NULL, "eint17", NULL}, 6, 17}, + {"PB4", 1, 4, {"gpio_in", "gpio_out", "ir0", NULL, NULL, NULL, "eint18", NULL}, 6, 18}, + {"PB10", 1, 10, {"gpio_in", "gpio_out", "spi2", NULL, NULL, NULL, "eint24", NULL}, 6, 24}, {"PB15", 1, 15, {"gpio_in", "gpio_out", "i2c1", NULL, NULL, NULL, NULL, NULL}}, {"PB16", 1, 16, {"gpio_in", "gpio_out", "i2c1", NULL, NULL, NULL, NULL, NULL}}, {"PB17", 1, 17, {"gpio_in", "gpio_out", "i2c2", NULL, NULL, NULL, NULL, NULL}}, @@ -90,8 +90,8 @@ const static struct allwinner_pins a13_pins[] = { {"PD26", 3, 26, {"gpio_in", "gpio_out", "lcd0", NULL, NULL, NULL, NULL, NULL}}, {"PD27", 3, 27, {"gpio_in", "gpio_out", "lcd0", NULL, NULL, NULL, NULL, NULL}}, - {"PE0", 4, 0, {"gpio_in", NULL, NULL, "csi0", "spi2", NULL, "eint", NULL}}, - {"PE1", 4, 1, {"gpio_in", NULL, NULL, "csi0", "spi2", NULL, NULL, NULL}}, + {"PE0", 4, 0, {"gpio_in", NULL, NULL, "csi0", "spi2", NULL, "eint14", NULL}, 6, 14}, + {"PE1", 4, 1, {"gpio_in", NULL, NULL, "csi0", "spi2", NULL, "eint15", NULL}, 6, 15}, {"PE2", 4, 2, {"gpio_in", NULL, NULL, "csi0", "spi2", NULL, NULL, NULL}}, {"PE3", 4, 3, {"gpio_in", "gpio_out", NULL, "csi0", "spi2", NULL, NULL, NULL}}, {"PE4", 4, 4, {"gpio_in", "gpio_out", NULL, "csi0", "mmc2", NULL, NULL, NULL}}, @@ -110,15 +110,15 @@ const static struct allwinner_pins a13_pins[] = { {"PF4", 5, 4, {"gpio_in", "gpio_out", "mmc0", NULL, NULL, NULL, NULL, NULL}}, {"PF5", 5, 5, {"gpio_in", "gpio_out", "mmc0", NULL, NULL, NULL, NULL, NULL}}, - {"PG0", 6, 0, {"gpio_in", NULL, NULL, NULL, NULL, NULL, "eint", NULL}}, - {"PG1", 6, 1, {"gpio_in", NULL, NULL, NULL, NULL, NULL, "eint", NULL}}, - {"PG2", 6, 2, {"gpio_in", NULL, NULL, NULL, NULL, NULL, "eint", NULL}}, - {"PG3", 6, 3, {"gpio_in", "gpio_out", "mmc1", NULL, "uart1", NULL, "eint", NULL}}, - {"PG4", 6, 4, {"gpio_in", "gpio_out", "mmc1", NULL, "uart1", NULL, "eint", NULL}}, - {"PG9", 6, 9, {"gpio_in", "gpio_out", "spi1", "uart3", NULL, NULL, "eint", NULL}}, - {"PG10", 6, 10, {"gpio_in", "gpio_out", "spi1", "uart3", NULL, NULL, "eint", NULL}}, - {"PG11", 6, 11, {"gpio_in", "gpio_out", "spi1", "uart3", NULL, NULL, "eint", NULL}}, - {"PG12", 6, 12, {"gpio_in", "gpio_out", "spi1", "uart3", NULL, NULL, "eint", NULL}}, + {"PG0", 6, 0, {"gpio_in", NULL, NULL, NULL, NULL, NULL, "eint0", NULL}, 6, 0}, + {"PG1", 6, 1, {"gpio_in", NULL, NULL, NULL, NULL, NULL, "eint1", NULL}, 6, 1}, + {"PG2", 6, 2, {"gpio_in", NULL, NULL, NULL, NULL, NULL, "eint2", NULL}, 6, 2}, + {"PG3", 6, 3, {"gpio_in", "gpio_out", "mmc1", NULL, "uart1", NULL, "eint3", NULL}, 6, 3}, + {"PG4", 6, 4, {"gpio_in", "gpio_out", "mmc1", NULL, "uart1", NULL, "eint4", NULL}, 6, 4}, + {"PG9", 6, 9, {"gpio_in", "gpio_out", "spi1", "uart3", NULL, NULL, "eint9", NULL}, 6, 9}, + {"PG10", 6, 10, {"gpio_in", "gpio_out", "spi1", "uart3", NULL, NULL, "eint10", NULL}, 6, 10}, + {"PG11", 6, 11, {"gpio_in", "gpio_out", "spi1", "uart3", NULL, NULL, "eint11", NULL}, 6, 11}, + {"PG12", 6, 12, {"gpio_in", "gpio_out", "spi1", "uart3", NULL, NULL, "eint12", NULL}, 6, 12}, }; const struct allwinner_padconf a13_padconf = { diff --git a/sys/arm/allwinner/a20/a20_padconf.c b/sys/arm/allwinner/a20/a20_padconf.c index 70eef1b38a7..7502136ff4d 100644 --- a/sys/arm/allwinner/a20/a20_padconf.c +++ b/sys/arm/allwinner/a20/a20_padconf.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Emmanuel Vadot + * Copyright (c) 2016 Emmanuel Vadot * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -101,10 +101,10 @@ const static struct allwinner_pins a20_pins[] = { {"PC16", 2, 16, {"gpio_in", "gpio_out", "nand0", NULL, NULL, NULL, NULL, NULL}}, {"PC17", 2, 17, {"gpio_in", "gpio_out", "nand0", NULL, NULL, NULL, NULL, NULL}}, {"PC18", 2, 18, {"gpio_in", "gpio_out", "nand0", NULL, NULL, NULL, NULL, NULL}}, - {"PC19", 2, 19, {"gpio_in", "gpio_out", "nand0", "spi2", NULL, NULL, "eint", NULL}}, - {"PC20", 2, 20, {"gpio_in", "gpio_out", "nand0", "spi2", NULL, NULL, "eint", NULL}}, - {"PC21", 2, 21, {"gpio_in", "gpio_out", "nand0", "spi2", NULL, NULL, "eint", NULL}}, - {"PC22", 2, 22, {"gpio_in", "gpio_out", "nand0", "spi2", NULL, NULL, "eint", NULL}}, + {"PC19", 2, 19, {"gpio_in", "gpio_out", "nand0", "spi2", NULL, NULL, "eint12", NULL}, 6, 12}, + {"PC20", 2, 20, {"gpio_in", "gpio_out", "nand0", "spi2", NULL, NULL, "eint13", NULL}, 6, 13}, + {"PC21", 2, 21, {"gpio_in", "gpio_out", "nand0", "spi2", NULL, NULL, "eint14", NULL}, 6, 14}, + {"PC22", 2, 22, {"gpio_in", "gpio_out", "nand0", "spi2", NULL, NULL, "eint15", NULL}, 6, 15}, {"PC23", 2, 23, {"gpio_in", "gpio_out", NULL, "spi0", NULL, NULL, NULL, NULL}}, {"PC24", 2, 24, {"gpio_in", "gpio_out", "nand0", NULL, NULL, NULL, NULL, NULL}}, @@ -170,28 +170,28 @@ const static struct allwinner_pins a20_pins[] = { {"PG10", 6, 10, {"gpio_in", "gpio_out", "ts1", "csi1", "uart4", "csi0", NULL, NULL}}, {"PG11", 6, 11, {"gpio_in", "gpio_out", "ts1", "csi1", "uart4", "csi0", NULL, NULL}}, - {"PH0", 7, 0, {"gpio_in", "gpio_out", "lcd1", NULL, "uart3", NULL, "eint", "csi1"}}, - {"PH1", 7, 1, {"gpio_in", "gpio_out", "lcd1", NULL, "uart3", NULL, "eint", "csi1"}}, - {"PH2", 7, 2, {"gpio_in", "gpio_out", "lcd1", NULL, "uart3", NULL, "eint", "csi1"}}, - {"PH3", 7, 3, {"gpio_in", "gpio_out", "lcd1", NULL, "uart3", NULL, "eint", "csi1"}}, - {"PH4", 7, 4, {"gpio_in", "gpio_out", "lcd1", NULL, "uart4", NULL, "eint", "csi1"}}, - {"PH5", 7, 5, {"gpio_in", "gpio_out", "lcd1", NULL, "uart4", NULL, "eint", "csi1"}}, - {"PH6", 7, 6, {"gpio_in", "gpio_out", "lcd1", NULL, "uart5", "ms", "eint", "csi1"}}, - {"PH7", 7, 7, {"gpio_in", "gpio_out", "lcd1", NULL, "uart5", "ms", "eint", "csi1"}}, - {"PH8", 7, 8, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "ms", "eint", "csi1"}}, - {"PH9", 7, 9, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "ms", "eint", "csi1"}}, - {"PH10", 7, 10, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "ms", "eint", "csi1"}}, - {"PH11", 7, 11, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "ms", "eint", "csi1"}}, - {"PH12", 7, 12, {"gpio_in", "gpio_out", "lcd1", NULL, "ps2", NULL, "eint", "csi1"}}, - {"PH13", 7, 13, {"gpio_in", "gpio_out", "lcd1", NULL, "ps2", "sim", "eint", "csi1"}}, - {"PH14", 7, 14, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "sim", "eint", "csi1"}}, - {"PH15", 7, 15, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "sim", "eint", "csi1"}}, - {"PH16", 7, 16, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "sim", "eint", "csi1"}}, - {"PH17", 7, 17, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "sim", "eint", "csi1"}}, - {"PH18", 7, 18, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "sim", "eint", "csi1"}}, - {"PH19", 7, 19, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "sim", "eint", "csi1"}}, - {"PH20", 7, 20, {"gpio_in", "gpio_out", "lcd1", NULL, "can", NULL, "eint", "csi1"}}, - {"PH21", 7, 21, {"gpio_in", "gpio_out", "lcd1", NULL, "can", NULL, "eint", "csi1"}}, + {"PH0", 7, 0, {"gpio_in", "gpio_out", "lcd1", NULL, "uart3", NULL, "eint0", "csi1"}, 6, 0}, + {"PH1", 7, 1, {"gpio_in", "gpio_out", "lcd1", NULL, "uart3", NULL, "eint1", "csi1"}, 6, 1}, + {"PH2", 7, 2, {"gpio_in", "gpio_out", "lcd1", NULL, "uart3", NULL, "eint2", "csi1"}, 6, 2}, + {"PH3", 7, 3, {"gpio_in", "gpio_out", "lcd1", NULL, "uart3", NULL, "eint3", "csi1"}, 6, 3}, + {"PH4", 7, 4, {"gpio_in", "gpio_out", "lcd1", NULL, "uart4", NULL, "eint4", "csi1"}, 6, 4}, + {"PH5", 7, 5, {"gpio_in", "gpio_out", "lcd1", NULL, "uart4", NULL, "eint5", "csi1"}, 6, 5}, + {"PH6", 7, 6, {"gpio_in", "gpio_out", "lcd1", NULL, "uart5", "ms", "eint6", "csi1"}, 6, 6}, + {"PH7", 7, 7, {"gpio_in", "gpio_out", "lcd1", NULL, "uart5", "ms", "eint7", "csi1"}, 6, 7}, + {"PH8", 7, 8, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "ms", "eint8", "csi1"}, 6, 8}, + {"PH9", 7, 9, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "ms", "eint9", "csi1"}, 6, 9}, + {"PH10", 7, 10, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "ms", "eint10", "csi1"}, 6, 10}, + {"PH11", 7, 11, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "ms", "eint11", "csi1"}, 6, 11}, + {"PH12", 7, 12, {"gpio_in", "gpio_out", "lcd1", NULL, "ps2", NULL, "eint12", "csi1"}, 6, 12}, + {"PH13", 7, 13, {"gpio_in", "gpio_out", "lcd1", NULL, "ps2", "sim", "eint13", "csi1"}, 6, 13}, + {"PH14", 7, 14, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "sim", "eint14", "csi1"}, 6, 14}, + {"PH15", 7, 15, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "sim", "eint15", "csi1"}, 6, 15}, + {"PH16", 7, 16, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "sim", "eint16", "csi1"}, 6, 16}, + {"PH17", 7, 17, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "sim", "eint17", "csi1"}, 6, 17}, + {"PH18", 7, 18, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "sim", "eint18", "csi1"}, 6, 18}, + {"PH19", 7, 19, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "sim", "eint19", "csi1"}, 6, 19}, + {"PH20", 7, 20, {"gpio_in", "gpio_out", "lcd1", NULL, "can", NULL, "eint20", "csi1"}, 6, 20}, + {"PH21", 7, 21, {"gpio_in", "gpio_out", "lcd1", NULL, "can", NULL, "eint21", "csi1"}, 6, 21}, {"PH22", 7, 22, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "mmc1", NULL, "csi1"}}, {"PH23", 7, 23, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "mmc1", NULL, "csi1"}}, {"PH24", 7, 24, {"gpio_in", "gpio_out", "lcd1", NULL, "keypad", "mmc1", NULL, "csi1"}}, diff --git a/sys/arm/allwinner/a31/a31_padconf.c b/sys/arm/allwinner/a31/a31_padconf.c index 830a0661dcb..60a2befeae7 100644 --- a/sys/arm/allwinner/a31/a31_padconf.c +++ b/sys/arm/allwinner/a31/a31_padconf.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Emmanuel Vadot + * Copyright (c) 2016 Emmanuel Vadot * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -38,43 +38,43 @@ __FBSDID("$FreeBSD$"); #ifdef SOC_ALLWINNER_A31 const static struct allwinner_pins a31_pins[] = { - {"PA0", 0, 0, {"gpio_in", "gpio_out", "gmac", "lcd1", "uart1", NULL, NULL, NULL}}, - {"PA1", 0, 1, {"gpio_in", "gpio_out", "gmac", "lcd1", "uart1", NULL, NULL, NULL}}, - {"PA2", 0, 2, {"gpio_in", "gpio_out", "gmac", "lcd1", "uart1", NULL, NULL, NULL}}, - {"PA3", 0, 3, {"gpio_in", "gpio_out", "gmac", "lcd1", "uart1", NULL, NULL, NULL}}, - {"PA4", 0, 4, {"gpio_in", "gpio_out", "gmac", "lcd1", "uart1", NULL, NULL, NULL}}, - {"PA5", 0, 5, {"gpio_in", "gpio_out", "gmac", "lcd1", "uart1", NULL, NULL, NULL}}, - {"PA6", 0, 6, {"gpio_in", "gpio_out", "gmac", "lcd1", "uart1", NULL, NULL, NULL}}, - {"PA7", 0, 7, {"gpio_in", "gpio_out", "gmac", "lcd1", "uart1", NULL, NULL, NULL}}, - {"PA8", 0, 8, {"gpio_in", "gpio_out", "gmac", "lcd1", NULL, NULL, NULL, NULL}}, - {"PA9", 0, 9, {"gpio_in", "gpio_out", "gmac", "lcd1", NULL, NULL, NULL, NULL}}, - {"PA10", 0, 10, {"gpio_in", "gpio_out", "gmac", "lcd1", "mmc3", "mmc2", NULL, NULL}}, - {"PA11", 0, 11, {"gpio_in", "gpio_out", "gmac", "lcd1", "mmc3", "mmc2", NULL, NULL}}, - {"PA12", 0, 12, {"gpio_in", "gpio_out", "gmac", "lcd1", "mmc3", "mmc2", NULL, NULL}}, - {"PA13", 0, 13, {"gpio_in", "gpio_out", "gmac", "lcd1", "mmc3", "mmc2", NULL, NULL}}, - {"PA14", 0, 14, {"gpio_in", "gpio_out", "gmac", "lcd1", "mmc3", "mmc2", NULL, NULL}}, - {"PA15", 0, 15, {"gpio_in", "gpio_out", "gmac", "lcd1", "clk_out_a", NULL, NULL, NULL}}, - {"PA16", 0, 16, {"gpio_in", "gpio_out", "gmac", "lcd1", "dmic", NULL, NULL, NULL}}, - {"PA17", 0, 17, {"gpio_in", "gpio_out", "gmac", "lcd1", "dmic", NULL, NULL, NULL}}, - {"PA18", 0, 18, {"gpio_in", "gpio_out", "gmac", "lcd1", "clk_out_b", NULL, NULL, NULL}}, - {"PA19", 0, 19, {"gpio_in", "gpio_out", "gmac", "lcd1", "pwm3", NULL, NULL, NULL}}, - {"PA20", 0, 20, {"gpio_in", "gpio_out", "gmac", "lcd1", "pwm3", NULL, NULL, NULL}}, - {"PA21", 0, 21, {"gpio_in", "gpio_out", "gmac", "lcd1", "spi3", NULL, NULL, NULL}}, - {"PA22", 0, 22, {"gpio_in", "gpio_out", "gmac", "lcd1", "spi3", NULL, NULL, NULL}}, - {"PA23", 0, 23, {"gpio_in", "gpio_out", "gmac", "lcd1", "spi3", NULL, NULL, NULL}}, - {"PA24", 0, 24, {"gpio_in", "gpio_out", "gmac", "lcd1", "spi3", NULL, NULL, NULL}}, - {"PA25", 0, 25, {"gpio_in", "gpio_out", "gmac", "lcd1", "spi3", NULL, NULL, NULL}}, - {"PA26", 0, 26, {"gpio_in", "gpio_out", "gmac", "lcd1", "clk_out_c", NULL, NULL, NULL}}, - {"PA27", 0, 27, {"gpio_in", "gpio_out", "gmac", "lcd1", NULL, NULL, NULL, NULL}}, + {"PA0", 0, 0, {"gpio_in", "gpio_out", "gmac", "lcd1", "uart1", NULL, "pa_eint0", NULL}, 6, 0}, + {"PA1", 0, 1, {"gpio_in", "gpio_out", "gmac", "lcd1", "uart1", NULL, "pa_eint1", NULL}, 6, 1}, + {"PA2", 0, 2, {"gpio_in", "gpio_out", "gmac", "lcd1", "uart1", NULL, "pa_eint2", NULL}, 6, 2}, + {"PA3", 0, 3, {"gpio_in", "gpio_out", "gmac", "lcd1", "uart1", NULL, "pa_eint3", NULL}, 6, 3}, + {"PA4", 0, 4, {"gpio_in", "gpio_out", "gmac", "lcd1", "uart1", NULL, "pa_eint4", NULL}, 6, 4}, + {"PA5", 0, 5, {"gpio_in", "gpio_out", "gmac", "lcd1", "uart1", NULL, "pa_eint5", NULL}, 6, 5}, + {"PA6", 0, 6, {"gpio_in", "gpio_out", "gmac", "lcd1", "uart1", NULL, "pa_eint6", NULL}, 6, 6}, + {"PA7", 0, 7, {"gpio_in", "gpio_out", "gmac", "lcd1", "uart1", NULL, "pa_eint7", NULL}, 6, 7}, + {"PA8", 0, 8, {"gpio_in", "gpio_out", "gmac", "lcd1", NULL, NULL, "pa_eint8", NULL}, 6, 8}, + {"PA9", 0, 9, {"gpio_in", "gpio_out", "gmac", "lcd1", NULL, "mmc2", "pa_eint9", NULL}, 6, 9}, + {"PA10", 0, 10, {"gpio_in", "gpio_out", "gmac", "lcd1", "mmc3", "mmc2", "pa_eint10", NULL}, 6, 10}, + {"PA11", 0, 11, {"gpio_in", "gpio_out", "gmac", "lcd1", "mmc3", "mmc2", "pa_eint11", NULL}, 6, 11}, + {"PA12", 0, 12, {"gpio_in", "gpio_out", "gmac", "lcd1", "mmc3", "mmc2", "pa_eint12", NULL}, 6, 12}, + {"PA13", 0, 13, {"gpio_in", "gpio_out", "gmac", "lcd1", "mmc3", "mmc2", "pa_eint13", NULL}, 6, 13}, + {"PA14", 0, 14, {"gpio_in", "gpio_out", "gmac", "lcd1", "mmc3", "mmc2", "pa_eint14", NULL}, 6, 14}, + {"PA15", 0, 15, {"gpio_in", "gpio_out", "gmac", "lcd1", "clk_out_a", NULL, "pa_eint15", NULL}, 6, 15}, + {"PA16", 0, 16, {"gpio_in", "gpio_out", "gmac", "lcd1", "dmic", NULL, "pa_eint16", NULL}, 6, 16}, + {"PA17", 0, 17, {"gpio_in", "gpio_out", "gmac", "lcd1", "dmic", NULL, "pa_eint17", NULL}, 6, 17}, + {"PA18", 0, 18, {"gpio_in", "gpio_out", "gmac", "lcd1", "clk_out_b", NULL, "pa_eint18", NULL}, 6, 18}, + {"PA19", 0, 19, {"gpio_in", "gpio_out", "gmac", "lcd1", "pwm3", NULL, "pa_eint19", NULL}, 6, 19}, + {"PA20", 0, 20, {"gpio_in", "gpio_out", "gmac", "lcd1", "pwm3", NULL, "pa_eint20", NULL}, 6, 20}, + {"PA21", 0, 21, {"gpio_in", "gpio_out", "gmac", "lcd1", "spi3", NULL, "pa_eint21", NULL}, 6, 21}, + {"PA22", 0, 22, {"gpio_in", "gpio_out", "gmac", "lcd1", "spi3", NULL, "pa_eint22", NULL}, 6, 22}, + {"PA23", 0, 23, {"gpio_in", "gpio_out", "gmac", "lcd1", "spi3", NULL, "pa_eint23", NULL}, 6, 23}, + {"PA24", 0, 24, {"gpio_in", "gpio_out", "gmac", "lcd1", "spi3", NULL, "pa_eint24", NULL}, 6, 24}, + {"PA25", 0, 25, {"gpio_in", "gpio_out", "gmac", "lcd1", "spi3", NULL, "pa_eint25", NULL}, 6, 25}, + {"PA26", 0, 26, {"gpio_in", "gpio_out", "gmac", "lcd1", "clk_out_c", NULL, "pa_eint26", NULL}, 6, 26}, + {"PA27", 0, 27, {"gpio_in", "gpio_out", "gmac", "lcd1", NULL, NULL, "pa_eint27", NULL}, 6, 27}, - {"PB0", 1, 0, {"gpio_in", "gpio_out", "i2s0", "uart3", "csi", NULL, NULL, NULL}}, - {"PB1", 1, 1, {"gpio_in", "gpio_out", "i2s0", NULL, NULL, NULL, NULL, NULL}}, - {"PB2", 1, 2, {"gpio_in", "gpio_out", "i2s0", NULL, NULL, NULL, NULL, NULL}}, - {"PB3", 1, 3, {"gpio_in", "gpio_out", "i2s0", NULL, NULL, NULL, NULL, NULL}}, - {"PB4", 1, 4, {"gpio_in", "gpio_out", "i2s0", "uart3", NULL, NULL, NULL, NULL}}, - {"PB5", 1, 5, {"gpio_in", "gpio_out", "i2s0", "uart3", "i2c3", NULL, NULL, NULL}}, - {"PB6", 1, 6, {"gpio_in", "gpio_out", "i2s0", "uart3", "i2c3", NULL, NULL, NULL}}, - {"PB7", 1, 7, {"gpio_in", "gpio_out", "i2s0", NULL, NULL, NULL, NULL, NULL}}, + {"PB0", 1, 0, {"gpio_in", "gpio_out", "i2s0", "uart3", "csi", NULL, "pb_eint0", NULL}, 6, 0}, + {"PB1", 1, 1, {"gpio_in", "gpio_out", "i2s0", NULL, NULL, NULL, "pb_eint1", NULL}, 6, 1}, + {"PB2", 1, 2, {"gpio_in", "gpio_out", "i2s0", NULL, NULL, NULL, "pb_eint2", NULL}, 6, 2}, + {"PB3", 1, 3, {"gpio_in", "gpio_out", "i2s0", NULL, NULL, NULL, "pb_eint3", NULL}, 6, 3}, + {"PB4", 1, 4, {"gpio_in", "gpio_out", "i2s0", "uart3", NULL, NULL, "pb_eint4", NULL}, 6, 4}, + {"PB5", 1, 5, {"gpio_in", "gpio_out", "i2s0", "uart3", "i2c3", NULL, "pb_eint5", NULL}, 6, 5}, + {"PB6", 1, 6, {"gpio_in", "gpio_out", "i2s0", "uart3", "i2c3", NULL, "pb_eint6", NULL}, 6, 6}, + {"PB7", 1, 7, {"gpio_in", "gpio_out", "i2s0", NULL, NULL, NULL, "pb_eint7", NULL}, 6, 7}, {"PC0", 2, 0, {"gpio_in", "gpio_out", "nand0", "spi0", NULL, NULL, NULL, NULL}}, {"PC1", 2, 1, {"gpio_in", "gpio_out", "nand0", "spi0", NULL, NULL, NULL, NULL}}, @@ -101,9 +101,9 @@ const static struct allwinner_pins a31_pins[] = { {"PC22", 2, 22, {"gpio_in", "gpio_out", "nand0", "nand1", NULL, NULL, NULL, NULL}}, {"PC23", 2, 23, {"gpio_in", "gpio_out", "nand0", "nand1", NULL, NULL, NULL, NULL}}, {"PC24", 2, 24, {"gpio_in", "gpio_out", "nand0", "mmc2", "mmc3", NULL, NULL, NULL}}, - {"PC25", 2, 24, {"gpio_in", "gpio_out", "nand0", NULL, NULL, NULL, NULL, NULL}}, - {"PC26", 2, 24, {"gpio_in", "gpio_out", "nand0", NULL, NULL, NULL, NULL, NULL}}, - {"PC27", 2, 24, {"gpio_in", "gpio_out", NULL, "spi0",NULL, NULL, NULL, NULL}}, + {"PC25", 2, 25, {"gpio_in", "gpio_out", "nand0", NULL, NULL, NULL, NULL, NULL}}, + {"PC26", 2, 26, {"gpio_in", "gpio_out", "nand0", NULL, NULL, NULL, NULL, NULL}}, + {"PC27", 2, 27, {"gpio_in", "gpio_out", NULL, "spi0",NULL, NULL, NULL, NULL}}, {"PD0", 3, 0, {"gpio_in", "gpio_out", "lcd0", "lvds0", NULL, NULL, NULL, NULL}}, {"PD1", 3, 1, {"gpio_in", "gpio_out", "lcd0", "lvds0", NULL, NULL, NULL, NULL}}, @@ -134,23 +134,23 @@ const static struct allwinner_pins a31_pins[] = { {"PD26", 3, 26, {"gpio_in", "gpio_out", "lcd0", NULL, NULL, NULL, NULL, NULL}}, {"PD27", 3, 27, {"gpio_in", "gpio_out", "lcd0", NULL, NULL, NULL, NULL, NULL}}, - {"PE0", 4, 0, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE1", 4, 1, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE2", 4, 2, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE3", 4, 3, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE4", 4, 4, {"gpio_in", "gpio_out", "csi", "uart5", NULL, NULL, NULL, NULL}}, - {"PE5", 4, 5, {"gpio_in", "gpio_out", "csi", "uart5", NULL, NULL, NULL, NULL}}, - {"PE6", 4, 6, {"gpio_in", "gpio_out", "csi", "uart5", NULL, NULL, NULL, NULL}}, - {"PE7", 4, 7, {"gpio_in", "gpio_out", "csi", "uart5", NULL, NULL, NULL, NULL}}, - {"PE8", 4, 8, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE9", 4, 9, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE10", 4, 10, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE11", 4, 11, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE12", 4, 12, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE13", 4, 13, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE14", 4, 14, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE15", 4, 15, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE16", 4, 16, {"gpio_in", "gpio_out", "csi", NULL, NULL, NULL, NULL, NULL}}, + {"PE0", 4, 0, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint0", NULL}, 6, 0}, + {"PE1", 4, 1, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint1", NULL}, 6, 1}, + {"PE2", 4, 2, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint2", NULL}, 6, 2}, + {"PE3", 4, 3, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint3", NULL}, 6, 3}, + {"PE4", 4, 4, {"gpio_in", "gpio_out", "csi", "uart5", NULL, NULL, "pe_eint4", NULL}, 6, 4}, + {"PE5", 4, 5, {"gpio_in", "gpio_out", "csi", "uart5", NULL, NULL, "pe_eint5", NULL}, 6, 5}, + {"PE6", 4, 6, {"gpio_in", "gpio_out", "csi", "uart5", NULL, NULL, "pe_eint6", NULL}, 6, 6}, + {"PE7", 4, 7, {"gpio_in", "gpio_out", "csi", "uart5", NULL, NULL, "pe_eint7", NULL}, 6, 7}, + {"PE8", 4, 8, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint8", NULL}, 6, 8}, + {"PE9", 4, 9, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint9", NULL}, 6, 9}, + {"PE10", 4, 10, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint10", NULL}, 6, 10}, + {"PE11", 4, 11, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint11", NULL}, 6, 11}, + {"PE12", 4, 12, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint12", NULL}, 6, 12}, + {"PE13", 4, 13, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint13", NULL}, 6, 13}, + {"PE14", 4, 14, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint14", NULL}, 6, 14}, + {"PE15", 4, 15, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint15", NULL}, 6, 15}, + {"PE16", 4, 16, {"gpio_in", "gpio_out", "csi", NULL, NULL, NULL, "pe_eint16", NULL}, 6, 16}, {"PF0", 5, 0, {"gpio_in", "gpio_out", "mmc0", NULL, "jtag", NULL, NULL, NULL}}, {"PF1", 5, 1, {"gpio_in", "gpio_out", "mmc0", NULL, "jtag", NULL, NULL, NULL}}, @@ -159,25 +159,25 @@ const static struct allwinner_pins a31_pins[] = { {"PF4", 5, 4, {"gpio_in", "gpio_out", "mmc0", NULL, "uart0", NULL, NULL, NULL}}, {"PF5", 5, 5, {"gpio_in", "gpio_out", "mmc0", NULL, "jtag", NULL, NULL, NULL}}, - {"PG0", 6, 0, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, NULL}}, - {"PG1", 6, 1, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, NULL}}, - {"PG2", 6, 2, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, NULL}}, - {"PG3", 6, 3, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, NULL}}, - {"PG4", 6, 4, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, NULL}}, - {"PG5", 6, 5, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, NULL}}, - {"PG6", 6, 6, {"gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, NULL, NULL}}, - {"PG7", 6, 7, {"gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, NULL, NULL}}, - {"PG8", 6, 8, {"gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, NULL, NULL}}, - {"PG9", 6, 9, {"gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, NULL, NULL}}, - {"PG10", 6, 10, {"gpio_in", "gpio_out", "i2c3", "usb", NULL, NULL, NULL, NULL}}, - {"PG11", 6, 11, {"gpio_in", "gpio_out", "i2c3", "usb", NULL, NULL, NULL, NULL}}, - {"PG12", 6, 11, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, NULL, NULL}}, - {"PG13", 6, 11, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, NULL, NULL}}, - {"PG14", 6, 11, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, NULL, NULL}}, - {"PG15", 6, 11, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, NULL, NULL}}, - {"PG16", 6, 11, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, NULL, NULL}}, - {"PG17", 6, 11, {"gpio_in", "gpio_out", "uart4", NULL, NULL, NULL, NULL, NULL}}, - {"PG18", 6, 11, {"gpio_in", "gpio_out", "uart4", NULL, NULL, NULL, NULL, NULL}}, + {"PG0", 6, 0, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint0", NULL}, 6, 0}, + {"PG1", 6, 1, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint1", NULL}, 6, 1}, + {"PG2", 6, 2, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint2", NULL}, 6, 2}, + {"PG3", 6, 3, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint3", NULL}, 6, 3}, + {"PG4", 6, 4, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint4", NULL}, 6, 4}, + {"PG5", 6, 5, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint5", NULL}, 6, 5}, + {"PG6", 6, 6, {"gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, "pg_eint6", NULL}, 6, 6}, + {"PG7", 6, 7, {"gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, "pg_eint7", NULL}, 6, 7}, + {"PG8", 6, 8, {"gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, "pg_eint8", NULL}, 6, 8}, + {"PG9", 6, 9, {"gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, "pg_eint9", NULL}, 6, 9}, + {"PG10", 6, 10, {"gpio_in", "gpio_out", "i2c3", "usb", NULL, NULL, "pg_eint10", NULL}, 6, 10}, + {"PG11", 6, 11, {"gpio_in", "gpio_out", "i2c3", "usb", NULL, NULL, "pg_eint11", NULL}, 6, 11}, + {"PG12", 6, 12, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, "pg_eint12", NULL}, 6, 12}, + {"PG13", 6, 13, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, "pg_eint13", NULL}, 6, 13}, + {"PG14", 6, 14, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, "pg_eint14", NULL}, 6, 14}, + {"PG15", 6, 15, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, "pg_eint15", NULL}, 6, 15}, + {"PG16", 6, 16, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, "pg_eint16", NULL}, 6, 16}, + {"PG17", 6, 17, {"gpio_in", "gpio_out", "uart4", NULL, NULL, NULL, "pg_eint17", NULL}, 6, 17}, + {"PG18", 6, 18, {"gpio_in", "gpio_out", "uart4", NULL, NULL, NULL, "pg_eint18", NULL}, 6, 18}, {"PH0", 7, 0, {"gpio_in", "gpio_out", "nand1", NULL, NULL, NULL, NULL, NULL}}, {"PH1", 7, 1, {"gpio_in", "gpio_out", "nand1", NULL, NULL, NULL, NULL, NULL}}, diff --git a/sys/arm/allwinner/a31/a31_r_padconf.c b/sys/arm/allwinner/a31/a31_r_padconf.c index b36b0d3c72b..306f129f468 100644 --- a/sys/arm/allwinner/a31/a31_r_padconf.c +++ b/sys/arm/allwinner/a31/a31_r_padconf.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Emmanuel Vadot + * Copyright (c) 2016 Emmanuel Vadot * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,19 +43,19 @@ const static struct allwinner_pins a31_r_pins[] = { {"PL2", 0, 2, {"gpio_in", "gpio_out", "s_uart", NULL, NULL, NULL, NULL, NULL}}, {"PL3", 0, 3, {"gpio_in", "gpio_out", "s_uart", NULL, NULL, NULL, NULL, NULL}}, {"PL4", 0, 4, {"gpio_in", "gpio_out", "s_ir", NULL, NULL, NULL, NULL, NULL}}, - {"PL5", 0, 5, {"gpio_in", "gpio_out", "pl_eint0", "s_jtag", NULL, NULL, NULL, NULL}}, - {"PL6", 0, 6, {"gpio_in", "gpio_out", "pl_eint1", "s_jtag", NULL, NULL, NULL, NULL}}, - {"PL7", 0, 7, {"gpio_in", "gpio_out", "pl_eint2", "s_jtag", NULL, NULL, NULL, NULL}}, - {"PL8", 0, 8, {"gpio_in", "gpio_out", "pl_eint3", "s_jtag", NULL, NULL, NULL, NULL}}, + {"PL5", 0, 5, {"gpio_in", "gpio_out", "pl_eint0", "s_jtag", NULL, NULL, NULL, NULL}, 2, 0}, + {"PL6", 0, 6, {"gpio_in", "gpio_out", "pl_eint1", "s_jtag", NULL, NULL, NULL, NULL}, 2, 1}, + {"PL7", 0, 7, {"gpio_in", "gpio_out", "pl_eint2", "s_jtag", NULL, NULL, NULL, NULL}, 2, 2}, + {"PL8", 0, 8, {"gpio_in", "gpio_out", "pl_eint3", "s_jtag", NULL, NULL, NULL, NULL}, 2, 3}, - {"PM0", 1, 0, {"gpio_in", "gpio_out", "pm_eint0", NULL, NULL, NULL, NULL, NULL}}, - {"PM1", 1, 1, {"gpio_in", "gpio_out", "pm_eint1", NULL, NULL, NULL, NULL, NULL}}, - {"PM2", 1, 2, {"gpio_in", "gpio_out", "pm_eint2", "1wire", NULL, NULL, NULL, NULL}}, - {"PM3", 1, 3, {"gpio_in", "gpio_out", "pm_eint3", NULL, NULL, NULL, NULL, NULL}}, - {"PM4", 1, 4, {"gpio_in", "gpio_out", "pm_eint4", NULL, NULL, NULL, NULL, NULL}}, - {"PM5", 1, 5, {"gpio_in", "gpio_out", "pm_eint5", NULL, NULL, NULL, NULL, NULL}}, - {"PM6", 1, 6, {"gpio_in", "gpio_out", "pm_eint6", NULL, NULL, NULL, NULL, NULL}}, - {"PM7", 1, 7, {"gpio_in", "gpio_out", "pm_eint7", "rtc", NULL, NULL, NULL, NULL}}, + {"PM0", 1, 0, {"gpio_in", "gpio_out", "pm_eint0", NULL, NULL, NULL, NULL, NULL}, 2, 0}, + {"PM1", 1, 1, {"gpio_in", "gpio_out", "pm_eint1", NULL, NULL, NULL, NULL, NULL}, 2, 1}, + {"PM2", 1, 2, {"gpio_in", "gpio_out", "pm_eint2", "1wire", NULL, NULL, NULL, NULL}, 2, 2}, + {"PM3", 1, 3, {"gpio_in", "gpio_out", "pm_eint3", NULL, NULL, NULL, NULL, NULL}, 2, 3}, + {"PM4", 1, 4, {"gpio_in", "gpio_out", "pm_eint4", NULL, NULL, NULL, NULL, NULL}, 2, 4}, + {"PM5", 1, 5, {"gpio_in", "gpio_out", "pm_eint5", NULL, NULL, NULL, NULL, NULL}, 2, 5}, + {"PM6", 1, 6, {"gpio_in", "gpio_out", "pm_eint6", NULL, NULL, NULL, NULL, NULL}, 2, 6}, + {"PM7", 1, 7, {"gpio_in", "gpio_out", "pm_eint7", "rtc", NULL, NULL, NULL, NULL}, 2, 7}, }; const struct allwinner_padconf a31_r_padconf = { diff --git a/sys/arm/allwinner/a31/a31s_padconf.c b/sys/arm/allwinner/a31/a31s_padconf.c index 1901313cc27..7b0317cc6a2 100644 --- a/sys/arm/allwinner/a31/a31s_padconf.c +++ b/sys/arm/allwinner/a31/a31s_padconf.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Emmanuel Vadot + * Copyright (c) 2016 Emmanuel Vadot * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -38,43 +38,43 @@ __FBSDID("$FreeBSD$"); #ifdef SOC_ALLWINNER_A31S const static struct allwinner_pins a31s_pins[] = { - {"PA0", 0, 0, {"gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, NULL, NULL}}, - {"PA1", 0, 1, {"gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, NULL, NULL}}, - {"PA2", 0, 2, {"gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, NULL, NULL}}, - {"PA3", 0, 3, {"gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, NULL, NULL}}, - {"PA4", 0, 4, {"gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, NULL, NULL}}, - {"PA5", 0, 5, {"gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, NULL, NULL}}, - {"PA6", 0, 6, {"gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, NULL, NULL}}, - {"PA7", 0, 7, {"gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, NULL, NULL}}, - {"PA8", 0, 8, {"gpio_in", "gpio_out", "gmac", NULL, NULL, NULL, NULL, NULL}}, - {"PA9", 0, 9, {"gpio_in", "gpio_out", "gmac", NULL, NULL, NULL, NULL, NULL}}, - {"PA10", 0, 10, {"gpio_in", "gpio_out", "gmac", NULL, "mmc3", "mmc2", NULL, NULL}}, - {"PA11", 0, 11, {"gpio_in", "gpio_out", "gmac", NULL, "mmc3", "mmc2", NULL, NULL}}, - {"PA12", 0, 12, {"gpio_in", "gpio_out", "gmac", NULL, "mmc3", "mmc2", NULL, NULL}}, - {"PA13", 0, 13, {"gpio_in", "gpio_out", "gmac", NULL, "mmc3", "mmc2", NULL, NULL}}, - {"PA14", 0, 14, {"gpio_in", "gpio_out", "gmac", NULL, "mmc3", "mmc2", NULL, NULL}}, - {"PA15", 0, 15, {"gpio_in", "gpio_out", "gmac", NULL, "dmic", NULL, NULL, NULL}}, - {"PA16", 0, 16, {"gpio_in", "gpio_out", "gmac", NULL, "dmic", NULL, NULL, NULL}}, - {"PA17", 0, 17, {"gpio_in", "gpio_out", "gmac", NULL, "clk_out_b", NULL, NULL, NULL}}, - {"PA18", 0, 17, {"gpio_in", "gpio_out", "gmac", NULL, "pwm3", NULL, NULL, NULL}}, - {"PA19", 0, 17, {"gpio_in", "gpio_out", "gmac", NULL, "pwm3", NULL, NULL, NULL}}, - {"PA20", 0, 17, {"gpio_in", "gpio_out", "gmac", NULL, "spi3", NULL, NULL, NULL}}, - {"PA21", 0, 17, {"gpio_in", "gpio_out", "gmac", NULL, "spi3", NULL, NULL, NULL}}, - {"PA22", 0, 17, {"gpio_in", "gpio_out", "gmac", NULL, "spi3", NULL, NULL, NULL}}, - {"PA23", 0, 17, {"gpio_in", "gpio_out", "gmac", NULL, "spi3", NULL, NULL, NULL}}, - {"PA24", 0, 17, {"gpio_in", "gpio_out", "gmac", NULL, "spi3", NULL, NULL, NULL}}, - {"PA25", 0, 17, {"gpio_in", "gpio_out", "gmac", NULL, "spi3", NULL, NULL, NULL}}, - {"PA26", 0, 17, {"gpio_in", "gpio_out", "gmac", NULL, "clk_out_c", NULL, NULL, NULL}}, - {"PA27", 0, 17, {"gpio_in", "gpio_out", "gmac", NULL, NULL, NULL, NULL, NULL}}, + {"PA0", 0, 0, {"gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, "pa_eint0", NULL}, 6, 0}, + {"PA1", 0, 1, {"gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, "pa_eint1", NULL}, 6, 1}, + {"PA2", 0, 2, {"gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, "pa_eint2", NULL}, 6, 2}, + {"PA3", 0, 3, {"gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, "pa_eint3", NULL}, 6, 3}, + {"PA4", 0, 4, {"gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, "pa_eint4", NULL}, 6, 4}, + {"PA5", 0, 5, {"gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, "pa_eint5", NULL}, 6, 5}, + {"PA6", 0, 6, {"gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, "pa_eint6", NULL}, 6, 6}, + {"PA7", 0, 7, {"gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, "pa_eint7", NULL}, 6, 7}, + {"PA8", 0, 8, {"gpio_in", "gpio_out", "gmac", NULL, NULL, NULL, "pa_eint8", NULL}, 6, 8}, + {"PA9", 0, 9, {"gpio_in", "gpio_out", "gmac", NULL, NULL, NULL, "pa_eint9", NULL}, 6, 9}, + {"PA10", 0, 10, {"gpio_in", "gpio_out", "gmac", NULL, "mmc3", "mmc2", "pa_eint10", NULL}, 6, 10}, + {"PA11", 0, 11, {"gpio_in", "gpio_out", "gmac", NULL, "mmc3", "mmc2", "pa_eint11", NULL}, 6, 11}, + {"PA12", 0, 12, {"gpio_in", "gpio_out", "gmac", NULL, "mmc3", "mmc2", "pa_eint12", NULL}, 6, 12}, + {"PA13", 0, 13, {"gpio_in", "gpio_out", "gmac", NULL, "mmc3", "mmc2", "pa_eint13", NULL}, 6, 13}, + {"PA14", 0, 14, {"gpio_in", "gpio_out", "gmac", NULL, "mmc3", "mmc2", "pa_eint14", NULL}, 6, 14}, + {"PA15", 0, 15, {"gpio_in", "gpio_out", "gmac", NULL, "dmic", NULL, "pa_eint15", NULL}, 6, 15}, + {"PA16", 0, 16, {"gpio_in", "gpio_out", "gmac", NULL, "dmic", NULL, "pa_eint16", NULL}, 6, 16}, + {"PA17", 0, 17, {"gpio_in", "gpio_out", "gmac", NULL, "clk_out_b", NULL, "pa_eint17", NULL}, 6, 17}, + {"PA18", 0, 18, {"gpio_in", "gpio_out", "gmac", NULL, "pwm3", NULL, "pa_eint18", NULL}, 6, 18}, + {"PA19", 0, 19, {"gpio_in", "gpio_out", "gmac", NULL, "pwm3", NULL, "pa_eint19", NULL}, 6, 19}, + {"PA20", 0, 20, {"gpio_in", "gpio_out", "gmac", NULL, "spi3", NULL, "pa_eint20", NULL}, 6, 20}, + {"PA21", 0, 21, {"gpio_in", "gpio_out", "gmac", NULL, "spi3", NULL, "pa_eint21", NULL}, 6, 21}, + {"PA22", 0, 22, {"gpio_in", "gpio_out", "gmac", NULL, "spi3", NULL, "pa_eint22", NULL}, 6, 22}, + {"PA23", 0, 23, {"gpio_in", "gpio_out", "gmac", NULL, "spi3", NULL, "pa_eint23", NULL}, 6, 23}, + {"PA24", 0, 24, {"gpio_in", "gpio_out", "gmac", NULL, "spi3", NULL, "pa_eint24", NULL}, 6, 24}, + {"PA25", 0, 25, {"gpio_in", "gpio_out", "gmac", NULL, "spi3", NULL, "pa_eint25", NULL}, 6, 25}, + {"PA26", 0, 26, {"gpio_in", "gpio_out", "gmac", NULL, "clk_out_c", NULL, "pa_eint26", NULL}, 6, 26}, + {"PA27", 0, 27, {"gpio_in", "gpio_out", "gmac", NULL, NULL, NULL, "pa_eint27", NULL}, 6, 27}, - {"PB0", 1, 0, {"gpio_in", "gpio_out", "i2s0", "uart3", NULL , NULL, NULL, NULL}}, - {"PB1", 1, 1, {"gpio_in", "gpio_out", "i2s0", NULL, NULL, NULL, NULL, NULL}}, - {"PB2", 1, 2, {"gpio_in", "gpio_out", "i2s0", NULL, NULL, NULL, NULL, NULL}}, - {"PB3", 1, 3, {"gpio_in", "gpio_out", "i2s0", NULL, NULL, NULL, NULL, NULL}}, - {"PB4", 1, 4, {"gpio_in", "gpio_out", "i2s0", "uart3", NULL, NULL, NULL, NULL}}, - {"PB5", 1, 5, {"gpio_in", "gpio_out", "i2s0", "uart3", "i2c3", NULL, NULL, NULL}}, - {"PB6", 1, 6, {"gpio_in", "gpio_out", "i2s0", "uart3", "i2c3", NULL, NULL, NULL}}, - {"PB7", 1, 7, {"gpio_in", "gpio_out", "i2s0", NULL, NULL, NULL, NULL, NULL}}, + {"PB0", 1, 0, {"gpio_in", "gpio_out", "i2s0", "uart3", NULL , NULL, "pb_eint0", NULL}, 6, 0}, + {"PB1", 1, 1, {"gpio_in", "gpio_out", "i2s0", NULL, NULL, NULL, "pb_eint1", NULL}, 6, 1}, + {"PB2", 1, 2, {"gpio_in", "gpio_out", "i2s0", NULL, NULL, NULL, "pb_eint2", NULL}, 6, 2}, + {"PB3", 1, 3, {"gpio_in", "gpio_out", "i2s0", NULL, NULL, NULL, "pb_eint3", NULL}, 6, 3}, + {"PB4", 1, 4, {"gpio_in", "gpio_out", "i2s0", "uart3", NULL, NULL, "pb_eint4", NULL}, 6, 4}, + {"PB5", 1, 5, {"gpio_in", "gpio_out", "i2s0", "uart3", "i2c3", NULL, "pb_eint5", NULL}, 6, 5}, + {"PB6", 1, 6, {"gpio_in", "gpio_out", "i2s0", "uart3", "i2c3", NULL, "pb_eint6", NULL}, 6, 6}, + {"PB7", 1, 7, {"gpio_in", "gpio_out", "i2s0", NULL, NULL, NULL, "pb_eint7", NULL}, 6, 7}, {"PC0", 2, 0, {"gpio_in", "gpio_out", "nand0", "spi0", NULL, NULL, NULL, NULL}}, {"PC1", 2, 1, {"gpio_in", "gpio_out", "nand0", "spi0", NULL, NULL, NULL, NULL}}, @@ -93,9 +93,9 @@ const static struct allwinner_pins a31s_pins[] = { {"PC14", 2, 14, {"gpio_in", "gpio_out", "nand0", "mmc2", "mmc3", NULL, NULL, NULL}}, {"PC15", 2, 15, {"gpio_in", "gpio_out", "nand0", "mmc2", "mmc3", NULL, NULL, NULL}}, {"PC24", 2, 24, {"gpio_in", "gpio_out", "nand0", "mmc2", "mmc3", NULL, NULL, NULL}}, - {"PC25", 2, 24, {"gpio_in", "gpio_out", "nand0", NULL, NULL, NULL, NULL, NULL}}, - {"PC26", 2, 24, {"gpio_in", "gpio_out", "nand0", NULL, NULL, NULL, NULL, NULL}}, - {"PC27", 2, 24, {"gpio_in", "gpio_out", NULL, "spi0",NULL, NULL, NULL, NULL}}, + {"PC25", 2, 25, {"gpio_in", "gpio_out", "nand0", NULL, NULL, NULL, NULL, NULL}}, + {"PC26", 2, 26, {"gpio_in", "gpio_out", "nand0", NULL, NULL, NULL, NULL, NULL}}, + {"PC27", 2, 27, {"gpio_in", "gpio_out", NULL, "spi0",NULL, NULL, NULL, NULL}}, {"PD0", 3, 0, {"gpio_in", "gpio_out", "lcd0", "lvds0", NULL, NULL, NULL, NULL}}, {"PD1", 3, 1, {"gpio_in", "gpio_out", "lcd0", "lvds0", NULL, NULL, NULL, NULL}}, @@ -126,22 +126,22 @@ const static struct allwinner_pins a31s_pins[] = { {"PD26", 3, 26, {"gpio_in", "gpio_out", "lcd0", NULL, NULL, NULL, NULL, NULL}}, {"PD27", 3, 27, {"gpio_in", "gpio_out", "lcd0", NULL, NULL, NULL, NULL, NULL}}, - {"PE0", 4, 0, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE1", 4, 1, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE2", 4, 2, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE3", 4, 3, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE4", 4, 4, {"gpio_in", "gpio_out", "csi", "uart5", NULL, NULL, NULL, NULL}}, - {"PE5", 4, 5, {"gpio_in", "gpio_out", "csi", "uart5", NULL, NULL, NULL, NULL}}, - {"PE6", 4, 6, {"gpio_in", "gpio_out", "csi", "uart5", NULL, NULL, NULL, NULL}}, - {"PE7", 4, 7, {"gpio_in", "gpio_out", "csi", "uart5", NULL, NULL, NULL, NULL}}, - {"PE8", 4, 8, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE9", 4, 9, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE10", 4, 10, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE11", 4, 11, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE12", 4, 11, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE13", 4, 11, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE14", 4, 11, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, - {"PE15", 4, 11, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, NULL, NULL}}, + {"PE0", 4, 0, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint0", NULL}, 6, 0}, + {"PE1", 4, 1, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint1", NULL}, 6, 1}, + {"PE2", 4, 2, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint2", NULL}, 6, 2}, + {"PE3", 4, 3, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint3", NULL}, 6, 3}, + {"PE4", 4, 4, {"gpio_in", "gpio_out", "csi", "uart5", NULL, NULL, "pe_eint4", NULL}, 6, 4}, + {"PE5", 4, 5, {"gpio_in", "gpio_out", "csi", "uart5", NULL, NULL, "pe_eint5", NULL}, 6, 5}, + {"PE6", 4, 6, {"gpio_in", "gpio_out", "csi", "uart5", NULL, NULL, "pe_eint6", NULL}, 6, 6}, + {"PE7", 4, 7, {"gpio_in", "gpio_out", "csi", "uart5", NULL, NULL, "pe_eint7", NULL}, 6, 7}, + {"PE8", 4, 8, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint8", NULL}, 6, 8}, + {"PE9", 4, 9, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint9", NULL}, 6, 9}, + {"PE10", 4, 10, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint10", NULL}, 6, 10}, + {"PE11", 4, 11, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint11", NULL}, 6, 11}, + {"PE12", 4, 12, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint12", NULL}, 6, 12}, + {"PE13", 4, 13, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint13", NULL}, 6, 13}, + {"PE14", 4, 14, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint14", NULL}, 6, 14}, + {"PE15", 4, 15, {"gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "pe_eint15", NULL}, 6, 15}, {"PF0", 5, 0, {"gpio_in", "gpio_out", "mmc0", NULL, "jtag", NULL, NULL, NULL}}, {"PF1", 5, 1, {"gpio_in", "gpio_out", "mmc0", NULL, "jtag", NULL, NULL, NULL}}, @@ -150,25 +150,25 @@ const static struct allwinner_pins a31s_pins[] = { {"PF4", 5, 4, {"gpio_in", "gpio_out", "mmc0", NULL, "uart0", NULL, NULL, NULL}}, {"PF5", 5, 5, {"gpio_in", "gpio_out", "mmc0", NULL, "jtag", NULL, NULL, NULL}}, - {"PG0", 6, 0, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, NULL}}, - {"PG1", 6, 1, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, NULL}}, - {"PG2", 6, 2, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, NULL}}, - {"PG3", 6, 3, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, NULL}}, - {"PG4", 6, 4, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, NULL}}, - {"PG5", 6, 5, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, NULL}}, - {"PG6", 6, 6, {"gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, NULL, NULL}}, - {"PG7", 6, 7, {"gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, NULL, NULL}}, - {"PG8", 6, 8, {"gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, NULL, NULL}}, - {"PG9", 6, 9, {"gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, NULL, NULL}}, - {"PG10", 6, 10, {"gpio_in", "gpio_out", "i2c3", NULL, NULL, NULL, NULL, NULL}}, - {"PG11", 6, 11, {"gpio_in", "gpio_out", "i2c3", NULL, NULL, NULL, NULL, NULL}}, - {"PG12", 6, 11, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, NULL, NULL}}, - {"PG13", 6, 11, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, NULL, NULL}}, - {"PG14", 6, 11, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, NULL, NULL}}, - {"PG15", 6, 11, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, NULL, NULL}}, - {"PG16", 6, 11, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, NULL, NULL}}, - {"PG17", 6, 11, {"gpio_in", "gpio_out", "uart4", NULL, NULL, NULL, NULL, NULL}}, - {"PG18", 6, 11, {"gpio_in", "gpio_out", "uart4", NULL, NULL, NULL, NULL, NULL}}, + {"PG0", 6, 0, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint0", NULL}, 6, 0}, + {"PG1", 6, 1, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint1", NULL}, 6, 1}, + {"PG2", 6, 2, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint2", NULL}, 6, 2}, + {"PG3", 6, 3, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint3", NULL}, 6, 3}, + {"PG4", 6, 4, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint4", NULL}, 6, 4}, + {"PG5", 6, 5, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint5", NULL}, 6, 5}, + {"PG6", 6, 6, {"gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, "pg_eint6", NULL}, 6, 6}, + {"PG7", 6, 7, {"gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, "pg_eint7", NULL}, 6, 7}, + {"PG8", 6, 8, {"gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, "pg_eint8", NULL}, 6, 8}, + {"PG9", 6, 9, {"gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, "pg_eint9", NULL}, 6, 9}, + {"PG10", 6, 10, {"gpio_in", "gpio_out", "i2c3", NULL, NULL, NULL, "pg_eint10", NULL}, 6, 10}, + {"PG11", 6, 11, {"gpio_in", "gpio_out", "i2c3", NULL, NULL, NULL, "pg_eint11", NULL}, 6, 11}, + {"PG12", 6, 12, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, "pg_eint12", NULL}, 6, 12}, + {"PG13", 6, 13, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, "pg_eint13", NULL}, 6, 13}, + {"PG14", 6, 14, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, "pg_eint14", NULL}, 6, 14}, + {"PG15", 6, 15, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, "pg_eint15", NULL}, 6, 15}, + {"PG16", 6, 16, {"gpio_in", "gpio_out", "spi1", "i2s1", NULL, NULL, "pg_eint16", NULL}, 6, 16}, + {"PG17", 6, 17, {"gpio_in", "gpio_out", "uart4", NULL, NULL, NULL, "pg_eint17", NULL}, 6, 17}, + {"PG18", 6, 18, {"gpio_in", "gpio_out", "uart4", NULL, NULL, NULL, "pg_eint18", NULL}, 6, 18}, {"PH9", 7, 9, {"gpio_in", "gpio_out", "spi2", "jtag", "pwm1", NULL, NULL, NULL}}, {"PH10", 7, 10, {"gpio_in", "gpio_out", "spi2", "jtag", "pwm1", NULL, NULL, NULL}}, diff --git a/sys/arm/allwinner/a64/a64_padconf.c b/sys/arm/allwinner/a64/a64_padconf.c index 486e0ced2d0..c904365162b 100644 --- a/sys/arm/allwinner/a64/a64_padconf.c +++ b/sys/arm/allwinner/a64/a64_padconf.c @@ -41,16 +41,16 @@ __FBSDID("$FreeBSD$"); #ifdef SOC_ALLWINNER_A64 static const struct allwinner_pins a64_pins[] = { - { "PB0", 1, 0, { "gpio_in", "gpio_out", "uart2", NULL, "jtag", NULL, "eint" } }, - { "PB1", 1, 1, { "gpio_in", "gpio_out", "uart2", NULL, "jtag", "sim", "eint" } }, - { "PB2", 1, 2, { "gpio_in", "gpio_out", "uart2", NULL, "jtag", "sim", "eint" } }, - { "PB3", 1, 3, { "gpio_in", "gpio_out", "uart2", "i2s0", "jtag", "sim", "eint" } }, - { "PB4", 1, 4, { "gpio_in", "gpio_out", "aif2", "pcm0", NULL, "sim", "eint" } }, - { "PB5", 1, 5, { "gpio_in", "gpio_out", "aif2", "pcm0", NULL, "sim", "eint" } }, - { "PB6", 1, 6, { "gpio_in", "gpio_out", "aif2", "pcm0", NULL, "sim", "eint" } }, - { "PB7", 1, 7, { "gpio_in", "gpio_out", "aif2", "pcm0", NULL, "sim", "eint" } }, - { "PB8", 1, 8, { "gpio_in", "gpio_out", NULL, NULL, "uart0", NULL, "eint" } }, - { "PB9", 1, 9, { "gpio_in", "gpio_out", NULL, NULL, "uart0", NULL, "eint" } }, + { "PB0", 1, 0, { "gpio_in", "gpio_out", "uart2", NULL, "jtag", NULL, "pb_eint0" } 6, 0}, + { "PB1", 1, 1, { "gpio_in", "gpio_out", "uart2", NULL, "jtag", "sim", "pb_eint1" } 6, 1}, + { "PB2", 1, 2, { "gpio_in", "gpio_out", "uart2", NULL, "jtag", "sim", "pb_eint2" } 6, 2}, + { "PB3", 1, 3, { "gpio_in", "gpio_out", "uart2", "i2s0", "jtag", "sim", "pb_eint3" } 6, 3}, + { "PB4", 1, 4, { "gpio_in", "gpio_out", "aif2", "pcm0", NULL, "sim", "pb_eint4" } 6, 4}, + { "PB5", 1, 5, { "gpio_in", "gpio_out", "aif2", "pcm0", NULL, "sim", "pb_eint5" } 6, 5}, + { "PB6", 1, 6, { "gpio_in", "gpio_out", "aif2", "pcm0", NULL, "sim", "pb_eint6" } 6, 6}, + { "PB7", 1, 7, { "gpio_in", "gpio_out", "aif2", "pcm0", NULL, "sim", "pb_eint7" } 6, 7}, + { "PB8", 1, 8, { "gpio_in", "gpio_out", NULL, NULL, "uart0", NULL, "pb_eint8" } 6, 8}, + { "PB9", 1, 9, { "gpio_in", "gpio_out", NULL, NULL, "uart0", NULL, "pb_eint9" } 6, 9}, { "PC0", 2, 0, { "gpio_in", "gpio_out", "nand", NULL, "spi0" } }, { "PC1", 2, 1, { "gpio_in", "gpio_out", "nand", "mmc2", "spi0" } }, @@ -123,33 +123,33 @@ static const struct allwinner_pins a64_pins[] = { { "PF5", 5, 5, { "gpio_in", "gpio_out", "mmc0", "jtag" } }, { "PF6", 5, 6, { "gpio_in", "gpio_out" } }, - { "PG0", 6, 0, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "eint" } }, - { "PG1", 6, 1, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "eint" } }, - { "PG2", 6, 2, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "eint" } }, - { "PG3", 6, 3, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "eint" } }, - { "PG4", 6, 4, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "eint" } }, - { "PG5", 6, 5, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "eint" } }, - { "PG6", 6, 6, { "gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "eint" } }, - { "PG7", 6, 7, { "gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "eint" } }, - { "PG8", 6, 8, { "gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "eint" } }, - { "PG9", 6, 9, { "gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "eint" } }, - { "PG10", 6, 10, { "gpio_in", "gpio_out", "aif3", "pcm1", NULL, NULL, "eint" } }, - { "PG11", 6, 11, { "gpio_in", "gpio_out", "aif3", "pcm1", NULL, NULL, "eint" } }, - { "PG12", 6, 12, { "gpio_in", "gpio_out", "aif3", "pcm1", NULL, NULL, "eint" } }, - { "PG13", 6, 13, { "gpio_in", "gpio_out", "aif3", "pcm1", NULL, NULL, "eint" } }, + { "PG0", 6, 0, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint0" } 6, 0}, + { "PG1", 6, 1, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint1" } 6, 1}, + { "PG2", 6, 2, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint2" } 6, 2}, + { "PG3", 6, 3, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint3" } 6, 3}, + { "PG4", 6, 4, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint4" } 6, 4}, + { "PG5", 6, 5, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint5" } 6, 5}, + { "PG6", 6, 6, { "gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "pg_eint6" } 6, 6}, + { "PG7", 6, 7, { "gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "pg_eint7" } 6, 7}, + { "PG8", 6, 8, { "gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "pg_eint8" } 6, 8}, + { "PG9", 6, 9, { "gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "pg_eint9" } 6, 9}, + { "PG10", 6, 10, { "gpio_in", "gpio_out", "aif3", "pcm1", NULL, NULL, "pg_eint10" } 6, 10}, + { "PG11", 6, 11, { "gpio_in", "gpio_out", "aif3", "pcm1", NULL, NULL, "pg_eint11" } 6, 11}, + { "PG12", 6, 12, { "gpio_in", "gpio_out", "aif3", "pcm1", NULL, NULL, "pg_eint12" } 6, 12}, + { "PG13", 6, 13, { "gpio_in", "gpio_out", "aif3", "pcm1", NULL, NULL, "pg_eint13" } 6, 13}, - { "PH0", 7, 0, { "gpio_in", "gpio_out", "i2c0", NULL, NULL, NULL, "eint" } }, - { "PH1", 7, 1, { "gpio_in", "gpio_out", "i2c0", NULL, NULL, NULL, "eint" } }, - { "PH2", 7, 2, { "gpio_in", "gpio_out", "i2c1", NULL, NULL, NULL, "eint" } }, - { "PH3", 7, 3, { "gpio_in", "gpio_out", "i2c1", NULL, NULL, NULL, "eint" } }, - { "PH4", 7, 4, { "gpio_in", "gpio_out", "uart3", NULL, NULL, NULL, "eint" } }, - { "PH5", 7, 5, { "gpio_in", "gpio_out", "uart3", NULL, NULL, NULL, "eint" } }, - { "PH6", 7, 6, { "gpio_in", "gpio_out", "uart3", NULL, NULL, NULL, "eint" } }, - { "PH7", 7, 7, { "gpio_in", "gpio_out", "uart3", NULL, NULL, NULL, "eint" } }, - { "PH8", 7, 8, { "gpio_in", "gpio_out", "owa", NULL, NULL, NULL, "eint" } }, - { "PH9", 7, 9, { "gpio_in", "gpio_out", NULL, NULL, NULL, NULL, "eint" } }, - { "PH10", 7, 10, { "gpio_in", "gpio_out", "mic", NULL, NULL, NULL, "eint" } }, - { "PH11", 7, 11, { "gpio_in", "gpio_out", "mic", NULL, NULL, NULL, "eint" } }, + { "PH0", 7, 0, { "gpio_in", "gpio_out", "i2c0", NULL, NULL, NULL, "ph_eint0" } 6, 0}, + { "PH1", 7, 1, { "gpio_in", "gpio_out", "i2c0", NULL, NULL, NULL, "ph_eint1" } 6, 1}, + { "PH2", 7, 2, { "gpio_in", "gpio_out", "i2c1", NULL, NULL, NULL, "ph_eint2" } 6, 2}, + { "PH3", 7, 3, { "gpio_in", "gpio_out", "i2c1", NULL, NULL, NULL, "ph_eint3" } 6, 3}, + { "PH4", 7, 4, { "gpio_in", "gpio_out", "uart3", NULL, NULL, NULL, "ph_eint4" } 6, 4}, + { "PH5", 7, 5, { "gpio_in", "gpio_out", "uart3", NULL, NULL, NULL, "ph_eint5" } 6, 5}, + { "PH6", 7, 6, { "gpio_in", "gpio_out", "uart3", NULL, NULL, NULL, "ph_eint6" } 6, 6}, + { "PH7", 7, 7, { "gpio_in", "gpio_out", "uart3", NULL, NULL, NULL, "ph_eint7" } 6, 7}, + { "PH8", 7, 8, { "gpio_in", "gpio_out", "owa", NULL, NULL, NULL, "ph_eint8" } 6, 8}, + { "PH9", 7, 9, { "gpio_in", "gpio_out", NULL, NULL, NULL, NULL, "ph_eint9" } 6, 9}, + { "PH10", 7, 10, { "gpio_in", "gpio_out", "mic", NULL, NULL, NULL, "ph_eint10" } 6, 10}, + { "PH11", 7, 11, { "gpio_in", "gpio_out", "mic", NULL, NULL, NULL, "ph_eint11" } 6, 11}, }; const struct allwinner_padconf a64_padconf = { diff --git a/sys/arm/allwinner/a64/a64_r_padconf.c b/sys/arm/allwinner/a64/a64_r_padconf.c index 88edc3f0aa7..daac9e6efe9 100644 --- a/sys/arm/allwinner/a64/a64_r_padconf.c +++ b/sys/arm/allwinner/a64/a64_r_padconf.c @@ -41,19 +41,19 @@ __FBSDID("$FreeBSD$"); #ifdef SOC_ALLWINNER_A64 static const struct allwinner_pins a64_r_pins[] = { - { "PL0", 0, 0, { "gpio_in", "gpio_out", "s_rsb", "s_i2c", NULL, NULL, "eint" } }, - { "PL1", 0, 1, { "gpio_in", "gpio_out", "s_rsb", "s_i2c", NULL, NULL, "eint" } }, - { "PL2", 0, 2, { "gpio_in", "gpio_out", "s_uart", NULL, NULL, NULL, "eint" } }, - { "PL3", 0, 3, { "gpio_in", "gpio_out", "s_uart", NULL, NULL, NULL, "eint" } }, - { "PL4", 0, 4, { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "eint" } }, - { "PL5", 0, 5, { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "eint" } }, - { "PL6", 0, 6, { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "eint" } }, - { "PL7", 0, 7, { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "eint" } }, - { "PL8", 0, 8, { "gpio_in", "gpio_out", "s_i2c", NULL, NULL, NULL, "eint" } }, - { "PL9", 0, 9, { "gpio_in", "gpio_out", "s_i2c", NULL, NULL, NULL, "eint" } }, - { "PL10", 0, 10, { "gpio_in", "gpio_out", "s_pwm", NULL, NULL, NULL, "eint" } }, - { "PL11", 0, 11, { "gpio_in", "gpio_out", "s_cir", NULL, NULL, NULL, "eint" } }, - { "PL12", 0, 12, { "gpio_in", "gpio_out", NULL, NULL, NULL, NULL, "eint" } }, + { "PL0", 0, 0, { "gpio_in", "gpio_out", "s_rsb", "s_i2c", NULL, NULL, "pl_eint0" } 6, 0}, + { "PL1", 0, 1, { "gpio_in", "gpio_out", "s_rsb", "s_i2c", NULL, NULL, "pl_eint1" } 6, 1}, + { "PL2", 0, 2, { "gpio_in", "gpio_out", "s_uart", NULL, NULL, NULL, "pl_eint2" } 6, 2}, + { "PL3", 0, 3, { "gpio_in", "gpio_out", "s_uart", NULL, NULL, NULL, "pl_eint3" } 6, 3}, + { "PL4", 0, 4, { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "pl_eint4" } 6, 4}, + { "PL5", 0, 5, { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "pl_eint5" } 6, 5}, + { "PL6", 0, 6, { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "pl_eint6" } 6, 6}, + { "PL7", 0, 7, { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "pl_eint7" } 6, 7}, + { "PL8", 0, 8, { "gpio_in", "gpio_out", "s_i2c", NULL, NULL, NULL, "pl_eint8" } 6, 8}, + { "PL9", 0, 9, { "gpio_in", "gpio_out", "s_i2c", NULL, NULL, NULL, "pl_eint9" } 6, 9}, + { "PL10", 0, 10, { "gpio_in", "gpio_out", "s_pwm", NULL, NULL, NULL, "pl_eint10" } 6, 10}, + { "PL11", 0, 11, { "gpio_in", "gpio_out", "s_cir", NULL, NULL, NULL, "pl_eint11" } 6, 11}, + { "PL12", 0, 12, { "gpio_in", "gpio_out", NULL, NULL, NULL, NULL, "pl_eint12" } 6, 12}, }; const struct allwinner_padconf a64_r_padconf = { diff --git a/sys/arm/allwinner/allwinner_pinctrl.h b/sys/arm/allwinner/allwinner_pinctrl.h index b02b9e3100d..b8a6c96d238 100644 --- a/sys/arm/allwinner/allwinner_pinctrl.h +++ b/sys/arm/allwinner/allwinner_pinctrl.h @@ -36,6 +36,8 @@ struct allwinner_pins { uint8_t port; uint8_t pin; const char *functions[8]; + uint8_t eint_func; + uint8_t eint_num; }; struct allwinner_padconf { diff --git a/sys/arm/allwinner/h3/h3_padconf.c b/sys/arm/allwinner/h3/h3_padconf.c index 654f28e80e6..6142e4d7fce 100644 --- a/sys/arm/allwinner/h3/h3_padconf.c +++ b/sys/arm/allwinner/h3/h3_padconf.c @@ -38,28 +38,28 @@ __FBSDID("$FreeBSD$"); #ifdef SOC_ALLWINNER_H3 const static struct allwinner_pins h3_pins[] = { - {"PA0", 0, 0, {"gpio_in", "gpio_out", "uart2", "jtag", NULL, NULL, "eint", NULL}}, - {"PA1", 0, 1, {"gpio_in", "gpio_out", "uart2", "jtag", NULL, NULL, "eint", NULL}}, - {"PA2", 0, 2, {"gpio_in", "gpio_out", "uart2", "jtag", NULL, NULL, "eint", NULL}}, - {"PA3", 0, 3, {"gpio_in", "gpio_out", "uart2", "jtag", NULL, NULL, "eint", NULL}}, - {"PA4", 0, 4, {"gpio_in", "gpio_out", "uart0", NULL, NULL, NULL, "eint", NULL}}, - {"PA5", 0, 5, {"gpio_in", "gpio_out", "uart0", "pwm0", NULL, NULL, "eint", NULL}}, - {"PA6", 0, 6, {"gpio_in", "gpio_out", "sim", NULL, NULL, NULL, "eint", NULL}}, - {"PA7", 0, 7, {"gpio_in", "gpio_out", "sim", NULL, NULL, NULL, "eint", NULL}}, - {"PA8", 0, 8, {"gpio_in", "gpio_out", "sim", NULL, NULL, NULL, "eint", NULL}}, - {"PA9", 0, 9, {"gpio_in", "gpio_out", "sim", NULL, NULL, NULL, "eint", NULL}}, - {"PA10", 0, 10, {"gpio_in", "gpio_out", "sim", NULL, NULL, NULL, "eint", NULL}}, - {"PA11", 0, 11, {"gpio_in", "gpio_out", "i2c0", "di", NULL, NULL, "eint", NULL}}, - {"PA12", 0, 12, {"gpio_in", "gpio_out", "i2c0", "di", NULL, NULL, "eint", NULL}}, - {"PA13", 0, 13, {"gpio_in", "gpio_out", "spi1", "uart3", NULL, NULL, "eint", NULL}}, - {"PA14", 0, 14, {"gpio_in", "gpio_out", "spi1", "uart3", NULL, NULL, "eint", NULL}}, - {"PA15", 0, 15, {"gpio_in", "gpio_out", "spi1", "uart3", NULL, NULL, "eint", NULL}}, - {"PA16", 0, 16, {"gpio_in", "gpio_out", "spi1", "uart3", NULL, NULL, "eint", NULL}}, - {"PA17", 0, 17, {"gpio_in", "gpio_out", "spdif", NULL, NULL, NULL, "eint", NULL}}, - {"PA18", 0, 18, {"gpio_in", "gpio_out", "i2s0", "i2c1", NULL, NULL, "eint", NULL}}, - {"PA19", 0, 19, {"gpio_in", "gpio_out", "i2s0", "i2c1", NULL, NULL, "eint", NULL}}, - {"PA20", 0, 20, {"gpio_in", "gpio_out", "i2s0", "sim", NULL, NULL, "eint", NULL}}, - {"PA21", 0, 21, {"gpio_in", "gpio_out", "i2s0", "sim", NULL, NULL, "eint", NULL}}, + {"PA0", 0, 0, {"gpio_in", "gpio_out", "uart2", "jtag", NULL, NULL, "pa_eint0", NULL}, 6, 0}, + {"PA1", 0, 1, {"gpio_in", "gpio_out", "uart2", "jtag", NULL, NULL, "pa_eint1", NULL}, 6, 1}, + {"PA2", 0, 2, {"gpio_in", "gpio_out", "uart2", "jtag", NULL, NULL, "pa_eint2", NULL}, 6, 2}, + {"PA3", 0, 3, {"gpio_in", "gpio_out", "uart2", "jtag", NULL, NULL, "pa_eint3", NULL}, 6, 3}, + {"PA4", 0, 4, {"gpio_in", "gpio_out", "uart0", NULL, NULL, NULL, "pa_eint4", NULL}, 6, 4}, + {"PA5", 0, 5, {"gpio_in", "gpio_out", "uart0", "pwm0", NULL, NULL, "pa_eint5", NULL}, 6, 5}, + {"PA6", 0, 6, {"gpio_in", "gpio_out", "sim", NULL, NULL, NULL, "pa_eint6", NULL}, 6, 6}, + {"PA7", 0, 7, {"gpio_in", "gpio_out", "sim", NULL, NULL, NULL, "pa_eint7", NULL}, 6, 7}, + {"PA8", 0, 8, {"gpio_in", "gpio_out", "sim", NULL, NULL, NULL, "pa_eint8", NULL}, 6, 8}, + {"PA9", 0, 9, {"gpio_in", "gpio_out", "sim", NULL, NULL, NULL, "pa_eint9", NULL}, 6, 9}, + {"PA10", 0, 10, {"gpio_in", "gpio_out", "sim", NULL, NULL, NULL, "pa_eint10", NULL}, 6, 10}, + {"PA11", 0, 11, {"gpio_in", "gpio_out", "i2c0", "di", NULL, NULL, "pa_eint11", NULL}, 6, 11}, + {"PA12", 0, 12, {"gpio_in", "gpio_out", "i2c0", "di", NULL, NULL, "pa_eint12", NULL}, 6, 12}, + {"PA13", 0, 13, {"gpio_in", "gpio_out", "spi1", "uart3", NULL, NULL, "pa_eint13", NULL}, 6, 13}, + {"PA14", 0, 14, {"gpio_in", "gpio_out", "spi1", "uart3", NULL, NULL, "pa_eint14", NULL}, 6, 14}, + {"PA15", 0, 15, {"gpio_in", "gpio_out", "spi1", "uart3", NULL, NULL, "pa_eint15", NULL}, 6, 15}, + {"PA16", 0, 16, {"gpio_in", "gpio_out", "spi1", "uart3", NULL, NULL, "pa_eint16", NULL}, 6, 16}, + {"PA17", 0, 17, {"gpio_in", "gpio_out", "spdif", NULL, NULL, NULL, "pa_eint17", NULL}, 6, 17}, + {"PA18", 0, 18, {"gpio_in", "gpio_out", "i2s0", "i2c1", NULL, NULL, "pa_eint18", NULL}, 6, 18}, + {"PA19", 0, 19, {"gpio_in", "gpio_out", "i2s0", "i2c1", NULL, NULL, "pa_eint19", NULL}, 6, 19}, + {"PA20", 0, 20, {"gpio_in", "gpio_out", "i2s0", "sim", NULL, NULL, "pa_eint20", NULL}, 6, 20}, + {"PA21", 0, 21, {"gpio_in", "gpio_out", "i2s0", "sim", NULL, NULL, "pa_eint21", NULL}, 6, 21}, {"PC0", 2, 0, {"gpio_in", "gpio_out", "nand", "spi0", NULL, NULL, NULL, NULL}}, {"PC1", 2, 1, {"gpio_in", "gpio_out", "nand", "spi0", NULL, NULL, NULL, NULL}}, @@ -123,20 +123,20 @@ const static struct allwinner_pins h3_pins[] = { {"PF5", 5, 5, {"gpio_in", "gpio_out", "mmc0", "jtag", NULL, NULL, NULL, NULL}}, {"PF6", 5, 6, {"gpio_in", "gpio_out", NULL, NULL, NULL, NULL, NULL, NULL}}, - {"PG0", 6, 0, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, "eint"}}, - {"PG1", 6, 1, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, "eint"}}, - {"PG2", 6, 2, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, "eint"}}, - {"PG3", 6, 3, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, "eint"}}, - {"PG4", 6, 4, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, "eint"}}, - {"PG5", 6, 5, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, NULL, "eint"}}, - {"PG6", 6, 6, {"gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, NULL, "eint"}}, - {"PG7", 6, 7, {"gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, NULL, "eint"}}, - {"PG8", 6, 8, {"gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, NULL, "eint"}}, - {"PG9", 6, 9, {"gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, NULL, "eint"}}, - {"PG10", 6, 10, {"gpio_in", "gpio_out", "i2s1", NULL, NULL, NULL, NULL, "eint"}}, - {"PG11", 6, 11, {"gpio_in", "gpio_out", "i2s1", NULL, NULL, NULL, NULL, "eint"}}, - {"PG12", 6, 11, {"gpio_in", "gpio_out", "i2s1", NULL, NULL, NULL, NULL, "eint"}}, - {"PG13", 6, 11, {"gpio_in", "gpio_out", "i2s1", NULL, NULL, NULL, NULL, "eint"}}, + {"PG0", 6, 0, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint0", NULL}, 6, 0}, + {"PG1", 6, 1, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint1", NULL}, 6, 1}, + {"PG2", 6, 2, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint2", NULL}, 6, 2}, + {"PG3", 6, 3, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint3", NULL}, 6, 3}, + {"PG4", 6, 4, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint4", NULL}, 6, 4}, + {"PG5", 6, 5, {"gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint5", NULL}, 6, 5}, + {"PG6", 6, 6, {"gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "pg_eint6", NULL}, 6, 6}, + {"PG7", 6, 7, {"gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "pg_eint7", NULL}, 6, 7}, + {"PG8", 6, 8, {"gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "pg_eint8", NULL}, 6, 8}, + {"PG9", 6, 9, {"gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "pg_eint9", NULL}, 6, 9}, + {"PG10", 6, 10, {"gpio_in", "gpio_out", "i2s1", NULL, NULL, NULL, "pg_eint10", NULL}, 6, 10}, + {"PG11", 6, 11, {"gpio_in", "gpio_out", "i2s1", NULL, NULL, NULL, "pg_eint11", NULL}, 6, 11}, + {"PG12", 6, 12, {"gpio_in", "gpio_out", "i2s1", NULL, NULL, NULL, "pg_eint12", NULL}, 6, 12}, + {"PG13", 6, 13, {"gpio_in", "gpio_out", "i2s1", NULL, NULL, NULL, "pg_eint13", NULL}, 6, 13}, }; const struct allwinner_padconf h3_padconf = { diff --git a/sys/arm/allwinner/h3/h3_r_padconf.c b/sys/arm/allwinner/h3/h3_r_padconf.c index 111bb1f95f2..bc02935386d 100644 --- a/sys/arm/allwinner/h3/h3_r_padconf.c +++ b/sys/arm/allwinner/h3/h3_r_padconf.c @@ -38,18 +38,18 @@ __FBSDID("$FreeBSD$"); #ifdef SOC_ALLWINNER_H3 const static struct allwinner_pins h3_r_pins[] = { - {"PL0", 0, 0, {"gpio_in", "gpio_out", "s_twi", NULL, NULL, NULL, NULL, "eint"}}, - {"PL1", 0, 1, {"gpio_in", "gpio_out", "s_twi", NULL, NULL, NULL, NULL, "eint"}}, - {"PL2", 0, 2, {"gpio_in", "gpio_out", "s_uart", NULL, NULL, NULL, NULL, "eint"}}, - {"PL3", 0, 3, {"gpio_in", "gpio_out", "s_uart", NULL, NULL, NULL, NULL, "eint"}}, - {"PL4", 0, 4, {"gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, NULL, "eint"}}, - {"PL5", 0, 5, {"gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, NULL, "eint"}}, - {"PL6", 0, 6, {"gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, NULL, "eint"}}, - {"PL7", 0, 7, {"gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, NULL, "eint"}}, - {"PL8", 0, 8, {"gpio_in", "gpio_out", NULL, NULL, NULL, NULL, NULL, "eint"}}, - {"PL9", 0, 9, {"gpio_in", "gpio_out", NULL, NULL, NULL, NULL, NULL, "eint"}}, - {"PL10", 0, 10, {"gpio_in", "gpio_out", "s_pwm", NULL, NULL, NULL, NULL, "eint"}}, - {"PL11", 0, 11, {"gpio_in", "gpio_out", "s_cir_rx", NULL, NULL, NULL, NULL, "eint"}}, + {"PL0", 0, 0, {"gpio_in", "gpio_out", "s_twi", NULL, NULL, NULL, "pl_eint0", NULL}, 6, 0}, + {"PL1", 0, 1, {"gpio_in", "gpio_out", "s_twi", NULL, NULL, NULL, "pl_eint1", NULL}, 6, 1}, + {"PL2", 0, 2, {"gpio_in", "gpio_out", "s_uart", NULL, NULL, NULL, "pl_eint2", NULL}, 6, 2}, + {"PL3", 0, 3, {"gpio_in", "gpio_out", "s_uart", NULL, NULL, NULL, "pl_eint3", NULL}, 6, 3}, + {"PL4", 0, 4, {"gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "pl_eint4", NULL}, 6, 4}, + {"PL5", 0, 5, {"gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "pl_eint5", NULL}, 6, 5}, + {"PL6", 0, 6, {"gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "pl_eint6", NULL}, 6, 6}, + {"PL7", 0, 7, {"gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "pl_eint7", NULL}, 6, 7}, + {"PL8", 0, 8, {"gpio_in", "gpio_out", NULL, NULL, NULL, NULL, "pl_eint8", NULL}, 6, 8}, + {"PL9", 0, 9, {"gpio_in", "gpio_out", NULL, NULL, NULL, NULL, "pl_eint9", NULL}, 6, 9}, + {"PL10", 0, 10, {"gpio_in", "gpio_out", "s_pwm", NULL, NULL, NULL, "pl_eint10", NULL}, 6, 10}, + {"PL11", 0, 11, {"gpio_in", "gpio_out", "s_cir_rx", NULL, NULL, NULL, "pl_eint11", NULL}, 6, 11}, }; const struct allwinner_padconf h3_r_padconf = { From f698b621da3b1abd6dad828d58af999f0081c34c Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Thu, 15 Dec 2016 16:13:52 +0000 Subject: [PATCH 197/226] Fix ls_tests:o_flag with ZFS TMPDIR Unlike UFS or TMPFS, ZFS sets uarch automatically whenever a file is updated. The test must explicitly clear uarch to be portable across filesystems. Also, it doesn't need to run as root. PR: 215179 MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D8741 --- bin/ls/tests/ls_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ls/tests/ls_tests.sh b/bin/ls/tests/ls_tests.sh index 32ead031485..14f7895e699 100755 --- a/bin/ls/tests/ls_tests.sh +++ b/bin/ls/tests/ls_tests.sh @@ -697,7 +697,6 @@ atf_test_case o_flag o_flag_head() { atf_set "descr" "Verify that the output from ls -o prints out the chflag values or '-' if none are set" - atf_set "require.user" "root" } o_flag_body() @@ -711,6 +710,7 @@ o_flag_body() atf_check -e ignore -o empty -s exit:0 dd if=/dev/zero of=b.file \ bs=$size count=1 atf_check -e empty -o empty -s exit:0 chflags uarch a.file + atf_check -e empty -o empty -s exit:0 chflags 0 b.file atf_check -e empty -o match:"[[:space:]]+uarch[[:space:]]$size+.+a\\.file" \ -s exit:0 ls -lo a.file From 74b66ae1497e1d6acf97c9efb53be3191bedade0 Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Thu, 15 Dec 2016 17:26:16 +0000 Subject: [PATCH 198/226] Fix building arm64 kernel after r310117 Pointy hat: me MFC after: 3 days --- sys/arm/allwinner/a64/a64_padconf.c | 72 +++++++++++++-------------- sys/arm/allwinner/a64/a64_r_padconf.c | 26 +++++----- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/sys/arm/allwinner/a64/a64_padconf.c b/sys/arm/allwinner/a64/a64_padconf.c index c904365162b..19b5c128e4e 100644 --- a/sys/arm/allwinner/a64/a64_padconf.c +++ b/sys/arm/allwinner/a64/a64_padconf.c @@ -41,16 +41,16 @@ __FBSDID("$FreeBSD$"); #ifdef SOC_ALLWINNER_A64 static const struct allwinner_pins a64_pins[] = { - { "PB0", 1, 0, { "gpio_in", "gpio_out", "uart2", NULL, "jtag", NULL, "pb_eint0" } 6, 0}, - { "PB1", 1, 1, { "gpio_in", "gpio_out", "uart2", NULL, "jtag", "sim", "pb_eint1" } 6, 1}, - { "PB2", 1, 2, { "gpio_in", "gpio_out", "uart2", NULL, "jtag", "sim", "pb_eint2" } 6, 2}, - { "PB3", 1, 3, { "gpio_in", "gpio_out", "uart2", "i2s0", "jtag", "sim", "pb_eint3" } 6, 3}, - { "PB4", 1, 4, { "gpio_in", "gpio_out", "aif2", "pcm0", NULL, "sim", "pb_eint4" } 6, 4}, - { "PB5", 1, 5, { "gpio_in", "gpio_out", "aif2", "pcm0", NULL, "sim", "pb_eint5" } 6, 5}, - { "PB6", 1, 6, { "gpio_in", "gpio_out", "aif2", "pcm0", NULL, "sim", "pb_eint6" } 6, 6}, - { "PB7", 1, 7, { "gpio_in", "gpio_out", "aif2", "pcm0", NULL, "sim", "pb_eint7" } 6, 7}, - { "PB8", 1, 8, { "gpio_in", "gpio_out", NULL, NULL, "uart0", NULL, "pb_eint8" } 6, 8}, - { "PB9", 1, 9, { "gpio_in", "gpio_out", NULL, NULL, "uart0", NULL, "pb_eint9" } 6, 9}, + { "PB0", 1, 0, { "gpio_in", "gpio_out", "uart2", NULL, "jtag", NULL, "pb_eint0" }, 6, 0}, + { "PB1", 1, 1, { "gpio_in", "gpio_out", "uart2", NULL, "jtag", "sim", "pb_eint1" }, 6, 1}, + { "PB2", 1, 2, { "gpio_in", "gpio_out", "uart2", NULL, "jtag", "sim", "pb_eint2" }, 6, 2}, + { "PB3", 1, 3, { "gpio_in", "gpio_out", "uart2", "i2s0", "jtag", "sim", "pb_eint3" }, 6, 3}, + { "PB4", 1, 4, { "gpio_in", "gpio_out", "aif2", "pcm0", NULL, "sim", "pb_eint4" }, 6, 4}, + { "PB5", 1, 5, { "gpio_in", "gpio_out", "aif2", "pcm0", NULL, "sim", "pb_eint5" }, 6, 5}, + { "PB6", 1, 6, { "gpio_in", "gpio_out", "aif2", "pcm0", NULL, "sim", "pb_eint6" }, 6, 6}, + { "PB7", 1, 7, { "gpio_in", "gpio_out", "aif2", "pcm0", NULL, "sim", "pb_eint7" }, 6, 7}, + { "PB8", 1, 8, { "gpio_in", "gpio_out", NULL, NULL, "uart0", NULL, "pb_eint8" }, 6, 8}, + { "PB9", 1, 9, { "gpio_in", "gpio_out", NULL, NULL, "uart0", NULL, "pb_eint9" }, 6, 9}, { "PC0", 2, 0, { "gpio_in", "gpio_out", "nand", NULL, "spi0" } }, { "PC1", 2, 1, { "gpio_in", "gpio_out", "nand", "mmc2", "spi0" } }, @@ -123,33 +123,33 @@ static const struct allwinner_pins a64_pins[] = { { "PF5", 5, 5, { "gpio_in", "gpio_out", "mmc0", "jtag" } }, { "PF6", 5, 6, { "gpio_in", "gpio_out" } }, - { "PG0", 6, 0, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint0" } 6, 0}, - { "PG1", 6, 1, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint1" } 6, 1}, - { "PG2", 6, 2, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint2" } 6, 2}, - { "PG3", 6, 3, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint3" } 6, 3}, - { "PG4", 6, 4, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint4" } 6, 4}, - { "PG5", 6, 5, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint5" } 6, 5}, - { "PG6", 6, 6, { "gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "pg_eint6" } 6, 6}, - { "PG7", 6, 7, { "gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "pg_eint7" } 6, 7}, - { "PG8", 6, 8, { "gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "pg_eint8" } 6, 8}, - { "PG9", 6, 9, { "gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "pg_eint9" } 6, 9}, - { "PG10", 6, 10, { "gpio_in", "gpio_out", "aif3", "pcm1", NULL, NULL, "pg_eint10" } 6, 10}, - { "PG11", 6, 11, { "gpio_in", "gpio_out", "aif3", "pcm1", NULL, NULL, "pg_eint11" } 6, 11}, - { "PG12", 6, 12, { "gpio_in", "gpio_out", "aif3", "pcm1", NULL, NULL, "pg_eint12" } 6, 12}, - { "PG13", 6, 13, { "gpio_in", "gpio_out", "aif3", "pcm1", NULL, NULL, "pg_eint13" } 6, 13}, + { "PG0", 6, 0, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint0" }, 6, 0}, + { "PG1", 6, 1, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint1" }, 6, 1}, + { "PG2", 6, 2, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint2" }, 6, 2}, + { "PG3", 6, 3, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint3" }, 6, 3}, + { "PG4", 6, 4, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint4" }, 6, 4}, + { "PG5", 6, 5, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "pg_eint5" }, 6, 5}, + { "PG6", 6, 6, { "gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "pg_eint6" }, 6, 6}, + { "PG7", 6, 7, { "gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "pg_eint7" }, 6, 7}, + { "PG8", 6, 8, { "gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "pg_eint8" }, 6, 8}, + { "PG9", 6, 9, { "gpio_in", "gpio_out", "uart1", NULL, NULL, NULL, "pg_eint9" }, 6, 9}, + { "PG10", 6, 10, { "gpio_in", "gpio_out", "aif3", "pcm1", NULL, NULL, "pg_eint10" }, 6, 10}, + { "PG11", 6, 11, { "gpio_in", "gpio_out", "aif3", "pcm1", NULL, NULL, "pg_eint11" }, 6, 11}, + { "PG12", 6, 12, { "gpio_in", "gpio_out", "aif3", "pcm1", NULL, NULL, "pg_eint12" }, 6, 12}, + { "PG13", 6, 13, { "gpio_in", "gpio_out", "aif3", "pcm1", NULL, NULL, "pg_eint13" }, 6, 13}, - { "PH0", 7, 0, { "gpio_in", "gpio_out", "i2c0", NULL, NULL, NULL, "ph_eint0" } 6, 0}, - { "PH1", 7, 1, { "gpio_in", "gpio_out", "i2c0", NULL, NULL, NULL, "ph_eint1" } 6, 1}, - { "PH2", 7, 2, { "gpio_in", "gpio_out", "i2c1", NULL, NULL, NULL, "ph_eint2" } 6, 2}, - { "PH3", 7, 3, { "gpio_in", "gpio_out", "i2c1", NULL, NULL, NULL, "ph_eint3" } 6, 3}, - { "PH4", 7, 4, { "gpio_in", "gpio_out", "uart3", NULL, NULL, NULL, "ph_eint4" } 6, 4}, - { "PH5", 7, 5, { "gpio_in", "gpio_out", "uart3", NULL, NULL, NULL, "ph_eint5" } 6, 5}, - { "PH6", 7, 6, { "gpio_in", "gpio_out", "uart3", NULL, NULL, NULL, "ph_eint6" } 6, 6}, - { "PH7", 7, 7, { "gpio_in", "gpio_out", "uart3", NULL, NULL, NULL, "ph_eint7" } 6, 7}, - { "PH8", 7, 8, { "gpio_in", "gpio_out", "owa", NULL, NULL, NULL, "ph_eint8" } 6, 8}, - { "PH9", 7, 9, { "gpio_in", "gpio_out", NULL, NULL, NULL, NULL, "ph_eint9" } 6, 9}, - { "PH10", 7, 10, { "gpio_in", "gpio_out", "mic", NULL, NULL, NULL, "ph_eint10" } 6, 10}, - { "PH11", 7, 11, { "gpio_in", "gpio_out", "mic", NULL, NULL, NULL, "ph_eint11" } 6, 11}, + { "PH0", 7, 0, { "gpio_in", "gpio_out", "i2c0", NULL, NULL, NULL, "ph_eint0" }, 6, 0}, + { "PH1", 7, 1, { "gpio_in", "gpio_out", "i2c0", NULL, NULL, NULL, "ph_eint1" }, 6, 1}, + { "PH2", 7, 2, { "gpio_in", "gpio_out", "i2c1", NULL, NULL, NULL, "ph_eint2" }, 6, 2}, + { "PH3", 7, 3, { "gpio_in", "gpio_out", "i2c1", NULL, NULL, NULL, "ph_eint3" }, 6, 3}, + { "PH4", 7, 4, { "gpio_in", "gpio_out", "uart3", NULL, NULL, NULL, "ph_eint4" }, 6, 4}, + { "PH5", 7, 5, { "gpio_in", "gpio_out", "uart3", NULL, NULL, NULL, "ph_eint5" }, 6, 5}, + { "PH6", 7, 6, { "gpio_in", "gpio_out", "uart3", NULL, NULL, NULL, "ph_eint6" }, 6, 6}, + { "PH7", 7, 7, { "gpio_in", "gpio_out", "uart3", NULL, NULL, NULL, "ph_eint7" }, 6, 7}, + { "PH8", 7, 8, { "gpio_in", "gpio_out", "owa", NULL, NULL, NULL, "ph_eint8" }, 6, 8}, + { "PH9", 7, 9, { "gpio_in", "gpio_out", NULL, NULL, NULL, NULL, "ph_eint9" }, 6, 9}, + { "PH10", 7, 10, { "gpio_in", "gpio_out", "mic", NULL, NULL, NULL, "ph_eint10" }, 6, 10}, + { "PH11", 7, 11, { "gpio_in", "gpio_out", "mic", NULL, NULL, NULL, "ph_eint11" }, 6, 11}, }; const struct allwinner_padconf a64_padconf = { diff --git a/sys/arm/allwinner/a64/a64_r_padconf.c b/sys/arm/allwinner/a64/a64_r_padconf.c index daac9e6efe9..fb5dc62cf07 100644 --- a/sys/arm/allwinner/a64/a64_r_padconf.c +++ b/sys/arm/allwinner/a64/a64_r_padconf.c @@ -41,19 +41,19 @@ __FBSDID("$FreeBSD$"); #ifdef SOC_ALLWINNER_A64 static const struct allwinner_pins a64_r_pins[] = { - { "PL0", 0, 0, { "gpio_in", "gpio_out", "s_rsb", "s_i2c", NULL, NULL, "pl_eint0" } 6, 0}, - { "PL1", 0, 1, { "gpio_in", "gpio_out", "s_rsb", "s_i2c", NULL, NULL, "pl_eint1" } 6, 1}, - { "PL2", 0, 2, { "gpio_in", "gpio_out", "s_uart", NULL, NULL, NULL, "pl_eint2" } 6, 2}, - { "PL3", 0, 3, { "gpio_in", "gpio_out", "s_uart", NULL, NULL, NULL, "pl_eint3" } 6, 3}, - { "PL4", 0, 4, { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "pl_eint4" } 6, 4}, - { "PL5", 0, 5, { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "pl_eint5" } 6, 5}, - { "PL6", 0, 6, { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "pl_eint6" } 6, 6}, - { "PL7", 0, 7, { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "pl_eint7" } 6, 7}, - { "PL8", 0, 8, { "gpio_in", "gpio_out", "s_i2c", NULL, NULL, NULL, "pl_eint8" } 6, 8}, - { "PL9", 0, 9, { "gpio_in", "gpio_out", "s_i2c", NULL, NULL, NULL, "pl_eint9" } 6, 9}, - { "PL10", 0, 10, { "gpio_in", "gpio_out", "s_pwm", NULL, NULL, NULL, "pl_eint10" } 6, 10}, - { "PL11", 0, 11, { "gpio_in", "gpio_out", "s_cir", NULL, NULL, NULL, "pl_eint11" } 6, 11}, - { "PL12", 0, 12, { "gpio_in", "gpio_out", NULL, NULL, NULL, NULL, "pl_eint12" } 6, 12}, + { "PL0", 0, 0, { "gpio_in", "gpio_out", "s_rsb", "s_i2c", NULL, NULL, "pl_eint0" }, 6, 0}, + { "PL1", 0, 1, { "gpio_in", "gpio_out", "s_rsb", "s_i2c", NULL, NULL, "pl_eint1" }, 6, 1}, + { "PL2", 0, 2, { "gpio_in", "gpio_out", "s_uart", NULL, NULL, NULL, "pl_eint2" }, 6, 2}, + { "PL3", 0, 3, { "gpio_in", "gpio_out", "s_uart", NULL, NULL, NULL, "pl_eint3" }, 6, 3}, + { "PL4", 0, 4, { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "pl_eint4" }, 6, 4}, + { "PL5", 0, 5, { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "pl_eint5" }, 6, 5}, + { "PL6", 0, 6, { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "pl_eint6" }, 6, 6}, + { "PL7", 0, 7, { "gpio_in", "gpio_out", "s_jtag", NULL, NULL, NULL, "pl_eint7" }, 6, 7}, + { "PL8", 0, 8, { "gpio_in", "gpio_out", "s_i2c", NULL, NULL, NULL, "pl_eint8" }, 6, 8}, + { "PL9", 0, 9, { "gpio_in", "gpio_out", "s_i2c", NULL, NULL, NULL, "pl_eint9" }, 6, 9}, + { "PL10", 0, 10, { "gpio_in", "gpio_out", "s_pwm", NULL, NULL, NULL, "pl_eint10" }, 6, 10}, + { "PL11", 0, 11, { "gpio_in", "gpio_out", "s_cir", NULL, NULL, NULL, "pl_eint11" }, 6, 11}, + { "PL12", 0, 12, { "gpio_in", "gpio_out", NULL, NULL, NULL, NULL, "pl_eint12" }, 6, 12}, }; const struct allwinner_padconf a64_r_padconf = { From 6eef8586945dfaac8a3c049ff8ad9a63439931cc Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Thu, 15 Dec 2016 17:36:54 +0000 Subject: [PATCH 199/226] Add -fPIC to the ubldr build. Without this the self relocation code will try to use an absolute address in a switch statement, jumping to an invalid memory location. Sponsored by: ABT Systems Ltd --- sys/boot/arm/uboot/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/boot/arm/uboot/Makefile b/sys/boot/arm/uboot/Makefile index 8b4b8caea59..94955d84e82 100644 --- a/sys/boot/arm/uboot/Makefile +++ b/sys/boot/arm/uboot/Makefile @@ -109,6 +109,8 @@ CFLAGS+= -I${.OBJDIR}/../../uboot/lib # where to get libstand from CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ +CFLAGS+= -fPIC + # clang doesn't understand %D as a specifier to printf NO_WERROR.clang= From 602f95d4c4b87003655c74f5c0b25de0b381dfcc Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Thu, 15 Dec 2016 21:26:58 +0000 Subject: [PATCH 200/226] Add WITH_REPRODUCIBLE_BUILD src.conf(5) knob to disable kernel metadata The kernel builds reproducibly, except for the time, date, user, and hostname baked into the kernel (reported at startup and via the kern.version sysctl for uname). Add a build knob to disable the inclusion of this metadata. Reviewed by: jhb MFC after: 1 month Relnotes: Yes Sponsored by: Reproducible Builds World Summit 2, Berlin Differential Revision: https://reviews.freebsd.org/D8809 --- sys/conf/kern.opts.mk | 3 ++- sys/conf/kern.post.mk | 5 ++++- tools/build/options/WITH_REPRODUCIBLE_BUILD | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 tools/build/options/WITH_REPRODUCIBLE_BUILD diff --git a/sys/conf/kern.opts.mk b/sys/conf/kern.opts.mk index b8f0c3ec62b..66d43b2ac51 100644 --- a/sys/conf/kern.opts.mk +++ b/sys/conf/kern.opts.mk @@ -47,7 +47,8 @@ __DEFAULT_NO_OPTIONS = \ EISA \ EXTRA_TCP_STACKS \ NAND \ - OFED + OFED \ + REPRODUCIBLE_BUILD # Some options are totally broken on some architectures. We disable # them. If you need to enable them on an experimental basis, you diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk index 128e47d6743..a16cb031875 100644 --- a/sys/conf/kern.post.mk +++ b/sys/conf/kern.post.mk @@ -357,8 +357,11 @@ config.o env.o hints.o vers.o vnode_if.o: config.ln env.ln hints.ln vers.ln vnode_if.ln: ${NORMAL_LINT} +.if ${MK_REPRODUCIBLE_BUILD} != "no" +REPRO_FLAG="-r" +.endif vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} - MAKE=${MAKE} sh $S/conf/newvers.sh ${KERN_IDENT} + MAKE=${MAKE} sh $S/conf/newvers.sh ${REPRO_FLAG} ${KERN_IDENT} vnode_if.c: $S/tools/vnode_if.awk $S/kern/vnode_if.src ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -c diff --git a/tools/build/options/WITH_REPRODUCIBLE_BUILD b/tools/build/options/WITH_REPRODUCIBLE_BUILD new file mode 100644 index 00000000000..fec4b1eef16 --- /dev/null +++ b/tools/build/options/WITH_REPRODUCIBLE_BUILD @@ -0,0 +1,3 @@ +$FreeBSD$ +Set to exclude build metadata (build time, user, host and path) from the +kernel and uname output. From 26eae5c68170049d53865571346c3119f81ce380 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Fri, 16 Dec 2016 00:04:32 +0000 Subject: [PATCH 201/226] [ar933x] don't waste memory/flash; drop the UMTX_CHAINS count down to 16. --- sys/mips/conf/std.AR933X | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/mips/conf/std.AR933X b/sys/mips/conf/std.AR933X index 5b35213d9c3..f082b31731d 100644 --- a/sys/mips/conf/std.AR933X +++ b/sys/mips/conf/std.AR933X @@ -27,6 +27,8 @@ options KDB options ALQ options ALT_BREAK_TO_DEBUGGER +options UMTX_CHAINS=16 + options SCHED_4BSD #4BSD scheduler options INET #InterNETworking #options INET6 #InterNETworking From d90714d2c5929530465e251cb79e671a72c57860 Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Fri, 16 Dec 2016 00:23:59 +0000 Subject: [PATCH 202/226] libbfd: drop unnecessary variable increment. Do not increment `s' before it is initialized. At the time of the increment, `s' is otherwise unused anyway. Obtained from: OpenBSD (CVS rev 1.11) --- contrib/binutils/bfd/elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/binutils/bfd/elf.c b/contrib/binutils/bfd/elf.c index ed09cb51c47..4020a50888c 100644 --- a/contrib/binutils/bfd/elf.c +++ b/contrib/binutils/bfd/elf.c @@ -8826,7 +8826,7 @@ _bfd_elf_get_synthetic_symtab (bfd *abfd, count = relplt->size / hdr->sh_entsize; size = count * sizeof (asymbol); p = relplt->relocation; - for (i = 0; i < count; i++, s++, p++) + for (i = 0; i < count; i++, p++) size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt"); s = *ret = bfd_malloc (size); From 6e183b4b25eabca8c696162fb4411b03d8b34f99 Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Fri, 16 Dec 2016 00:35:59 +0000 Subject: [PATCH 203/226] libbfd: make sure variables are initialized before using them. Initialize l_sec_contents to make sure that free(l_sec_contents) is called on valid pointers. Obtained from: OpenBSD (partial CVS rev 1.18) MFC after: 5 days --- contrib/binutils/bfd/elflink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/binutils/bfd/elflink.c b/contrib/binutils/bfd/elflink.c index f1e50def8b5..10d987ccf2b 100644 --- a/contrib/binutils/bfd/elflink.c +++ b/contrib/binutils/bfd/elflink.c @@ -11487,7 +11487,7 @@ _bfd_elf_section_already_linked (bfd *abfd, struct bfd_section *sec, abfd, sec); else if (sec->size != 0) { - bfd_byte *sec_contents, *l_sec_contents; + bfd_byte *sec_contents, *l_sec_contents = NULL; if (!bfd_malloc_and_get_section (abfd, sec, &sec_contents)) (*_bfd_error_handler) From 6a1c4d1efcf53060fcb982478a6a2f330573c725 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Fri, 16 Dec 2016 01:37:44 +0000 Subject: [PATCH 204/226] capsicum_helpers: Add LOOKUP flag Add a helper routine for opening a directory that is restricted to being used for opening relative files as stdio streams. I think this will really help basic adaptation of multi-file programs to Capsicum. Rather than having each program initialize a rights object and ioctl/fcntl arrays for their root fd for relative opens, consolidate in the logical place. Reviewed by: oshogbo@ Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8743 --- lib/libcapsicum/capsicum_helpers.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/libcapsicum/capsicum_helpers.h b/lib/libcapsicum/capsicum_helpers.h index 1f7655d5fb9..d1a84a98a85 100644 --- a/lib/libcapsicum/capsicum_helpers.h +++ b/lib/libcapsicum/capsicum_helpers.h @@ -41,6 +41,7 @@ #define CAPH_IGNORE_EBADF 0x0001 #define CAPH_READ 0x0002 #define CAPH_WRITE 0x0004 +#define CAPH_LOOKUP 0x0008 static __inline int caph_limit_stream(int fd, int flags) @@ -54,6 +55,8 @@ caph_limit_stream(int fd, int flags) cap_rights_set(&rights, CAP_READ); if ((flags & CAPH_WRITE) != 0) cap_rights_set(&rights, CAP_WRITE); + if ((flags & CAPH_LOOKUP) != 0) + cap_rights_set(&rights, CAP_LOOKUP); if (cap_rights_limit(fd, &rights) < 0 && errno != ENOSYS) { if (errno == EBADF && (flags & CAPH_IGNORE_EBADF) != 0) From 1d1bfbbb385c6849c5f45f095ddc06b18749eef8 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Fri, 16 Dec 2016 01:39:06 +0000 Subject: [PATCH 205/226] libelf: Fix extended numbering detection Extended numbering is used for any of these fields overflowing. Reviewed by: emaste@ Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8701 --- contrib/elftoolchain/libelf/libelf_ehdr.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/contrib/elftoolchain/libelf/libelf_ehdr.c b/contrib/elftoolchain/libelf/libelf_ehdr.c index d375fb30028..08c4a17ed5d 100644 --- a/contrib/elftoolchain/libelf/libelf_ehdr.c +++ b/contrib/elftoolchain/libelf/libelf_ehdr.c @@ -170,10 +170,6 @@ _libelf_ehdr(Elf *e, int ec, int allocate) (*xlator)((unsigned char*) ehdr, msz, e->e_rawfile, (size_t) 1, e->e_byteorder != LIBELF_PRIVATE(byteorder)); - /* - * If extended numbering is being used, read the correct - * number of sections and program header entries. - */ if (ec == ELFCLASS32) { phnum = ((Elf32_Ehdr *) ehdr)->e_phnum; shnum = ((Elf32_Ehdr *) ehdr)->e_shnum; @@ -193,12 +189,19 @@ _libelf_ehdr(Elf *e, int ec, int allocate) return (NULL); } - if (shnum != 0 || shoff == 0LL) { /* not using extended numbering */ + /* + * If extended numbering is being used, read the correct + * number of sections and program header entries. + */ + if ((shnum == 0 && shoff != 0) || phnum == PN_XNUM || strndx == SHN_XINDEX) { + if (_libelf_load_extended(e, ec, shoff, phnum, strndx) == 0) + return (NULL); + } else { + /* not using extended numbering */ e->e_u.e_elf.e_nphdr = phnum; e->e_u.e_elf.e_nscn = shnum; e->e_u.e_elf.e_strndx = strndx; - } else if (_libelf_load_extended(e, ec, shoff, phnum, strndx) == 0) - return (NULL); + } return (ehdr); } From 93326017f627976ea17f60a1bc17f98f1249c6b3 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Fri, 16 Dec 2016 01:42:51 +0000 Subject: [PATCH 206/226] gelf_getphdr: Allow extended indices Needed for 'readelf -l' of extended phnum files. (Parity with GNU binutils.) Reviewed by: no one, unfortunately Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8703 --- contrib/elftoolchain/libelf/gelf_phdr.c | 32 ++++++++++--------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/contrib/elftoolchain/libelf/gelf_phdr.c b/contrib/elftoolchain/libelf/gelf_phdr.c index 31e20b0680c..4786b27c62b 100644 --- a/contrib/elftoolchain/libelf/gelf_phdr.c +++ b/contrib/elftoolchain/libelf/gelf_phdr.c @@ -53,10 +53,17 @@ gelf_getphdr(Elf *e, int index, GElf_Phdr *d) Elf64_Ehdr *eh64; Elf32_Phdr *ep32; Elf64_Phdr *ep64; + size_t phnum; if (d == NULL || e == NULL || ((ec = e->e_class) != ELFCLASS32 && ec != ELFCLASS64) || - (e->e_kind != ELF_K_ELF) || index < 0) { + (e->e_kind != ELF_K_ELF) || index < 0 || + elf_getphdrnum(e, &phnum) < 0) { + LIBELF_SET_ERROR(ARGUMENT, 0); + return (NULL); + } + + if ((size_t)index >= phnum) { LIBELF_SET_ERROR(ARGUMENT, 0); return (NULL); } @@ -66,11 +73,6 @@ gelf_getphdr(Elf *e, int index, GElf_Phdr *d) ((ep32 = _libelf_getphdr(e, ELFCLASS32)) == NULL)) return (NULL); - if (index >= eh32->e_phnum) { - LIBELF_SET_ERROR(ARGUMENT, 0); - return (NULL); - } - ep32 += index; d->p_type = ep32->p_type; @@ -87,11 +89,6 @@ gelf_getphdr(Elf *e, int index, GElf_Phdr *d) (ep64 = _libelf_getphdr(e, ELFCLASS64)) == NULL) return (NULL); - if (index >= eh64->e_phnum) { - LIBELF_SET_ERROR(ARGUMENT, 0); - return (NULL); - } - ep64 += index; *d = *ep64; @@ -125,13 +122,15 @@ gelf_newphdr(Elf *e, size_t count) int gelf_update_phdr(Elf *e, int ndx, GElf_Phdr *s) { - int ec, phnum; + int ec; + size_t phnum; void *ehdr; Elf32_Phdr *ph32; Elf64_Phdr *ph64; if (s == NULL || e == NULL || e->e_kind != ELF_K_ELF || - ((ec = e->e_class) != ELFCLASS32 && ec != ELFCLASS64)) { + ((ec = e->e_class) != ELFCLASS32 && ec != ELFCLASS64) || + elf_getphdrnum(e, &phnum) < 0) { LIBELF_SET_ERROR(ARGUMENT, 0); return (0); } @@ -144,12 +143,7 @@ gelf_update_phdr(Elf *e, int ndx, GElf_Phdr *s) if ((ehdr = _libelf_ehdr(e, ec, 0)) == NULL) return (0); - if (ec == ELFCLASS32) - phnum = ((Elf32_Ehdr *) ehdr)->e_phnum; - else - phnum = ((Elf64_Ehdr *) ehdr)->e_phnum; - - if (ndx < 0 || ndx > phnum) { + if (ndx < 0 || (size_t)ndx > phnum) { LIBELF_SET_ERROR(ARGUMENT, 0); return (0); } From ec055aeff50e6b6311e3307fed436a89d01085da Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Fri, 16 Dec 2016 01:44:50 +0000 Subject: [PATCH 207/226] vfprintf(3): Add support for kernel %b format This is a direct port of the kernel %b format. I'm unclear on if (more) non-portable printf extensions will be a problem. I think it's desirable to have userspace formats include all kernel formats, but there may be competing goals I'm not aware of. Reviewed by: no one, unfortunately Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8426 --- lib/libc/stdio/vfprintf.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index bf45bfb421e..37b8f3f00d8 100644 --- a/lib/libc/stdio/vfprintf.c +++ b/lib/libc/stdio/vfprintf.c @@ -611,6 +611,37 @@ reswitch: switch (ch) { case 'z': flags |= SIZET; goto rflag; + case 'b': + { + const char *q; + int anybitset, bit; + + ulval = (u_int)GETARG(int); + cp = GETARG(char *); + + q = __ultoa(ulval, buf + BUF, *cp++, 0, xdigs_lower); + PRINT(q, buf + BUF - q); + + if (ulval == 0) + break; + + for (anybitset = 0; *cp;) { + bit = *cp++; + if (ulval & (1 << (bit - 1))) { + PRINT(anybitset ? "," : "<", 1); + q = cp; + for (; (bit = *cp) > ' '; ++cp) + continue; + PRINT(q, cp - q); + anybitset = 1; + } else + for (; *cp > ' '; ++cp) + continue; + } + if (anybitset) + PRINT(">", 1); + } + continue; case 'C': flags |= LONGINT; /*FALLTHROUGH*/ From 941e22d17d46fefc701405faca9124c39f299d92 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Fri, 16 Dec 2016 01:47:08 +0000 Subject: [PATCH 208/226] Capsicumify last(1) Reviewed by: ed (earlier version), emaste (earlier version) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8001 --- usr.bin/last/last.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c index 1db10b399df..1f31ae3c79d 100644 --- a/usr.bin/last/last.c +++ b/usr.bin/last/last.c @@ -40,8 +40,11 @@ static const char sccsid[] = "@(#)last.c 8.2 (Berkeley) 4/2/94"; __FBSDID("$FreeBSD$"); #include +#include +#include #include +#include #include #include #include @@ -56,7 +59,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #define NO 0 /* false/no */ #define YES 1 /* true/yes */ @@ -176,6 +178,19 @@ main(int argc, char *argv[]) usage(); } + if (caph_limit_stdio() < 0) + err(1, "can't limit stdio rights"); + + caph_cache_catpages(); + caph_cache_tzdata(); + + /* Cache UTX database. */ + if (setutxdb(UTXDB_LOG, file) != 0) + err(1, "%s", file != NULL ? file : "(default utx db)"); + + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "cap_enter"); + if (sflag && width == 8) usage(); if (argc) { @@ -213,8 +228,6 @@ wtmp(void) (void)time(&t); /* Load the last entries from the file. */ - if (setutxdb(UTXDB_LOG, file) != 0) - err(1, "%s", file); while ((ut = getutxent()) != NULL) { if (amount % 128 == 0) { buf = realloc(buf, (amount + 128) * sizeof *ut); From 9716e7d4e4551df05a9418d261b87901cefe4ae8 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Fri, 16 Dec 2016 01:48:55 +0000 Subject: [PATCH 209/226] dma-mbox-create: Restrict with Capsicum The restriction here is pretty late and pretty minimal. We need a lot of authority to open password databases, and don't do much after that point. Feedback from: lifanov at mail.lifanov.com (earlier version), emaste (earlier version) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D7988 --- contrib/dma/dma-mbox-create.c | 39 ++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/contrib/dma/dma-mbox-create.c b/contrib/dma/dma-mbox-create.c index 80088601f2d..75cd741a69a 100644 --- a/contrib/dma/dma-mbox-create.c +++ b/contrib/dma/dma-mbox-create.c @@ -38,9 +38,18 @@ * user-supplied information. Keep the root window as small as possible. */ +#ifdef __FreeBSD__ +#define USE_CAPSICUM 1 +#endif + #include +#if USE_CAPSICUM +#include +#endif #include +#include +#include #include #include #include @@ -84,6 +93,9 @@ logfail(int exitcode, const char *fmt, ...) int main(int argc, char **argv) { +#if USE_CAPSICUM + cap_rights_t rights; +#endif const char *user; struct passwd *pw; struct group *gr; @@ -91,7 +103,10 @@ main(int argc, char **argv) gid_t mail_gid; int f, maildirfd; - openlog("dma-mbox-create", 0, LOG_MAIL); + /* + * Open log fd now for capability sandbox. + */ + openlog("dma-mbox-create", LOG_NDELAY, LOG_MAIL); errno = 0; gr = getgrnam(DMA_GROUP); @@ -133,6 +148,28 @@ main(int argc, char **argv) if (maildirfd < 0) logfail(EX_NOINPUT, "cannot open maildir %s", _PATH_MAILDIR); + /* + * Cache NLS data, for strerror, for err(3), before entering capability + * mode. + */ + caph_cache_catpages(); + + /* + * Cache local time before entering Capsicum capability sandbox. + */ + caph_cache_tzdata(); + +#if USE_CAPSICUM + cap_rights_init(&rights, CAP_CREATE, CAP_FCHMOD, CAP_FCHOWN, + CAP_LOOKUP, CAP_READ); + if (cap_rights_limit(maildirfd, &rights) < 0 && errno != ENOSYS) + err(EX_OSERR, "can't limit maildirfd rights"); + + /* Enter Capsicum capability sandbox */ + if (cap_enter() < 0 && errno != ENOSYS) + err(EX_OSERR, "cap_enter"); +#endif + user_uid = pw->pw_uid; f = openat(maildirfd, user, O_RDONLY|O_CREAT|O_NOFOLLOW, 0600); From 20502a13a09f1fe17d9c6bdd039fd34bcaabf55d Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Fri, 16 Dec 2016 01:51:12 +0000 Subject: [PATCH 210/226] ministat(1): Capsicumify Separate dataset opening from reading/parsing. The number of input files is already capped to a small number, so just open all input files before sandboxing. Feedback from: allanjude@ (earlier version), emaste@ (earlier version) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D7925 --- usr.bin/ministat/ministat.c | 65 +++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/usr.bin/ministat/ministat.c b/usr.bin/ministat/ministat.c index 02b5025a436..ae4f977a5fb 100644 --- a/usr.bin/ministat/ministat.c +++ b/usr.bin/ministat/ministat.c @@ -11,17 +11,21 @@ #include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include -#include -#include -#include +#include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #define NSTUDENT 100 #define NCONF 6 static double const studentpct[] = { 80, 90, 95, 98, 99, 99.5 }; @@ -455,26 +459,14 @@ dbl_cmp(const void *a, const void *b) } static struct dataset * -ReadSet(const char *n, int column, const char *delim) +ReadSet(FILE *f, const char *n, int column, const char *delim) { - FILE *f; char buf[BUFSIZ], *p, *t; struct dataset *s; double d; int line; int i; - if (n == NULL) { - f = stdin; - n = ""; - } else if (!strcmp(n, "-")) { - f = stdin; - n = ""; - } else { - f = fopen(n, "r"); - } - if (f == NULL) - err(1, "Cannot open %s", n); s = NewSet(); s->name = strdup(n); line = 0; @@ -499,7 +491,6 @@ ReadSet(const char *n, int column, const char *delim) if (*buf != '\0') AddPoint(s, d); } - fclose(f); if (s->n < 3) { fprintf(stderr, "Dataset %s must contain at least 3 data points\n", n); @@ -536,7 +527,9 @@ usage(char const *whine) int main(int argc, char **argv) { - struct dataset *ds[7]; + const char *setfilenames[MAX_DS - 1]; + struct dataset *ds[MAX_DS - 1]; + FILE *setfiles[MAX_DS - 1]; int nds; double a; const char *delim = " \t"; @@ -609,14 +602,36 @@ main(int argc, char **argv) argv += optind; if (argc == 0) { - ds[0] = ReadSet("-", column, delim); + setfilenames[0] = ""; + setfiles[0] = stdin; nds = 1; } else { if (argc > (MAX_DS - 1)) usage("Too many datasets."); nds = argc; - for (i = 0; i < nds; i++) - ds[i] = ReadSet(argv[i], column, delim); + for (i = 0; i < nds; i++) { + setfilenames[i] = argv[i]; + setfiles[i] = fopen(argv[i], "r"); + if (setfiles[i] == NULL) + err(2, "Cannot open %s", argv[i]); + } + } + + if (caph_limit_stdio() < 0) + err(2, "capsicum"); + + for (i = 0; i < nds; i++) + if (caph_limit_stream(fileno(setfiles[i]), CAPH_READ) < 0) + err(2, "unable to limit rights for %s", + setfilenames[i]); + + /* Enter Capsicum sandbox. */ + if (cap_enter() < 0 && errno != ENOSYS) + err(2, "unable to enter capability mode"); + + for (i = 0; i < nds; i++) { + ds[i] = ReadSet(setfiles[i], setfilenames[i], column, delim); + fclose(setfiles[i]); } for (i = 0; i < nds; i++) From 208a8594598481b55ed54e7bd7e6386372f542ec Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Fri, 16 Dec 2016 01:59:28 +0000 Subject: [PATCH 211/226] ktrdump(8): Capsicumify We restrict the (optional) input file and output files. It would be nice to restrict the KVM files, but that's up to libkvm. We wait until after kvm_nlist() is invoked to cap_enter() because kldsym() isn't supported in the Capsicum sandbox. Feedback from: emaste@ (earlier versions) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D7921 --- usr.bin/ktrdump/ktrdump.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/usr.bin/ktrdump/ktrdump.c b/usr.bin/ktrdump/ktrdump.c index 84ab3a837fb..d6a4e0911d0 100644 --- a/usr.bin/ktrdump/ktrdump.c +++ b/usr.bin/ktrdump/ktrdump.c @@ -29,11 +29,14 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include +#include #include +#include #include #include #include @@ -70,6 +73,7 @@ static int hflag; static char corefile[PATH_MAX]; static char execfile[PATH_MAX]; +static char outfile[PATH_MAX] = "stdout"; static char desc[SBUFLEN]; static char errbuf[_POSIX2_LINE_MAX]; @@ -87,6 +91,7 @@ main(int ac, char **av) struct ktr_entry *buf; uintmax_t tlast, tnow; unsigned long bufptr; + cap_rights_t rights; struct stat sb; kvm_t *kd; FILE *out; @@ -122,6 +127,11 @@ main(int ac, char **av) iflag = 1; if ((in = open(optarg, O_RDONLY)) == -1) err(1, "%s", optarg); + cap_rights_init(&rights, CAP_FSTAT, CAP_MMAP_R); + if (cap_rights_limit(in, &rights) < 0 && + errno != ENOSYS) + err(1, "unable to limit rights for %s", + optarg); break; case 'M': case 'm': @@ -133,6 +143,7 @@ main(int ac, char **av) case 'o': if ((out = fopen(optarg, "w")) == NULL) err(1, "%s", optarg); + strlcpy(outfile, optarg, sizeof(outfile)); break; case 'q': qflag++; @@ -155,6 +166,10 @@ main(int ac, char **av) if (ac != 0) usage(); + cap_rights_init(&rights, CAP_FSTAT, CAP_WRITE); + if (cap_rights_limit(fileno(out), &rights) < 0 && errno != ENOSYS) + err(1, "unable to limit rights for %s", outfile); + /* * Open our execfile and corefile, resolve needed symbols and read in * the trace buffer. @@ -162,11 +177,28 @@ main(int ac, char **av) if ((kd = kvm_openfiles(Nflag ? execfile : NULL, Mflag ? corefile : NULL, NULL, O_RDONLY, errbuf)) == NULL) errx(1, "%s", errbuf); + + /* + * Cache NLS data, for strerror, for err(3), before entering capability + * mode. + */ + caph_cache_catpages(); + if (kvm_nlist(kd, nl) != 0 || kvm_read(kd, nl[0].n_value, &version, sizeof(version)) == -1) errx(1, "%s", kvm_geterr(kd)); if (version != KTR_VERSION) errx(1, "ktr version mismatch"); + + /* + * Enter Capsicum sandbox. + * + * kvm_nlist() above uses kldsym(2) for native kernels, and that isn't + * allowed in the sandbox. + */ + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "unable to enter capability mode"); + if (iflag) { if (fstat(in, &sb) == -1) errx(1, "stat"); From 327240c75f23d6b4bdb2385e98208749a4aae554 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Fri, 16 Dec 2016 02:03:40 +0000 Subject: [PATCH 212/226] hexdump(1): First cut capsicumification For now, only enter the sandbox for the last file processed (including stdin for zero-argument mode). Sandboxing all inputs will require a little restructuring of the program. Feedback by: emaste@ (earlier versions) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D7915 --- usr.bin/hexdump/display.c | 16 ++++++++++++++++ usr.bin/hexdump/hexdump.c | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/usr.bin/hexdump/display.c b/usr.bin/hexdump/display.c index 36230aa7da5..afa4672bc93 100644 --- a/usr.bin/hexdump/display.c +++ b/usr.bin/hexdump/display.c @@ -36,10 +36,13 @@ static char sccsid[] = "@(#)display.c 8.1 (Berkeley) 6/6/93"; __FBSDID("$FreeBSD$"); #include +#include #include +#include #include #include +#include #include #include #include @@ -355,6 +358,19 @@ next(char **argv) return(0); statok = 0; } + + if (caph_limit_stream(fileno(stdin), CAPH_READ) < 0) + err(1, "unable to restrict %s", + statok ? _argv[-1] : "stdin"); + + /* + * We've opened our last input file; enter capsicum sandbox. + */ + if (*_argv == NULL) { + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "unable to enter capability mode"); + } + if (skip) doskip(statok ? *_argv : "stdin", statok); if (*_argv) diff --git a/usr.bin/hexdump/hexdump.c b/usr.bin/hexdump/hexdump.c index d3c4bb51bac..450c05316db 100644 --- a/usr.bin/hexdump/hexdump.c +++ b/usr.bin/hexdump/hexdump.c @@ -42,6 +42,9 @@ static char sccsid[] = "@(#)hexdump.c 8.1 (Berkeley) 6/6/93"; __FBSDID("$FreeBSD$"); #include +#include +#include +#include #include #include #include @@ -76,6 +79,14 @@ main(int argc, char *argv[]) for (tfs = fshead; tfs; tfs = tfs->nextfs) rewrite(tfs); + /* + * Cache NLS data, for strerror, for err(3), before entering capability + * mode. + */ + caph_cache_catpages(); + if (caph_limit_stdio() < 0) + err(1, "capsicum"); + (void)next(argv); display(); exit(exitval); From 280dd9fc2ec8083ce172532d9644bb3c80072abf Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Fri, 16 Dec 2016 02:06:34 +0000 Subject: [PATCH 213/226] iconv(1): Capsicumify This takes the usual shortcut of only sandboxing the last input file. It's a first cut and this program will be easy to adapt to sandbox all files in the future. iconv(1) has been changed to only open the conversion descriptor once, since the input and output encodings are fixed over all inputs. Instead, the descriptor is simply reset after each use (documented in iconv(3) API). Reviewed by: no one, unfortunately Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D7917 --- usr.bin/iconv/iconv.c | 56 ++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/usr.bin/iconv/iconv.c b/usr.bin/iconv/iconv.c index 161b22e32d1..0c3d83e6171 100644 --- a/usr.bin/iconv/iconv.c +++ b/usr.bin/iconv/iconv.c @@ -28,7 +28,9 @@ */ #include +#include +#include #include #include #include @@ -41,7 +43,7 @@ #include #include -static int do_conv(FILE *, const char *, const char *, bool, bool); +static int do_conv(FILE *, iconv_t, bool, bool); static int do_list(unsigned int, const char * const *, void *); static void usage(void) __dead2; @@ -67,23 +69,16 @@ usage(void) #define INBUFSIZE 1024 #define OUTBUFSIZE (INBUFSIZE * 2) static int -do_conv(FILE *fp, const char *from, const char *to, bool silent, - bool hide_invalid) +do_conv(FILE *fp, iconv_t cd, bool silent, bool hide_invalid) { - iconv_t cd; char inbuf[INBUFSIZE], outbuf[OUTBUFSIZE], *in, *out; unsigned long long invalids; size_t inbytes, outbytes, ret; - if ((cd = iconv_open(to, from)) == (iconv_t)-1) - err(EXIT_FAILURE, "iconv_open(%s, %s)", to, from); + int arg = (int)hide_invalid; + if (iconvctl(cd, ICONV_SET_DISCARD_ILSEQ, (void *)&arg) == -1) + err(EXIT_FAILURE, "iconvctl(DISCARD_ILSEQ, %d)", arg); - if (hide_invalid) { - int arg = 1; - - if (iconvctl(cd, ICONV_SET_DISCARD_ILSEQ, (void *)&arg) == -1) - err(EXIT_FAILURE, NULL); - } invalids = 0; while ((inbytes = fread(inbuf, 1, INBUFSIZE, fp)) > 0) { in = inbuf; @@ -133,7 +128,6 @@ do_conv(FILE *fp, const char *from, const char *to, bool silent, if (invalids > 0 && !silent) warnx("warning: invalid characters: %llu", invalids); - iconv_close(cd); return (invalids > 0); } @@ -155,6 +149,7 @@ do_list(unsigned int n, const char * const *list, void *data __unused) int main(int argc, char **argv) { + iconv_t cd; FILE *fp; const char *opt_f, *opt_t; int ch, i, res; @@ -201,9 +196,28 @@ main(int argc, char **argv) argv += optind; if ((strcmp(opt_f, "") == 0) && (strcmp(opt_t, "") == 0)) usage(); - if (argc == 0) - res = do_conv(stdin, opt_f, opt_t, opt_s, opt_c); - else { + + if (caph_limit_stdio() < 0) + err(EXIT_FAILURE, "capsicum"); + + /* + * Cache NLS data, for strerror, for err(3), before entering capability + * mode. + */ + caph_cache_catpages(); + + /* + * Cache iconv conversion handle before entering sandbox. + */ + cd = iconv_open(opt_t, opt_f); + if (cd == (iconv_t)-1) + err(EXIT_FAILURE, "iconv_open(%s, %s)", opt_t, opt_f); + + if (argc == 0) { + if (cap_enter() < 0 && errno != ENOSYS) + err(EXIT_FAILURE, "unable to enter capability mode"); + res = do_conv(stdin, cd, opt_s, opt_c); + } else { res = 0; for (i = 0; i < argc; i++) { fp = (strcmp(argv[i], "-") != 0) ? @@ -211,9 +225,17 @@ main(int argc, char **argv) if (fp == NULL) err(EXIT_FAILURE, "Cannot open `%s'", argv[i]); - res |= do_conv(fp, opt_f, opt_t, opt_s, opt_c); + /* Enter Capsicum sandbox for final input file. */ + if (i + 1 == argc && cap_enter() < 0 && errno != ENOSYS) + err(EXIT_FAILURE, + "unable to enter capability mode"); + res |= do_conv(fp, cd, opt_s, opt_c); (void)fclose(fp); + + /* Reset iconv descriptor state. */ + (void)iconv(cd, NULL, NULL, NULL, NULL); } } + iconv_close(cd); return (res == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } From 1ea1b275780cf47d1495d8c6a2f1f7cca6a37452 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Fri, 16 Dec 2016 02:09:48 +0000 Subject: [PATCH 214/226] ident(1): Capsicumify Preopen input file list before entering Capsicum capability mode. Feedback by: allanjude@, bapt@, emaste@ (earlier versions) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D7918 --- usr.bin/ident/ident.c | 49 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/usr.bin/ident/ident.c b/usr.bin/ident/ident.c index 36e56a0cefd..fa04f00274f 100644 --- a/usr.bin/ident/ident.c +++ b/usr.bin/ident/ident.c @@ -28,11 +28,14 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include +#include #include #include +#include #include #include #include @@ -202,8 +205,9 @@ int main(int argc, char **argv) { bool quiet = false; - int ch, i; + int ch, i, *fds, fd; int ret = EXIT_SUCCESS; + size_t nfds; FILE *fp; while ((ch = getopt(argc, argv, "qV")) != -1) { @@ -223,17 +227,50 @@ main(int argc, char **argv) argc -= optind; argv += optind; - if (argc == 0) - return (scan(stdin, NULL, quiet)); + if (caph_limit_stdio() < 0) + err(EXIT_FAILURE, "unable to limit stdio"); - for (i = 0; i < argc; i++) { - fp = fopen(argv[i], "r"); + if (argc == 0) { + nfds = 1; + fds = malloc(sizeof(*fds)); + if (fds == NULL) + err(EXIT_FAILURE, "unable to allocate fds array"); + fds[0] = STDIN_FILENO; + } else { + nfds = argc; + fds = malloc(sizeof(*fds) * nfds); + if (fds == NULL) + err(EXIT_FAILURE, "unable to allocate fds array"); + + for (i = 0; i < argc; i++) { + fds[i] = fd = open(argv[i], O_RDONLY); + if (fd < 0) { + warn("%s", argv[i]); + ret = EXIT_FAILURE; + continue; + } + if (caph_limit_stream(fd, CAPH_READ) < 0) + err(EXIT_FAILURE, + "unable to limit fcntls/rights for %s", + argv[i]); + } + } + + /* Enter Capsicum sandbox. */ + if (cap_enter() < 0 && errno != ENOSYS) + err(EXIT_FAILURE, "unable to enter capability mode"); + + for (i = 0; i < (int)nfds; i++) { + if (fds[i] < 0) + continue; + + fp = fdopen(fds[i], "r"); if (fp == NULL) { warn("%s", argv[i]); ret = EXIT_FAILURE; continue; } - if (scan(fp, argv[i], quiet) != EXIT_SUCCESS) + if (scan(fp, argc == 0 ? NULL : argv[i], quiet) != EXIT_SUCCESS) ret = EXIT_FAILURE; fclose(fp); } From fa133b6bf028e8dce5694b6a41538cf7de87fc05 Mon Sep 17 00:00:00 2001 From: Justin Hibbits Date: Fri, 16 Dec 2016 04:38:53 +0000 Subject: [PATCH 215/226] Use the right bitwise OR operation for clearing single-step at trap time. DBCR0_IDM || DBCRO_IC yields 1, which in this register is DBCR0_FT, not what we want. Reported by: Mark Millard MFC after: 2 weeks --- sys/powerpc/powerpc/trap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/powerpc/powerpc/trap.c b/sys/powerpc/powerpc/trap.c index b3217628943..a98b5c77ef5 100644 --- a/sys/powerpc/powerpc/trap.c +++ b/sys/powerpc/powerpc/trap.c @@ -280,7 +280,7 @@ trap(struct trapframe *frame) case EXC_DEBUG: /* Single stepping */ mtspr(SPR_DBSR, mfspr(SPR_DBSR)); frame->srr1 &= ~PSL_DE; - frame->cpu.booke.dbcr0 &= ~(DBCR0_IDM || DBCR0_IC); + frame->cpu.booke.dbcr0 &= ~(DBCR0_IDM | DBCR0_IC); sig = SIGTRAP; ucode = TRAP_TRACE; break; From fdbc9e6e82c9a4ede2629dd22e6b505cbdadb0ee Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Fri, 16 Dec 2016 04:43:31 +0000 Subject: [PATCH 216/226] [net80211] start laying down the foundation for 11ac support. This is a work in progress and some of this stuff may change; but hopefully I'm laying down enough stuff and space in fields to allow it to grow without another major recompile. We'll see! * Add a net80211 PHY type for VHT 2G and VHT 5G. Note - yes, VHT is supposed to be for 5GHZ, however some vendors (*cough* most of them) support some subset of VHT rate support in 2GHz. No - not 80MHz wide channels, but at least some MCS8-9 support, maybe some beamforming, and maybe some longer A-MPDU aggregates. I don't want to even think about MU-MIMO on 2GHz. * Add an ifmedia placeholder type for VHT rates. * Add channel flags for VHT, VHT20/40U/40D/80/80+80/160 * Add channel macros for the above * Add ieee80211_channel fields for the VHT information and flags, along with some padding (so this struct definitely grows.) * Add a phy type flag for VHT - 'v' * Bump the number of channels to a much higher amount - until we get something like the linux mac80211 chanctx abstraction (where the stack provides a current channel configuration via callbacks, versus the driver ever checking ic->ic_curchan or similar) we'll have to populate VHT+HT combinations. Eg, there'll likely be a full set of duplicate VHT20/40 channels to match HT channels. There will also be a full set of duplicate VHT80 channels - note that for VHT80, its assumed you're doing VHT40 as a base, so we don't need a duplicate of VHT80 + 20MHz only primary channels, only a duplicate of all the VHT40 combinations. I don't want to think about VHT80+80 or VHT160 for now - and I won't, as the current device I'm doing 11ac bringup on (QCA9880) only does VHT80. I'll likely revisit the channel configuration and scanning related stuff after I get VHT20/40 up. * Add vht flags and the basic MCS rate setup to ieee80211com, ieee80211vap and ieee80211_node in preparation for 11ac configuration. There is zero code that uses this right now. * Whilst here, add some more placeholders in case I need to extend out things by some uint32_t flag sized fields. Hopefully I won't! What I haven't yet done: * any of the code that uses this * any of the beamforming related fields * any of the MU-MIMO fields required for STA/AP operation * any of the IE fields in beacon frame / probe request/response handling and the calculations required for shifting beacon contents around when the TIM grows/shrinks This will require a full rebuild of net80211 related programs - ifconfig, hostapd, wpa_supplicant. --- sys/net/if_media.h | 3 ++ sys/net80211/_ieee80211.h | 54 ++++++++++++++++++++++++++++++++--- sys/net80211/ieee80211_node.h | 9 ++++++ sys/net80211/ieee80211_var.h | 13 +++++++++ 4 files changed, 75 insertions(+), 4 deletions(-) diff --git a/sys/net/if_media.h b/sys/net/if_media.h index 86439950c32..19bf4686937 100644 --- a/sys/net/if_media.h +++ b/sys/net/if_media.h @@ -264,6 +264,7 @@ uint64_t ifmedia_baudrate(int); #define IFM_IEEE80211_OFDM27 23 /* OFDM 27Mbps */ /* NB: not enough bits to express MCS fully */ #define IFM_IEEE80211_MCS 24 /* HT MCS rate */ +#define IFM_IEEE80211_VHT 25 /* HT MCS rate */ #define IFM_IEEE80211_ADHOC 0x00000100 /* Operate in Adhoc mode */ #define IFM_IEEE80211_HOSTAP 0x00000200 /* Operate in Host AP mode */ @@ -280,6 +281,8 @@ uint64_t ifmedia_baudrate(int); #define IFM_IEEE80211_FH 0x00040000 /* 2Ghz, GFSK mode */ #define IFM_IEEE80211_11NA 0x00050000 /* 5Ghz, HT mode */ #define IFM_IEEE80211_11NG 0x00060000 /* 2Ghz, HT mode */ +#define IFM_IEEE80211_VHT5G 0x00070000 /* 5Ghz, VHT mode */ +#define IFM_IEEE80211_VHT2G 0x00080000 /* 2Ghz, VHT mode */ /* * ATM diff --git a/sys/net80211/_ieee80211.h b/sys/net80211/_ieee80211.h index 7a33b53a232..0faeeb4c8f9 100644 --- a/sys/net80211/_ieee80211.h +++ b/sys/net80211/_ieee80211.h @@ -45,6 +45,7 @@ enum ieee80211_phytype { IEEE80211_T_HT, /* high throughput */ IEEE80211_T_OFDM_HALF, /* 1/2 rate OFDM */ IEEE80211_T_OFDM_QUARTER, /* 1/4 rate OFDM */ + IEEE80211_T_VHT, /* VHT PHY */ }; #define IEEE80211_T_CCK IEEE80211_T_DS /* more common nomenclature */ @@ -68,8 +69,10 @@ enum ieee80211_phymode { IEEE80211_MODE_11NG = 9, /* 2GHz, w/ HT */ IEEE80211_MODE_HALF = 10, /* OFDM, 1/2x clock */ IEEE80211_MODE_QUARTER = 11, /* OFDM, 1/4x clock */ + IEEE80211_MODE_VHT_2GHZ = 12, /* 2GHz, VHT */ + IEEE80211_MODE_VHT_5GHZ = 13, /* 5GHz, VHT */ }; -#define IEEE80211_MODE_MAX (IEEE80211_MODE_QUARTER+1) +#define IEEE80211_MODE_MAX (IEEE80211_MODE_VHT_5GHZ+1) #define IEEE80211_MODE_BYTES howmany(IEEE80211_MODE_MAX, NBBY) /* @@ -134,7 +137,7 @@ enum ieee80211_roamingmode { */ struct ieee80211_channel { uint32_t ic_flags; /* see below */ - uint16_t ic_freq; /* setting in MHz */ + uint16_t ic_freq; /* primary centre frequency in MHz */ uint8_t ic_ieee; /* IEEE channel number */ int8_t ic_maxregpower; /* maximum regulatory tx power in dBm */ int8_t ic_maxpower; /* maximum tx power in .5 dBm */ @@ -144,9 +147,17 @@ struct ieee80211_channel { int8_t ic_maxantgain; /* maximum antenna gain in .5 dBm */ uint8_t ic_pad; uint16_t ic_devdata; /* opaque device/driver data */ + uint8_t ic_vht_ch_freq1; /* VHT primary freq1 IEEE value */ + uint8_t ic_vht_ch_freq2; /* VHT secondary 80MHz freq2 IEEE value */ + uint16_t ic_freq2; /* VHT secondary 80MHz freq2 MHz */ }; -#define IEEE80211_CHAN_MAX 256 +/* + * Note: for VHT operation we will need significantly more than + * IEEE80211_CHAN_MAX channels because of the combinations of + * VHT20, VHT40, VHT80, VHT80+80 and VHT160. + */ +#define IEEE80211_CHAN_MAX 1024 #define IEEE80211_CHAN_BYTES howmany(IEEE80211_CHAN_MAX, NBBY) #define IEEE80211_CHAN_ANY 0xffff /* token for ``any channel'' */ #define IEEE80211_CHAN_ANYC \ @@ -177,14 +188,26 @@ struct ieee80211_channel { #define IEEE80211_CHAN_NOADHOC 0x00200000 /* adhoc mode not allowed */ #define IEEE80211_CHAN_NOHOSTAP 0x00400000 /* hostap mode not allowed */ #define IEEE80211_CHAN_11D 0x00800000 /* 802.11d required */ +#define IEEE80211_CHAN_VHT20 0x01000000 /* VHT20 channel */ +#define IEEE80211_CHAN_VHT40U 0x02000000 /* VHT40 channel, ext above */ +#define IEEE80211_CHAN_VHT40D 0x04000000 /* VHT40 channel, ext below */ +#define IEEE80211_CHAN_VHT80 0x08000000 /* VHT80 channel */ +#define IEEE80211_CHAN_VHT80_80 0x10000000 /* VHT80+80 channel */ +#define IEEE80211_CHAN_VHT160 0x20000000 /* VHT160 channel */ #define IEEE80211_CHAN_HT40 (IEEE80211_CHAN_HT40U | IEEE80211_CHAN_HT40D) #define IEEE80211_CHAN_HT (IEEE80211_CHAN_HT20 | IEEE80211_CHAN_HT40) +#define IEEE80211_CHAN_VHT40 (IEEE80211_CHAN_VHT40U | IEEE80211_CHAN_VHT40D) +#define IEEE80211_CHAN_VHT (IEEE80211_CHAN_VHT20 | IEEE80211_CHAN_VHT40 \ + | IEEE80211_CHAN_VHT80 | IEEE80211_CHAN_VHT80_80 \ + | IEEE80211_CHAN_VHT160) + #define IEEE80211_CHAN_BITS \ "\20\1PRIV0\2PRIV2\3PRIV3\4PRIV4\5TURBO\6CCK\7OFDM\0102GHZ\0115GHZ" \ "\12PASSIVE\13DYN\14GFSK\15GSM\16STURBO\17HALF\20QUARTER\21HT20" \ "\22HT40U\23HT40D\24DFS\0254MSXMIT\26NOADHOC\27NOHOSTAP\03011D" +/* XXX TODO: add VHT bits */ /* * Useful combinations of channel characteristics. @@ -210,7 +233,7 @@ struct ieee80211_channel { (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_GFSK | \ IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_DYN | \ IEEE80211_CHAN_HALF | IEEE80211_CHAN_QUARTER | \ - IEEE80211_CHAN_HT) + IEEE80211_CHAN_HT | IEEE80211_CHAN_VHT) #define IEEE80211_CHAN_ALLTURBO \ (IEEE80211_CHAN_ALL | IEEE80211_CHAN_TURBO | IEEE80211_CHAN_STURBO) @@ -287,6 +310,29 @@ struct ieee80211_channel { #define IEEE80211_IS_CHAN_11D(_c) \ (((_c)->ic_flags & IEEE80211_CHAN_11D) != 0) +#define IEEE80211_IS_CHAN_VHT(_c) \ + (((_c)->ic_flags & IEEE80211_CHAN_VHT) != 0) +#define IEEE80211_IS_CHAN_VHT20(_c) \ + (((_c)->ic_flags & IEEE80211_CHAN_VHT20) != 0) +#define IEEE80211_IS_CHAN_VHT40(_c) \ + (((_c)->ic_flags & IEEE80211_CHAN_VHT40) != 0) +#define IEEE80211_IS_CHAN_VHT40U(_c) \ + (((_c)->ic_flags & IEEE80211_CHAN_VHT40U) != 0) +#define IEEE80211_IS_CHAN_VHT40D(_c) \ + (((_c)->ic_flags & IEEE80211_CHAN_VHT40D) != 0) +#define IEEE80211_IS_CHAN_VHTA(_c) \ + (IEEE80211_IS_CHAN_5GHZ(_c) && \ + ((_c)->ic_flags & IEEE80211_CHAN_VHT) != 0) +#define IEEE80211_IS_CHAN_VHTG(_c) \ + (IEEE80211_IS_CHAN_2GHZ(_c) && \ + ((_c)->ic_flags & IEEE80211_CHAN_VHT) != 0) +#define IEEE80211_IS_CHAN_VHT80(_c) \ + (((_c)->ic_flags & IEEE80211_CHAN_VHT80) != 0) +#define IEEE80211_IS_CHAN_VHT80_80(_c) \ + (((_c)->ic_flags & IEEE80211_CHAN_VHT80_80) != 0) +#define IEEE80211_IS_CHAN_VHT160(_c) \ + (((_c)->ic_flags & IEEE80211_CHAN_VHT160) != 0) + #define IEEE80211_CHAN2IEEE(_c) (_c)->ic_ieee /* dynamic state */ diff --git a/sys/net80211/ieee80211_node.h b/sys/net80211/ieee80211_node.h index 699247d658e..7a706731bb6 100644 --- a/sys/net80211/ieee80211_node.h +++ b/sys/net80211/ieee80211_node.h @@ -224,6 +224,15 @@ struct ieee80211_node { struct ieee80211_tx_ampdu ni_tx_ampdu[WME_NUM_TID]; struct ieee80211_rx_ampdu ni_rx_ampdu[WME_NUM_TID]; + /* VHT state */ + uint32_t ni_vhtcap; + uint32_t ni_vhtinfo; + struct ieee80211_vht_mcs_info ni_vht_mcsinfo; + uint8_t ni_vht_chan1; /* 20/40/80/160 - VHT chan1 */ + uint8_t ni_vht_chan2; /* 80+80 - VHT chan2 */ + uint16_t ni_vht_pad1; + uint32_t ni_vht_spare[8]; + /* fast-frames state */ struct mbuf * ni_tx_superg[WME_NUM_TID]; diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index d8e20c2d631..358f2601188 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -229,6 +229,12 @@ struct ieee80211com { uint8_t ic_rxstream; /* # RX streams */ uint8_t ic_txstream; /* # TX streams */ + /* VHT information */ + uint32_t ic_vhtcaps; /* VHT capabilities */ + uint32_t ic_vhtextcaps; /* VHT extended capabilities (TODO) */ + struct ieee80211_vht_mcs_info iv_vht_mcsinfo; /* Support TX/RX VHT MCS */ + uint32_t ic_vht_spare[4]; + /* optional state for Atheros SuperG protocol extensions */ struct ieee80211_superg *ic_superg; @@ -390,6 +396,13 @@ struct ieee80211vap { int iv_inact_run; /* authorized setting */ int iv_inact_probe; /* inactive probe time */ + /* VHT flags */ + uint32_t iv_flags_vht; /* VHT state flags */ + uint32_t iv_vhtcaps; /* VHT capabilities */ + uint32_t iv_vhtextcaps; /* VHT extended capabilities (TODO) */ + struct ieee80211_vht_mcs_info iv_vht_mcsinfo; + uint32_t iv_vht_spare[4]; + int iv_des_nssid; /* # desired ssids */ struct ieee80211_scan_ssid iv_des_ssid[1];/* desired ssid table */ uint8_t iv_des_bssid[IEEE80211_ADDR_LEN]; From 7aebd3e55da25970e8b73fbf2317256cdc6d4ab6 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Fri, 16 Dec 2016 04:44:14 +0000 Subject: [PATCH 217/226] [net80211] sigh, course I would miss a commit from the 11ac prep commit. --- sys/net80211/ieee80211.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c index 229217ee765..5ea073290e2 100644 --- a/sys/net80211/ieee80211.c +++ b/sys/net80211/ieee80211.c @@ -2020,6 +2020,10 @@ ieee80211_rate2media(struct ieee80211com *ic, int rate, enum ieee80211_phymode m case IEEE80211_MODE_11NG: case IEEE80211_MODE_TURBO_G: return findmedia(rates, nitems(rates), rate | IFM_IEEE80211_11G); + case IEEE80211_MODE_VHT_2GHZ: + case IEEE80211_MODE_VHT_5GHZ: + /* XXX TODO: need to figure out mapping for VHT rates */ + return IFM_AUTO; } return IFM_AUTO; } @@ -2053,6 +2057,7 @@ ieee80211_media2rate(int mword) 9, /* IFM_IEEE80211_OFDM4 */ 54, /* IFM_IEEE80211_OFDM27 */ -1, /* IFM_IEEE80211_MCS */ + -1, /* IFM_IEEE80211_VHT */ }; return IFM_SUBTYPE(mword) < nitems(ieeerates) ? ieeerates[IFM_SUBTYPE(mword)] : 0; @@ -2103,6 +2108,8 @@ ieee80211_channel_type_char(const struct ieee80211_channel *c) return 'T'; if (IEEE80211_IS_CHAN_108G(c)) return 'G'; + if (IEEE80211_IS_CHAN_VHT(c)) + return 'v'; if (IEEE80211_IS_CHAN_HT(c)) return 'n'; if (IEEE80211_IS_CHAN_A(c)) From df85a9edd92ed80e534921ba4b6efc09dc7b9ee4 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Fri, 16 Dec 2016 04:44:46 +0000 Subject: [PATCH 218/226] Bump FreeBSD_version . --- sys/sys/param.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/param.h b/sys/sys/param.h index 7bdc85f314b..b182fa39378 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1200018 /* Master, propagated to newvers */ +#define __FreeBSD_version 1200019 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From 8d58dade1a3255aa86832c58ca9d8a83dce1f67d Mon Sep 17 00:00:00 2001 From: Justin Hibbits Date: Fri, 16 Dec 2016 04:47:29 +0000 Subject: [PATCH 219/226] Fix disassembly by adding back some deleted lines. When importing for r309309, as part of conflict resolution, too much extra was removed, resulting in bad disassembly for branches. Correct this. Also re-apply the 0->NULL change from r298052. X-MFC-With: r309309 --- sys/powerpc/powerpc/db_disasm.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/powerpc/powerpc/db_disasm.c b/sys/powerpc/powerpc/db_disasm.c index 88c03276259..29d74629c12 100644 --- a/sys/powerpc/powerpc/db_disasm.c +++ b/sys/powerpc/powerpc/db_disasm.c @@ -871,8 +871,11 @@ disasm_fields(const struct opcode *popcode, instr_t instr, vm_offset_t loc, func &= ~Op_crbB; } if (func & Op_LI) { - u_int LI; + int LI; LI = extract_field(instr, 31 - 29, 24); + LI = LI << 8; + LI = LI >> 6; + LI += loc; APP_PSTR("0x%x", LI); func &= ~Op_LI; } @@ -897,8 +900,11 @@ disasm_fields(const struct opcode *popcode, instr_t instr, vm_offset_t loc, ; } if (func & Op_BD) { - u_int BD; + int BD; BD = extract_field(instr, 31 - 29, 14); + BD = BD << 18; + BD = BD >> 16; + BD += loc; /* Need to sign extend and shift up 2, then add addr */ APP_PSTR("0x%x", BD); func &= ~Op_BD; @@ -968,9 +974,9 @@ disasm_fields(const struct opcode *popcode, instr_t instr, vm_offset_t loc, reg = "tbu"; break; default: - reg = 0; + reg = NULL; } - if (reg == 0) + if (reg == NULL) APP_PSTR(", [unknown tbr %d ]", tbr); else APP_PSTR(", %s", reg); From 07b5fdfd01215720b0a14d849962bcad0a41da2a Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Fri, 16 Dec 2016 06:25:51 +0000 Subject: [PATCH 220/226] cxgbe(4): Changes to the default T6 firmware configuration file. - Disable features that are not supported or not used on FreeBSD. - Increase the RSS table slice per interface. - Increase the share of the TCAM reserved for filtering. MFH: 2 weeks Sponsored by: Chelsio Communications --- sys/dev/cxgbe/firmware/t6fw_cfg.txt | 616 +++++++--------------------- 1 file changed, 157 insertions(+), 459 deletions(-) diff --git a/sys/dev/cxgbe/firmware/t6fw_cfg.txt b/sys/dev/cxgbe/firmware/t6fw_cfg.txt index 0027ee32370..019fd68e663 100644 --- a/sys/dev/cxgbe/firmware/t6fw_cfg.txt +++ b/sys/dev/cxgbe/firmware/t6fw_cfg.txt @@ -1,63 +1,12 @@ -# Chelsio T6 Factory Default configuration file. +# Firmware configuration file. # -# Copyright (C) 2014-2016 Chelsio Communications. All rights reserved. -# -# DO NOT MODIFY THIS FILE UNDER ANY CIRCUMSTANCES. MODIFICATION OF THIS FILE -# WILL RESULT IN A NON-FUNCTIONAL ADAPTER AND MAY RESULT IN PHYSICAL DAMAGE -# TO ADAPTERS. +# Global limits (some are hardware limits, others are due to the firmware). +# nvi = 128 virtual interfaces +# niqflint = 1023 ingress queues with freelists and/or interrupts +# nethctrl = 64K Ethernet or ctrl egress queues +# neq = 64K egress queues of all kinds, including freelists +# nexactf = 512 MPS TCAM entries, can oversubscribe. - -# This file provides the default, power-on configuration for 2-port T6-based -# adapters shipped from the factory. These defaults are designed to address -# the needs of the vast majority of Terminator customers. The basic idea is to -# have a default configuration which allows a customer to plug a Terminator -# adapter in and have it work regardless of OS, driver or application except in -# the most unusual and/or demanding customer applications. -# -# Many of the Terminator resources which are described by this configuration -# are finite. This requires balancing the configuration/operation needs of -# device drivers across OSes and a large number of customer application. -# -# Some of the more important resources to allocate and their constaints are: -# 1. Virtual Interfaces: 256. -# 2. Ingress Queues with Free Lists: 1024. -# 3. Egress Queues: 128K. -# 4. MSI-X Vectors: 1088. -# 5. Multi-Port Support (MPS) TCAM: 336 entries to support MAC destination -# address matching on Ingress Packets. -# -# Some of the important OS/Driver resource needs are: -# 6. Some OS Drivers will manage all resources through a single Physical -# Function (currently PF4 but it could be any Physical Function). -# 7. Some OS Drivers will manage different ports and functions (NIC, -# storage, etc.) on different Physical Functions. For example, NIC -# functions for ports 0-1 on PF0-1, FCoE on PF4, iSCSI on PF5, etc. -# -# Some of the customer application needs which need to be accommodated: -# 8. Some customers will want to support large CPU count systems with -# good scaling. Thus, we'll need to accommodate a number of -# Ingress Queues and MSI-X Vectors to allow up to some number of CPUs -# to be involved per port and per application function. For example, -# in the case where all ports and application functions will be -# managed via a single Unified PF and we want to accommodate scaling up -# to 8 CPUs, we would want: -# -# 2 ports * -# 3 application functions (NIC, FCoE, iSCSI) per port * -# 16 Ingress Queue/MSI-X Vectors per application function -# -# for a total of 96 Ingress Queues and MSI-X Vectors on the Unified PF. -# (Plus a few for Firmware Event Queues, etc.) -# -# 9. Some customers will want to use PCI-E SR-IOV Capability to allow Virtual -# Machines to directly access T6 functionality via SR-IOV Virtual Functions -# and "PCI Device Passthrough" -- this is especially true for the NIC -# application functionality. -# - - -# Global configuration settings. -# [global] rss_glb_config_mode = basicvirtual rss_glb_config_options = tnlmapen,hashtoeplitz,tnlalllkp @@ -65,75 +14,29 @@ # PL_TIMEOUT register pl_timeout_value = 200 # the timeout value in units of us - # The following Scatter Gather Engine (SGE) settings assume a 4KB Host - # Page Size and a 64B L1 Cache Line Size. It programs the - # EgrStatusPageSize and IngPadBoundary to 64B and the PktShift to 2. - # If a Master PF Driver finds itself on a machine with different - # parameters, then the Master PF Driver is responsible for initializing - # these parameters to appropriate values. - # - # Notes: - # 1. The Free List Buffer Sizes below are raw and the firmware will - # round them up to the Ingress Padding Boundary. - # 2. The SGE Timer Values below are expressed below in microseconds. - # The firmware will convert these values to Core Clock Ticks when - # it processes the configuration parameters. - # - reg[0x1008] = 0x40810/0x21c70 # SGE_CONTROL - reg[0x100c] = 0x22222222 # SGE_HOST_PAGE_SIZE - reg[0x10a0] = 0x01040810 # SGE_INGRESS_RX_THRESHOLD - reg[0x1044] = 4096 # SGE_FL_BUFFER_SIZE0 - reg[0x1048] = 65536 # SGE_FL_BUFFER_SIZE1 - reg[0x104c] = 1536 # SGE_FL_BUFFER_SIZE2 - reg[0x1050] = 9024 # SGE_FL_BUFFER_SIZE3 - reg[0x1054] = 9216 # SGE_FL_BUFFER_SIZE4 - reg[0x1058] = 2048 # SGE_FL_BUFFER_SIZE5 - reg[0x105c] = 128 # SGE_FL_BUFFER_SIZE6 - reg[0x1060] = 8192 # SGE_FL_BUFFER_SIZE7 - reg[0x1064] = 16384 # SGE_FL_BUFFER_SIZE8 - reg[0x10a4] = 0xa000a000/0xf000f000 # SGE_DBFIFO_STATUS - reg[0x10a8] = 0x402000/0x402000 # SGE_DOORBELL_CONTROL - sge_timer_value = 5, 10, 20, 50, 100, 200 # SGE_TIMER_VALUE* in usecs - reg[0x10c4] = 0x20000000/0x20000000 # GK_CONTROL, enable 5th thread + sge_timer_value = 1, 5, 10, 50, 100, 200 # SGE_TIMER_VALUE* in usecs - # enable TP_OUT_CONFIG.IPIDSPLITMODE - reg[0x7d04] = 0x00010000/0x00010000 + reg[0x10c4] = 0x20000000/0x20000000 # GK_CONTROL, enable 5th thread reg[0x7dc0] = 0x0e2f8849 # TP_SHIFT_CNT #Tick granularities in kbps tsch_ticks = 100000, 10000, 1000, 10 - # TP_VLAN_PRI_MAP to select filter tuples and enable ServerSram - # filter control: compact, fcoemask - # server sram : srvrsram - # filter tuples : fragmentation, mpshittype, macmatch, ethertype, - # protocol, tos, vlan, vnic_id, port, fcoe - # valid filterModes are described the Terminator 5 Data Book - filterMode = fcoemask, srvrsram, fragmentation, mpshittype, protocol, vlan, port, fcoe - - # filter tuples enforced in LE active region (equal to or subset of filterMode) + filterMode = fragmentation, mpshittype, protocol, vlan, port, fcoe filterMask = protocol, fcoe - # Percentage of dynamic memory (in either the EDRAM or external MEM) - # to use for TP RX payload - tp_pmrx = 30 - - # TP RX payload page size + tp_pmrx = 36, 512 tp_pmrx_pagesize = 64K - # TP number of RX channels - tp_nrxch = 0 # 0 (auto) = 1 + # TP number of RX channels (0 = auto) + tp_nrxch = 0 - # Percentage of dynamic memory (in either the EDRAM or external MEM) - # to use for TP TX payload - tp_pmtx = 50 - - # TP TX payload page size + tp_pmtx = 46, 512 tp_pmtx_pagesize = 64K - # TP number of TX channels - tp_ntxch = 0 # 0 (auto) = equal number of ports + # TP number of TX channels (0 = auto) + tp_ntxch = 0 # TP OFLD MTUs tp_mtus = 88, 256, 512, 576, 808, 1024, 1280, 1488, 1500, 2002, 2048, 4096, 4352, 8192, 9000, 9600 @@ -150,6 +53,9 @@ # TP_PARA_REG0 reg[0x7d60] = 0x06000000/0x07000000 # set InitCWND to 6 + # cluster, lan, or wan. + tp_tcptuning = lan + # LE_DB_CONFIG reg[0x19c04] = 0x00000000/0x00440000 # LE Server SRAM disabled # LE IPv4 compression disabled @@ -179,301 +85,117 @@ # MC configuration #mc_mode_brc[0] = 1 # mc0 - 1: enable BRC, 0: enable RBC -# Some "definitions" to make the rest of this a bit more readable. We support -# 4 ports, 3 functions (NIC, FCoE and iSCSI), scaling up to 8 "CPU Queue Sets" -# per function per port ... -# -# NMSIX = 1088 # available MSI-X Vectors -# NVI = 256 # available Virtual Interfaces -# NMPSTCAM = 336 # MPS TCAM entries -# -# NPORTS = 2 # ports -# NCPUS = 16 # CPUs we want to support scalably -# NFUNCS = 3 # functions per port (NIC, FCoE, iSCSI) - -# Breakdown of Virtual Interface/Queue/Interrupt resources for the "Unified -# PF" which many OS Drivers will use to manage most or all functions. -# -# Each Ingress Queue can use one MSI-X interrupt but some Ingress Queues can -# use Forwarded Interrupt Ingress Queues. For these latter, an Ingress Queue -# would be created and the Queue ID of a Forwarded Interrupt Ingress Queue -# will be specified as the "Ingress Queue Asynchronous Destination Index." -# Thus, the number of MSI-X Vectors assigned to the Unified PF will be less -# than or equal to the number of Ingress Queues ... -# -# NVI_NIC = 4 # NIC access to NPORTS -# NFLIQ_NIC = 32 # NIC Ingress Queues with Free Lists -# NETHCTRL_NIC = 32 # NIC Ethernet Control/TX Queues -# NEQ_NIC = 64 # NIC Egress Queues (FL, ETHCTRL/TX) -# NMPSTCAM_NIC = 16 # NIC MPS TCAM Entries (NPORTS*4) -# NMSIX_NIC = 32 # NIC MSI-X Interrupt Vectors (FLIQ) -# -# NVI_OFLD = 0 # Offload uses NIC function to access ports -# NFLIQ_OFLD = 16 # Offload Ingress Queues with Free Lists -# NETHCTRL_OFLD = 0 # Offload Ethernet Control/TX Queues -# NEQ_OFLD = 16 # Offload Egress Queues (FL) -# NMPSTCAM_OFLD = 0 # Offload MPS TCAM Entries (uses NIC's) -# NMSIX_OFLD = 16 # Offload MSI-X Interrupt Vectors (FLIQ) -# -# NVI_RDMA = 0 # RDMA uses NIC function to access ports -# NFLIQ_RDMA = 4 # RDMA Ingress Queues with Free Lists -# NETHCTRL_RDMA = 0 # RDMA Ethernet Control/TX Queues -# NEQ_RDMA = 4 # RDMA Egress Queues (FL) -# NMPSTCAM_RDMA = 0 # RDMA MPS TCAM Entries (uses NIC's) -# NMSIX_RDMA = 4 # RDMA MSI-X Interrupt Vectors (FLIQ) -# -# NEQ_WD = 128 # Wire Direct TX Queues and FLs -# NETHCTRL_WD = 64 # Wire Direct TX Queues -# NFLIQ_WD = 64 ` # Wire Direct Ingress Queues with Free Lists -# -# NVI_ISCSI = 4 # ISCSI access to NPORTS -# NFLIQ_ISCSI = 4 # ISCSI Ingress Queues with Free Lists -# NETHCTRL_ISCSI = 0 # ISCSI Ethernet Control/TX Queues -# NEQ_ISCSI = 4 # ISCSI Egress Queues (FL) -# NMPSTCAM_ISCSI = 4 # ISCSI MPS TCAM Entries (NPORTS) -# NMSIX_ISCSI = 4 # ISCSI MSI-X Interrupt Vectors (FLIQ) -# -# NVI_FCOE = 4 # FCOE access to NPORTS -# NFLIQ_FCOE = 34 # FCOE Ingress Queues with Free Lists -# NETHCTRL_FCOE = 32 # FCOE Ethernet Control/TX Queues -# NEQ_FCOE = 66 # FCOE Egress Queues (FL) -# NMPSTCAM_FCOE = 32 # FCOE MPS TCAM Entries (NPORTS) -# NMSIX_FCOE = 34 # FCOE MSI-X Interrupt Vectors (FLIQ) - -# Two extra Ingress Queues per function for Firmware Events and Forwarded -# Interrupts, and two extra interrupts per function for Firmware Events (or a -# Forwarded Interrupt Queue) and General Interrupts per function. -# -# NFLIQ_EXTRA = 6 # "extra" Ingress Queues 2*NFUNCS (Firmware and -# # Forwarded Interrupts -# NMSIX_EXTRA = 6 # extra interrupts 2*NFUNCS (Firmware and -# # General Interrupts - -# Microsoft HyperV resources. The HyperV Virtual Ingress Queues will have -# their interrupts forwarded to another set of Forwarded Interrupt Queues. -# -# NVI_HYPERV = 16 # VMs we want to support -# NVIIQ_HYPERV = 2 # Virtual Ingress Queues with Free Lists per VM -# NFLIQ_HYPERV = 40 # VIQs + NCPUS Forwarded Interrupt Queues -# NEQ_HYPERV = 32 # VIQs Free Lists -# NMPSTCAM_HYPERV = 16 # MPS TCAM Entries (NVI_HYPERV) -# NMSIX_HYPERV = 8 # NCPUS Forwarded Interrupt Queues - -# Adding all of the above Unified PF resource needs together: (NIC + OFLD + -# RDMA + ISCSI + FCOE + EXTRA + HYPERV) -# -# NVI_UNIFIED = 28 -# NFLIQ_UNIFIED = 106 -# NETHCTRL_UNIFIED = 32 -# NEQ_UNIFIED = 124 -# NMPSTCAM_UNIFIED = 40 -# -# The sum of all the MSI-X resources above is 74 MSI-X Vectors but we'll round -# that up to 128 to make sure the Unified PF doesn't run out of resources. -# -# NMSIX_UNIFIED = 128 -# -# The Storage PFs could need up to NPORTS*NCPUS + NMSIX_EXTRA MSI-X Vectors -# which is 34 but they're probably safe with 32. -# -# NMSIX_STORAGE = 32 - -# Note: The UnifiedPF is PF4 which doesn't have any Virtual Functions -# associated with it. Thus, the MSI-X Vector allocations we give to the -# UnifiedPF aren't inherited by any Virtual Functions. As a result we can -# provision many more Virtual Functions than we can if the UnifiedPF were -# one of PF0-3. -# - -# All of the below PCI-E parameters are actually stored in various *_init.txt -# files. We include them below essentially as comments. -# -# For PF0-3 we assign 8 vectors each for NIC Ingress Queues of the associated -# ports 0-3. -# -# For PF4, the Unified PF, we give it an MSI-X Table Size as outlined above. -# -# For PF5-6 we assign enough MSI-X Vectors to support FCoE and iSCSI -# storage applications across all four possible ports. -# -# Additionally, since the UnifiedPF isn't one of the per-port Physical -# Functions, we give the UnifiedPF and the PF0-3 Physical Functions -# different PCI Device IDs which will allow Unified and Per-Port Drivers -# to directly select the type of Physical Function to which they wish to be -# attached. -# -# Note that the actual values used for the PCI-E Intelectual Property will be -# 1 less than those below since that's the way it "counts" things. For -# readability, we use the number we actually mean ... -# -# PF0_INT = 8 # NCPUS -# PF1_INT = 8 # NCPUS -# PF0_3_INT = 32 # PF0_INT + PF1_INT + PF2_INT + PF3_INT -# -# PF4_INT = 128 # NMSIX_UNIFIED -# PF5_INT = 32 # NMSIX_STORAGE -# PF6_INT = 32 # NMSIX_STORAGE -# PF7_INT = 0 # Nothing Assigned -# PF4_7_INT = 192 # PF4_INT + PF5_INT + PF6_INT + PF7_INT -# -# PF0_7_INT = 224 # PF0_3_INT + PF4_7_INT -# -# With the above we can get 17 VFs/PF0-3 (limited by 336 MPS TCAM entries) -# but we'll lower that to 16 to make our total 64 and a nice power of 2 ... -# -# NVF = 16 - - -# For those OSes which manage different ports on different PFs, we need -# only enough resources to support a single port's NIC application functions -# on PF0-3. The below assumes that we're only doing NIC with NCPUS "Queue -# Sets" for ports 0-3. The FCoE and iSCSI functions for such OSes will be -# managed on the "storage PFs" (see below). -# +# PFs 0-3. These get 8 MSI/8 MSI-X vectors each. VFs are supported by +# these 4 PFs only. [function "0"] - nvf = 16 # NVF on this function - wx_caps = all # write/execute permissions for all commands - r_caps = all # read permissions for all commands - nvi = 1 # 1 port - niqflint = 8 # NCPUS "Queue Sets" - nethctrl = 8 # NCPUS "Queue Sets" - neq = 16 # niqflint + nethctrl Egress Queues - nexactf = 8 # number of exact MPSTCAM MAC filters - cmask = all # access to all channels - pmask = 0x1 # access to only one port - + nvf = 4 + wx_caps = all + r_caps = all + nvi = 2 + rssnvi = 2 + niqflint = 4 + nethctrl = 4 + neq = 8 + nexactf = 4 + cmask = all + pmask = 0x1 [function "1"] - nvf = 16 # NVF on this function - wx_caps = all # write/execute permissions for all commands - r_caps = all # read permissions for all commands - nvi = 1 # 1 port - niqflint = 8 # NCPUS "Queue Sets" - nethctrl = 8 # NCPUS "Queue Sets" - neq = 16 # niqflint + nethctrl Egress Queues - nexactf = 8 # number of exact MPSTCAM MAC filters - cmask = all # access to all channels - pmask = 0x2 # access to only one port + nvf = 4 + wx_caps = all + r_caps = all + nvi = 2 + rssnvi = 2 + niqflint = 4 + nethctrl = 4 + neq = 8 + nexactf = 4 + cmask = all + pmask = 0x2 [function "2"] - nvf = 16 # NVF on this function - wx_caps = all # write/execute permissions for all commands - r_caps = all # read permissions for all commands - nvi = 1 # 1 port - niqflint = 8 # NCPUS "Queue Sets" - nethctrl = 8 # NCPUS "Queue Sets" - neq = 16 # niqflint + nethctrl Egress Queues - nexactf = 8 # number of exact MPSTCAM MAC filters - cmask = all # access to all channels - pmask = 0x4 # access to only one port + nvf = 4 + wx_caps = all + r_caps = all + nvi = 2 + rssnvi = 2 + niqflint = 4 + nethctrl = 4 + neq = 8 + nexactf = 4 + cmask = all + pmask = 0x4 [function "3"] - nvf = 16 # NVF on this function - wx_caps = all # write/execute permissions for all commands - r_caps = all # read permissions for all commands - nvi = 1 # 1 port - niqflint = 8 # NCPUS "Queue Sets" - nethctrl = 8 # NCPUS "Queue Sets" - neq = 16 # niqflint + nethctrl Egress Queues - nexactf = 8 # number of exact MPSTCAM MAC filters - cmask = all # access to all channels - pmask = 0x8 # access to only one port + nvf = 4 + wx_caps = all + r_caps = all + nvi = 2 + rssnvi = 2 + niqflint = 4 + nethctrl = 4 + neq = 8 + nexactf = 4 + cmask = all + pmask = 0x8 - -# Some OS Drivers manage all application functions for all ports via PF4. -# Thus we need to provide a large number of resources here. For Egress -# Queues we need to account for both TX Queues as well as Free List Queues -# (because the host is responsible for producing Free List Buffers for the -# hardware to consume). -# +# PF4 is the resource-rich PF that the bus/nexus driver attaches to. +# It gets 32 MSI/128 MSI-X vectors. [function "4"] - wx_caps = all # write/execute permissions for all commands - r_caps = all # read permissions for all commands - nvi = 28 # NVI_UNIFIED - niqflint = 202 # NFLIQ_UNIFIED + NLFIQ_WD + NFLIQ_CRYPTO (32) - nethctrl = 100 # NETHCTRL_UNIFIED + NETHCTRL_WD - neq = 256 # NEQ_UNIFIED + NEQ_WD - nqpcq = 12288 - nexactf = 40 # NMPSTCAM_UNIFIED - cmask = all # access to all channels - pmask = all # access to all four ports ... - nethofld = 1024 # number of user mode ethernet flow contexts - ncrypto_lookaside = 16 # Number of lookaside flow contexts - nclip = 320 # number of clip region entries - nfilter = 496 # number of filter region entries - nserver = 496 # number of server region entries - nhash = 12288 # number of hash region entries - nhpfilter = 0 # number of high priority filter region entries - protocol = nic_vm, ofld, rddp, rdmac, iscsi_initiator_pdu, iscsi_target_pdu, iscsi_t10dif, tlskeys, crypto_lookaside - tp_l2t = 3072 + wx_caps = all + r_caps = all + nvi = 32 + rssnvi = 8 + niqflint = 512 + nethctrl = 1024 + neq = 2048 + nqpcq = 8192 + nexactf = 456 + cmask = all + pmask = all + nclip = 320 + + # TCAM has 6K cells; each region must start at a multiple of 128 cell. + # Each entry in these categories takes 2 cells each. nhash will use the + # TCAM iff there is room left (that is, the rest don't add up to 3072). + nfilter = 2032 + nserver = 512 + nhpfilter = 0 + nhash = 16384 + protocol = ofld, rddp, rdmac, iscsi_initiator_pdu, iscsi_target_pdu, iscsi_t10dif + tp_l2t = 4096 tp_ddp = 2 tp_ddp_iscsi = 2 - tp_tls_key = 3 - tp_tls_mxrxsize = 17408 # 16384 + 1024, governs max rx data, pm max xfer len, rx coalesce sizes tp_stag = 2 tp_pbl = 5 tp_rq = 7 tp_srq = 128 -# We have FCoE and iSCSI storage functions on PF5 and PF6 each of which may -# need to have Virtual Interfaces on each of the four ports with up to NCPUS -# "Queue Sets" each. -# +# PF5 is the SCSI Controller PF. It gets 32 MSI/40 MSI-X vectors. +# Not used right now. [function "5"] - wx_caps = all # write/execute permissions for all commands - r_caps = all # read permissions for all commands - nvi = 4 # NPORTS - niqflint = 34 # NPORTS*NCPUS + NMSIX_EXTRA - nethctrl = 32 # NPORTS*NCPUS - neq = 64 # NPORTS*NCPUS * 2 (FL, ETHCTRL/TX) - nexactf = 16 # (NPORTS *(no of snmc grp + 1 hw mac) + 1 anmc grp)) rounded to 16. - cmask = all # access to all channels - pmask = all # access to all four ports ... - nserver = 16 - nhash = 2048 - tp_l2t = 1020 - nclip = 64 - protocol = iscsi_initiator_fofld - tp_ddp_iscsi = 2 - iscsi_ntask = 2048 - iscsi_nsess = 2048 - iscsi_nconn_per_session = 1 - iscsi_ninitiator_instance = 64 - + nvi = 1 + rssnvi = 0 +# PF6 is the FCoE Controller PF. It gets 32 MSI/40 MSI-X vectors. +# Not used right now. [function "6"] - wx_caps = all # write/execute permissions for all commands - r_caps = all # read permissions for all commands - nvi = 4 # NPORTS - niqflint = 34 # NPORTS*NCPUS + NMSIX_EXTRA - nethctrl = 32 # NPORTS*NCPUS - neq = 66 # NPORTS*NCPUS * 2 (FL, ETHCTRL/TX) + 2 (EXTRA) - nexactf = 32 # NPORTS + adding 28 exact entries for FCoE - # which is OK since < MIN(SUM PF0..3, PF4) - # and we never load PF0..3 and PF4 concurrently - cmask = all # access to all channels - pmask = all # access to all four ports ... - nhash = 2048 - tp_l2t = 4 - protocol = fcoe_initiator - tp_ddp = 2 - fcoe_nfcf = 16 - fcoe_nvnp = 32 - fcoe_nssn = 1024 - + nvi = 1 + rssnvi = 0 # The following function, 1023, is not an actual PCIE function but is used to # configure and reserve firmware internal resources that come from the global # resource pool. # [function "1023"] - wx_caps = all # write/execute permissions for all commands - r_caps = all # read permissions for all commands - nvi = 4 # NVI_UNIFIED - cmask = all # access to all channels - pmask = all # access to all four ports ... - nexactf = 8 # NPORTS + DCBX + - nfilter = 16 # number of filter region entries + wx_caps = all + r_caps = all + nvi = 4 + rssnvi = 0 + cmask = all + pmask = all + nexactf = 8 + nfilter = 16 # For Virtual functions, we only allow NIC functionality and we only allow @@ -482,107 +204,83 @@ # and GTS registers, the number of Ingress and Egress Queues must be a power # of 2. # -[function "0/*"] # NVF - wx_caps = 0x82 # DMAQ | VF - r_caps = 0x86 # DMAQ | VF | PORT - nvi = 1 # 1 port - niqflint = 4 # 2 "Queue Sets" + NXIQ - nethctrl = 2 # 2 "Queue Sets" - neq = 4 # 2 "Queue Sets" * 2 - nexactf = 4 - cmask = all # access to all channels - pmask = 0x1 # access to only one port ... +[function "0/*"] + wx_caps = 0x82 + r_caps = 0x86 + nvi = 1 + rssnvi = 1 + niqflint = 2 + nethctrl = 2 + neq = 4 + nexactf = 2 + cmask = all + pmask = 0x1 +[function "1/*"] + wx_caps = 0x82 + r_caps = 0x86 + nvi = 1 + rssnvi = 1 + niqflint = 2 + nethctrl = 2 + neq = 4 + nexactf = 2 + cmask = all + pmask = 0x2 -[function "1/*"] # NVF - wx_caps = 0x82 # DMAQ | VF - r_caps = 0x86 # DMAQ | VF | PORT - nvi = 1 # 1 port - niqflint = 4 # 2 "Queue Sets" + NXIQ - nethctrl = 2 # 2 "Queue Sets" - neq = 4 # 2 "Queue Sets" * 2 - nexactf = 4 - cmask = all # access to all channels - pmask = 0x2 # access to only one port ... +[function "2/*"] + wx_caps = 0x82 + r_caps = 0x86 + nvi = 1 + rssnvi = 1 + niqflint = 2 + nethctrl = 2 + neq = 4 + nexactf = 2 + cmask = all + pmask = 0x1 -[function "2/*"] # NVF - wx_caps = 0x82 # DMAQ | VF - r_caps = 0x86 # DMAQ | VF | PORT - nvi = 1 # 1 port - niqflint = 4 # 2 "Queue Sets" + NXIQ - nethctrl = 2 # 2 "Queue Sets" - neq = 4 # 2 "Queue Sets" * 2 - nexactf = 4 - cmask = all # access to all channels - pmask = 0x1 # access to only one port ... +[function "3/*"] + wx_caps = 0x82 + r_caps = 0x86 + nvi = 1 + rssnvi = 1 + niqflint = 2 + nethctrl = 2 + neq = 4 + nexactf = 2 + cmask = all + pmask = 0x2 - -[function "3/*"] # NVF - wx_caps = 0x82 # DMAQ | VF - r_caps = 0x86 # DMAQ | VF | PORT - nvi = 1 # 1 port - niqflint = 4 # 2 "Queue Sets" + NXIQ - nethctrl = 2 # 2 "Queue Sets" - neq = 4 # 2 "Queue Sets" * 2 - nexactf = 4 - cmask = all # access to all channels - pmask = 0x2 # access to only one port ... - -# MPS features a 196608 bytes ingress buffer that is used for ingress buffering -# for packets from the wire as well as the loopback path of the L2 switch. The -# folling params control how the buffer memory is distributed and the L2 flow -# control settings: -# -# bg_mem: %-age of mem to use for port/buffer group -# lpbk_mem: %-age of port/bg mem to use for loopback -# hwm: high watermark; bytes available when starting to send pause -# frames (in units of 0.1 MTU) -# lwm: low watermark; bytes remaining when sending 'unpause' frame -# (in inuits of 0.1 MTU) -# dwm: minimum delta between high and low watermark (in units of 100 -# Bytes) -# +# MPS has 192K buffer space for ingress packets from the wire as well as +# loopback path of the L2 switch. [port "0"] - dcb = ppp, dcbx # configure for DCB PPP and enable DCBX offload + dcb = none #bg_mem = 25 #lpbk_mem = 25 hwm = 60 lwm = 15 dwm = 30 - dcb_app_tlv[0] = 0x8906, ethertype, 3 - dcb_app_tlv[1] = 0x8914, ethertype, 3 - dcb_app_tlv[2] = 3260, socketnum, 5 #aec_retry_cnt = 4 flags = an_dis - fec = none # FEC type none/rs/firecode + fec = none [port "1"] - dcb = ppp, dcbx + dcb = none #bg_mem = 25 #lpbk_mem = 25 hwm = 60 lwm = 15 dwm = 30 - dcb_app_tlv[0] = 0x8906, ethertype, 3 - dcb_app_tlv[1] = 0x8914, ethertype, 3 - dcb_app_tlv[2] = 3260, socketnum, 5 #aec_retry_cnt = 4 flags = an_dis - fec = none # FEC type none/rs/firecode + fec = none [fini] - version = 0x01000024 - checksum = 0x36cebfcb - -# Total resources used by above allocations: -# Virtual Interfaces: 104 -# Ingress Queues/w Free Lists and Interrupts: 526 -# Egress Queues: 702 -# MPS TCAM Entries: 336 -# MSI-X Vectors: 736 -# Virtual Functions: 64 + version = 0x1 + checksum = 0xc3afb4e0 # # $FreeBSD$ # From 5a8b662ea6af8ec3315771ce1e713661e21b9bac Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Fri, 16 Dec 2016 06:30:07 +0000 Subject: [PATCH 221/226] cxgbe(4): Fix typo in an unused macro. MFC after: 3 days Sponsored by: Chelsio Communications --- sys/dev/cxgbe/common/t4_msg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/cxgbe/common/t4_msg.h b/sys/dev/cxgbe/common/t4_msg.h index 3264bac65a8..830743b91a8 100644 --- a/sys/dev/cxgbe/common/t4_msg.h +++ b/sys/dev/cxgbe/common/t4_msg.h @@ -2026,7 +2026,7 @@ struct cpl_rx_pkt { * RX_ERROR_IP_HDR_LEN, RX_ERROR_ETH_HDR_LEN */ #define S_T6_COMPR_RXERR_LEN 1 -#define V_T6_COMPR_RXERR_LEN(x) ((x) << S_COMPR_T6_RXERR_LEN) +#define V_T6_COMPR_RXERR_LEN(x) ((x) << S_T6_COMPR_RXERR_LEN) #define F_T6_COMPR_RXERR_LEN V_COMPR_T6_RXERR_LEN(1U) #define S_T6_COMPR_RXERR_TCP_OPT 2 From 6c925b9c81036a86db387f75a32b423420eadf6c Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Fri, 16 Dec 2016 10:31:13 +0000 Subject: [PATCH 222/226] All armv6 platforms have the same implementation of platform_lastaddr. Replace them with a default handler that returns devmap_lastaddr. Reviewed by: mmel Sponsored by: ABT Systems Ltd Differential Revision: https://reviews.freebsd.org/D8806 --- sys/arm/allwinner/aw_machdep.c | 15 --------------- sys/arm/arm/platform_if.m | 10 ++++++++-- sys/arm/broadcom/bcm2835/bcm2835_machdep.c | 10 ---------- sys/arm/freescale/imx/imx51_machdep.c | 9 --------- sys/arm/freescale/imx/imx53_machdep.c | 9 --------- sys/arm/freescale/imx/imx6_machdep.c | 9 --------- sys/arm/nvidia/tegra124/tegra124_machdep.c | 8 -------- sys/arm/qemu/virt_machdep.c | 9 --------- sys/arm/rockchip/rk30xx_machdep.c | 9 --------- sys/arm/ti/ti_machdep.c | 10 ---------- 10 files changed, 8 insertions(+), 90 deletions(-) diff --git a/sys/arm/allwinner/aw_machdep.c b/sys/arm/allwinner/aw_machdep.c index 2c34475656e..0fd20a5083a 100644 --- a/sys/arm/allwinner/aw_machdep.c +++ b/sys/arm/allwinner/aw_machdep.c @@ -61,7 +61,6 @@ static platform_attach_t a31_attach; static platform_attach_t a31s_attach; static platform_attach_t a83t_attach; static platform_attach_t h3_attach; -static platform_lastaddr_t allwinner_lastaddr; static platform_devmap_init_t allwinner_devmap_init; static platform_cpu_reset_t allwinner_cpu_reset; @@ -129,13 +128,6 @@ h3_attach(platform_t plat) return (0); } -static vm_offset_t -allwinner_lastaddr(platform_t plat) -{ - - return (devmap_lastaddr()); -} - /* * Set up static device mappings. * @@ -166,7 +158,6 @@ allwinner_cpu_reset(platform_t plat) #if defined(SOC_ALLWINNER_A10) static platform_method_t a10_methods[] = { PLATFORMMETHOD(platform_attach, a10_attach), - PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr), PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init), PLATFORMMETHOD(platform_cpu_reset, allwinner_cpu_reset), @@ -178,7 +169,6 @@ FDT_PLATFORM_DEF(a10, "a10", 0, "allwinner,sun4i-a10", 200); #if defined(SOC_ALLWINNER_A13) static platform_method_t a13_methods[] = { PLATFORMMETHOD(platform_attach, a13_attach), - PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr), PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init), PLATFORMMETHOD(platform_cpu_reset, allwinner_cpu_reset), @@ -190,7 +180,6 @@ FDT_PLATFORM_DEF(a13, "a13", 0, "allwinner,sun5i-a13", 200); #if defined(SOC_ALLWINNER_A20) static platform_method_t a20_methods[] = { PLATFORMMETHOD(platform_attach, a20_attach), - PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr), PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init), PLATFORMMETHOD(platform_cpu_reset, allwinner_cpu_reset), @@ -206,7 +195,6 @@ FDT_PLATFORM_DEF(a20, "a20", 0, "allwinner,sun7i-a20", 200); #if defined(SOC_ALLWINNER_A31) static platform_method_t a31_methods[] = { PLATFORMMETHOD(platform_attach, a31_attach), - PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr), PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init), PLATFORMMETHOD(platform_cpu_reset, allwinner_cpu_reset), @@ -222,7 +210,6 @@ FDT_PLATFORM_DEF(a31, "a31", 0, "allwinner,sun6i-a31", 200); #if defined(SOC_ALLWINNER_A31S) static platform_method_t a31s_methods[] = { PLATFORMMETHOD(platform_attach, a31s_attach), - PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr), PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init), PLATFORMMETHOD(platform_cpu_reset, allwinner_cpu_reset), @@ -238,7 +225,6 @@ FDT_PLATFORM_DEF(a31s, "a31s", 0, "allwinner,sun6i-a31s", 200); #if defined(SOC_ALLWINNER_A83T) static platform_method_t a83t_methods[] = { PLATFORMMETHOD(platform_attach, a83t_attach), - PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr), PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init), PLATFORMMETHOD(platform_cpu_reset, allwinner_cpu_reset), @@ -254,7 +240,6 @@ FDT_PLATFORM_DEF(a83t, "a83t", 0, "allwinner,sun8i-a83t", 200); #if defined(SOC_ALLWINNER_H3) static platform_method_t h3_methods[] = { PLATFORMMETHOD(platform_attach, h3_attach), - PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr), PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init), PLATFORMMETHOD(platform_cpu_reset, allwinner_cpu_reset), diff --git a/sys/arm/arm/platform_if.m b/sys/arm/arm/platform_if.m index 5647b22867c..1539e771c4e 100644 --- a/sys/arm/arm/platform_if.m +++ b/sys/arm/arm/platform_if.m @@ -27,9 +27,10 @@ # #include +#include +#include #include #include -#include #include #include @@ -58,6 +59,11 @@ CODE { return; } + static vm_offset_t platform_default_lastaddr(platform_t plat) + { + return (devmap_lastaddr()); + } + static void platform_default_mp_setmaxid(platform_t plat) { mp_ncpus = 1; @@ -100,7 +106,7 @@ METHOD int devmap_init { */ METHOD vm_offset_t lastaddr { platform_t _plat; -}; +} DEFAULT platform_default_lastaddr; /** * @brief Called after the static device mappings are established and just diff --git a/sys/arm/broadcom/bcm2835/bcm2835_machdep.c b/sys/arm/broadcom/bcm2835/bcm2835_machdep.c index 5d0507998b3..a29a1c14805 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_machdep.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_machdep.c @@ -68,17 +68,9 @@ static platform_devmap_init_t bcm2835_devmap_init; #ifdef SOC_BCM2836 static platform_devmap_init_t bcm2836_devmap_init; #endif -static platform_lastaddr_t bcm2835_lastaddr; static platform_late_init_t bcm2835_late_init; static platform_cpu_reset_t bcm2835_cpu_reset; -static vm_offset_t -bcm2835_lastaddr(platform_t plat) -{ - - return (devmap_lastaddr()); -} - static void bcm2835_late_init(platform_t plat) { @@ -136,7 +128,6 @@ bcm2835_cpu_reset(platform_t plat) #ifdef SOC_BCM2835 static platform_method_t bcm2835_methods[] = { PLATFORMMETHOD(platform_devmap_init, bcm2835_devmap_init), - PLATFORMMETHOD(platform_lastaddr, bcm2835_lastaddr), PLATFORMMETHOD(platform_late_init, bcm2835_late_init), PLATFORMMETHOD(platform_cpu_reset, bcm2835_cpu_reset), @@ -148,7 +139,6 @@ FDT_PLATFORM_DEF(bcm2835, "bcm2835", 0, "raspberrypi,model-b", 100); #ifdef SOC_BCM2836 static platform_method_t bcm2836_methods[] = { PLATFORMMETHOD(platform_devmap_init, bcm2836_devmap_init), - PLATFORMMETHOD(platform_lastaddr, bcm2835_lastaddr), PLATFORMMETHOD(platform_late_init, bcm2835_late_init), PLATFORMMETHOD(platform_cpu_reset, bcm2835_cpu_reset), diff --git a/sys/arm/freescale/imx/imx51_machdep.c b/sys/arm/freescale/imx/imx51_machdep.c index 3d208768b98..cbf6c9690eb 100644 --- a/sys/arm/freescale/imx/imx51_machdep.c +++ b/sys/arm/freescale/imx/imx51_machdep.c @@ -47,16 +47,8 @@ __FBSDID("$FreeBSD$"); static platform_attach_t imx51_attach; static platform_devmap_init_t imx51_devmap_init; -static platform_lastaddr_t imx51_lastaddr; static platform_cpu_reset_t imx51_cpu_reset; -static vm_offset_t -imx51_lastaddr(platform_t plat) -{ - - return (devmap_lastaddr()); -} - static int imx51_attach(platform_t plat) { @@ -102,7 +94,6 @@ imx_soc_type(void) static platform_method_t imx51_methods[] = { PLATFORMMETHOD(platform_attach, imx51_attach), PLATFORMMETHOD(platform_devmap_init, imx51_devmap_init), - PLATFORMMETHOD(platform_lastaddr, imx51_lastaddr), PLATFORMMETHOD(platform_cpu_reset, imx51_cpu_reset), PLATFORMMETHOD_END, diff --git a/sys/arm/freescale/imx/imx53_machdep.c b/sys/arm/freescale/imx/imx53_machdep.c index 81a5486a1a1..3b4d9f1d845 100644 --- a/sys/arm/freescale/imx/imx53_machdep.c +++ b/sys/arm/freescale/imx/imx53_machdep.c @@ -47,16 +47,8 @@ __FBSDID("$FreeBSD$"); static platform_attach_t imx53_attach; static platform_devmap_init_t imx53_devmap_init; -static platform_lastaddr_t imx53_lastaddr; static platform_cpu_reset_t imx53_cpu_reset; -static vm_offset_t -imx53_lastaddr(platform_t plat) -{ - - return (devmap_lastaddr()); -} - static int imx53_attach(platform_t plat) { @@ -102,7 +94,6 @@ imx_soc_type(void) static platform_method_t imx53_methods[] = { PLATFORMMETHOD(platform_attach, imx53_attach), PLATFORMMETHOD(platform_devmap_init, imx53_devmap_init), - PLATFORMMETHOD(platform_lastaddr, imx53_lastaddr), PLATFORMMETHOD(platform_cpu_reset, imx53_cpu_reset), PLATFORMMETHOD_END, diff --git a/sys/arm/freescale/imx/imx6_machdep.c b/sys/arm/freescale/imx/imx6_machdep.c index a2c5fd8d51e..4e1d77b9432 100644 --- a/sys/arm/freescale/imx/imx6_machdep.c +++ b/sys/arm/freescale/imx/imx6_machdep.c @@ -56,7 +56,6 @@ static uint32_t gpio1_node; static platform_attach_t imx6_attach; static platform_devmap_init_t imx6_devmap_init; -static platform_lastaddr_t imx6_lastaddr; static platform_late_init_t imx6_late_init; static platform_cpu_reset_t imx6_cpu_reset; @@ -164,13 +163,6 @@ fix_fdt_interrupt_data(void) OF_setprop(socnode, "interrupt-parent", &gicxref, sizeof(gicxref)); } -static vm_offset_t -imx6_lastaddr(platform_t plat) -{ - - return (devmap_lastaddr()); -} - static int imx6_attach(platform_t plat) { @@ -350,7 +342,6 @@ early_putc_t *early_putc = imx6_early_putc; static platform_method_t imx6_methods[] = { PLATFORMMETHOD(platform_attach, imx6_attach), - PLATFORMMETHOD(platform_lastaddr, imx6_lastaddr), PLATFORMMETHOD(platform_devmap_init, imx6_devmap_init), PLATFORMMETHOD(platform_late_init, imx6_late_init), PLATFORMMETHOD(platform_cpu_reset, imx6_cpu_reset), diff --git a/sys/arm/nvidia/tegra124/tegra124_machdep.c b/sys/arm/nvidia/tegra124/tegra124_machdep.c index 3ef47a16abb..55b411dd791 100644 --- a/sys/arm/nvidia/tegra124/tegra124_machdep.c +++ b/sys/arm/nvidia/tegra124/tegra124_machdep.c @@ -66,13 +66,6 @@ static platform_devmap_init_t tegra124_devmap_init; static platform_late_init_t tegra124_late_init; static platform_cpu_reset_t tegra124_cpu_reset; -static vm_offset_t -tegra124_lastaddr(platform_t plat) -{ - - return (devmap_lastaddr()); -} - static int tegra124_attach(platform_t plat) { @@ -146,7 +139,6 @@ early_putc_t *early_putc = tegra124_early_putc; static platform_method_t tegra124_methods[] = { PLATFORMMETHOD(platform_attach, tegra124_attach), - PLATFORMMETHOD(platform_lastaddr, tegra124_lastaddr), PLATFORMMETHOD(platform_devmap_init, tegra124_devmap_init), PLATFORMMETHOD(platform_late_init, tegra124_late_init), PLATFORMMETHOD(platform_cpu_reset, tegra124_cpu_reset), diff --git a/sys/arm/qemu/virt_machdep.c b/sys/arm/qemu/virt_machdep.c index 08ea4602dd3..72ed0fae0e4 100644 --- a/sys/arm/qemu/virt_machdep.c +++ b/sys/arm/qemu/virt_machdep.c @@ -44,13 +44,6 @@ __FBSDID("$FreeBSD$"); #include "platform_if.h" -static vm_offset_t -virt_lastaddr(platform_t plat) -{ - - return (devmap_lastaddr()); -} - /* * Set up static device mappings. */ @@ -64,7 +57,6 @@ virt_devmap_init(platform_t plat) static platform_method_t virt_methods[] = { PLATFORMMETHOD(platform_devmap_init, virt_devmap_init), - PLATFORMMETHOD(platform_lastaddr, virt_lastaddr), #ifdef SMP PLATFORMMETHOD(platform_mp_start_ap, virt_mp_start_ap), @@ -86,7 +78,6 @@ gem5_devmap_init(platform_t plat) static platform_method_t gem5_methods[] = { PLATFORMMETHOD(platform_devmap_init, gem5_devmap_init), - PLATFORMMETHOD(platform_lastaddr, virt_lastaddr), PLATFORMMETHOD_END, }; diff --git a/sys/arm/rockchip/rk30xx_machdep.c b/sys/arm/rockchip/rk30xx_machdep.c index 92c98bb6813..f5f5c93ff32 100644 --- a/sys/arm/rockchip/rk30xx_machdep.c +++ b/sys/arm/rockchip/rk30xx_machdep.c @@ -52,18 +52,10 @@ __FBSDID("$FreeBSD$"); #include "platform_if.h" -static platform_lastaddr_t rk30xx_lastaddr; static platform_devmap_init_t rk30xx_devmap_init; static platform_late_init_t rk30xx_late_init; static platform_cpu_reset_t rk30xx_cpu_reset; -static vm_offset_t -rk30xx_lastaddr(platform_t plat) -{ - - return (devmap_lastaddr()); -} - static void rk30xx_late_init(platform_t plat) { @@ -97,7 +89,6 @@ rk30xx_cpu_reset(platform_t plat) #if defined(SOC_ROCKCHIP_RK3188) static platform_method_t rk30xx_methods[] = { - PLATFORMMETHOD(platform_lastaddr, rk30xx_lastaddr), PLATFORMMETHOD(platform_devmap_init, rk30xx_devmap_init), PLATFORMMETHOD(platform_late_init, rk30xx_late_init), PLATFORMMETHOD(platform_cpu_reset, rk30xx_cpu_reset), diff --git a/sys/arm/ti/ti_machdep.c b/sys/arm/ti/ti_machdep.c index 7963e225696..eb10700b3cd 100644 --- a/sys/arm/ti/ti_machdep.c +++ b/sys/arm/ti/ti_machdep.c @@ -66,7 +66,6 @@ static platform_devmap_init_t ti_omap4_devmap_init; static platform_attach_t ti_am335x_attach; static platform_devmap_init_t ti_am335x_devmap_init; #endif -static platform_lastaddr_t ti_lastaddr; static platform_cpu_reset_t ti_plat_cpu_reset; void (*ti_cpu_reset)(void) = NULL; @@ -91,13 +90,6 @@ ti_am335x_attach(platform_t plat) } #endif -static vm_offset_t -ti_lastaddr(platform_t plat) -{ - - return (devmap_lastaddr()); -} - /* * Construct static devmap entries to map out the most frequently used * peripherals using 1mb section mappings. @@ -141,7 +133,6 @@ ti_plat_cpu_reset(platform_t plat) static platform_method_t omap4_methods[] = { PLATFORMMETHOD(platform_attach, omap4_attach), PLATFORMMETHOD(platform_devmap_init, ti_omap4_devmap_init), - PLATFORMMETHOD(platform_lastaddr, ti_lastaddr), PLATFORMMETHOD(platform_cpu_reset, ti_plat_cpu_reset), #ifdef SMP @@ -157,7 +148,6 @@ FDT_PLATFORM_DEF(omap4, "omap4", 0, "ti,omap4430", 200); static platform_method_t am335x_methods[] = { PLATFORMMETHOD(platform_attach, ti_am335x_attach), PLATFORMMETHOD(platform_devmap_init, ti_am335x_devmap_init), - PLATFORMMETHOD(platform_lastaddr, ti_lastaddr), PLATFORMMETHOD(platform_cpu_reset, ti_plat_cpu_reset), PLATFORMMETHOD_END, From 0e68afe553d9ede70ce83eaa697a5517b1defb31 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Fri, 16 Dec 2016 10:40:00 +0000 Subject: [PATCH 223/226] Add support to read the _CLS entry if it's present. It is used by memory-mapped devices that are normally PCIe drives. Devices can then use the existing pci_get_class, etc. accessors to query this data. The ivar values are different enough from the existing ACPI and ISA values to not conflict. Reviewed by: jhb Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8721 --- sys/dev/acpica/acpi.c | 24 ++++++++++++++++++++++++ sys/dev/acpica/acpivar.h | 1 + 2 files changed, 25 insertions(+) diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 12c9d25adab..58b4467aa3b 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -68,6 +68,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include static MALLOC_DEFINE(M_ACPIDEV, "acpidev", "ACPI devices"); @@ -923,6 +925,15 @@ acpi_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) case ISA_IVAR_LOGICALID: *(int *)result = acpi_isa_get_logicalid(child); break; + case PCI_IVAR_CLASS: + *(uint8_t*)result = (ad->ad_cls_class >> 16) & 0xff; + break; + case PCI_IVAR_SUBCLASS: + *(uint8_t*)result = (ad->ad_cls_class >> 8) & 0xff; + break; + case PCI_IVAR_PROGIF: + *(uint8_t*)result = (ad->ad_cls_class >> 0) & 0xff; + break; default: return (ENOENT); } @@ -1961,6 +1972,8 @@ acpi_probe_order(ACPI_HANDLE handle, int *order) static ACPI_STATUS acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status) { + ACPI_DEVICE_INFO *devinfo; + struct acpi_device *ad; struct acpi_prw_data prw; ACPI_OBJECT_TYPE type; ACPI_HANDLE h; @@ -2054,6 +2067,17 @@ acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status) * device not to have any resources. */ acpi_parse_resources(child, handle, &acpi_res_parse_set, NULL); + + ad = device_get_ivars(child); + ad->ad_cls_class = 0xffffff; + if (ACPI_SUCCESS(AcpiGetObjectInfo(handle, &devinfo))) { + if ((devinfo->Valid & ACPI_VALID_CLS) != 0 && + devinfo->ClassCode.Length >= ACPI_PCICLS_STRING_SIZE) { + ad->ad_cls_class = strtoul(devinfo->ClassCode.String, + NULL, 16); + } + AcpiOsFree(devinfo); + } break; } } diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index bdd179b9696..6382205d3e3 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -85,6 +85,7 @@ struct acpi_device { ACPI_HANDLE ad_handle; void *ad_private; int ad_flags; + int ad_cls_class; /* Resources */ struct resource_list ad_rl; From 3931b59fadbb2374ff1161d4e8c33a86fd451fff Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Fri, 16 Dec 2016 14:23:08 +0000 Subject: [PATCH 224/226] Fix typo. MFC after: 3 days --- libexec/rtld-elf/rtld.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index ec33d87888d..6062a683220 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -2493,7 +2493,7 @@ objlist_call_init(Objlist *list, RtldLockState *lockstate) continue; /* * Race: other thread might try to use this object before current - * one completes the initilization. Not much can be done here + * one completes the initialization. Not much can be done here * without better locking. */ elm->obj->init_done = true; From 69baec361998267e9f2e49cccab935986c60ab33 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Fri, 16 Dec 2016 17:41:20 +0000 Subject: [PATCH 225/226] Switch from stdatomic.h to atomic.h for kernel. Apparently stdatomic.h implementation for gcc 4.2 on sparc64 does not work properly. This effectively reverts r251803. Reported and tested by: lidl Discussed with: ed Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/kern/kern_event.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 36fe20fbc91..b734cf271bc 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -69,6 +68,7 @@ __FBSDID("$FreeBSD$"); #ifdef KTRACE #include #endif +#include #include @@ -188,7 +188,7 @@ static struct filterops user_filtops = { }; static uma_zone_t knote_zone; -static atomic_uint kq_ncallouts = ATOMIC_VAR_INIT(0); +static unsigned int kq_ncallouts = 0; static unsigned int kq_calloutmax = 4 * 1024; SYSCTL_UINT(_kern, OID_AUTO, kq_calloutmax, CTLFLAG_RW, &kq_calloutmax, 0, "Maximum number of callouts allocated for kqueue"); @@ -672,13 +672,11 @@ filt_timerattach(struct knote *kn) if (to < 0) return (EINVAL); - ncallouts = atomic_load_explicit(&kq_ncallouts, memory_order_relaxed); do { + ncallouts = kq_ncallouts; if (ncallouts >= kq_calloutmax) return (ENOMEM); - } while (!atomic_compare_exchange_weak_explicit(&kq_ncallouts, - &ncallouts, ncallouts + 1, memory_order_relaxed, - memory_order_relaxed)); + } while (!atomic_cmpset_int(&kq_ncallouts, ncallouts, ncallouts + 1)); kn->kn_flags |= EV_CLEAR; /* automatically set */ kn->kn_status &= ~KN_DETACHED; /* knlist_add clears it */ @@ -703,7 +701,7 @@ filt_timerdetach(struct knote *kn) callout_drain(calloutp); free(calloutp, M_KQUEUE); free(kn->kn_ptr.p_nexttime, M_KQUEUE); - old = atomic_fetch_sub_explicit(&kq_ncallouts, 1, memory_order_relaxed); + old = atomic_fetchadd_int(&kq_ncallouts, -1); KASSERT(old > 0, ("Number of callouts cannot become negative")); kn->kn_status |= KN_DETACHED; /* knlist_remove sets it */ } From 37db9b78db132c7d0f492f595e9d1be0aa0e0b5d Mon Sep 17 00:00:00 2001 From: Nikolai Lifanov Date: Fri, 16 Dec 2016 17:44:56 +0000 Subject: [PATCH 226/226] retain cc.4.gz man page for Chelsio T6 NICs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This man page was removed in r225583 when cc.4 was renamed to mod_cc.4 With reintroduction of cc.4 "make installworld; make delete-old" was no longer convergent. Reported by: Trond Endrestøl Reviewed by: np, matthew Approved by: np, matthew (mentor) Differential Revision: https://reviews.freebsd.org/D8816 --- ObsoleteFiles.inc | 1 - 1 file changed, 1 deletion(-) diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index ae30b23ec76..958293532d3 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -2939,7 +2939,6 @@ OLD_FILES+=usr/lib32/libftpio_p.a OLD_FILES+=usr/include/ftpio.h OLD_FILES+=usr/share/man/man3/ftpio.3.gz # 20110915: rename congestion control manpages -OLD_FILES+=usr/share/man/man4/cc.4.gz OLD_FILES+=usr/share/man/man9/cc.9.gz # 20110831: atomic page flags operations OLD_FILES+=usr/share/man/man9/vm_page_flag.9.gz