diff options
author | Olivier Blin <oblin@mandriva.com> | 2007-08-27 13:38:51 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.com> | 2007-08-27 13:38:51 +0000 |
commit | 735b543e8ed403f2c02cbdc03d222781dea55675 (patch) | |
tree | 415861bac93dc28bcb6b34c44f072bade7cf727d | |
parent | 7fb5ebcf422d5f870d8c673c838c1f2510a8f16d (diff) | |
download | drakx-735b543e8ed403f2c02cbdc03d222781dea55675.tar drakx-735b543e8ed403f2c02cbdc03d222781dea55675.tar.gz drakx-735b543e8ed403f2c02cbdc03d222781dea55675.tar.bz2 drakx-735b543e8ed403f2c02cbdc03d222781dea55675.tar.xz drakx-735b543e8ed403f2c02cbdc03d222781dea55675.zip |
read modules description from /modules/modules.description (and drop hardcoded descriptions...)
-rw-r--r-- | mdk-stage1/NEWS | 1 | ||||
-rw-r--r-- | mdk-stage1/modules.c | 62 | ||||
-rw-r--r-- | mdk-stage1/modules.h | 5 | ||||
-rw-r--r-- | mdk-stage1/modules_descr.h | 66 |
4 files changed, 62 insertions, 72 deletions
diff --git a/mdk-stage1/NEWS b/mdk-stage1/NEWS index ba4ae7f49..6b1cfa041 100644 --- a/mdk-stage1/NEWS +++ b/mdk-stage1/NEWS @@ -1,4 +1,5 @@ - ask loading modules from /modules if needed +- read modules description from /modules/modules.description 1.14: - fix segfault in USB detection code (when no module match, #32624) diff --git a/mdk-stage1/modules.c b/mdk-stage1/modules.c index 9aeaf2a4a..06165b10d 100644 --- a/mdk-stage1/modules.c +++ b/mdk-stage1/modules.c @@ -33,12 +33,12 @@ #include "utils.h" #include "frontend.h" #include "mount.h" -#include "modules_descr.h" #include "zlibsupport.h" #include "modules.h" static struct module_deps_elem * modules_deps = NULL; +static struct module_descr_elem * modules_descr = NULL; extern long init_module(void *, unsigned long, const char *); @@ -160,11 +160,58 @@ static int load_modules_dependencies(void) } +static int load_modules_descriptions(void) +{ + char * descr_file = "/modules/modules.description"; + char * buf, * ptr, * start, * end; + struct stat s; + int line; + + log_message("loading modules descriptions"); + + buf = cat_file(descr_file, &s); + if (!buf) + return -1; + line = line_counts(buf); + modules_descr = malloc(sizeof(*modules_descr) * (line+1)); + + start = buf; + line = 0; + while (start < (buf+s.st_size) && *start) { + end = strchr(start, '\n'); + *end = '\0'; + + ptr = strchr(start, '\t'); + if (!ptr) { + start = end + 1; + continue; + } + *ptr = '\0'; + ptr++; + + modules_descr[line].modname = strdup(start); + filename2modname(modules_deps[line].modname); + modules_descr[line].description = strndup(ptr, 50); + + line++; + start = end + 1; + } + modules_descr[line].modname = NULL; + + free(buf); + + return 0; +} + + void init_modules_insmoding(void) { if (load_modules_dependencies()) { fatal_error("warning, error initing modules stuff, modules loading disabled"); } + if (load_modules_descriptions()) { + log_message("warning, error initing modules stuff, modules loading disabled"); + } } @@ -349,7 +396,8 @@ enum return_type ask_insmod(enum driver_type type) unset_automatic(); /* we are in a fallback mode */ while (p_dlist && *p_dlist) { - int i; + struct module_descr_elem * descr; + if (!strstr(*p_dlist, kernel_module_extension())) { p_dlist++; continue; @@ -357,10 +405,12 @@ enum return_type ask_insmod(enum driver_type type) *p_modules = *p_dlist; *p_descrs = NULL; (*p_modules)[strlen(*p_modules)-strlen(kernel_module_extension())] = '\0'; /* remove trailing .ko.gz */ - for (i = 0 ; i < modules_descriptions_num ; i++) { - if (!strcmp(*p_modules, modules_descriptions[i].module)) - *p_descrs = modules_descriptions[i].descr; - } + + descr = modules_descr; + while (descr && descr->modname && strcmp(descr->modname, *p_modules)) descr++; + if (descr) + *p_descrs = descr->description; + p_dlist++; p_modules++; p_descrs++; diff --git a/mdk-stage1/modules.h b/mdk-stage1/modules.h index 10c9ebf4b..b5a597ac2 100644 --- a/mdk-stage1/modules.h +++ b/mdk-stage1/modules.h @@ -32,6 +32,11 @@ struct module_deps_elem { char ** deps; }; +struct module_descr_elem { + char * modname; + char * description; +}; + extern int disable_modules; #endif diff --git a/mdk-stage1/modules_descr.h b/mdk-stage1/modules_descr.h deleted file mode 100644 index 8faf726af..000000000 --- a/mdk-stage1/modules_descr.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Guillaume Cottenceau (gc@mandrakesoft.com) - * - * Copyright 2001 Mandrakesoft - * - * This software may be freely redistributed under the terms of the GNU - * public license. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#ifndef _MODULES_DESCR_H_ -#define _MODULES_DESCR_H_ - -struct module_descr { - const char * module; - char * descr; -}; - -struct module_descr modules_descriptions[] = { -#ifndef DISABLE_NETWORK - /* description of network drivers that have not very explicit names */ - { "ne", "NE1000/NE2000/clones" }, - { "ne2k-pci", "PCI NE2000" }, - { "depca", "DEC DEPCA/DE100/DE101/DE200/DE201/DE202/DE210/DE422" }, - { "dgrs", "Digi RightSwitch SE-X" }, - { "ewrk3", "DEC DE203/DE204/DE205" }, - { "lance", "Allied Telesis AT1500, HP J2405A, NE2100/NE2500" }, - { "sis900", "SiS 900/7016/630E, Am79c901, RTL8201" }, - { "via-rhine", "VIA VT86c100A Rhine-II, 3043 Rhine-I" }, - { "tulip", "DEC 21040-family based cards" }, - { "wd", "WD8003/WD8013" }, - { "bmac", "Macintosh integrated ethernet (G3)" }, - { "gmac", "Macintosh integrated ethernet (G4/iBook)" }, - { "mace", "Macintosh integrated ethernet (PowerMac)" }, -#endif - -#ifndef DISABLE_MEDIAS - /* description of scsi drivers that have not very explicit names */ - { "53c7,8xx", "NCR53c810/700" }, - { "sim710", "NCR53c710" }, - { "aic7xxx", "Adaptec 7xxx family (AIC/AHA/etc)" }, - { "atp870u", "ACARD/ARTOP AEC-6710/6712" }, - { "ncr53c8xx", "Symbios 53c family" }, - { "sym53c8xx", "Symbios 53c family" }, - { "sim710", "NCR53C710 family" }, - { "mesh", "Macintosh integrated SCSI (NewWorld or internal SCSI)" }, - { "mac53c94", "Macintosh integrated SCSI (OldWorld or external SCSI)" }, -#endif - -#ifdef ENABLE_USB - /* description of usb drivers that have not very explicit names */ - { "usbnet", "Netchip or Prolific USB-USB Bridge" }, - { "pegasus", "ADMtek AN986 (USB Ethernet chipset)" }, - { "kaweth", "KL5KUSB101 (USB Ethernet chipset)" }, - { "catc", "CATC EL1210A NetMate USB Ethernet" }, -#endif -}; - -int modules_descriptions_num = sizeof(modules_descriptions) / sizeof(struct module_descr); - - -#endif |