Changeset 3354 in MondoRescue
- Timestamp:
- Mar 5, 2015, 1:23:38 PM (9 years ago)
- Location:
- branches/3.2/MondoRescue
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/MondoRescue/bin/mr-kernel-get-modules
r3250 r3354 6 6 use ProjectBuilder::Base; 7 7 use MondoRescue::Kernel; 8 use Getopt::Long qw(:config auto_abbrev no_ignore_case); 8 9 9 my $ver = undef;10 my %opts; # CLI Options 10 11 11 if ((defined $ARGV[0]) && ($ARGV[0] eq "-v")) { 12 #$pbverbose = 1; 13 shift; 14 } 15 if ((defined $ARGV[0]) && ($ARGV[0] eq "-k")) { 16 shift; 17 $ver = $ARGV[0]; 18 shift; 19 } 20 if ((defined $ARGV[0]) && ($ARGV[0] eq "-m")) { 21 shift; 22 } 12 GetOptions( 13 "kernel|k:s" => \$opts{'k'}, 14 "verbose|v+" => \$opts{'v'}, 15 ); 23 16 24 print join(' ',mr_kernel_get_modules($ver,@ARGV))."\n"; 17 $pbdebug = $opts{'v'}; 18 $pbdebug = 0 if (not defined $pbdebug); 19 print join(' ',mr_kernel_get_modules($opts{'k'},@ARGV))."\n"; -
branches/3.2/MondoRescue/lib/MondoRescue/Kernel.pm
r3314 r3354 5 5 # $Id$ 6 6 # 7 # Copyright B. Cornec 2008-201 47 # Copyright B. Cornec 2008-2015 8 8 # Provided under the GPL v2 9 9 … … 12 12 use strict 'vars'; 13 13 use Data::Dumper; 14 use File::Basename; 14 15 use POSIX "uname"; 15 16 use lib qw (lib); … … 82 83 my $module = ""; 83 84 my %modlist; 85 my %modpath; 84 86 my $void = ""; 85 87 my @alllivemodules; … … 106 108 107 109 # Now computes the dependencies of each module and store them in %modlist 110 # # Some depmods gives a full path, others a relative path to /lib/modules/$ver 108 111 open(DEPMOD, "/sbin/depmod -n $ver |") or die "Unable to launch depmod"; 109 112 while (<DEPMOD>) { … … 112 115 chomp($void); 113 116 $void =~ s/\s+//; 117 $module = "/lib/modules/$ver/$module" if ($module !~ /^\/lib\/modules/); 118 # Now module is a full path whatever depmod version 119 $void = join(' ',map { "/lib/modules/$ver/".$_ } split(/ /,$void)) if ($void !~ /^\/lib\/modules/); 120 # Now void is a full path of modules whatever depmod version 114 121 $modlist{$module} = $void; 122 my $m = basename($module,".ko",".o",".ko.gz",".ko.bz",".ko.xz",".o.gz",".o.bz",".o.xz"); 123 $modpath{$m} = $module; 115 124 pb_log(2,"Depmod on $module gives $void\n"); 116 125 } … … 127 136 foreach my $m (@allmodules) { 128 137 pb_log(1,"Analyzing $m\n"); 129 open(MODINFO, "/sbin/modinfo -n -k $ver $m 2>/dev/null |") or die "Unable to launch modinfo"; 138 if (not defined $modpath{$m}) { 139 pb_log(1,"WARNING: No modpath for module $m\n"); 140 next; 141 } 142 pb_log(2,"$m has a modpath of $modpath{$m}\n"); 143 open(MODINFO, "/sbin/modinfo -n $modpath{$m} 2>/dev/null |") or die "Unable to launch modinfo"; 130 144 $module = <MODINFO>; 131 145 close(MODINFO); … … 137 151 ($void,$lib,$modulep,$kernelv,$modpath) = split(/\//,$module,5); 138 152 next if (not defined $modpath); 139 if (not defined $modlist{$mod path}) {140 pb_log(0,"No modlist found for $mod path\n");153 if (not defined $modlist{$module}) { 154 pb_log(0,"No modlist found for $module\n"); 141 155 next; 142 156 } 143 $modulepath = "/$lib/$modulep/$kernelv"; 144 pb_log(2,"modpath: $modulepath/$modpath\n"); 145 push @allmodpaths,"$modulepath/$modpath",map { "$modulepath/".$_ } split(/ /,$modlist{$modpath}); 157 pb_log(2,"modpath: $module\n"); 158 push @allmodpaths,$module,split(/ /,$modlist{$module}); 146 159 } 147 160 pb_log(1,"all modpaths: ".join(' ',@allmodpaths)."\n");
Note:
See TracChangeset
for help on using the changeset viewer.