summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaud Patard <rtp@mageia.org>2011-03-18 21:21:26 +0000
committerArnaud Patard <rtp@mageia.org>2011-03-18 21:21:26 +0000
commit2923175afa8b253cffdea00c1087c29e877d7fea (patch)
treea3507f3b193fde9731ecbc49b984faf0da4651e6
parent0dae133a236a21d79d7292593fe7fc6658b227c6 (diff)
downloaddrakx-2923175afa8b253cffdea00c1087c29e877d7fea.tar
drakx-2923175afa8b253cffdea00c1087c29e877d7fea.tar.gz
drakx-2923175afa8b253cffdea00c1087c29e877d7fea.tar.bz2
drakx-2923175afa8b253cffdea00c1087c29e877d7fea.tar.xz
drakx-2923175afa8b253cffdea00c1087c29e877d7fea.zip
- try to handle the built-in module case before trying to load a module.
-rw-r--r--mdk-stage1/modules.c11
-rw-r--r--mdk-stage1/network.c12
-rw-r--r--perl-install/modules.pm25
3 files changed, 45 insertions, 3 deletions
diff --git a/mdk-stage1/modules.c b/mdk-stage1/modules.c
index 5f02d2a6d..9cbb43598 100644
--- a/mdk-stage1/modules.c
+++ b/mdk-stage1/modules.c
@@ -30,6 +30,7 @@
#include <string.h>
#include <stdio.h>
#include <errno.h>
+#include <time.h>
#include <sys/utsname.h>
#include "log.h"
#include "utils.h"
@@ -287,6 +288,8 @@ static void add_modules_conf(char * str)
int module_already_present(const char * name)
{
FILE * f;
+ struct stat sb;
+ char *path;
int answ = 0;
if ((f = fopen("/proc/modules", "rb"))) {
@@ -298,6 +301,14 @@ int module_already_present(const char * name)
}
fclose(f);
}
+
+ /* built-in module case. try to find them through sysfs */
+ if (!answ) {
+ asprintf(&path, "/sys/module/%s", name);
+ if (!stat(path, &sb))
+ answ = 1;
+ free(path);
+ }
return answ;
}
diff --git a/mdk-stage1/network.c b/mdk-stage1/network.c
index 85704b805..a1af8af0f 100644
--- a/mdk-stage1/network.c
+++ b/mdk-stage1/network.c
@@ -31,6 +31,7 @@
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <stdio.h>
+#include <fcntl.h>
#include <netdb.h>
#include <resolv.h>
#include <sys/utsname.h>
@@ -568,8 +569,15 @@ static enum return_type bringup_networking(struct interface_info * intf)
{
static struct interface_info loopback;
enum return_type results;
-
- my_insmod("af_packet", ANY_DRIVER_TYPE, NULL, 1);
+ int fd;
+
+ /* try to find if module already loaded or built-in to avoid failing */
+ /* badly */
+ fd = open("/proc/net/packet", O_RDONLY);
+ if (fd < 0)
+ my_insmod("af_packet", ANY_DRIVER_TYPE, NULL, 1);
+ else
+ close(fd);
do {
results = configure_wireless(intf->device);
diff --git a/perl-install/modules.pm b/perl-install/modules.pm
index f81b1af4b..5b5f7de5f 100644
--- a/perl-install/modules.pm
+++ b/perl-install/modules.pm
@@ -61,7 +61,30 @@ sub module_is_available {
#-###############################################################################
# handles dependencies
sub load_raw {
- my ($l, $h_options) = @_;
+ my ($lm, $h_options) = @_;
+
+ # try to detect built-in modules by looking at /sys/module
+ # unfortunately it does not work for all modules eg :
+ # - networks protocols like af_packet
+ # - file systems
+ foreach my $mod (@$lm) {
+ $mod =~ s/-/_/g;
+ if (-d "/sys/module/$mod") {
+ log::l("$mod already loaded");
+ } elsif ($mod =~ /af_packet/) {
+ if (-f "/proc/net/packet") {
+ log::l("$mod already loaded");
+ } else {
+ @$l = (@$l, $mod);
+ }
+ } elsif (cat_("/proc/filesystems") =~ /$mod/) {
+ log::l("$mod already loaded");
+ } elsif ($mod =~ /serial/) {
+ # hack ... must find who tries to load the module serial
+ } else {
+ @$l = (@$l, $mod);
+ }
+ }
if ($::testing || $::local_install) {
log::l("i would load module $_ ($h_options->{$_})") foreach @$l;
} elsif ($::isInstall) {