diff options
Diffstat (limited to 'mdk-stage1/modules.c')
-rw-r--r-- | mdk-stage1/modules.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/mdk-stage1/modules.c b/mdk-stage1/modules.c index 53bc87d4c..5f02d2a6d 100644 --- a/mdk-stage1/modules.c +++ b/mdk-stage1/modules.c @@ -1,7 +1,7 @@ /* - * Guillaume Cottenceau (gc@mandrakesoft.com) + * Guillaume Cottenceau (gc@mandriva.com) * - * Copyright 2000 Mandrakesoft + * Copyright 2000 Mandriva * * This software may be freely redistributed under the terms of the GNU * public license. @@ -39,8 +39,8 @@ #include "modules.h" -#define FIRMWARE_TIMEOUT_FILE "/sys/class/firmware/timeout" -#define FIRMWARE_TIMEOUT_VALUE "1" +#define UEVENT_HELPER_FILE "/sys/kernel/uevent_helper" +#define UEVENT_HELPER_VALUE "/sbin/hotplug" static char modules_directory[100]; static struct module_deps_elem * modules_deps = NULL; @@ -156,12 +156,12 @@ static int load_modules_dependencies(void) while (*ptr && (*ptr == ' ')) ptr++; /* sort of a good line */ - modules_deps[line].filename = strdup(start); + modules_deps[line].filename = start[0] == '/' ? strdup(start) : asprintf_("%s/%s", modules_directory, start); modules_deps[line].modname = filename2modname(start); start = ptr; i = 0; - while (start && *start) { + while (start && *start && i < sizeof(tmp_deps)/sizeof(char *)) { ptr = strchr(start, ' '); if (ptr) *ptr = '\0'; tmp_deps[i++] = filename2modname(start); @@ -172,6 +172,12 @@ static int load_modules_dependencies(void) while (start && *start && *start == ' ') start++; } + if(i >= sizeof(tmp_deps)/sizeof(char *)-1) { + log_message("warning, more than %zu dependencies for module %s", + sizeof(tmp_deps)/sizeof(char *)-1, + modules_deps[line].modname); + i = sizeof(tmp_deps)/sizeof(char *)-1; + } tmp_deps[i++] = NULL; modules_deps[line].deps = memdup(tmp_deps, sizeof(char *) * i); @@ -229,14 +235,14 @@ static int load_modules_descriptions(void) return 0; } -void init_firmware_timeout(void) +void init_firmware_loader(void) { - int fd = open(FIRMWARE_TIMEOUT_FILE, O_WRONLY|O_TRUNC, 0666); + int fd = open(UEVENT_HELPER_FILE, O_WRONLY|O_TRUNC, 0666); if (!fd) { - log_message("warning, unable to set firmware timeout"); + log_message("warning, unable to set firmware loader"); return; } - write(fd, FIRMWARE_TIMEOUT_VALUE, strlen(FIRMWARE_TIMEOUT_VALUE)); + write(fd, UEVENT_HELPER_VALUE, strlen(UEVENT_HELPER_VALUE)); close(fd); } @@ -247,7 +253,7 @@ void init_modules_insmoding(void) fatal_error("warning, error initing modules stuff, modules loading disabled"); } if (load_modules_descriptions()) { - log_message("warning, error initing modules stuff, modules loading disabled"); + log_message("warning, error initing modules stuff"); } } @@ -420,6 +426,11 @@ static enum return_type insmod_with_options(char * mod, enum driver_type type) return RETURN_OK; } +static int strsortfunc(const void *a, const void *b) +{ + return strcmp(* (char * const *) a, * (char * const *) b); +} + enum return_type ask_insmod(enum driver_type type) { enum return_type results; @@ -431,11 +442,12 @@ enum return_type ask_insmod(enum driver_type type) char ** p_modules = modules; char ** p_descrs = descrs; + qsort(dlist, string_array_length(dlist), sizeof(char *), strsortfunc); + unset_automatic(); /* we are in a fallback mode */ while (p_dlist && *p_dlist) { struct module_descr_elem * descr; - if (!strstr(*p_dlist, kernel_module_extension())) { p_dlist++; continue; |