diff options
Diffstat (limited to 'mdk-stage1')
-rw-r--r-- | mdk-stage1/modules.c | 77 |
1 files changed, 40 insertions, 37 deletions
diff --git a/mdk-stage1/modules.c b/mdk-stage1/modules.c index 49d8a3512..c390a504c 100644 --- a/mdk-stage1/modules.c +++ b/mdk-stage1/modules.c @@ -129,35 +129,6 @@ static enum return_type ensure_additional_modules_available(void) return RETURN_OK; } -static const char * get_name_kernel_26_transition(const char * name) -{ - struct kernel_24_26_mapping { - const char * name_24; - const char * name_26; - }; - static struct kernel_24_26_mapping mappings[] = { - { "usb-ohci", "ohci-hcd" }, - { "usb-uhci", "uhci-hcd" }, - { "uhci", "uhci-hcd" }, -// { "printer", "usblp" }, - { "bcm4400", "b44" }, - { "3c559", "3c359" }, - { "3c90x", "3c59x" }, - { "dc395x_trm", "dc395x" }, -// { "audigy", "snd-emu10k1" }, - }; - int mappings_nb = sizeof(mappings) / sizeof(struct kernel_24_26_mapping); - int i; - - /* pcitable contains 2.4 names. this will need to change if/when it contains 2.6 names! */ - if (kernel_version() > 4) - for (i=0; i<mappings_nb; i++) { - if (streq(name, mappings[i].name_24)) - return mappings[i].name_26; - } - return name; -} - /* unarchive and insmod given module * WARNING: module must not contain the trailing ".o" */ @@ -167,7 +138,7 @@ static enum insmod_return insmod_archived_file(const char * mod_name, char * opt char final_name[50] = "/tmp/"; int i, rc; - strncpy(module_name, get_name_kernel_26_transition(mod_name), sizeof(module_name)); + strncpy(module_name, mod_name, sizeof(module_name)); if (kernel_version() <= 4) strcat(module_name, ".o"); else @@ -344,12 +315,12 @@ int module_already_present(const char * name) { FILE * f; int answ = 0; - const char * real_name = get_name_kernel_26_transition(name); + if ((f = fopen("/proc/modules", "rb"))) { while (1) { char buf[500]; if (!fgets(buf, sizeof(buf), f)) break; - if (!strncmp(real_name, buf, strlen(real_name)) && buf[strlen(real_name)] == ' ') + if (!strncmp(name, buf, strlen(name)) && buf[strlen(name)] == ' ') answ = 1; } fclose(f); @@ -384,6 +355,36 @@ static enum insmod_return insmod_with_deps(const char * mod_name, char * options } +static const char * get_name_kernel_26_transition(const char * name) +{ + struct kernel_24_26_mapping { + const char * name_24; + const char * name_26; + }; + static struct kernel_24_26_mapping mappings[] = { + { "usb-ohci", "ohci-hcd" }, + { "usb-uhci", "uhci-hcd" }, + { "uhci", "uhci-hcd" }, +// { "printer", "usblp" }, + { "bcm4400", "b44" }, + { "3c559", "3c359" }, + { "3c90x", "3c59x" }, + { "dc395x_trm", "dc395x" }, +// { "audigy", "snd-emu10k1" }, + }; + int mappings_nb = sizeof(mappings) / sizeof(struct kernel_24_26_mapping); + int i; + + /* pcitable contains 2.4 names. this will need to change if/when it contains 2.6 names! */ + if (kernel_version() > 4) + for (i=0; i<mappings_nb; i++) { + if (streq(name, mappings[i].name_24)) + return mappings[i].name_26; + } + return name; +} + + #ifndef DISABLE_NETWORK enum insmod_return my_insmod(const char * mod_name, enum driver_type type, char * options, int allow_modules_floppy) #else @@ -395,10 +396,12 @@ enum insmod_return my_insmod(const char * mod_name, enum driver_type type __attr char ** net_devices = NULL; /* fucking compiler */ #endif - if (module_already_present(mod_name)) + const char * real_mod_name = get_name_kernel_26_transition(mod_name); + + if (module_already_present(real_mod_name)) return INSMOD_OK; - log_message("have to insmod %s", mod_name); + log_message("have to insmod %s", real_mod_name); if (disable_modules) { log_message("\tdisabled"); @@ -413,9 +416,9 @@ enum insmod_return my_insmod(const char * mod_name, enum driver_type type __attr if (IS_TESTING) return INSMOD_OK; - i = insmod_with_deps(mod_name, options, allow_modules_floppy); + i = insmod_with_deps(real_mod_name, options, allow_modules_floppy); if (i == 0) { - log_message("\tsucceeded %s", mod_name); + log_message("\tsucceeded %s", real_mod_name); #ifndef DISABLE_NETWORK if (type == NETWORK_DEVICES) { char ** new_net_devices = get_net_devices(); @@ -438,7 +441,7 @@ enum insmod_return my_insmod(const char * mod_name, enum driver_type type __attr } #endif } else - log_message("warning, insmod failed (%s %s) (%d)", mod_name, options, i); + log_message("warning, insmod failed (%s %s) (%d)", real_mod_name, options, i); return i; |