Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/examples/depmod.pl
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/examples/depmod.pl
r1765 r2725 14 14 # This program is free software; you can redistribute it and/or modify it 15 15 # under the same terms as Perl itself. 16 use Getopt::Long ;16 use Getopt::Long qw(:config no_auto_abbrev no_ignore_case); 17 17 use File::Find; 18 18 use strict; … … 24 24 my $kernelsyms=""; 25 25 my $symprefix=""; 26 my $all=0; 27 my $quick=0; 28 my $errsyms=0; 26 29 my $stdout=0; 27 30 my $verbose=0; … … 45 48 -v --verbose : Print out lots of debugging stuff 46 49 -P --symbol-prefix : Symbol prefix 50 -a --all : Probe all modules (default/only thing supported) 51 -e --errsyms : Report any symbols not supplied by modules/kernel 47 52 TXT 48 53 … … 56 61 "verbose|v" => \$verbose, 57 62 "symbol-prefix|P=s" => \$symprefix, 63 "all|a" => \$all, 64 # unsupported options 65 "quick|A" => \$quick, 66 # ignored options (for historical usage) 67 "quiet|q", 68 "root|r", 69 "unresolved-error|u" 58 70 ); 59 71 … … 61 73 die $usage unless $basedir && ( $kernel || $kernelsyms ); 62 74 die "can't use both -k and -F\n\n$usage" if $kernel && $kernelsyms; 75 die "sorry, -A/--quick is not supported" if $quick; 76 die "--errsyms requires --kernelsyms" if $errsyms && !$kernelsyms; 63 77 64 78 # Strip any trailing or multiple slashes from basedir 65 $basedir =~ s- (/)\1+-/-g;79 $basedir =~ s-/+$--g; 66 80 67 81 # The base directory should contain /lib/modules somewhere … … 138 152 } 139 153 154 # build a complete dependency list for each module and make sure it 155 # is kept in order proper order 156 my $mod2 = {}; 157 sub maybe_unshift 158 { 159 my ($array, $ele) = @_; 160 # chop off the leading path /lib/modules/<kver>/ as modprobe 161 # will handle relative paths just fine 162 $ele =~ s:^/lib/modules/[^/]*/::; 163 foreach (@{$array}) { 164 if ($_ eq $ele) { 165 return; 166 } 167 } 168 unshift (@{$array}, $ele); 169 } 170 sub add_mod_deps 171 { 172 my ($depth, $mod, $mod2, $module, $this_module) = @_; 173 174 $depth .= " "; 175 warn "${depth}loading deps of module: $this_module\n" if $verbose; 176 if (length($depth) > 50) { 177 die "too much recursion (circular dependencies in modules?)"; 178 } 179 180 foreach my $md (keys %{$mod->{$this_module}}) { 181 add_mod_deps ($depth, $mod, $mod2, $module, $md); 182 warn "${depth} outputting $md\n" if $verbose; 183 maybe_unshift (\@{$$mod2->{$module}}, $md); 184 } 185 186 if (!%{$mod->{$this_module}}) { 187 warn "${depth} no deps\n" if $verbose; 188 } 189 } 190 foreach my $module (keys %$mod) { 191 warn "filling out module: $module\n" if $verbose; 192 @{$mod2->{$module}} = (); 193 add_mod_deps ("", $mod, \$mod2, $module, $module); 194 } 195 140 196 # figure out where the output should go 141 197 if ($stdout == 0) { 198 warn "writing $basedir/modules.dep\n" if $verbose; 142 199 open(STDOUT, ">$basedir/modules.dep") 143 200 or die "cannot open $basedir/modules.dep: $!"; … … 152 209 print "\n\n"; 153 210 } else { 154 print "$module: "; 155 my @sorted = sort bydep keys %{$mod->{$module}}; 211 my $shortmod = $module; 212 $shortmod =~ s:^/lib/modules/[^/]*/::; 213 print "$shortmod:"; 214 my @sorted = @{$mod2->{$module}}; 215 printf " " if @sorted; 156 216 print join(" ",@sorted); 157 217 print "\n"; … … 164 224 my ($name, $sym_ar, $exp, $dep) = @_; 165 225 166 my $ksymtab = grep m/ __ksymtab/, @$sym_ar;226 my $ksymtab = grep m/ ${symprefix}__ksymtab/, @$sym_ar; 167 227 168 228 # gather the exported symbols … … 170 230 # explicitly exported 171 231 foreach ( @$sym_ar ) { 172 / __ksymtab_(.*)$/ and do { 173 warn "sym = $1\n" if $verbose; 174 $exp->{$1} = $name; 232 / ${symprefix}__ksymtab_(.*)$/ and do { 233 my $sym = ${symprefix} . $1; 234 warn "sym = $sym\n" if $verbose; 235 $exp->{$sym} = $name; 175 236 }; 176 237 } … … 178 239 # exporting all symbols 179 240 foreach ( @$sym_ar ) { 180 / [ABCDGRST ] (.*)$/ and do {241 / [ABCDGRSTW] (.*)$/ and do { 181 242 warn "syma = $1\n" if $verbose; 182 243 $exp->{$1} = $name; … … 190 251 # gather the unresolved symbols 191 252 foreach ( @$sym_ar ) { 192 !/ __this_module/ && / U (.*)$/ and do {253 !/ ${symprefix}__this_module/ && / U (.*)$/ and do { 193 254 warn "und = $1\n" if $verbose; 194 255 push @{$dep->{$name}}, $1;
Note:
See TracChangeset
for help on using the changeset viewer.