diff options
author | Olivier Blin <oblin@mandriva.com> | 2007-08-27 12:22:14 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.com> | 2007-08-27 12:22:14 +0000 |
commit | d3f6e876d0d51d44127c8dfe25efd08ffeb657ef (patch) | |
tree | db65ba3e2768ab9a98e364bfcda73008868d4229 | |
parent | d464131a8ca42251852280801a080572a698db9b (diff) | |
download | drakx-d3f6e876d0d51d44127c8dfe25efd08ffeb657ef.tar drakx-d3f6e876d0d51d44127c8dfe25efd08ffeb657ef.tar.gz drakx-d3f6e876d0d51d44127c8dfe25efd08ffeb657ef.tar.bz2 drakx-d3f6e876d0d51d44127c8dfe25efd08ffeb657ef.tar.xz drakx-d3f6e876d0d51d44127c8dfe25efd08ffeb657ef.zip |
reorganize code
-rw-r--r-- | mdk-stage1/modules.c | 82 |
1 files changed, 40 insertions, 42 deletions
diff --git a/mdk-stage1/modules.c b/mdk-stage1/modules.c index 5132b8c30..66eb5ef0b 100644 --- a/mdk-stage1/modules.c +++ b/mdk-stage1/modules.c @@ -351,55 +351,53 @@ static enum return_type insmod_with_options(char * mod, enum driver_type type) enum return_type ask_insmod(enum driver_type type) { - char * mytype; - char msg[200]; enum return_type results; char * choice; + char ** dlist = list_directory("/modules"); + char ** modules = malloc(sizeof(char *) * string_array_length(dlist) + 1); + char ** descrs = malloc(sizeof(char *) * string_array_length(dlist) + 1); + char ** p_dlist = dlist; + char ** p_modules = modules; + char ** p_descrs = descrs; unset_automatic(); /* we are in a fallback mode */ - if (type == SCSI_ADAPTERS) - mytype = "SCSI"; - else if (type == NETWORK_DEVICES) - mytype = "NET"; - else - return RETURN_ERROR; - - snprintf(msg, sizeof(msg), "Which driver should I try to gain %s access?", mytype); - - { - char ** dlist = list_directory("/modules"); - char ** modules = malloc(sizeof(char *) * string_array_length(dlist) + 1); - char ** descrs = malloc(sizeof(char *) * string_array_length(dlist) + 1); - char ** p_dlist = dlist; - char ** p_modules = modules; - char ** p_descrs = descrs; - while (p_dlist && *p_dlist) { - int i; - if (!strstr(*p_dlist, kernel_module_extension())) { - p_dlist++; - continue; - } - *p_modules = *p_dlist; - (*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; - } + while (p_dlist && *p_dlist) { + int i; + if (!strstr(*p_dlist, kernel_module_extension())) { p_dlist++; - p_modules++; - p_descrs++; + continue; } - *p_modules = NULL; - *p_descrs = NULL; - if (modules && *modules) - results = ask_from_list_comments(msg, modules, descrs, &choice); - else - results = RETURN_BACK; + *p_modules = *p_dlist; + (*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; + } + p_dlist++; + p_modules++; + p_descrs++; } + *p_modules = NULL; + *p_descrs = NULL; + + if (modules && *modules) { + char * mytype; + char msg[200]; + if (type == SCSI_ADAPTERS) + mytype = "SCSI"; + else if (type == NETWORK_DEVICES) + mytype = "NET"; + else + return RETURN_ERROR; - if (results == RETURN_OK) { - return insmod_with_options(choice, type); - } else - return results; + snprintf(msg, sizeof(msg), "Which driver should I try to gain %s access?", mytype); + results = ask_from_list_comments(msg, modules, descrs, &choice); + if (results == RETURN_OK) + return insmod_with_options(choice, type); + else + return results; + } else { + return RETURN_BACK; + } } |