diff options
author | Olivier Blin <oblin@mandriva.org> | 2005-04-04 18:46:37 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2005-04-04 18:46:37 +0000 |
commit | 2091e3f2fee9f7697eefb00d2ca1e94a5a4945cc (patch) | |
tree | 9c83248eb7bab71b7b4c8edf0905f77be3a72d63 | |
parent | 63eda05b692c6d765dc391e5c46fd752ffd670f7 (diff) | |
download | drakx-2091e3f2fee9f7697eefb00d2ca1e94a5a4945cc.tar drakx-2091e3f2fee9f7697eefb00d2ca1e94a5a4945cc.tar.gz drakx-2091e3f2fee9f7697eefb00d2ca1e94a5a4945cc.tar.bz2 drakx-2091e3f2fee9f7697eefb00d2ca1e94a5a4945cc.tar.xz drakx-2091e3f2fee9f7697eefb00d2ca1e94a5a4945cc.zip |
add thirdparty_load_media_modules(), try to find third party modules on the install media
-rw-r--r-- | mdk-stage1/stage1.c | 3 | ||||
-rw-r--r-- | mdk-stage1/thirdparty.c | 109 | ||||
-rw-r--r-- | mdk-stage1/thirdparty.h | 9 |
3 files changed, 81 insertions, 40 deletions
diff --git a/mdk-stage1/stage1.c b/mdk-stage1/stage1.c index a338c990b..e3a5b364c 100644 --- a/mdk-stage1/stage1.c +++ b/mdk-stage1/stage1.c @@ -324,6 +324,9 @@ static void method_select_and_prepare(void) if (results != RETURN_OK) return method_select_and_prepare(); + + /* try to find third party modules on the install media */ + thirdparty_load_media_modules(); } static enum return_type create_initial_fs_symlinks(char* symlinks) diff --git a/mdk-stage1/thirdparty.c b/mdk-stage1/thirdparty.c index cd4e6b83c..1c8942d3c 100644 --- a/mdk-stage1/thirdparty.c +++ b/mdk-stage1/thirdparty.c @@ -26,13 +26,14 @@ #include "frontend.h" #include "partition.h" #include "automatic.h" +#include "probing.h" #include "thirdparty.h" #define THIRDPARTY_MOUNT_LOCATION "/tmp/thirdparty" #define THIRDPARTY_DIRECTORY "/install/thirdparty" -static enum return_type third_party_choose_device(char ** device, int probe_only) +static enum return_type thirdparty_choose_device(char ** device, int probe_only) { char ** medias, ** medias_models; char ** ptr, ** ptr_models; @@ -210,7 +211,7 @@ static enum return_type thirdparty_prompt_modules(const char *modules_location, } -static enum return_type thirdparty_autoload_modules(const char *modules_location, char ** modules_list, FILE *f) +static enum return_type thirdparty_autoload_modules(const char *modules_location, char ** modules_list, FILE *f, int load_probed_only) { while (1) { char final_name[500]; @@ -230,6 +231,11 @@ static enum return_type thirdparty_autoload_modules(const char *modules_location options++; } + if (load_probed_only && !exists_orphan_device(module)) { + log_message("third party: no device detected for module %s, skipping", module); + continue; + } + log_message("third party: auto-loading module (%s) (%s)", module, options); while (entry && *entry) { if (!strncmp(*entry, module, strlen(module)) && (*entry)[strlen(module)] == '.') { @@ -250,31 +256,83 @@ static enum return_type thirdparty_autoload_modules(const char *modules_location } } } - fclose(f); return RETURN_OK; } +static enum return_type thirdparty_try_directory(char * root_directory, int interactive) { + char modules_location[100]; + char list_filename[50]; + FILE *f_load, *f_detect; + char **modules_list; + + /* look first in the specific third-party directory */ + strcpy(modules_location, root_directory); + strcat(modules_location, THIRDPARTY_DIRECTORY); + modules_list = list_directory(modules_location); + + /* if it's empty, look in the root of selected device */ + if (!modules_list || !modules_list[0]) { + modules_location[strlen(root_directory)] = '\0'; + modules_list = list_directory(modules_location); + } + + log_message("third party: using modules location %s", modules_location); + + if (!modules_list || !*modules_list) { + log_message("third party: no modules found"); + if (interactive) + stg1_error_message("No modules found on selected device."); + return RETURN_ERROR; + } + + sprintf(list_filename, "%s/to_load", modules_location); + f_load = fopen(list_filename, "rb"); + if (f_load) { + thirdparty_autoload_modules(modules_location, modules_list, f_load, 0); + fclose(f_load); + } + + sprintf(list_filename, "%s/to_detect", modules_location); + f_detect = fopen(list_filename, "rb"); + if (f_detect) { + thirdparty_autoload_modules(modules_location, modules_list, f_detect, 1); + fclose(f_detect); + } + + if (f_load || f_detect) + return RETURN_OK; + else if (interactive) { + if (IS_AUTOMATIC) + stg1_error_message("I can't find a \"to_load\" file. Please select the modules manually."); + log_message("third party: no \"to_load\" file, prompting for modules"); + return thirdparty_prompt_modules(modules_location, modules_list); + } else { + return RETURN_OK; + } +} + +void thirdparty_load_media_modules(void) +{ + thirdparty_try_directory(IMAGE_LOCATION, 0); +} void thirdparty_load_modules(void) { enum return_type results; - char * device, * modules_location; - char ** modules_list; - char toload_name[500]; - FILE * f; + char * device; device = NULL; if (IS_AUTOMATIC) { device = get_auto_value("thirdparty"); - third_party_choose_device(NULL, 1); /* probe only to create devices */ + thirdparty_choose_device(NULL, 1); /* probe only to create devices */ log_message("third party: trying automatic device %s", device); if (thirdparty_mount_device(device) != RETURN_OK) device = NULL; } while (!device || streq(device, "")) { - results = third_party_choose_device(&device, 0); + results = thirdparty_choose_device(&device, 0); if (results == RETURN_BACK) return; if (thirdparty_mount_device(device) != RETURN_OK) @@ -283,38 +341,9 @@ void thirdparty_load_modules(void) log_message("third party: using device %s", device); - /* look first in the specific third-party directory */ - modules_location = THIRDPARTY_MOUNT_LOCATION THIRDPARTY_DIRECTORY; - modules_list = list_directory(modules_location); - if (!modules_list || !modules_list[0]) { - /* if it's empty, look in the root of selected device */ - modules_location = THIRDPARTY_MOUNT_LOCATION; - modules_list = list_directory(modules_location); - } - - log_message("third party: using modules location %s", modules_location); - - if (!modules_list || !*modules_list) { - log_message("third party: no modules found"); - stg1_error_message("No modules found on selected device."); - umount(THIRDPARTY_MOUNT_LOCATION); - return thirdparty_load_modules(); - } - - sprintf(toload_name, "%s/to_load", modules_location); - f = fopen(toload_name, "rb"); - if (f) { - results = thirdparty_autoload_modules(modules_location, modules_list, f); - } else { - if (IS_AUTOMATIC) - stg1_error_message("I can't find a \"to_load\" file. Please select the modules manually."); - log_message("third party: no \"to_load\" file, prompting for modules"); - results = thirdparty_prompt_modules(modules_location, modules_list); - } + results = thirdparty_try_directory(THIRDPARTY_MOUNT_LOCATION, 1); umount(THIRDPARTY_MOUNT_LOCATION); - if (results == RETURN_OK) - return; - else + if (results != RETURN_OK) return thirdparty_load_modules(); } diff --git a/mdk-stage1/thirdparty.h b/mdk-stage1/thirdparty.h index b09f36682..b88db7e0e 100644 --- a/mdk-stage1/thirdparty.h +++ b/mdk-stage1/thirdparty.h @@ -16,6 +16,15 @@ #ifndef _THIRDPARTY_H_ #define _THIRDPARTY_H_ +/* load third party modules present on install media + * use to_load and to_detect files in /install/thirdparty + * do not prompt user + */ +void thirdparty_load_media_modules(void); + +/* load modules if to_load or to_detect files are present + * prompt user if no to_load file is present + */ void thirdparty_load_modules(void); #endif |