diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2000-04-20 20:58:03 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2000-04-20 20:58:03 +0000 |
commit | cea41ee6a61d844cde0b4dbd6d325f351dadf4b1 (patch) | |
tree | 01d6eb78d00ec94c885a33a757500193ef1e1d85 /rescue/tree/sbin | |
parent | 448bd28d082118bf27c724df11b6a0a41bca9ca4 (diff) | |
download | drakx-backup-do-not-use-cea41ee6a61d844cde0b4dbd6d325f351dadf4b1.tar drakx-backup-do-not-use-cea41ee6a61d844cde0b4dbd6d325f351dadf4b1.tar.gz drakx-backup-do-not-use-cea41ee6a61d844cde0b4dbd6d325f351dadf4b1.tar.bz2 drakx-backup-do-not-use-cea41ee6a61d844cde0b4dbd6d325f351dadf4b1.tar.xz drakx-backup-do-not-use-cea41ee6a61d844cde0b4dbd6d325f351dadf4b1.zip |
no_comment
Diffstat (limited to 'rescue/tree/sbin')
-rwxr-xr-x | rescue/tree/sbin/modprobe | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/rescue/tree/sbin/modprobe b/rescue/tree/sbin/modprobe new file mode 100755 index 000000000..494f5b2a2 --- /dev/null +++ b/rescue/tree/sbin/modprobe @@ -0,0 +1,39 @@ +#!/usr/bin/perl + +sub cat_ { local *F; open F, $_[0] or $_[1] ? die "cat of file $_[0] failed: $!\n" : return; my @l = <F>; wantarray ? @l : join '', @l } + +sub read_already_loaded() { + foreach (cat_("/proc/modules")) { + my ($name) = split; + $conf{$name}{loaded} = 1; + } +} + +sub load_deps($) { + my ($file) = @_; + + local *F; + open F, $file or log::l("error opening $file: $!"), return 0; + foreach (<F>) { + my ($f, $deps) = split ':'; + push @{$deps{$f}}, split ' ', $deps; + } +} + +sub load { + my ($name, @options) = @_; + $name =~ s/\.o//; + + $conf{$name}{loaded} and return; + eval { load($_, 'prereq') } foreach @{$deps{$name}}; + + system("extract_archive /modules/modules.cz* /tmp $name.o >/dev/null"); + -r "/tmp/$name.o" or die "can't find module $name\n"; + system("/sbin/insmod -f /tmp/$name.o"); $? and die("insmod $name failed"); +} + +!@ARGV || $ARGV[0] =~ /-h/ and die "usage: modprobe <module> [<options...>]\n"; + +read_already_loaded(); +load_deps("/modules/modules.dep"); +load(@ARGV); |