3 # This creates sys_errlist from <asm/errno.h> through somewhat
4 # heuristic matching. It presumes the relevant entries are of the form
5 # #define Exxxx <integer> /* comment */
13 $rootdir = '../linux/include/'; # Must have trailing /
17 my($fh) = new FileHandle;
18 my($line, $error, $msg);
21 $file = $rootdir.$file;
23 print STDERR "opening $file\n" unless ( $quiet );
25 if ( !($fh->open("< ".$file)) ) {
26 die "$0: cannot open $file\n";
29 while ( defined($line = <$fh>) ) {
31 if ( $line =~ /^\#\s*endif/ ) {
33 } elsif ( $line =~ /^\#\sif/ ) {
37 if ( $line =~ /^\#\s*define\s+([A-Z0-9_]+)\s+([0-9]+)\s*\/\*\s*(.*\S)\s*\*\// ) {
41 print STDERR "$error ($errno) => \"$msg\"\n" unless ( $quiet );
42 $errors{$errno} = $error;
43 $errmsg{$errno} = $msg;
44 $maxerr = $errno if ( $errno > $maxerr );
45 } elsif ( $line =~ /^\#\s*include\s+[\<\"](.*)[\>\"]/ ) {
47 } elsif ( $line =~ /^\#\s*ifdef\s+__KERNEL__/ ) {
53 print STDERR "closing $file\n" unless ( $quiet );
56 $v = $ENV{'KBUILD_VERBOSE'};
57 $quiet = defined($v) ? !$v : 0;
59 foreach $arg ( @ARGV ) {
62 } elsif ( $arg =~ /^-(errlist|errnos|maxerr)$/ ) {
65 die "$0: Unknown option: $arg\n";
69 parse_file('linux/errno.h');
71 if ( $type eq '-errlist' ) {
72 print "#include <errno.h>\n";
73 printf "const int sys_nerr = %d;\n", $maxerr+1;
74 printf "const char * const sys_errlist[%d] = {\n", $maxerr+1;
75 foreach $e ( sort(keys(%errors)) ) {
76 printf " [%s] = \"%s\",\n", $errors{$e}, $errmsg{$e};
79 } elsif ( $type eq '-errnos' ) {
80 print "#include <errno.h>\n";
81 printf "const int sys_nerr = %d;\n", $maxerr+1;
82 printf "const char * const sys_errlist[%d] = {\n", $maxerr+1;
83 foreach $e ( sort(keys(%errors)) ) {
84 printf " [%s] = \"%s\",\n", $errors{$e}, $errors{$e};
87 } elsif ( $type eq '-maxerr' ) {