Changeset 3249 in MondoRescue for branches/3.2/mindi/get-modules.pl


Ignore:
Timestamp:
Feb 27, 2014, 3:48:19 AM (7 years ago)
Author:
Bruno Cornec
Message:
  • create function mr_kernel_get_modules in MondoRescue::Kernel.pm from code previously in get-modules.pl which now just calls it
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi/get-modules.pl

    r3213 r3249  
    44use POSIX "uname";
    55use Data::Dumper;
     6use ProjectBuilder::Base;
     7use MondoRescue::Kernel;
    68
    7 my ($sysname, $nodename, $release, $version, $machine ) = uname();
    8 my $ver = "";
    9 my $module = "";
    10 my %modlist;
    11 my $void = "";
    12 my $allmodules = "";
     9my $ver = undef;
    1310
    14 
    15 if (not (defined $ARGV[0])) {
    16         $ver = $release;
    17 } else {
    18         $ver = $ARGV[0];
     11if ((defined $ARGV[0]) && ($ARGV[0] eq "-v")) {
     12    #$pbverbose = 1;
     13    shift;
    1914}
    20 open(LSMOD, "/sbin/lsmod |") or die "Unable to launch lsmod";
    21 open(DEPMOD, "/sbin/depmod -n $ver |") or die "Unable to launch depmod";
    22 
    23 while (<DEPMOD>) {
    24     ($module, $modlist{$module}) = split(/:/);
    25     chomp($modlist{$module});
    26     last if ($module =~ /^#/);
    27     #print "Analyzing $module\n";
     15if ((defined $ARGV[0]) && ($ARGV[0] eq "-k")) {
     16    shift;
     17    $ver = $ARGV[0];
     18    shift;
    2819}
    29 print Dumper(%modlist)."\n";
    30 while (<LSMOD>) {
    31     next if (/^Module/);
    32     ($module, $void) = split(/ /);
    33     #print "Analyzing $module\n";
    34     $module = `/sbin/modinfo -n $module`;
    35     chomp($module);
    36     my ($void,$lib,$modulep,$kernelv,$modpath) = split(/\//,$module,5);
    37     print "modpath: $modpath\n";
    38     $allmodules .= $modlist{$modpath};
    39 }
    40 close(LSMOD);
    41 close(DEPMOD);
    42 $allmodules =~ s/\n/ /g;
    43 $allmodules =~ s/  */ /g;
    44 $allmodules =~ s/ [0-9A-z\/]*\// /g;
    45 $allmodules =~ s/\.ko.xz//g;
    46 print "all modules: $allmodules\n";
     20my ($modulepath,@allmodpaths) = mr_kernel_get_modules($ver,@ARGV);
     21print "modules path: $modulepath\n";
     22print "all modpaths: ".join(' ',@allmodpaths)."\n";
Note: See TracChangeset for help on using the changeset viewer.