aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl84
-rw-r--r--scripts/dtc/data.c2
-rw-r--r--scripts/dtc/dtc-lexer.l2
-rw-r--r--scripts/dtc/dtc-lexer.lex.c_shipped69
-rw-r--r--scripts/dtc/libfdt/fdt_ro.c2
-rw-r--r--scripts/dtc/treesource.c2
-rw-r--r--scripts/genksyms/keywords.c_shipped95
-rw-r--r--scripts/genksyms/keywords.gperf2
-rwxr-xr-xscripts/get_maintainer.pl41
-rw-r--r--scripts/kconfig/Makefile4
-rw-r--r--scripts/kconfig/lex.zconf.c_shipped25
-rw-r--r--scripts/kconfig/streamline_config.pl12
-rw-r--r--scripts/kconfig/zconf.gperf2
-rw-r--r--scripts/kconfig/zconf.hash.c_shipped2
-rw-r--r--scripts/kconfig/zconf.l6
-rw-r--r--scripts/kconfig/zconf.tab.c_shipped379
-rw-r--r--scripts/kconfig/zconf.y13
-rw-r--r--scripts/selinux/Makefile4
-rw-r--r--scripts/selinux/genheaders/.gitignore1
-rw-r--r--scripts/selinux/genheaders/Makefile5
-rw-r--r--scripts/selinux/genheaders/genheaders.c118
-rw-r--r--scripts/selinux/mdp/mdp.c151
22 files changed, 575 insertions, 446 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 87bbb8bce9bf..bc4114f1ab30 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2,7 +2,7 @@
2# (c) 2001, Dave Jones. <davej@redhat.com> (the file handling bit) 2# (c) 2001, Dave Jones. <davej@redhat.com> (the file handling bit)
3# (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit) 3# (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit)
4# (c) 2007,2008, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite) 4# (c) 2007,2008, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite)
5# (c) 2008, Andy Whitcroft <apw@canonical.com> 5# (c) 2008,2009, Andy Whitcroft <apw@canonical.com>
6# Licensed under the terms of the GNU GPL License version 2 6# Licensed under the terms of the GNU GPL License version 2
7 7
8use strict; 8use strict;
@@ -10,7 +10,7 @@ use strict;
10my $P = $0; 10my $P = $0;
11$P =~ s@.*/@@g; 11$P =~ s@.*/@@g;
12 12
13my $V = '0.29'; 13my $V = '0.30';
14 14
15use Getopt::Long qw(:config no_auto_abbrev); 15use Getopt::Long qw(:config no_auto_abbrev);
16 16
@@ -130,7 +130,10 @@ if ($tree) {
130 130
131my $emitted_corrupt = 0; 131my $emitted_corrupt = 0;
132 132
133our $Ident = qr{[A-Za-z_][A-Za-z\d_]*}; 133our $Ident = qr{
134 [A-Za-z_][A-Za-z\d_]*
135 (?:\s*\#\#\s*[A-Za-z_][A-Za-z\d_]*)*
136 }x;
134our $Storage = qr{extern|static|asmlinkage}; 137our $Storage = qr{extern|static|asmlinkage};
135our $Sparse = qr{ 138our $Sparse = qr{
136 __user| 139 __user|
@@ -997,23 +1000,25 @@ sub annotate_values {
997 1000
998sub possible { 1001sub possible {
999 my ($possible, $line) = @_; 1002 my ($possible, $line) = @_;
1000 1003 my $notPermitted = qr{(?:
1001 print "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);
1002 if ($possible !~ /(?:
1003 ^(?: 1004 ^(?:
1004 $Modifier| 1005 $Modifier|
1005 $Storage| 1006 $Storage|
1006 $Type| 1007 $Type|
1007 DEFINE_\S+| 1008 DEFINE_\S+
1009 )$|
1010 ^(?:
1008 goto| 1011 goto|
1009 return| 1012 return|
1010 case| 1013 case|
1011 else| 1014 else|
1012 asm|__asm__| 1015 asm|__asm__|
1013 do 1016 do
1014 )$| 1017 )(?:\s|$)|
1015 ^(?:typedef|struct|enum)\b 1018 ^(?:typedef|struct|enum)\b
1016 )/x) { 1019 )}x;
1020 warn "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);
1021 if ($possible !~ $notPermitted) {
1017 # Check for modifiers. 1022 # Check for modifiers.
1018 $possible =~ s/\s*$Storage\s*//g; 1023 $possible =~ s/\s*$Storage\s*//g;
1019 $possible =~ s/\s*$Sparse\s*//g; 1024 $possible =~ s/\s*$Sparse\s*//g;
@@ -1022,8 +1027,10 @@ sub possible {
1022 } elsif ($possible =~ /\s/) { 1027 } elsif ($possible =~ /\s/) {
1023 $possible =~ s/\s*$Type\s*//g; 1028 $possible =~ s/\s*$Type\s*//g;
1024 for my $modifier (split(' ', $possible)) { 1029 for my $modifier (split(' ', $possible)) {
1025 warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible); 1030 if ($modifier !~ $notPermitted) {
1026 push(@modifierList, $modifier); 1031 warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible);
1032 push(@modifierList, $modifier);
1033 }
1027 } 1034 }
1028 1035
1029 } else { 1036 } else {
@@ -1138,6 +1145,7 @@ sub process {
1138 # suppression flags 1145 # suppression flags
1139 my %suppress_ifbraces; 1146 my %suppress_ifbraces;
1140 my %suppress_whiletrailers; 1147 my %suppress_whiletrailers;
1148 my %suppress_export;
1141 1149
1142 # Pre-scan the patch sanitizing the lines. 1150 # Pre-scan the patch sanitizing the lines.
1143 # Pre-scan the patch looking for any __setup documentation. 1151 # Pre-scan the patch looking for any __setup documentation.
@@ -1230,7 +1238,6 @@ sub process {
1230 $linenr++; 1238 $linenr++;
1231 1239
1232 my $rawline = $rawlines[$linenr - 1]; 1240 my $rawline = $rawlines[$linenr - 1];
1233 my $hunk_line = ($realcnt != 0);
1234 1241
1235#extract the line range in the file after the patch is applied 1242#extract the line range in the file after the patch is applied
1236 if ($line=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) { 1243 if ($line=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
@@ -1247,6 +1254,7 @@ sub process {
1247 1254
1248 %suppress_ifbraces = (); 1255 %suppress_ifbraces = ();
1249 %suppress_whiletrailers = (); 1256 %suppress_whiletrailers = ();
1257 %suppress_export = ();
1250 next; 1258 next;
1251 1259
1252# track the line number as we move through the hunk, note that 1260# track the line number as we move through the hunk, note that
@@ -1270,6 +1278,8 @@ sub process {
1270 $realcnt--; 1278 $realcnt--;
1271 } 1279 }
1272 1280
1281 my $hunk_line = ($realcnt != 0);
1282
1273#make up the handle for any error we report on this line 1283#make up the handle for any error we report on this line
1274 $prefix = "$filename:$realline: " if ($emacs && $file); 1284 $prefix = "$filename:$realline: " if ($emacs && $file);
1275 $prefix = "$filename:$linenr: " if ($emacs && !$file); 1285 $prefix = "$filename:$linenr: " if ($emacs && !$file);
@@ -1420,13 +1430,22 @@ sub process {
1420 } 1430 }
1421 1431
1422# Check for potential 'bare' types 1432# Check for potential 'bare' types
1423 my ($stat, $cond, $line_nr_next, $remain_next, $off_next); 1433 my ($stat, $cond, $line_nr_next, $remain_next, $off_next,
1434 $realline_next);
1424 if ($realcnt && $line =~ /.\s*\S/) { 1435 if ($realcnt && $line =~ /.\s*\S/) {
1425 ($stat, $cond, $line_nr_next, $remain_next, $off_next) = 1436 ($stat, $cond, $line_nr_next, $remain_next, $off_next) =
1426 ctx_statement_block($linenr, $realcnt, 0); 1437 ctx_statement_block($linenr, $realcnt, 0);
1427 $stat =~ s/\n./\n /g; 1438 $stat =~ s/\n./\n /g;
1428 $cond =~ s/\n./\n /g; 1439 $cond =~ s/\n./\n /g;
1429 1440
1441 # Find the real next line.
1442 $realline_next = $line_nr_next;
1443 if (defined $realline_next &&
1444 (!defined $lines[$realline_next - 1] ||
1445 substr($lines[$realline_next - 1], $off_next) =~ /^\s*$/)) {
1446 $realline_next++;
1447 }
1448
1430 my $s = $stat; 1449 my $s = $stat;
1431 $s =~ s/{.*$//s; 1450 $s =~ s/{.*$//s;
1432 1451
@@ -1661,8 +1680,8 @@ sub process {
1661 } 1680 }
1662 1681
1663# check for initialisation to aggregates open brace on the next line 1682# check for initialisation to aggregates open brace on the next line
1664 if ($prevline =~ /$Declare\s*$Ident\s*=\s*$/ && 1683 if ($line =~ /^.\s*{/ &&
1665 $line =~ /^.\s*{/) { 1684 $prevline =~ /(?:^|[^=])=\s*$/) {
1666 ERROR("that open brace { should be on the previous line\n" . $hereprev); 1685 ERROR("that open brace { should be on the previous line\n" . $hereprev);
1667 } 1686 }
1668 1687
@@ -1687,21 +1706,40 @@ sub process {
1687 $line =~ s@//.*@@; 1706 $line =~ s@//.*@@;
1688 $opline =~ s@//.*@@; 1707 $opline =~ s@//.*@@;
1689 1708
1690#EXPORT_SYMBOL should immediately follow its function closing }. 1709# EXPORT_SYMBOL should immediately follow the thing it is exporting, consider
1691 if (($line =~ /EXPORT_SYMBOL.*\((.*)\)/) || 1710# the whole statement.
1692 ($line =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) { 1711#print "APW <$lines[$realline_next - 1]>\n";
1712 if (defined $realline_next &&
1713 exists $lines[$realline_next - 1] &&
1714 !defined $suppress_export{$realline_next} &&
1715 ($lines[$realline_next - 1] =~ /EXPORT_SYMBOL.*\((.*)\)/ ||
1716 $lines[$realline_next - 1] =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
1693 my $name = $1; 1717 my $name = $1;
1694 if ($prevline !~ /(?: 1718 if ($stat !~ /(?:
1695 ^.}| 1719 \n.}\s*$|
1696 ^.DEFINE_$Ident\(\Q$name\E\)| 1720 ^.DEFINE_$Ident\(\Q$name\E\)|
1697 ^.DECLARE_$Ident\(\Q$name\E\)| 1721 ^.DECLARE_$Ident\(\Q$name\E\)|
1698 ^.LIST_HEAD\(\Q$name\E\)| 1722 ^.LIST_HEAD\(\Q$name\E\)|
1699 ^.$Type\s*\(\s*\*\s*\Q$name\E\s*\)\s*\(| 1723 ^.(?:$Storage\s+)?$Type\s*\(\s*\*\s*\Q$name\E\s*\)\s*\(|
1700 \b\Q$name\E(?:\s+$Attribute)?\s*(?:;|=|\[) 1724 \b\Q$name\E(?:\s+$Attribute)*\s*(?:;|=|\[|\()
1701 )/x) { 1725 )/x) {
1702 WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr); 1726#print "FOO A<$lines[$realline_next - 1]> stat<$stat> name<$name>\n";
1727 $suppress_export{$realline_next} = 2;
1728 } else {
1729 $suppress_export{$realline_next} = 1;
1703 } 1730 }
1704 } 1731 }
1732 if (!defined $suppress_export{$linenr} &&
1733 $prevline =~ /^.\s*$/ &&
1734 ($line =~ /EXPORT_SYMBOL.*\((.*)\)/ ||
1735 $line =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
1736#print "FOO B <$lines[$linenr - 1]>\n";
1737 $suppress_export{$linenr} = 2;
1738 }
1739 if (defined $suppress_export{$linenr} &&
1740 $suppress_export{$linenr} == 2) {
1741 WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr);
1742 }
1705 1743
1706# check for external initialisers. 1744# check for external initialisers.
1707 if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) { 1745 if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) {
diff --git a/scripts/dtc/data.c b/scripts/dtc/data.c
index dd2e3d39d4c1..fe555e819bf8 100644
--- a/scripts/dtc/data.c
+++ b/scripts/dtc/data.c
@@ -217,7 +217,7 @@ struct data data_insert_at_marker(struct data d, struct marker *m,
217 return d; 217 return d;
218} 218}
219 219
220struct data data_append_markers(struct data d, struct marker *m) 220static struct data data_append_markers(struct data d, struct marker *m)
221{ 221{
222 struct marker **mp = &d.markers; 222 struct marker **mp = &d.markers;
223 223
diff --git a/scripts/dtc/dtc-lexer.l b/scripts/dtc/dtc-lexer.l
index 44dbfd3f0976..a627bbee91d4 100644
--- a/scripts/dtc/dtc-lexer.l
+++ b/scripts/dtc/dtc-lexer.l
@@ -18,7 +18,7 @@
18 * USA 18 * USA
19 */ 19 */
20 20
21%option noyywrap nounput yylineno 21%option noyywrap noinput nounput yylineno
22 22
23%x INCLUDE 23%x INCLUDE
24%x BYTESTRING 24%x BYTESTRING
diff --git a/scripts/dtc/dtc-lexer.lex.c_shipped b/scripts/dtc/dtc-lexer.lex.c_shipped
index ac392cb040f6..e27cc636e326 100644
--- a/scripts/dtc/dtc-lexer.lex.c_shipped
+++ b/scripts/dtc/dtc-lexer.lex.c_shipped
@@ -9,7 +9,7 @@
9#define FLEX_SCANNER 9#define FLEX_SCANNER
10#define YY_FLEX_MAJOR_VERSION 2 10#define YY_FLEX_MAJOR_VERSION 2
11#define YY_FLEX_MINOR_VERSION 5 11#define YY_FLEX_MINOR_VERSION 5
12#define YY_FLEX_SUBMINOR_VERSION 34 12#define YY_FLEX_SUBMINOR_VERSION 35
13#if YY_FLEX_SUBMINOR_VERSION > 0 13#if YY_FLEX_SUBMINOR_VERSION > 0
14#define FLEX_BETA 14#define FLEX_BETA
15#endif 15#endif
@@ -54,7 +54,6 @@ typedef int flex_int32_t;
54typedef unsigned char flex_uint8_t; 54typedef unsigned char flex_uint8_t;
55typedef unsigned short int flex_uint16_t; 55typedef unsigned short int flex_uint16_t;
56typedef unsigned int flex_uint32_t; 56typedef unsigned int flex_uint32_t;
57#endif /* ! C99 */
58 57
59/* Limits of integral types. */ 58/* Limits of integral types. */
60#ifndef INT8_MIN 59#ifndef INT8_MIN
@@ -85,6 +84,8 @@ typedef unsigned int flex_uint32_t;
85#define UINT32_MAX (4294967295U) 84#define UINT32_MAX (4294967295U)
86#endif 85#endif
87 86
87#endif /* ! C99 */
88
88#endif /* ! FLEXINT_H */ 89#endif /* ! FLEXINT_H */
89 90
90#ifdef __cplusplus 91#ifdef __cplusplus
@@ -141,7 +142,15 @@ typedef unsigned int flex_uint32_t;
141 142
142/* Size of default input buffer. */ 143/* Size of default input buffer. */
143#ifndef YY_BUF_SIZE 144#ifndef YY_BUF_SIZE
145#ifdef __ia64__
146/* On IA-64, the buffer size is 16k, not 8k.
147 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
148 * Ditto for the __ia64__ case accordingly.
149 */
150#define YY_BUF_SIZE 32768
151#else
144#define YY_BUF_SIZE 16384 152#define YY_BUF_SIZE 16384
153#endif /* __ia64__ */
145#endif 154#endif
146 155
147/* The state buf must be large enough to hold one state per character in the main buffer. 156/* The state buf must be large enough to hold one state per character in the main buffer.
@@ -192,13 +201,6 @@ extern FILE *yyin, *yyout;
192 201
193#define unput(c) yyunput( c, (yytext_ptr) ) 202#define unput(c) yyunput( c, (yytext_ptr) )
194 203
195/* The following is because we cannot portably get our hands on size_t
196 * (without autoconf's help, which isn't available because we want
197 * flex-generated scanners to compile on their own).
198 * Given that the standard has decreed that size_t exists since 1989,
199 * I guess we can afford to depend on it. Manoj.
200 */
201
202#ifndef YY_TYPEDEF_YY_SIZE_T 204#ifndef YY_TYPEDEF_YY_SIZE_T
203#define YY_TYPEDEF_YY_SIZE_T 205#define YY_TYPEDEF_YY_SIZE_T
204typedef size_t yy_size_t; 206typedef size_t yy_size_t;
@@ -604,6 +606,7 @@ char *yytext;
604 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 606 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
605 * USA 607 * USA
606 */ 608 */
609#define YY_NO_INPUT 1
607 610
608 611
609 612
@@ -634,7 +637,7 @@ static int dts_version; /* = 0 */
634 637
635static void push_input_file(const char *filename); 638static void push_input_file(const char *filename);
636static int pop_input_file(void); 639static int pop_input_file(void);
637#line 638 "dtc-lexer.lex.c" 640#line 641 "dtc-lexer.lex.c"
638 641
639#define INITIAL 0 642#define INITIAL 0
640#define INCLUDE 1 643#define INCLUDE 1
@@ -656,6 +659,35 @@ static int pop_input_file(void);
656 659
657static int yy_init_globals (void ); 660static int yy_init_globals (void );
658 661
662/* Accessor methods to globals.
663 These are made visible to non-reentrant scanners for convenience. */
664
665int yylex_destroy (void );
666
667int yyget_debug (void );
668
669void yyset_debug (int debug_flag );
670
671YY_EXTRA_TYPE yyget_extra (void );
672
673void yyset_extra (YY_EXTRA_TYPE user_defined );
674
675FILE *yyget_in (void );
676
677void yyset_in (FILE * in_str );
678
679FILE *yyget_out (void );
680
681void yyset_out (FILE * out_str );
682
683int yyget_leng (void );
684
685char *yyget_text (void );
686
687int yyget_lineno (void );
688
689void yyset_lineno (int line_number );
690
659/* Macros after this point can all be overridden by user definitions in 691/* Macros after this point can all be overridden by user definitions in
660 * section 1. 692 * section 1.
661 */ 693 */
@@ -688,7 +720,12 @@ static int input (void );
688 720
689/* Amount of stuff to slurp up with each read. */ 721/* Amount of stuff to slurp up with each read. */
690#ifndef YY_READ_BUF_SIZE 722#ifndef YY_READ_BUF_SIZE
723#ifdef __ia64__
724/* On IA-64, the buffer size is 16k, not 8k */
725#define YY_READ_BUF_SIZE 16384
726#else
691#define YY_READ_BUF_SIZE 8192 727#define YY_READ_BUF_SIZE 8192
728#endif /* __ia64__ */
692#endif 729#endif
693 730
694/* Copy whatever the last rule matched to the standard output. */ 731/* Copy whatever the last rule matched to the standard output. */
@@ -696,7 +733,7 @@ static int input (void );
696/* This used to be an fputs(), but since the string might contain NUL's, 733/* This used to be an fputs(), but since the string might contain NUL's,
697 * we now use fwrite(). 734 * we now use fwrite().
698 */ 735 */
699#define ECHO fwrite( yytext, yyleng, 1, yyout ) 736#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
700#endif 737#endif
701 738
702/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, 739/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -707,7 +744,7 @@ static int input (void );
707 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ 744 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
708 { \ 745 { \
709 int c = '*'; \ 746 int c = '*'; \
710 int n; \ 747 size_t n; \
711 for ( n = 0; n < max_size && \ 748 for ( n = 0; n < max_size && \
712 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ 749 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
713 buf[n] = (char) c; \ 750 buf[n] = (char) c; \
@@ -791,7 +828,7 @@ YY_DECL
791 828
792#line 64 "dtc-lexer.l" 829#line 64 "dtc-lexer.l"
793 830
794#line 795 "dtc-lexer.lex.c" 831#line 832 "dtc-lexer.lex.c"
795 832
796 if ( !(yy_init) ) 833 if ( !(yy_init) )
797 { 834 {
@@ -1116,7 +1153,7 @@ YY_RULE_SETUP
1116#line 222 "dtc-lexer.l" 1153#line 222 "dtc-lexer.l"
1117ECHO; 1154ECHO;
1118 YY_BREAK 1155 YY_BREAK
1119#line 1120 "dtc-lexer.lex.c" 1156#line 1157 "dtc-lexer.lex.c"
1120 1157
1121 case YY_END_OF_BUFFER: 1158 case YY_END_OF_BUFFER:
1122 { 1159 {
@@ -1840,8 +1877,8 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
1840 1877
1841/** Setup the input buffer state to scan the given bytes. The next call to yylex() will 1878/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
1842 * scan from a @e copy of @a bytes. 1879 * scan from a @e copy of @a bytes.
1843 * @param bytes the byte buffer to scan 1880 * @param yybytes the byte buffer to scan
1844 * @param len the number of bytes in the buffer pointed to by @a bytes. 1881 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1845 * 1882 *
1846 * @return the newly allocated buffer state object. 1883 * @return the newly allocated buffer state object.
1847 */ 1884 */
diff --git a/scripts/dtc/libfdt/fdt_ro.c b/scripts/dtc/libfdt/fdt_ro.c
index fbbba44fcd0d..22e692919ff9 100644
--- a/scripts/dtc/libfdt/fdt_ro.c
+++ b/scripts/dtc/libfdt/fdt_ro.c
@@ -411,7 +411,7 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle)
411 &phandle, sizeof(phandle)); 411 &phandle, sizeof(phandle));
412} 412}
413 413
414int _stringlist_contains(const char *strlist, int listlen, const char *str) 414static int _stringlist_contains(const char *strlist, int listlen, const char *str)
415{ 415{
416 int len = strlen(str); 416 int len = strlen(str);
417 const char *p; 417 const char *p;
diff --git a/scripts/dtc/treesource.c b/scripts/dtc/treesource.c
index ebeb6eb27907..1521ff11bb97 100644
--- a/scripts/dtc/treesource.c
+++ b/scripts/dtc/treesource.c
@@ -52,7 +52,7 @@ static void write_prefix(FILE *f, int level)
52 fputc('\t', f); 52 fputc('\t', f);
53} 53}
54 54
55int isstring(char c) 55static int isstring(char c)
56{ 56{
57 return (isprint(c) 57 return (isprint(c)
58 || (c == '\0') 58 || (c == '\0')
diff --git a/scripts/genksyms/keywords.c_shipped b/scripts/genksyms/keywords.c_shipped
index 971e0113ae7a..287467a2e8c7 100644
--- a/scripts/genksyms/keywords.c_shipped
+++ b/scripts/genksyms/keywords.c_shipped
@@ -1,4 +1,4 @@
1/* ANSI-C code produced by gperf version 3.0.2 */ 1/* ANSI-C code produced by gperf version 3.0.3 */
2/* Command-line: gperf -L ANSI-C -a -C -E -g -H is_reserved_hash -k '1,3,$' -N is_reserved_word -p -t scripts/genksyms/keywords.gperf */ 2/* Command-line: gperf -L ANSI-C -a -C -E -g -H is_reserved_hash -k '1,3,$' -N is_reserved_word -p -t scripts/genksyms/keywords.gperf */
3 3
4#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ 4#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
@@ -30,7 +30,9 @@
30 30
31#line 1 "scripts/genksyms/keywords.gperf" 31#line 1 "scripts/genksyms/keywords.gperf"
32 32
33#line 3 "scripts/genksyms/keywords.gperf" 33struct resword;
34static const struct resword *is_reserved_word(register const char *str, register unsigned int len);
35#line 5 "scripts/genksyms/keywords.gperf"
34struct resword { const char *name; int token; }; 36struct resword { const char *name; int token; };
35/* maximum key range = 62, duplicates = 0 */ 37/* maximum key range = 62, duplicates = 0 */
36 38
@@ -78,6 +80,9 @@ is_reserved_hash (register const char *str, register unsigned int len)
78 80
79#ifdef __GNUC__ 81#ifdef __GNUC__
80__inline 82__inline
83#ifdef __GNUC_STDC_INLINE__
84__attribute__ ((__gnu_inline__))
85#endif
81#endif 86#endif
82const struct resword * 87const struct resword *
83is_reserved_word (register const char *str, register unsigned int len) 88is_reserved_word (register const char *str, register unsigned int len)
@@ -94,105 +99,105 @@ is_reserved_word (register const char *str, register unsigned int len)
94 static const struct resword wordlist[] = 99 static const struct resword wordlist[] =
95 { 100 {
96 {""}, {""}, {""}, 101 {""}, {""}, {""},
97#line 26 "scripts/genksyms/keywords.gperf" 102#line 28 "scripts/genksyms/keywords.gperf"
98 {"asm", ASM_KEYW}, 103 {"asm", ASM_KEYW},
99 {""}, 104 {""},
100#line 8 "scripts/genksyms/keywords.gperf" 105#line 10 "scripts/genksyms/keywords.gperf"
101 {"__asm", ASM_KEYW}, 106 {"__asm", ASM_KEYW},
102 {""}, 107 {""},
103#line 9 "scripts/genksyms/keywords.gperf" 108#line 11 "scripts/genksyms/keywords.gperf"
104 {"__asm__", ASM_KEYW}, 109 {"__asm__", ASM_KEYW},
105 {""}, {""}, 110 {""}, {""},
106#line 52 "scripts/genksyms/keywords.gperf" 111#line 54 "scripts/genksyms/keywords.gperf"
107 {"__typeof__", TYPEOF_KEYW}, 112 {"__typeof__", TYPEOF_KEYW},
108 {""}, 113 {""},
109#line 12 "scripts/genksyms/keywords.gperf" 114#line 14 "scripts/genksyms/keywords.gperf"
110 {"__const", CONST_KEYW}, 115 {"__const", CONST_KEYW},
111#line 11 "scripts/genksyms/keywords.gperf"
112 {"__attribute__", ATTRIBUTE_KEYW},
113#line 13 "scripts/genksyms/keywords.gperf" 116#line 13 "scripts/genksyms/keywords.gperf"
117 {"__attribute__", ATTRIBUTE_KEYW},
118#line 15 "scripts/genksyms/keywords.gperf"
114 {"__const__", CONST_KEYW}, 119 {"__const__", CONST_KEYW},
115#line 18 "scripts/genksyms/keywords.gperf" 120#line 20 "scripts/genksyms/keywords.gperf"
116 {"__signed__", SIGNED_KEYW}, 121 {"__signed__", SIGNED_KEYW},
117#line 44 "scripts/genksyms/keywords.gperf" 122#line 46 "scripts/genksyms/keywords.gperf"
118 {"static", STATIC_KEYW}, 123 {"static", STATIC_KEYW},
119#line 20 "scripts/genksyms/keywords.gperf" 124#line 22 "scripts/genksyms/keywords.gperf"
120 {"__volatile__", VOLATILE_KEYW}, 125 {"__volatile__", VOLATILE_KEYW},
121#line 39 "scripts/genksyms/keywords.gperf" 126#line 41 "scripts/genksyms/keywords.gperf"
122 {"int", INT_KEYW}, 127 {"int", INT_KEYW},
123#line 32 "scripts/genksyms/keywords.gperf" 128#line 34 "scripts/genksyms/keywords.gperf"
124 {"char", CHAR_KEYW}, 129 {"char", CHAR_KEYW},
125#line 33 "scripts/genksyms/keywords.gperf" 130#line 35 "scripts/genksyms/keywords.gperf"
126 {"const", CONST_KEYW}, 131 {"const", CONST_KEYW},
127#line 45 "scripts/genksyms/keywords.gperf" 132#line 47 "scripts/genksyms/keywords.gperf"
128 {"struct", STRUCT_KEYW}, 133 {"struct", STRUCT_KEYW},
129#line 24 "scripts/genksyms/keywords.gperf" 134#line 26 "scripts/genksyms/keywords.gperf"
130 {"__restrict__", RESTRICT_KEYW}, 135 {"__restrict__", RESTRICT_KEYW},
131#line 25 "scripts/genksyms/keywords.gperf" 136#line 27 "scripts/genksyms/keywords.gperf"
132 {"restrict", RESTRICT_KEYW}, 137 {"restrict", RESTRICT_KEYW},
133#line 23 "scripts/genksyms/keywords.gperf" 138#line 25 "scripts/genksyms/keywords.gperf"
134 {"_restrict", RESTRICT_KEYW}, 139 {"_restrict", RESTRICT_KEYW},
135#line 16 "scripts/genksyms/keywords.gperf" 140#line 18 "scripts/genksyms/keywords.gperf"
136 {"__inline__", INLINE_KEYW}, 141 {"__inline__", INLINE_KEYW},
137#line 10 "scripts/genksyms/keywords.gperf" 142#line 12 "scripts/genksyms/keywords.gperf"
138 {"__attribute", ATTRIBUTE_KEYW}, 143 {"__attribute", ATTRIBUTE_KEYW},
139 {""}, 144 {""},
140#line 14 "scripts/genksyms/keywords.gperf" 145#line 16 "scripts/genksyms/keywords.gperf"
141 {"__extension__", EXTENSION_KEYW}, 146 {"__extension__", EXTENSION_KEYW},
142#line 35 "scripts/genksyms/keywords.gperf" 147#line 37 "scripts/genksyms/keywords.gperf"
143 {"enum", ENUM_KEYW}, 148 {"enum", ENUM_KEYW},
144#line 19 "scripts/genksyms/keywords.gperf" 149#line 21 "scripts/genksyms/keywords.gperf"
145 {"__volatile", VOLATILE_KEYW}, 150 {"__volatile", VOLATILE_KEYW},
146#line 36 "scripts/genksyms/keywords.gperf" 151#line 38 "scripts/genksyms/keywords.gperf"
147 {"extern", EXTERN_KEYW}, 152 {"extern", EXTERN_KEYW},
148 {""}, 153 {""},
149#line 17 "scripts/genksyms/keywords.gperf" 154#line 19 "scripts/genksyms/keywords.gperf"
150 {"__signed", SIGNED_KEYW}, 155 {"__signed", SIGNED_KEYW},
151#line 7 "scripts/genksyms/keywords.gperf" 156#line 9 "scripts/genksyms/keywords.gperf"
152 {"EXPORT_SYMBOL_GPL_FUTURE", EXPORT_SYMBOL_KEYW}, 157 {"EXPORT_SYMBOL_GPL_FUTURE", EXPORT_SYMBOL_KEYW},
153 {""}, 158 {""},
154#line 51 "scripts/genksyms/keywords.gperf" 159#line 53 "scripts/genksyms/keywords.gperf"
155 {"typeof", TYPEOF_KEYW}, 160 {"typeof", TYPEOF_KEYW},
156#line 46 "scripts/genksyms/keywords.gperf" 161#line 48 "scripts/genksyms/keywords.gperf"
157 {"typedef", TYPEDEF_KEYW}, 162 {"typedef", TYPEDEF_KEYW},
158#line 15 "scripts/genksyms/keywords.gperf" 163#line 17 "scripts/genksyms/keywords.gperf"
159 {"__inline", INLINE_KEYW}, 164 {"__inline", INLINE_KEYW},
160#line 31 "scripts/genksyms/keywords.gperf" 165#line 33 "scripts/genksyms/keywords.gperf"
161 {"auto", AUTO_KEYW}, 166 {"auto", AUTO_KEYW},
162#line 47 "scripts/genksyms/keywords.gperf" 167#line 49 "scripts/genksyms/keywords.gperf"
163 {"union", UNION_KEYW}, 168 {"union", UNION_KEYW},
164 {""}, {""}, 169 {""}, {""},
165#line 48 "scripts/genksyms/keywords.gperf" 170#line 50 "scripts/genksyms/keywords.gperf"
166 {"unsigned", UNSIGNED_KEYW}, 171 {"unsigned", UNSIGNED_KEYW},
167#line 49 "scripts/genksyms/keywords.gperf" 172#line 51 "scripts/genksyms/keywords.gperf"
168 {"void", VOID_KEYW}, 173 {"void", VOID_KEYW},
169#line 42 "scripts/genksyms/keywords.gperf" 174#line 44 "scripts/genksyms/keywords.gperf"
170 {"short", SHORT_KEYW}, 175 {"short", SHORT_KEYW},
171 {""}, {""}, 176 {""}, {""},
172#line 50 "scripts/genksyms/keywords.gperf" 177#line 52 "scripts/genksyms/keywords.gperf"
173 {"volatile", VOLATILE_KEYW}, 178 {"volatile", VOLATILE_KEYW},
174 {""}, 179 {""},
175#line 37 "scripts/genksyms/keywords.gperf" 180#line 39 "scripts/genksyms/keywords.gperf"
176 {"float", FLOAT_KEYW}, 181 {"float", FLOAT_KEYW},
177#line 34 "scripts/genksyms/keywords.gperf" 182#line 36 "scripts/genksyms/keywords.gperf"
178 {"double", DOUBLE_KEYW}, 183 {"double", DOUBLE_KEYW},
179 {""}, 184 {""},
180#line 5 "scripts/genksyms/keywords.gperf" 185#line 7 "scripts/genksyms/keywords.gperf"
181 {"EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW}, 186 {"EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW},
182 {""}, {""}, 187 {""}, {""},
183#line 38 "scripts/genksyms/keywords.gperf" 188#line 40 "scripts/genksyms/keywords.gperf"
184 {"inline", INLINE_KEYW}, 189 {"inline", INLINE_KEYW},
185#line 6 "scripts/genksyms/keywords.gperf" 190#line 8 "scripts/genksyms/keywords.gperf"
186 {"EXPORT_SYMBOL_GPL", EXPORT_SYMBOL_KEYW}, 191 {"EXPORT_SYMBOL_GPL", EXPORT_SYMBOL_KEYW},
187#line 41 "scripts/genksyms/keywords.gperf" 192#line 43 "scripts/genksyms/keywords.gperf"
188 {"register", REGISTER_KEYW}, 193 {"register", REGISTER_KEYW},
189 {""}, 194 {""},
190#line 22 "scripts/genksyms/keywords.gperf" 195#line 24 "scripts/genksyms/keywords.gperf"
191 {"_Bool", BOOL_KEYW}, 196 {"_Bool", BOOL_KEYW},
192#line 43 "scripts/genksyms/keywords.gperf" 197#line 45 "scripts/genksyms/keywords.gperf"
193 {"signed", SIGNED_KEYW}, 198 {"signed", SIGNED_KEYW},
194 {""}, {""}, 199 {""}, {""},
195#line 40 "scripts/genksyms/keywords.gperf" 200#line 42 "scripts/genksyms/keywords.gperf"
196 {"long", LONG_KEYW} 201 {"long", LONG_KEYW}
197 }; 202 };
198 203
diff --git a/scripts/genksyms/keywords.gperf b/scripts/genksyms/keywords.gperf
index 5ef3733225fb..8fe977a4d57b 100644
--- a/scripts/genksyms/keywords.gperf
+++ b/scripts/genksyms/keywords.gperf
@@ -1,4 +1,6 @@
1%{ 1%{
2struct resword;
3static const struct resword *is_reserved_word(register const char *str, register unsigned int len);
2%} 4%}
3struct resword { const char *name; int token; } 5struct resword { const char *name; int token; }
4%% 6%%
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index cdb44b63342e..81a67a458e78 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -5,15 +5,15 @@
5# Print selected MAINTAINERS information for 5# Print selected MAINTAINERS information for
6# the files modified in a patch or for a file 6# the files modified in a patch or for a file
7# 7#
8# usage: perl scripts/get_maintainers.pl [OPTIONS] <patch> 8# usage: perl scripts/get_maintainer.pl [OPTIONS] <patch>
9# perl scripts/get_maintainers.pl [OPTIONS] -f <file> 9# perl scripts/get_maintainer.pl [OPTIONS] -f <file>
10# 10#
11# Licensed under the terms of the GNU GPL License version 2 11# Licensed under the terms of the GNU GPL License version 2
12 12
13use strict; 13use strict;
14 14
15my $P = $0; 15my $P = $0;
16my $V = '0.20'; 16my $V = '0.21';
17 17
18use Getopt::Long qw(:config no_auto_abbrev); 18use Getopt::Long qw(:config no_auto_abbrev);
19 19
@@ -37,6 +37,7 @@ my $scm = 0;
37my $web = 0; 37my $web = 0;
38my $subsystem = 0; 38my $subsystem = 0;
39my $status = 0; 39my $status = 0;
40my $keywords = 1;
40my $from_filename = 0; 41my $from_filename = 0;
41my $pattern_depth = 0; 42my $pattern_depth = 0;
42my $version = 0; 43my $version = 0;
@@ -84,6 +85,7 @@ if (!GetOptions(
84 'scm!' => \$scm, 85 'scm!' => \$scm,
85 'web!' => \$web, 86 'web!' => \$web,
86 'pattern-depth=i' => \$pattern_depth, 87 'pattern-depth=i' => \$pattern_depth,
88 'k|keywords!' => \$keywords,
87 'f|file' => \$from_filename, 89 'f|file' => \$from_filename,
88 'v|version' => \$version, 90 'v|version' => \$version,
89 'h|help' => \$help, 91 'h|help' => \$help,
@@ -132,6 +134,8 @@ if (!top_of_kernel_tree($lk_path)) {
132## Read MAINTAINERS for type/value pairs 134## Read MAINTAINERS for type/value pairs
133 135
134my @typevalue = (); 136my @typevalue = ();
137my %keyword_hash;
138
135open(MAINT, "<${lk_path}MAINTAINERS") || die "$P: Can't open MAINTAINERS\n"; 139open(MAINT, "<${lk_path}MAINTAINERS") || die "$P: Can't open MAINTAINERS\n";
136while (<MAINT>) { 140while (<MAINT>) {
137 my $line = $_; 141 my $line = $_;
@@ -149,6 +153,8 @@ while (<MAINT>) {
149 if ((-d $value)) { 153 if ((-d $value)) {
150 $value =~ s@([^/])$@$1/@; 154 $value =~ s@([^/])$@$1/@;
151 } 155 }
156 } elsif ($type eq "K") {
157 $keyword_hash{@typevalue} = $value;
152 } 158 }
153 push(@typevalue, "$type:$value"); 159 push(@typevalue, "$type:$value");
154 } elsif (!/^(\s)*$/) { 160 } elsif (!/^(\s)*$/) {
@@ -188,6 +194,7 @@ if ($email_remove_duplicates) {
188 194
189my @files = (); 195my @files = ();
190my @range = (); 196my @range = ();
197my @keyword_tvi = ();
191 198
192foreach my $file (@ARGV) { 199foreach my $file (@ARGV) {
193 ##if $file is a directory and it lacks a trailing slash, add one 200 ##if $file is a directory and it lacks a trailing slash, add one
@@ -198,11 +205,24 @@ foreach my $file (@ARGV) {
198 } 205 }
199 if ($from_filename) { 206 if ($from_filename) {
200 push(@files, $file); 207 push(@files, $file);
208 if (-f $file && $keywords) {
209 open(FILE, "<$file") or die "$P: Can't open ${file}\n";
210 while (<FILE>) {
211 my $patch_line = $_;
212 foreach my $line (keys %keyword_hash) {
213 if ($patch_line =~ m/^.*$keyword_hash{$line}/x) {
214 push(@keyword_tvi, $line);
215 }
216 }
217 }
218 close(FILE);
219 }
201 } else { 220 } else {
202 my $file_cnt = @files; 221 my $file_cnt = @files;
203 my $lastfile; 222 my $lastfile;
204 open(PATCH, "<$file") or die "$P: Can't open ${file}\n"; 223 open(PATCH, "<$file") or die "$P: Can't open ${file}\n";
205 while (<PATCH>) { 224 while (<PATCH>) {
225 my $patch_line = $_;
206 if (m/^\+\+\+\s+(\S+)/) { 226 if (m/^\+\+\+\s+(\S+)/) {
207 my $filename = $1; 227 my $filename = $1;
208 $filename =~ s@^[^/]*/@@; 228 $filename =~ s@^[^/]*/@@;
@@ -213,6 +233,12 @@ foreach my $file (@ARGV) {
213 if ($email_git_blame) { 233 if ($email_git_blame) {
214 push(@range, "$lastfile:$1:$2"); 234 push(@range, "$lastfile:$1:$2");
215 } 235 }
236 } elsif ($keywords) {
237 foreach my $line (keys %keyword_hash) {
238 if ($patch_line =~ m/^[+-].*$keyword_hash{$line}/x) {
239 push(@keyword_tvi, $line);
240 }
241 }
216 } 242 }
217 } 243 }
218 close(PATCH); 244 close(PATCH);
@@ -286,6 +312,13 @@ foreach my $file (@files) {
286 } 312 }
287} 313}
288 314
315if ($keywords) {
316 @keyword_tvi = sort_and_uniq(@keyword_tvi);
317 foreach my $line (@keyword_tvi) {
318 add_categories($line);
319 }
320}
321
289if ($email) { 322if ($email) {
290 foreach my $chief (@penguin_chief) { 323 foreach my $chief (@penguin_chief) {
291 if ($chief =~ m/^(.*):(.*)/) { 324 if ($chief =~ m/^(.*):(.*)/) {
@@ -384,6 +417,7 @@ Output type options:
384 417
385Other options: 418Other options:
386 --pattern-depth => Number of pattern directory traversals (default: 0 (all)) 419 --pattern-depth => Number of pattern directory traversals (default: 0 (all))
420 --keywords => scan patch for keywords (default: 1 (on))
387 --version => show version 421 --version => show version
388 --help => show this help information 422 --help => show this help information
389 423
@@ -486,7 +520,6 @@ sub format_email {
486} 520}
487 521
488sub find_starting_index { 522sub find_starting_index {
489
490 my ($index) = @_; 523 my ($index) = @_;
491 524
492 while ($index > 0) { 525 while ($index > 0) {
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 6d69c7ccdcc7..80599e3a7994 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -30,7 +30,7 @@ silentoldconfig: $(obj)/conf
30 $< -s $(Kconfig) 30 $< -s $(Kconfig)
31 31
32localmodconfig: $(obj)/streamline_config.pl $(obj)/conf 32localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
33 $(Q)perl $< $(Kconfig) > .tmp.config 33 $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config
34 $(Q)if [ -f .config ]; then \ 34 $(Q)if [ -f .config ]; then \
35 cmp -s .tmp.config .config || \ 35 cmp -s .tmp.config .config || \
36 (mv -f .config .config.old.1; \ 36 (mv -f .config .config.old.1; \
@@ -44,7 +44,7 @@ localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
44 $(Q)rm -f .tmp.config 44 $(Q)rm -f .tmp.config
45 45
46localyesconfig: $(obj)/streamline_config.pl $(obj)/conf 46localyesconfig: $(obj)/streamline_config.pl $(obj)/conf
47 $(Q)perl $< $(Kconfig) > .tmp.config 47 $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config
48 $(Q)sed -i s/=m/=y/ .tmp.config 48 $(Q)sed -i s/=m/=y/ .tmp.config
49 $(Q)if [ -f .config ]; then \ 49 $(Q)if [ -f .config ]; then \
50 cmp -s .tmp.config .config || \ 50 cmp -s .tmp.config .config || \
diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped
index dc3e81807d13..fdc7113b08d1 100644
--- a/scripts/kconfig/lex.zconf.c_shipped
+++ b/scripts/kconfig/lex.zconf.c_shipped
@@ -160,7 +160,15 @@ typedef unsigned int flex_uint32_t;
160 160
161/* Size of default input buffer. */ 161/* Size of default input buffer. */
162#ifndef YY_BUF_SIZE 162#ifndef YY_BUF_SIZE
163#ifdef __ia64__
164/* On IA-64, the buffer size is 16k, not 8k.
165 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
166 * Ditto for the __ia64__ case accordingly.
167 */
168#define YY_BUF_SIZE 32768
169#else
163#define YY_BUF_SIZE 16384 170#define YY_BUF_SIZE 16384
171#endif /* __ia64__ */
164#endif 172#endif
165 173
166/* The state buf must be large enough to hold one state per character in the main buffer. 174/* The state buf must be large enough to hold one state per character in the main buffer.
@@ -802,7 +810,7 @@ static int last_ts, first_ts;
802static void zconf_endhelp(void); 810static void zconf_endhelp(void);
803static void zconf_endfile(void); 811static void zconf_endfile(void);
804 812
805void new_string(void) 813static void new_string(void)
806{ 814{
807 text = malloc(START_STRSIZE); 815 text = malloc(START_STRSIZE);
808 text_asize = START_STRSIZE; 816 text_asize = START_STRSIZE;
@@ -810,7 +818,7 @@ void new_string(void)
810 *text = 0; 818 *text = 0;
811} 819}
812 820
813void append_string(const char *str, int size) 821static void append_string(const char *str, int size)
814{ 822{
815 int new_size = text_size + size + 1; 823 int new_size = text_size + size + 1;
816 if (new_size > text_asize) { 824 if (new_size > text_asize) {
@@ -824,7 +832,7 @@ void append_string(const char *str, int size)
824 text[text_size] = 0; 832 text[text_size] = 0;
825} 833}
826 834
827void alloc_string(const char *str, int size) 835static void alloc_string(const char *str, int size)
828{ 836{
829 text = malloc(size + 1); 837 text = malloc(size + 1);
830 memcpy(text, str, size); 838 memcpy(text, str, size);
@@ -914,7 +922,12 @@ static int input (void );
914 922
915/* Amount of stuff to slurp up with each read. */ 923/* Amount of stuff to slurp up with each read. */
916#ifndef YY_READ_BUF_SIZE 924#ifndef YY_READ_BUF_SIZE
925#ifdef __ia64__
926/* On IA-64, the buffer size is 16k, not 8k */
927#define YY_READ_BUF_SIZE 16384
928#else
917#define YY_READ_BUF_SIZE 8192 929#define YY_READ_BUF_SIZE 8192
930#endif /* __ia64__ */
918#endif 931#endif
919 932
920/* Copy whatever the last rule matched to the standard output. */ 933/* Copy whatever the last rule matched to the standard output. */
@@ -922,7 +935,7 @@ static int input (void );
922/* This used to be an fputs(), but since the string might contain NUL's, 935/* This used to be an fputs(), but since the string might contain NUL's,
923 * we now use fwrite(). 936 * we now use fwrite().
924 */ 937 */
925#define ECHO fwrite( zconftext, zconfleng, 1, zconfout ) 938#define ECHO do { if (fwrite( zconftext, zconfleng, 1, zconfout )) {} } while (0)
926#endif 939#endif
927 940
928/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, 941/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -2060,8 +2073,8 @@ YY_BUFFER_STATE zconf_scan_string (yyconst char * yystr )
2060 2073
2061/** Setup the input buffer state to scan the given bytes. The next call to zconflex() will 2074/** Setup the input buffer state to scan the given bytes. The next call to zconflex() will
2062 * scan from a @e copy of @a bytes. 2075 * scan from a @e copy of @a bytes.
2063 * @param bytes the byte buffer to scan 2076 * @param yybytes the byte buffer to scan
2064 * @param len the number of bytes in the buffer pointed to by @a bytes. 2077 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
2065 * 2078 *
2066 * @return the newly allocated buffer state object. 2079 * @return the newly allocated buffer state object.
2067 */ 2080 */
diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
index 95984db8e1e0..0d800820c3cd 100644
--- a/scripts/kconfig/streamline_config.pl
+++ b/scripts/kconfig/streamline_config.pl
@@ -43,7 +43,6 @@
43# make oldconfig 43# make oldconfig
44# 44#
45my $config = ".config"; 45my $config = ".config";
46my $linuxpath = ".";
47 46
48my $uname = `uname -r`; 47my $uname = `uname -r`;
49chomp $uname; 48chomp $uname;
@@ -111,7 +110,11 @@ sub find_config {
111 110
112find_config; 111find_config;
113 112
114my @makefiles = `find $linuxpath -name Makefile`; 113# Get the build source and top level Kconfig file (passed in)
114my $ksource = $ARGV[0];
115my $kconfig = $ARGV[1];
116
117my @makefiles = `find $ksource -name Makefile`;
115my %depends; 118my %depends;
116my %selects; 119my %selects;
117my %prompts; 120my %prompts;
@@ -119,9 +122,6 @@ my %objects;
119my $var; 122my $var;
120my $cont = 0; 123my $cont = 0;
121 124
122# Get the top level Kconfig file (passed in)
123my $kconfig = $ARGV[0];
124
125# prevent recursion 125# prevent recursion
126my %read_kconfigs; 126my %read_kconfigs;
127 127
@@ -132,7 +132,7 @@ sub read_kconfig {
132 my $config; 132 my $config;
133 my @kconfigs; 133 my @kconfigs;
134 134
135 open(KIN, $kconfig) || die "Can't open $kconfig"; 135 open(KIN, "$ksource/$kconfig") || die "Can't open $kconfig";
136 while (<KIN>) { 136 while (<KIN>) {
137 chomp; 137 chomp;
138 138
diff --git a/scripts/kconfig/zconf.gperf b/scripts/kconfig/zconf.gperf
index 25ef5d01c0af..d8bc74249622 100644
--- a/scripts/kconfig/zconf.gperf
+++ b/scripts/kconfig/zconf.gperf
@@ -9,6 +9,8 @@
9 9
10struct kconf_id; 10struct kconf_id;
11 11
12static struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
13
12%% 14%%
13mainmenu, T_MAINMENU, TF_COMMAND 15mainmenu, T_MAINMENU, TF_COMMAND
14menu, T_MENU, TF_COMMAND 16menu, T_MENU, TF_COMMAND
diff --git a/scripts/kconfig/zconf.hash.c_shipped b/scripts/kconfig/zconf.hash.c_shipped
index 5c73d51339d8..c1748faf4634 100644
--- a/scripts/kconfig/zconf.hash.c_shipped
+++ b/scripts/kconfig/zconf.hash.c_shipped
@@ -30,6 +30,8 @@
30#endif 30#endif
31 31
32struct kconf_id; 32struct kconf_id;
33
34static struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
33/* maximum key range = 47, duplicates = 0 */ 35/* maximum key range = 47, duplicates = 0 */
34 36
35#ifdef __GNUC__ 37#ifdef __GNUC__
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
index 21ff69c9ad4e..d8f7236cb0a3 100644
--- a/scripts/kconfig/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -39,7 +39,7 @@ static int last_ts, first_ts;
39static void zconf_endhelp(void); 39static void zconf_endhelp(void);
40static void zconf_endfile(void); 40static void zconf_endfile(void);
41 41
42void new_string(void) 42static void new_string(void)
43{ 43{
44 text = malloc(START_STRSIZE); 44 text = malloc(START_STRSIZE);
45 text_asize = START_STRSIZE; 45 text_asize = START_STRSIZE;
@@ -47,7 +47,7 @@ void new_string(void)
47 *text = 0; 47 *text = 0;
48} 48}
49 49
50void append_string(const char *str, int size) 50static void append_string(const char *str, int size)
51{ 51{
52 int new_size = text_size + size + 1; 52 int new_size = text_size + size + 1;
53 if (new_size > text_asize) { 53 if (new_size > text_asize) {
@@ -61,7 +61,7 @@ void append_string(const char *str, int size)
61 text[text_size] = 0; 61 text[text_size] = 0;
62} 62}
63 63
64void alloc_string(const char *str, int size) 64static void alloc_string(const char *str, int size)
65{ 65{
66 text = malloc(size + 1); 66 text = malloc(size + 1);
67 memcpy(text, str, size); 67 memcpy(text, str, size);
diff --git a/scripts/kconfig/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped
index 95df833b5a9d..6e9dcd59aa87 100644
--- a/scripts/kconfig/zconf.tab.c_shipped
+++ b/scripts/kconfig/zconf.tab.c_shipped
@@ -1,24 +1,23 @@
1/* A Bison parser, made by GNU Bison 2.3. */
2 1
3/* Skeleton implementation for Bison's Yacc-like parsers in C 2/* A Bison parser, made by GNU Bison 2.4.1. */
4 3
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 4/* Skeleton implementation for Bison's Yacc-like parsers in C
5
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc. 7 Free Software Foundation, Inc.
7 8
8 This program is free software; you can redistribute it and/or modify 9 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option) 11 the Free Software Foundation, either version 3 of the License, or
11 any later version. 12 (at your option) any later version.
12 13
13 This program is distributed in the hope that it will be useful, 14 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 17 GNU General Public License for more details.
17 18
18 You should have received a copy of the GNU General Public License 19 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22 21
23/* As a special exception, you may create a larger work that contains 22/* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work 23 part or all of the Bison parser skeleton and distribute that work
@@ -29,7 +28,7 @@
29 special exception, which will cause the skeleton and the resulting 28 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public 29 Bison output files to be licensed under the GNU General Public
31 License without this special exception. 30 License without this special exception.
32 31
33 This special exception was added by the Free Software Foundation in 32 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */ 33 version 2.2 of Bison. */
35 34
@@ -47,7 +46,7 @@
47#define YYBISON 1 46#define YYBISON 1
48 47
49/* Bison version. */ 48/* Bison version. */
50#define YYBISON_VERSION "2.3" 49#define YYBISON_VERSION "2.4.1"
51 50
52/* Skeleton name. */ 51/* Skeleton name. */
53#define YYSKELETON_NAME "yacc.c" 52#define YYSKELETON_NAME "yacc.c"
@@ -55,94 +54,23 @@
55/* Pure parsers. */ 54/* Pure parsers. */
56#define YYPURE 0 55#define YYPURE 0
57 56
57/* Push parsers. */
58#define YYPUSH 0
59
60/* Pull parsers. */
61#define YYPULL 1
62
58/* Using locations. */ 63/* Using locations. */
59#define YYLSP_NEEDED 0 64#define YYLSP_NEEDED 0
60 65
61/* Substitute the variable and function names. */ 66/* Substitute the variable and function names. */
62#define yyparse zconfparse 67#define yyparse zconfparse
63#define yylex zconflex 68#define yylex zconflex
64#define yyerror zconferror 69#define yyerror zconferror
65#define yylval zconflval 70#define yylval zconflval
66#define yychar zconfchar 71#define yychar zconfchar
67#define yydebug zconfdebug 72#define yydebug zconfdebug
68#define yynerrs zconfnerrs 73#define yynerrs zconfnerrs
69
70
71/* Tokens. */
72#ifndef YYTOKENTYPE
73# define YYTOKENTYPE
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
75 know about them. */
76 enum yytokentype {
77 T_MAINMENU = 258,
78 T_MENU = 259,
79 T_ENDMENU = 260,
80 T_SOURCE = 261,
81 T_CHOICE = 262,
82 T_ENDCHOICE = 263,
83 T_COMMENT = 264,
84 T_CONFIG = 265,
85 T_MENUCONFIG = 266,
86 T_HELP = 267,
87 T_HELPTEXT = 268,
88 T_IF = 269,
89 T_ENDIF = 270,
90 T_DEPENDS = 271,
91 T_OPTIONAL = 272,
92 T_PROMPT = 273,
93 T_TYPE = 274,
94 T_DEFAULT = 275,
95 T_SELECT = 276,
96 T_RANGE = 277,
97 T_OPTION = 278,
98 T_ON = 279,
99 T_WORD = 280,
100 T_WORD_QUOTE = 281,
101 T_UNEQUAL = 282,
102 T_CLOSE_PAREN = 283,
103 T_OPEN_PAREN = 284,
104 T_EOL = 285,
105 T_OR = 286,
106 T_AND = 287,
107 T_EQUAL = 288,
108 T_NOT = 289
109 };
110#endif
111/* Tokens. */
112#define T_MAINMENU 258
113#define T_MENU 259
114#define T_ENDMENU 260
115#define T_SOURCE 261
116#define T_CHOICE 262
117#define T_ENDCHOICE 263
118#define T_COMMENT 264
119#define T_CONFIG 265
120#define T_MENUCONFIG 266
121#define T_HELP 267
122#define T_HELPTEXT 268
123#define T_IF 269
124#define T_ENDIF 270
125#define T_DEPENDS 271
126#define T_OPTIONAL 272
127#define T_PROMPT 273
128#define T_TYPE 274
129#define T_DEFAULT 275
130#define T_SELECT 276
131#define T_RANGE 277
132#define T_OPTION 278
133#define T_ON 279
134#define T_WORD 280
135#define T_WORD_QUOTE 281
136#define T_UNEQUAL 282
137#define T_CLOSE_PAREN 283
138#define T_OPEN_PAREN 284
139#define T_EOL 285
140#define T_OR 286
141#define T_AND 287
142#define T_EQUAL 288
143#define T_NOT 289
144
145
146 74
147 75
148/* Copy the first part of user declarations. */ 76/* Copy the first part of user declarations. */
@@ -163,8 +91,6 @@
163#define LKC_DIRECT_LINK 91#define LKC_DIRECT_LINK
164#include "lkc.h" 92#include "lkc.h"
165 93
166#include "zconf.hash.c"
167
168#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) 94#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
169 95
170#define PRINTD 0x0001 96#define PRINTD 0x0001
@@ -188,6 +114,7 @@ static struct menu *current_menu, *current_entry;
188#endif 114#endif
189 115
190 116
117
191/* Enabling traces. */ 118/* Enabling traces. */
192#ifndef YYDEBUG 119#ifndef YYDEBUG
193# define YYDEBUG 0 120# define YYDEBUG 0
@@ -206,31 +133,77 @@ static struct menu *current_menu, *current_entry;
206# define YYTOKEN_TABLE 0 133# define YYTOKEN_TABLE 0
207#endif 134#endif
208 135
136
137/* Tokens. */
138#ifndef YYTOKENTYPE
139# define YYTOKENTYPE
140 /* Put the tokens into the symbol table, so that GDB and other debuggers
141 know about them. */
142 enum yytokentype {
143 T_MAINMENU = 258,
144 T_MENU = 259,
145 T_ENDMENU = 260,
146 T_SOURCE = 261,
147 T_CHOICE = 262,
148 T_ENDCHOICE = 263,
149 T_COMMENT = 264,
150 T_CONFIG = 265,
151 T_MENUCONFIG = 266,
152 T_HELP = 267,
153 T_HELPTEXT = 268,
154 T_IF = 269,
155 T_ENDIF = 270,
156 T_DEPENDS = 271,
157 T_OPTIONAL = 272,
158 T_PROMPT = 273,
159 T_TYPE = 274,
160 T_DEFAULT = 275,
161 T_SELECT = 276,
162 T_RANGE = 277,
163 T_OPTION = 278,
164 T_ON = 279,
165 T_WORD = 280,
166 T_WORD_QUOTE = 281,
167 T_UNEQUAL = 282,
168 T_CLOSE_PAREN = 283,
169 T_OPEN_PAREN = 284,
170 T_EOL = 285,
171 T_OR = 286,
172 T_AND = 287,
173 T_EQUAL = 288,
174 T_NOT = 289
175 };
176#endif
177
178
179
209#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 180#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
210typedef union YYSTYPE 181typedef union YYSTYPE
211
212{ 182{
183
184
213 char *string; 185 char *string;
214 struct file *file; 186 struct file *file;
215 struct symbol *symbol; 187 struct symbol *symbol;
216 struct expr *expr; 188 struct expr *expr;
217 struct menu *menu; 189 struct menu *menu;
218 struct kconf_id *id; 190 struct kconf_id *id;
219}
220/* Line 187 of yacc.c. */
221 191
222 YYSTYPE; 192
193
194} YYSTYPE;
195# define YYSTYPE_IS_TRIVIAL 1
223# define yystype YYSTYPE /* obsolescent; will be withdrawn */ 196# define yystype YYSTYPE /* obsolescent; will be withdrawn */
224# define YYSTYPE_IS_DECLARED 1 197# define YYSTYPE_IS_DECLARED 1
225# define YYSTYPE_IS_TRIVIAL 1
226#endif 198#endif
227 199
228 200
229
230/* Copy the second part of user declarations. */ 201/* Copy the second part of user declarations. */
231 202
232 203
233/* Line 216 of yacc.c. */ 204/* Include zconf.hash.c here so it can see the token constants. */
205#include "zconf.hash.c"
206
234 207
235 208
236#ifdef short 209#ifdef short
@@ -306,14 +279,14 @@ typedef short int yytype_int16;
306#if (defined __STDC__ || defined __C99__FUNC__ \ 279#if (defined __STDC__ || defined __C99__FUNC__ \
307 || defined __cplusplus || defined _MSC_VER) 280 || defined __cplusplus || defined _MSC_VER)
308static int 281static int
309YYID (int i) 282YYID (int yyi)
310#else 283#else
311static int 284static int
312YYID (i) 285YYID (yyi)
313 int i; 286 int yyi;
314#endif 287#endif
315{ 288{
316 return i; 289 return yyi;
317} 290}
318#endif 291#endif
319 292
@@ -394,9 +367,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
394/* A type that is properly aligned for any stack member. */ 367/* A type that is properly aligned for any stack member. */
395union yyalloc 368union yyalloc
396{ 369{
397 yytype_int16 yyss; 370 yytype_int16 yyss_alloc;
398 YYSTYPE yyvs; 371 YYSTYPE yyvs_alloc;
399 }; 372};
400 373
401/* The size of the maximum gap between one aligned stack and the next. */ 374/* The size of the maximum gap between one aligned stack and the next. */
402# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) 375# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
@@ -430,12 +403,12 @@ union yyalloc
430 elements in the stack, and YYPTR gives the new location of the 403 elements in the stack, and YYPTR gives the new location of the
431 stack. Advance YYPTR to a properly aligned location for the next 404 stack. Advance YYPTR to a properly aligned location for the next
432 stack. */ 405 stack. */
433# define YYSTACK_RELOCATE(Stack) \ 406# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
434 do \ 407 do \
435 { \ 408 { \
436 YYSIZE_T yynewbytes; \ 409 YYSIZE_T yynewbytes; \
437 YYCOPY (&yyptr->Stack, Stack, yysize); \ 410 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
438 Stack = &yyptr->Stack; \ 411 Stack = &yyptr->Stack_alloc; \
439 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ 412 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
440 yyptr += yynewbytes / sizeof (*yyptr); \ 413 yyptr += yynewbytes / sizeof (*yyptr); \
441 } \ 414 } \
@@ -558,18 +531,18 @@ static const yytype_int8 yyrhs[] =
558/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 531/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
559static const yytype_uint16 yyrline[] = 532static const yytype_uint16 yyrline[] =
560{ 533{
561 0, 104, 104, 106, 108, 109, 110, 111, 112, 113, 534 0, 107, 107, 109, 111, 112, 113, 114, 115, 116,
562 114, 118, 122, 122, 122, 122, 122, 122, 122, 126, 535 117, 121, 125, 125, 125, 125, 125, 125, 125, 129,
563 127, 128, 129, 130, 131, 135, 136, 142, 150, 156, 536 130, 131, 132, 133, 134, 138, 139, 145, 153, 159,
564 164, 174, 176, 177, 178, 179, 180, 181, 184, 192, 537 167, 177, 179, 180, 181, 182, 183, 184, 187, 195,
565 198, 208, 214, 220, 223, 225, 236, 237, 242, 251, 538 201, 211, 217, 223, 226, 228, 239, 240, 245, 254,
566 256, 264, 267, 269, 270, 271, 272, 273, 276, 282, 539 259, 267, 270, 272, 273, 274, 275, 276, 279, 285,
567 293, 299, 309, 311, 316, 324, 332, 335, 337, 338, 540 296, 302, 312, 314, 319, 327, 335, 338, 340, 341,
568 339, 344, 351, 356, 364, 367, 369, 370, 371, 374, 541 342, 347, 354, 359, 367, 370, 372, 373, 374, 377,
569 382, 389, 396, 402, 409, 411, 412, 413, 416, 424, 542 385, 392, 399, 405, 412, 414, 415, 416, 419, 427,
570 426, 431, 432, 435, 436, 437, 441, 442, 445, 446, 543 429, 434, 435, 438, 439, 440, 444, 445, 448, 449,
571 449, 450, 451, 452, 453, 454, 455, 458, 459, 462, 544 452, 453, 454, 455, 456, 457, 458, 461, 462, 465,
572 463 545 466
573}; 546};
574#endif 547#endif
575 548
@@ -985,17 +958,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep)
985#if (defined __STDC__ || defined __C99__FUNC__ \ 958#if (defined __STDC__ || defined __C99__FUNC__ \
986 || defined __cplusplus || defined _MSC_VER) 959 || defined __cplusplus || defined _MSC_VER)
987static void 960static void
988yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) 961yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
989#else 962#else
990static void 963static void
991yy_stack_print (bottom, top) 964yy_stack_print (yybottom, yytop)
992 yytype_int16 *bottom; 965 yytype_int16 *yybottom;
993 yytype_int16 *top; 966 yytype_int16 *yytop;
994#endif 967#endif
995{ 968{
996 YYFPRINTF (stderr, "Stack now"); 969 YYFPRINTF (stderr, "Stack now");
997 for (; bottom <= top; ++bottom) 970 for (; yybottom <= yytop; yybottom++)
998 YYFPRINTF (stderr, " %d", *bottom); 971 {
972 int yybot = *yybottom;
973 YYFPRINTF (stderr, " %d", yybot);
974 }
999 YYFPRINTF (stderr, "\n"); 975 YYFPRINTF (stderr, "\n");
1000} 976}
1001 977
@@ -1029,11 +1005,11 @@ yy_reduce_print (yyvsp, yyrule)
1029 /* The symbols being reduced. */ 1005 /* The symbols being reduced. */
1030 for (yyi = 0; yyi < yynrhs; yyi++) 1006 for (yyi = 0; yyi < yynrhs; yyi++)
1031 { 1007 {
1032 fprintf (stderr, " $%d = ", yyi + 1); 1008 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1033 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], 1009 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1034 &(yyvsp[(yyi + 1) - (yynrhs)]) 1010 &(yyvsp[(yyi + 1) - (yynrhs)])
1035 ); 1011 );
1036 fprintf (stderr, "\n"); 1012 YYFPRINTF (stderr, "\n");
1037 } 1013 }
1038} 1014}
1039 1015
@@ -1343,10 +1319,8 @@ yydestruct (yymsg, yytype, yyvaluep)
1343 break; 1319 break;
1344 } 1320 }
1345} 1321}
1346
1347 1322
1348/* Prevent warnings from -Wmissing-prototypes. */ 1323/* Prevent warnings from -Wmissing-prototypes. */
1349
1350#ifdef YYPARSE_PARAM 1324#ifdef YYPARSE_PARAM
1351#if defined __STDC__ || defined __cplusplus 1325#if defined __STDC__ || defined __cplusplus
1352int yyparse (void *YYPARSE_PARAM); 1326int yyparse (void *YYPARSE_PARAM);
@@ -1362,11 +1336,10 @@ int yyparse ();
1362#endif /* ! YYPARSE_PARAM */ 1336#endif /* ! YYPARSE_PARAM */
1363 1337
1364 1338
1365 1339/* The lookahead symbol. */
1366/* The look-ahead symbol. */
1367int yychar; 1340int yychar;
1368 1341
1369/* The semantic value of the look-ahead symbol. */ 1342/* The semantic value of the lookahead symbol. */
1370YYSTYPE yylval; 1343YYSTYPE yylval;
1371 1344
1372/* Number of syntax errors so far. */ 1345/* Number of syntax errors so far. */
@@ -1374,9 +1347,9 @@ int yynerrs;
1374 1347
1375 1348
1376 1349
1377/*----------. 1350/*-------------------------.
1378| yyparse. | 1351| yyparse or yypush_parse. |
1379`----------*/ 1352`-------------------------*/
1380 1353
1381#ifdef YYPARSE_PARAM 1354#ifdef YYPARSE_PARAM
1382#if (defined __STDC__ || defined __C99__FUNC__ \ 1355#if (defined __STDC__ || defined __C99__FUNC__ \
@@ -1400,66 +1373,68 @@ yyparse ()
1400#endif 1373#endif
1401#endif 1374#endif
1402{ 1375{
1403
1404 int yystate;
1405 int yyn;
1406 int yyresult;
1407 /* Number of tokens to shift before error messages enabled. */
1408 int yyerrstatus;
1409 /* Look-ahead token as an internal (translated) token number. */
1410 int yytoken = 0;
1411#if YYERROR_VERBOSE
1412 /* Buffer for error messages, and its allocated size. */
1413 char yymsgbuf[128];
1414 char *yymsg = yymsgbuf;
1415 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1416#endif
1417
1418 /* Three stacks and their tools:
1419 `yyss': related to states,
1420 `yyvs': related to semantic values,
1421 `yyls': related to locations.
1422 1376
1423 Refer to the stacks thru separate pointers, to allow yyoverflow
1424 to reallocate them elsewhere. */
1425 1377
1426 /* The state stack. */ 1378 int yystate;
1427 yytype_int16 yyssa[YYINITDEPTH]; 1379 /* Number of tokens to shift before error messages enabled. */
1428 yytype_int16 *yyss = yyssa; 1380 int yyerrstatus;
1429 yytype_int16 *yyssp;
1430 1381
1431 /* The semantic value stack. */ 1382 /* The stacks and their tools:
1432 YYSTYPE yyvsa[YYINITDEPTH]; 1383 `yyss': related to states.
1433 YYSTYPE *yyvs = yyvsa; 1384 `yyvs': related to semantic values.
1434 YYSTYPE *yyvsp;
1435 1385
1386 Refer to the stacks thru separate pointers, to allow yyoverflow
1387 to reallocate them elsewhere. */
1436 1388
1389 /* The state stack. */
1390 yytype_int16 yyssa[YYINITDEPTH];
1391 yytype_int16 *yyss;
1392 yytype_int16 *yyssp;
1437 1393
1438#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) 1394 /* The semantic value stack. */
1395 YYSTYPE yyvsa[YYINITDEPTH];
1396 YYSTYPE *yyvs;
1397 YYSTYPE *yyvsp;
1439 1398
1440 YYSIZE_T yystacksize = YYINITDEPTH; 1399 YYSIZE_T yystacksize;
1441 1400
1401 int yyn;
1402 int yyresult;
1403 /* Lookahead token as an internal (translated) token number. */
1404 int yytoken;
1442 /* The variables used to return semantic value and location from the 1405 /* The variables used to return semantic value and location from the
1443 action routines. */ 1406 action routines. */
1444 YYSTYPE yyval; 1407 YYSTYPE yyval;
1445 1408
1409#if YYERROR_VERBOSE
1410 /* Buffer for error messages, and its allocated size. */
1411 char yymsgbuf[128];
1412 char *yymsg = yymsgbuf;
1413 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1414#endif
1415
1416#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1446 1417
1447 /* The number of symbols on the RHS of the reduced rule. 1418 /* The number of symbols on the RHS of the reduced rule.
1448 Keep to zero when no symbol should be popped. */ 1419 Keep to zero when no symbol should be popped. */
1449 int yylen = 0; 1420 int yylen = 0;
1450 1421
1422 yytoken = 0;
1423 yyss = yyssa;
1424 yyvs = yyvsa;
1425 yystacksize = YYINITDEPTH;
1426
1451 YYDPRINTF ((stderr, "Starting parse\n")); 1427 YYDPRINTF ((stderr, "Starting parse\n"));
1452 1428
1453 yystate = 0; 1429 yystate = 0;
1454 yyerrstatus = 0; 1430 yyerrstatus = 0;
1455 yynerrs = 0; 1431 yynerrs = 0;
1456 yychar = YYEMPTY; /* Cause a token to be read. */ 1432 yychar = YYEMPTY; /* Cause a token to be read. */
1457 1433
1458 /* Initialize stack pointers. 1434 /* Initialize stack pointers.
1459 Waste one element of value and location stack 1435 Waste one element of value and location stack
1460 so that they stay on the same level as the state stack. 1436 so that they stay on the same level as the state stack.
1461 The wasted elements are never initialized. */ 1437 The wasted elements are never initialized. */
1462
1463 yyssp = yyss; 1438 yyssp = yyss;
1464 yyvsp = yyvs; 1439 yyvsp = yyvs;
1465 1440
@@ -1489,7 +1464,6 @@ yyparse ()
1489 YYSTYPE *yyvs1 = yyvs; 1464 YYSTYPE *yyvs1 = yyvs;
1490 yytype_int16 *yyss1 = yyss; 1465 yytype_int16 *yyss1 = yyss;
1491 1466
1492
1493 /* Each stack pointer address is followed by the size of the 1467 /* Each stack pointer address is followed by the size of the
1494 data in use in that stack, in bytes. This used to be a 1468 data in use in that stack, in bytes. This used to be a
1495 conditional around just the two extra args, but that might 1469 conditional around just the two extra args, but that might
@@ -1497,7 +1471,6 @@ yyparse ()
1497 yyoverflow (YY_("memory exhausted"), 1471 yyoverflow (YY_("memory exhausted"),
1498 &yyss1, yysize * sizeof (*yyssp), 1472 &yyss1, yysize * sizeof (*yyssp),
1499 &yyvs1, yysize * sizeof (*yyvsp), 1473 &yyvs1, yysize * sizeof (*yyvsp),
1500
1501 &yystacksize); 1474 &yystacksize);
1502 1475
1503 yyss = yyss1; 1476 yyss = yyss1;
@@ -1520,9 +1493,8 @@ yyparse ()
1520 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 1493 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1521 if (! yyptr) 1494 if (! yyptr)
1522 goto yyexhaustedlab; 1495 goto yyexhaustedlab;
1523 YYSTACK_RELOCATE (yyss); 1496 YYSTACK_RELOCATE (yyss_alloc, yyss);
1524 YYSTACK_RELOCATE (yyvs); 1497 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1525
1526# undef YYSTACK_RELOCATE 1498# undef YYSTACK_RELOCATE
1527 if (yyss1 != yyssa) 1499 if (yyss1 != yyssa)
1528 YYSTACK_FREE (yyss1); 1500 YYSTACK_FREE (yyss1);
@@ -1533,7 +1505,6 @@ yyparse ()
1533 yyssp = yyss + yysize - 1; 1505 yyssp = yyss + yysize - 1;
1534 yyvsp = yyvs + yysize - 1; 1506 yyvsp = yyvs + yysize - 1;
1535 1507
1536
1537 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 1508 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1538 (unsigned long int) yystacksize)); 1509 (unsigned long int) yystacksize));
1539 1510
@@ -1543,6 +1514,9 @@ yyparse ()
1543 1514
1544 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 1515 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1545 1516
1517 if (yystate == YYFINAL)
1518 YYACCEPT;
1519
1546 goto yybackup; 1520 goto yybackup;
1547 1521
1548/*-----------. 1522/*-----------.
@@ -1551,16 +1525,16 @@ yyparse ()
1551yybackup: 1525yybackup:
1552 1526
1553 /* Do appropriate processing given the current state. Read a 1527 /* Do appropriate processing given the current state. Read a
1554 look-ahead token if we need one and don't already have one. */ 1528 lookahead token if we need one and don't already have one. */
1555 1529
1556 /* First try to decide what to do without reference to look-ahead token. */ 1530 /* First try to decide what to do without reference to lookahead token. */
1557 yyn = yypact[yystate]; 1531 yyn = yypact[yystate];
1558 if (yyn == YYPACT_NINF) 1532 if (yyn == YYPACT_NINF)
1559 goto yydefault; 1533 goto yydefault;
1560 1534
1561 /* Not known => get a look-ahead token if don't already have one. */ 1535 /* Not known => get a lookahead token if don't already have one. */
1562 1536
1563 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ 1537 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1564 if (yychar == YYEMPTY) 1538 if (yychar == YYEMPTY)
1565 { 1539 {
1566 YYDPRINTF ((stderr, "Reading a token: ")); 1540 YYDPRINTF ((stderr, "Reading a token: "));
@@ -1592,20 +1566,16 @@ yybackup:
1592 goto yyreduce; 1566 goto yyreduce;
1593 } 1567 }
1594 1568
1595 if (yyn == YYFINAL)
1596 YYACCEPT;
1597
1598 /* Count tokens shifted since error; after three, turn off error 1569 /* Count tokens shifted since error; after three, turn off error
1599 status. */ 1570 status. */
1600 if (yyerrstatus) 1571 if (yyerrstatus)
1601 yyerrstatus--; 1572 yyerrstatus--;
1602 1573
1603 /* Shift the look-ahead token. */ 1574 /* Shift the lookahead token. */
1604 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 1575 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1605 1576
1606 /* Discard the shifted token unless it is eof. */ 1577 /* Discard the shifted token. */
1607 if (yychar != YYEOF) 1578 yychar = YYEMPTY;
1608 yychar = YYEMPTY;
1609 1579
1610 yystate = yyn; 1580 yystate = yyn;
1611 *++yyvsp = yylval; 1581 *++yyvsp = yylval;
@@ -2029,7 +1999,6 @@ yyreduce:
2029 break; 1999 break;
2030 2000
2031 2001
2032/* Line 1267 of yacc.c. */
2033 2002
2034 default: break; 2003 default: break;
2035 } 2004 }
@@ -2041,7 +2010,6 @@ yyreduce:
2041 2010
2042 *++yyvsp = yyval; 2011 *++yyvsp = yyval;
2043 2012
2044
2045 /* Now `shift' the result of the reduction. Determine what state 2013 /* Now `shift' the result of the reduction. Determine what state
2046 that goes to, based on the state we popped back to and the rule 2014 that goes to, based on the state we popped back to and the rule
2047 number reduced by. */ 2015 number reduced by. */
@@ -2106,7 +2074,7 @@ yyerrlab:
2106 2074
2107 if (yyerrstatus == 3) 2075 if (yyerrstatus == 3)
2108 { 2076 {
2109 /* If just tried and failed to reuse look-ahead token after an 2077 /* If just tried and failed to reuse lookahead token after an
2110 error, discard it. */ 2078 error, discard it. */
2111 2079
2112 if (yychar <= YYEOF) 2080 if (yychar <= YYEOF)
@@ -2123,7 +2091,7 @@ yyerrlab:
2123 } 2091 }
2124 } 2092 }
2125 2093
2126 /* Else will try to reuse look-ahead token after shifting the error 2094 /* Else will try to reuse lookahead token after shifting the error
2127 token. */ 2095 token. */
2128 goto yyerrlab1; 2096 goto yyerrlab1;
2129 2097
@@ -2180,9 +2148,6 @@ yyerrlab1:
2180 YY_STACK_PRINT (yyss, yyssp); 2148 YY_STACK_PRINT (yyss, yyssp);
2181 } 2149 }
2182 2150
2183 if (yyn == YYFINAL)
2184 YYACCEPT;
2185
2186 *++yyvsp = yylval; 2151 *++yyvsp = yylval;
2187 2152
2188 2153
@@ -2207,7 +2172,7 @@ yyabortlab:
2207 yyresult = 1; 2172 yyresult = 1;
2208 goto yyreturn; 2173 goto yyreturn;
2209 2174
2210#ifndef yyoverflow 2175#if !defined(yyoverflow) || YYERROR_VERBOSE
2211/*-------------------------------------------------. 2176/*-------------------------------------------------.
2212| yyexhaustedlab -- memory exhaustion comes here. | 2177| yyexhaustedlab -- memory exhaustion comes here. |
2213`-------------------------------------------------*/ 2178`-------------------------------------------------*/
@@ -2218,7 +2183,7 @@ yyexhaustedlab:
2218#endif 2183#endif
2219 2184
2220yyreturn: 2185yyreturn:
2221 if (yychar != YYEOF && yychar != YYEMPTY) 2186 if (yychar != YYEMPTY)
2222 yydestruct ("Cleanup: discarding lookahead", 2187 yydestruct ("Cleanup: discarding lookahead",
2223 yytoken, &yylval); 2188 yytoken, &yylval);
2224 /* Do not reclaim the symbols of the rule which action triggered 2189 /* Do not reclaim the symbols of the rule which action triggered
@@ -2284,7 +2249,7 @@ void conf_parse(const char *name)
2284 sym_set_change_count(1); 2249 sym_set_change_count(1);
2285} 2250}
2286 2251
2287const char *zconf_tokenname(int token) 2252static const char *zconf_tokenname(int token)
2288{ 2253{
2289 switch (token) { 2254 switch (token) {
2290 case T_MENU: return "menu"; 2255 case T_MENU: return "menu";
@@ -2348,7 +2313,7 @@ static void zconferror(const char *err)
2348#endif 2313#endif
2349} 2314}
2350 2315
2351void print_quoted_string(FILE *out, const char *str) 2316static void print_quoted_string(FILE *out, const char *str)
2352{ 2317{
2353 const char *p; 2318 const char *p;
2354 int len; 2319 int len;
@@ -2365,7 +2330,7 @@ void print_quoted_string(FILE *out, const char *str)
2365 putc('"', out); 2330 putc('"', out);
2366} 2331}
2367 2332
2368void print_symbol(FILE *out, struct menu *menu) 2333static void print_symbol(FILE *out, struct menu *menu)
2369{ 2334{
2370 struct symbol *sym = menu->sym; 2335 struct symbol *sym = menu->sym;
2371 struct property *prop; 2336 struct property *prop;
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 9710b82466f2..8c43491f8cc9 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -14,8 +14,6 @@
14#define LKC_DIRECT_LINK 14#define LKC_DIRECT_LINK
15#include "lkc.h" 15#include "lkc.h"
16 16
17#include "zconf.hash.c"
18
19#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) 17#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
20 18
21#define PRINTD 0x0001 19#define PRINTD 0x0001
@@ -100,6 +98,11 @@ static struct menu *current_menu, *current_entry;
100 menu_end_menu(); 98 menu_end_menu();
101} if_entry menu_entry choice_entry 99} if_entry menu_entry choice_entry
102 100
101%{
102/* Include zconf.hash.c here so it can see the token constants. */
103#include "zconf.hash.c"
104%}
105
103%% 106%%
104input: stmt_list; 107input: stmt_list;
105 108
@@ -501,7 +504,7 @@ void conf_parse(const char *name)
501 sym_set_change_count(1); 504 sym_set_change_count(1);
502} 505}
503 506
504const char *zconf_tokenname(int token) 507static const char *zconf_tokenname(int token)
505{ 508{
506 switch (token) { 509 switch (token) {
507 case T_MENU: return "menu"; 510 case T_MENU: return "menu";
@@ -565,7 +568,7 @@ static void zconferror(const char *err)
565#endif 568#endif
566} 569}
567 570
568void print_quoted_string(FILE *out, const char *str) 571static void print_quoted_string(FILE *out, const char *str)
569{ 572{
570 const char *p; 573 const char *p;
571 int len; 574 int len;
@@ -582,7 +585,7 @@ void print_quoted_string(FILE *out, const char *str)
582 putc('"', out); 585 putc('"', out);
583} 586}
584 587
585void print_symbol(FILE *out, struct menu *menu) 588static void print_symbol(FILE *out, struct menu *menu)
586{ 589{
587 struct symbol *sym = menu->sym; 590 struct symbol *sym = menu->sym;
588 struct property *prop; 591 struct property *prop;
diff --git a/scripts/selinux/Makefile b/scripts/selinux/Makefile
index ca4b1ec01822..e8049da1831f 100644
--- a/scripts/selinux/Makefile
+++ b/scripts/selinux/Makefile
@@ -1,2 +1,2 @@
1subdir-y := mdp 1subdir-y := mdp genheaders
2subdir- += mdp 2subdir- += mdp genheaders
diff --git a/scripts/selinux/genheaders/.gitignore b/scripts/selinux/genheaders/.gitignore
new file mode 100644
index 000000000000..4c0b646ff8d5
--- /dev/null
+++ b/scripts/selinux/genheaders/.gitignore
@@ -0,0 +1 @@
genheaders
diff --git a/scripts/selinux/genheaders/Makefile b/scripts/selinux/genheaders/Makefile
new file mode 100644
index 000000000000..417b165008ee
--- /dev/null
+++ b/scripts/selinux/genheaders/Makefile
@@ -0,0 +1,5 @@
1hostprogs-y := genheaders
2HOST_EXTRACFLAGS += -Isecurity/selinux/include
3
4always := $(hostprogs-y)
5clean-files := $(hostprogs-y)
diff --git a/scripts/selinux/genheaders/genheaders.c b/scripts/selinux/genheaders/genheaders.c
new file mode 100644
index 000000000000..24626968055d
--- /dev/null
+++ b/scripts/selinux/genheaders/genheaders.c
@@ -0,0 +1,118 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <unistd.h>
4#include <string.h>
5#include <errno.h>
6#include <ctype.h>
7
8struct security_class_mapping {
9 const char *name;
10 const char *perms[sizeof(unsigned) * 8 + 1];
11};
12
13#include "classmap.h"
14#include "initial_sid_to_string.h"
15
16#define max(x, y) (((int)(x) > (int)(y)) ? x : y)
17
18const char *progname;
19
20static void usage(void)
21{
22 printf("usage: %s flask.h av_permissions.h\n", progname);
23 exit(1);
24}
25
26static char *stoupperx(const char *s)
27{
28 char *s2 = strdup(s);
29 char *p;
30
31 if (!s2) {
32 fprintf(stderr, "%s: out of memory\n", progname);
33 exit(3);
34 }
35
36 for (p = s2; *p; p++)
37 *p = toupper(*p);
38 return s2;
39}
40
41int main(int argc, char *argv[])
42{
43 int i, j, k;
44 int isids_len;
45 FILE *fout;
46
47 progname = argv[0];
48
49 if (argc < 3)
50 usage();
51
52 fout = fopen(argv[1], "w");
53 if (!fout) {
54 fprintf(stderr, "Could not open %s for writing: %s\n",
55 argv[1], strerror(errno));
56 exit(2);
57 }
58
59 for (i = 0; secclass_map[i].name; i++) {
60 struct security_class_mapping *map = &secclass_map[i];
61 map->name = stoupperx(map->name);
62 for (j = 0; map->perms[j]; j++)
63 map->perms[j] = stoupperx(map->perms[j]);
64 }
65
66 isids_len = sizeof(initial_sid_to_string) / sizeof (char *);
67 for (i = 1; i < isids_len; i++)
68 initial_sid_to_string[i] = stoupperx(initial_sid_to_string[i]);
69
70 fprintf(fout, "/* This file is automatically generated. Do not edit. */\n");
71 fprintf(fout, "#ifndef _SELINUX_FLASK_H_\n#define _SELINUX_FLASK_H_\n\n");
72
73 for (i = 0; secclass_map[i].name; i++) {
74 struct security_class_mapping *map = &secclass_map[i];
75 fprintf(fout, "#define SECCLASS_%s", map->name);
76 for (j = 0; j < max(1, 40 - strlen(map->name)); j++)
77 fprintf(fout, " ");
78 fprintf(fout, "%2d\n", i+1);
79 }
80
81 fprintf(fout, "\n");
82
83 for (i = 1; i < isids_len; i++) {
84 char *s = initial_sid_to_string[i];
85 fprintf(fout, "#define SECINITSID_%s", s);
86 for (j = 0; j < max(1, 40 - strlen(s)); j++)
87 fprintf(fout, " ");
88 fprintf(fout, "%2d\n", i);
89 }
90 fprintf(fout, "\n#define SECINITSID_NUM %d\n", i-1);
91 fprintf(fout, "\n#endif\n");
92 fclose(fout);
93
94 fout = fopen(argv[2], "w");
95 if (!fout) {
96 fprintf(stderr, "Could not open %s for writing: %s\n",
97 argv[2], strerror(errno));
98 exit(4);
99 }
100
101 fprintf(fout, "/* This file is automatically generated. Do not edit. */\n");
102 fprintf(fout, "#ifndef _SELINUX_AV_PERMISSIONS_H_\n#define _SELINUX_AV_PERMISSIONS_H_\n\n");
103
104 for (i = 0; secclass_map[i].name; i++) {
105 struct security_class_mapping *map = &secclass_map[i];
106 for (j = 0; map->perms[j]; j++) {
107 fprintf(fout, "#define %s__%s", map->name,
108 map->perms[j]);
109 for (k = 0; k < max(1, 40 - strlen(map->name) - strlen(map->perms[j])); k++)
110 fprintf(fout, " ");
111 fprintf(fout, "0x%08xUL\n", (1<<j));
112 }
113 }
114
115 fprintf(fout, "\n#endif\n");
116 fclose(fout);
117 exit(0);
118}
diff --git a/scripts/selinux/mdp/mdp.c b/scripts/selinux/mdp/mdp.c
index b4ced8562587..62b34ce1f50d 100644
--- a/scripts/selinux/mdp/mdp.c
+++ b/scripts/selinux/mdp/mdp.c
@@ -29,86 +29,27 @@
29#include <unistd.h> 29#include <unistd.h>
30#include <string.h> 30#include <string.h>
31 31
32#include "flask.h"
33
34static void usage(char *name) 32static void usage(char *name)
35{ 33{
36 printf("usage: %s [-m] policy_file context_file\n", name); 34 printf("usage: %s [-m] policy_file context_file\n", name);
37 exit(1); 35 exit(1);
38} 36}
39 37
40static void find_common_name(char *cname, char *dest, int len) 38/* Class/perm mapping support */
41{ 39struct security_class_mapping {
42 char *start, *end; 40 const char *name;
43 41 const char *perms[sizeof(unsigned) * 8 + 1];
44 start = strchr(cname, '_')+1;
45 end = strchr(start, '_');
46 if (!start || !end || start-cname > len || end-start > len) {
47 printf("Error with commons defines\n");
48 exit(1);
49 }
50 strncpy(dest, start, end-start);
51 dest[end-start] = '\0';
52}
53
54#define S_(x) x,
55static char *classlist[] = {
56#include "class_to_string.h"
57 NULL
58}; 42};
59#undef S_
60 43
44#include "classmap.h"
61#include "initial_sid_to_string.h" 45#include "initial_sid_to_string.h"
62 46
63#define TB_(x) char *x[] = {
64#define TE_(x) NULL };
65#define S_(x) x,
66#include "common_perm_to_string.h"
67#undef TB_
68#undef TE_
69#undef S_
70
71struct common {
72 char *cname;
73 char **perms;
74};
75struct common common[] = {
76#define TB_(x) { #x, x },
77#define S_(x)
78#define TE_(x)
79#include "common_perm_to_string.h"
80#undef TB_
81#undef TE_
82#undef S_
83};
84
85#define S_(x, y, z) {x, #y},
86struct av_inherit {
87 int class;
88 char *common;
89};
90struct av_inherit av_inherit[] = {
91#include "av_inherit.h"
92};
93#undef S_
94
95#include "av_permissions.h"
96#define S_(x, y, z) {x, y, z},
97struct av_perms {
98 int class;
99 int perm_i;
100 char *perm_s;
101};
102struct av_perms av_perms[] = {
103#include "av_perm_to_string.h"
104};
105#undef S_
106
107int main(int argc, char *argv[]) 47int main(int argc, char *argv[])
108{ 48{
109 int i, j, mls = 0; 49 int i, j, mls = 0;
50 int initial_sid_to_string_len;
110 char **arg, *polout, *ctxout; 51 char **arg, *polout, *ctxout;
111 int classlist_len, initial_sid_to_string_len; 52
112 FILE *fout; 53 FILE *fout;
113 54
114 if (argc < 3) 55 if (argc < 3)
@@ -127,64 +68,25 @@ int main(int argc, char *argv[])
127 usage(argv[0]); 68 usage(argv[0]);
128 } 69 }
129 70
130 classlist_len = sizeof(classlist) / sizeof(char *);
131 /* print out the classes */ 71 /* print out the classes */
132 for (i=1; i < classlist_len; i++) { 72 for (i = 0; secclass_map[i].name; i++)
133 if(classlist[i]) 73 fprintf(fout, "class %s\n", secclass_map[i].name);
134 fprintf(fout, "class %s\n", classlist[i]);
135 else
136 fprintf(fout, "class user%d\n", i);
137 }
138 fprintf(fout, "\n"); 74 fprintf(fout, "\n");
139 75
140 initial_sid_to_string_len = sizeof(initial_sid_to_string) / sizeof (char *); 76 initial_sid_to_string_len = sizeof(initial_sid_to_string) / sizeof (char *);
141 /* print out the sids */ 77 /* print out the sids */
142 for (i=1; i < initial_sid_to_string_len; i++) 78 for (i = 1; i < initial_sid_to_string_len; i++)
143 fprintf(fout, "sid %s\n", initial_sid_to_string[i]); 79 fprintf(fout, "sid %s\n", initial_sid_to_string[i]);
144 fprintf(fout, "\n"); 80 fprintf(fout, "\n");
145 81
146 /* print out the commons */
147 for (i=0; i< sizeof(common)/sizeof(struct common); i++) {
148 char cname[101];
149 find_common_name(common[i].cname, cname, 100);
150 cname[100] = '\0';
151 fprintf(fout, "common %s\n{\n", cname);
152 for (j=0; common[i].perms[j]; j++)
153 fprintf(fout, "\t%s\n", common[i].perms[j]);
154 fprintf(fout, "}\n\n");
155 }
156 fprintf(fout, "\n");
157
158 /* print out the class permissions */ 82 /* print out the class permissions */
159 for (i=1; i < classlist_len; i++) { 83 for (i = 0; secclass_map[i].name; i++) {
160 if (classlist[i]) { 84 struct security_class_mapping *map = &secclass_map[i];
161 int firstperm = -1, numperms = 0; 85 fprintf(fout, "class %s\n", map->name);
162 86 fprintf(fout, "{\n");
163 fprintf(fout, "class %s\n", classlist[i]); 87 for (j = 0; map->perms[j]; j++)
164 /* does it inherit from a common? */ 88 fprintf(fout, "\t%s\n", map->perms[j]);
165 for (j=0; j < sizeof(av_inherit)/sizeof(struct av_inherit); j++) 89 fprintf(fout, "}\n\n");
166 if (av_inherit[j].class == i)
167 fprintf(fout, "inherits %s\n", av_inherit[j].common);
168
169 for (j=0; j < sizeof(av_perms)/sizeof(struct av_perms); j++) {
170 if (av_perms[j].class == i) {
171 if (firstperm == -1)
172 firstperm = j;
173 numperms++;
174 }
175 }
176 if (!numperms) {
177 fprintf(fout, "\n");
178 continue;
179 }
180
181 fprintf(fout, "{\n");
182 /* print out the av_perms */
183 for (j=0; j < numperms; j++) {
184 fprintf(fout, "\t%s\n", av_perms[firstperm+j].perm_s);
185 }
186 fprintf(fout, "}\n\n");
187 }
188 } 90 }
189 fprintf(fout, "\n"); 91 fprintf(fout, "\n");
190 92
@@ -197,31 +99,34 @@ int main(int argc, char *argv[])
197 /* types, roles, and allows */ 99 /* types, roles, and allows */
198 fprintf(fout, "type base_t;\n"); 100 fprintf(fout, "type base_t;\n");
199 fprintf(fout, "role base_r types { base_t };\n"); 101 fprintf(fout, "role base_r types { base_t };\n");
200 for (i=1; i < classlist_len; i++) { 102 for (i = 0; secclass_map[i].name; i++)
201 if (classlist[i]) 103 fprintf(fout, "allow base_t base_t:%s *;\n",
202 fprintf(fout, "allow base_t base_t:%s *;\n", classlist[i]); 104 secclass_map[i].name);
203 else
204 fprintf(fout, "allow base_t base_t:user%d *;\n", i);
205 }
206 fprintf(fout, "user user_u roles { base_r };\n"); 105 fprintf(fout, "user user_u roles { base_r };\n");
207 fprintf(fout, "\n"); 106 fprintf(fout, "\n");
208 107
209 /* default sids */ 108 /* default sids */
210 for (i=1; i < initial_sid_to_string_len; i++) 109 for (i = 1; i < initial_sid_to_string_len; i++)
211 fprintf(fout, "sid %s user_u:base_r:base_t\n", initial_sid_to_string[i]); 110 fprintf(fout, "sid %s user_u:base_r:base_t\n", initial_sid_to_string[i]);
212 fprintf(fout, "\n"); 111 fprintf(fout, "\n");
213 112
214
215 fprintf(fout, "fs_use_xattr ext2 user_u:base_r:base_t;\n"); 113 fprintf(fout, "fs_use_xattr ext2 user_u:base_r:base_t;\n");
216 fprintf(fout, "fs_use_xattr ext3 user_u:base_r:base_t;\n"); 114 fprintf(fout, "fs_use_xattr ext3 user_u:base_r:base_t;\n");
115 fprintf(fout, "fs_use_xattr ext4 user_u:base_r:base_t;\n");
217 fprintf(fout, "fs_use_xattr jfs user_u:base_r:base_t;\n"); 116 fprintf(fout, "fs_use_xattr jfs user_u:base_r:base_t;\n");
218 fprintf(fout, "fs_use_xattr xfs user_u:base_r:base_t;\n"); 117 fprintf(fout, "fs_use_xattr xfs user_u:base_r:base_t;\n");
219 fprintf(fout, "fs_use_xattr reiserfs user_u:base_r:base_t;\n"); 118 fprintf(fout, "fs_use_xattr reiserfs user_u:base_r:base_t;\n");
119 fprintf(fout, "fs_use_xattr jffs2 user_u:base_r:base_t;\n");
120 fprintf(fout, "fs_use_xattr gfs2 user_u:base_r:base_t;\n");
121 fprintf(fout, "fs_use_xattr lustre user_u:base_r:base_t;\n");
220 122
123 fprintf(fout, "fs_use_task eventpollfs user_u:base_r:base_t;\n");
221 fprintf(fout, "fs_use_task pipefs user_u:base_r:base_t;\n"); 124 fprintf(fout, "fs_use_task pipefs user_u:base_r:base_t;\n");
222 fprintf(fout, "fs_use_task sockfs user_u:base_r:base_t;\n"); 125 fprintf(fout, "fs_use_task sockfs user_u:base_r:base_t;\n");
223 126
127 fprintf(fout, "fs_use_trans mqueue user_u:base_r:base_t;\n");
224 fprintf(fout, "fs_use_trans devpts user_u:base_r:base_t;\n"); 128 fprintf(fout, "fs_use_trans devpts user_u:base_r:base_t;\n");
129 fprintf(fout, "fs_use_trans hugetlbfs user_u:base_r:base_t;\n");
225 fprintf(fout, "fs_use_trans tmpfs user_u:base_r:base_t;\n"); 130 fprintf(fout, "fs_use_trans tmpfs user_u:base_r:base_t;\n");
226 fprintf(fout, "fs_use_trans shm user_u:base_r:base_t;\n"); 131 fprintf(fout, "fs_use_trans shm user_u:base_r:base_t;\n");
227 132