| 1 |
#! /usr/bin/perl -w |
| 2 |
use strict; |
| 3 |
# |
| 4 |
# Extract parameter documentation from *.ko files. |
| 5 |
# Assumes that parameter description include the default |
| 6 |
# value in the format we use in our DEF_PARM() macro |
| 7 |
# |
| 8 |
|
| 9 |
@ARGV || die "Usage: $0 module.ko....\n"; |
| 10 |
|
| 11 |
my $modinfo = '/sbin/modinfo'; |
| 12 |
my @mod_params; |
| 13 |
|
| 14 |
foreach my $file (glob "@ARGV") { |
| 15 |
undef @mod_params; |
| 16 |
print "$file:\n"; |
| 17 |
open(F, "$modinfo '$file' |") || die; |
| 18 |
while(<F>) { |
| 19 |
chomp; |
| 20 |
next unless s/^parm:\s*//; |
| 21 |
my ($name, $description) = split(/:/, $_, 2); |
| 22 |
# Extract type |
| 23 |
$description =~ s/\s*\(([^)]+)\)$//; |
| 24 |
my $type = $1; |
| 25 |
# Extract default value |
| 26 |
$description =~ s/\s*\[default\s+([^]]+)\]$//; |
| 27 |
my $default = $1; |
| 28 |
push(@mod_params, { |
| 29 |
NAME => $name, |
| 30 |
TYPE => $type, |
| 31 |
DEFVAL => $default, |
| 32 |
DESC => $description, |
| 33 |
}); |
| 34 |
} |
| 35 |
# Print sorted list |
| 36 |
foreach my $p (sort { $a->{NAME} cmp $b->{NAME} } @mod_params) { |
| 37 |
printf "\t%-8s %-22s = %-20s %s\n", $p->{TYPE}, $p->{NAME}, $p->{DEFVAL}, $p->{DESC}; |
| 38 |
} |
| 39 |
close F || die; |
| 40 |
} |