summaryrefslogtreecommitdiff
path: root/v4l
diff options
context:
space:
mode:
Diffstat (limited to 'v4l')
-rwxr-xr-xv4l/scripts/rmmod.pl30
1 files changed, 21 insertions, 9 deletions
diff --git a/v4l/scripts/rmmod.pl b/v4l/scripts/rmmod.pl
index ade231707..d190a9edf 100755
--- a/v4l/scripts/rmmod.pl
+++ b/v4l/scripts/rmmod.pl
@@ -28,8 +28,17 @@ my %debug = ( "tuner" => "tuner_debug=1",
);
+sub findprog($)
+{
+ foreach(split(/:/, $ENV{PATH}),qw(/sbin /usr/sbin /usr/local/sbin)) {
+ return "$_/$_[0]" if(-x "$_/$_[0]");
+ }
+ die "Can't find needed utility '$_[0]'";
+}
+
sub parse_dir {
my $file = $File::Find::name;
+ my $modinfo = findprog('modinfo');
if (!($file =~ /[.]ko$/)) {
return;
@@ -38,7 +47,7 @@ sub parse_dir {
my $module = $file;
$module =~ s|^[./]*(.*)[.]ko|\1|;
- open IN, "modinfo $file|grep depends|cut -b 17-|";
+ open IN, "$modinfo $file|grep depends|cut -b 17-|";
while (<IN>) {
my $deps = $_;
$deps =~ s/\n//;
@@ -123,33 +132,36 @@ sub orderdep ()
sub insmod ($)
{
my $debug=shift;
+ my $modprobe = findprog('modprobe');
+ my $insmod = findprog('insmod');
while ( my ($key, $value) = each(%reqmodules) ) {
- printf ("modprobe $key\n");
- system ("modprobe $key");
+ print ("$modprobe $key\n");
+ system ("$modprobe $key");
}
foreach my $key (@modlist) {
if ($debug) {
my $dbg=$debug{$key};
- printf "insmod ./$key.ko $dbg\n";
- system "insmod ./$key.ko $dbg\n";
+ print "$insmod ./$key.ko $dbg\n";
+ system "$insmod ./$key.ko $dbg\n";
} else {
- printf "insmod ./$key.ko\n";
- system "insmod ./$key.ko\n";
+ print "$insmod ./$key.ko\n";
+ system "$insmod ./$key.ko\n";
}
}
}
sub rmmod ()
{
+ my $rmmod = findprog('rmmod');
while (my $key=pop @modlist) {
my $dep=$key;
$dep=~s/[\-]/_/g;
if (exists ($loaded{$dep})) {
- printf "rmmod $dep\n";
- system "rmmod $dep\n";
+ print "$rmmod $dep\n";
+ system "$rmmod $dep\n";
}
}
}