diff options
-rw-r--r-- | mdk-stage1/modules.c | 66 | ||||
-rw-r--r-- | mdk-stage1/modules.h | 1 | ||||
-rw-r--r-- | mdk-stage1/stage1.c | 4 | ||||
-rw-r--r-- | mdk-stage1/stage1.h | 4 | ||||
-rw-r--r-- | mdk-stage1/thirdparty.c | 209 | ||||
-rw-r--r-- | mdk-stage1/tools.c | 6 |
6 files changed, 148 insertions, 142 deletions
diff --git a/mdk-stage1/modules.c b/mdk-stage1/modules.c index 01b342cd1..11e118030 100644 --- a/mdk-stage1/modules.c +++ b/mdk-stage1/modules.c @@ -556,69 +556,3 @@ enum return_type ask_insmod(enum driver_type type) } else return results; } - - -void update_modules(void) -{ - FILE * f; - char ** disk_contents; - char final_name[500]; - char floppy_mount_location[] = "/tmp/floppy"; - - stg1_info_message("Please insert the Update Modules floppy.");; - - if (my_mount(floppy_device(), floppy_mount_location, "ext2", 0) == -1) { - enum return_type results = ask_yes_no("I can't find a Linux ext2 floppy in first floppy drive.\n" - "Retry?"); - if (results == RETURN_OK) - return update_modules(); - return; - } - - disk_contents = list_directory(floppy_mount_location); - - if (!(f = fopen("/tmp/floppy/to_load", "rb"))) { - stg1_error_message("I can't find \"to_load\" file."); - umount(floppy_mount_location); - return update_modules(); - } - while (1) { - char module[500]; - char * options; - char ** entry = disk_contents; - - if (!fgets(module, sizeof(module), f)) break; - if (module[0] == '#' || strlen(module) == 0) - continue; - - while (module[strlen(module)-1] == '\n') - module[strlen(module)-1] = '\0'; - options = strchr(module, ' '); - if (options) { - options[0] = '\0'; - options++; - } - - log_message("updatemodules: (%s) (%s)", module, options); - while (entry && *entry) { - if (!strncmp(*entry, module, strlen(module)) && (*entry)[strlen(module)] == '.') { - sprintf(final_name, "%s/%s", floppy_mount_location, *entry); - if (insmod_local_file(final_name, options)) { - log_message("\t%s (floppy): failed", *entry); - stg1_error_message("Insmod %s (floppy) failed.", *entry); - } - break; - } - entry++; - } - if (!entry || !*entry) { - enum insmod_return ret = my_insmod(module, ANY_DRIVER_TYPE, options, 0); - if (ret != INSMOD_OK) { - log_message("\t%s (marfile): failed", module); - stg1_error_message("Insmod %s (marfile) failed.", module); - } - } - } - fclose(f); - umount(floppy_mount_location); -} diff --git a/mdk-stage1/modules.h b/mdk-stage1/modules.h index 3eb367d62..d42d55218 100644 --- a/mdk-stage1/modules.h +++ b/mdk-stage1/modules.h @@ -24,7 +24,6 @@ void init_modules_insmoding(void); int insmod_local_file(char * path, char * options); enum insmod_return my_insmod(const char * mod_name, enum driver_type type, char * options, int allow_modules_floppy); enum return_type ask_insmod(enum driver_type); -void update_modules(void); int module_already_present(const char * name); struct module_deps_elem { diff --git a/mdk-stage1/stage1.c b/mdk-stage1/stage1.c index b0c6979c5..a338c990b 100644 --- a/mdk-stage1/stage1.c +++ b/mdk-stage1/stage1.c @@ -585,8 +585,8 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)) /* load usb interface as soon as possible, helps usb mouse detection in stage2 */ probe_that_type(USB_CONTROLLERS, BUS_USB); - if (IS_UPDATEMODULES) - update_modules(); + if (IS_THIRDPARTY) + thirdparty_load_modules(); #ifdef ENABLE_PCMCIA if (!IS_NOAUTO) diff --git a/mdk-stage1/stage1.h b/mdk-stage1/stage1.h index 55a9c4307..a14311918 100644 --- a/mdk-stage1/stage1.h +++ b/mdk-stage1/stage1.h @@ -36,7 +36,7 @@ extern char * interactive_fifo; #define MODE_KEEP_MOUNTED (1 << 5) /* for rescue */ #define MODE_DEBUGSTAGE1 (1 << 6) #define MODE_CHANGEDISK (1 << 10) -#define MODE_UPDATEMODULES (1 << 11) +#define MODE_THIRDPARTY (1 << 11) #define MODE_NOAUTO (1 << 12) #define MODE_NETAUTO (1 << 13) #define MODE_RECOVERY (1 << 14) @@ -46,7 +46,7 @@ extern char * interactive_fifo; #define IS_AUTOMATIC (get_param(MODE_AUTOMATIC)) #define IS_DEBUGSTAGE1 (get_param(MODE_DEBUGSTAGE1)) #define IS_CHANGEDISK (get_param(MODE_CHANGEDISK)) -#define IS_UPDATEMODULES (get_param(MODE_UPDATEMODULES)) +#define IS_THIRDPARTY (get_param(MODE_THIRDPARTY)) #define IS_NOAUTO (get_param(MODE_NOAUTO)) #define IS_NETAUTO (get_param(MODE_NETAUTO)) #define IS_RECOVERY (get_param(MODE_RECOVERY)) diff --git a/mdk-stage1/thirdparty.c b/mdk-stage1/thirdparty.c index 48becc33a..94240d541 100644 --- a/mdk-stage1/thirdparty.c +++ b/mdk-stage1/thirdparty.c @@ -1,4 +1,5 @@ /* + * Guillaume Cottenceau (gc@mandrakesoft.com) * Olivier Blin (oblin@mandrakesoft.com) * * Copyright 2005 Mandrakesoft @@ -24,11 +25,13 @@ #include "mount.h" #include "frontend.h" #include "partition.h" +#include "automatic.h" #include "thirdparty.h" +#define THIRDPARTY_MOUNT_LOCATION "/tmp/thirdparty" -static enum return_type third_party_choose_device(char ** device, char *mount_location) +static enum return_type third_party_choose_device(char ** device) { char ** medias, ** medias_models; char ** ptr, ** ptr_models; @@ -61,23 +64,17 @@ static enum return_type third_party_choose_device(char ** device, char *mount_lo if (strstr(floppy_dev, "/dev/") == floppy_dev) { floppy_dev = floppy_dev + 5; } + if (floppy_dev) + count += 1; remove_wait_message(); if (count == 0) { - if (floppy_dev) { - log_message("third party : no disk or cdrom drive found, trying with floppy"); - *device = floppy_dev; - return RETURN_OK; - } else { - stg1_error_message("I can't find any floppy, disk or cdrom on this system. " - "No third-party kernel modules will be used."); - return RETURN_ERROR; - } + stg1_error_message("I can't find any floppy, disk or cdrom on this system. " + "No third-party kernel modules will be used."); + return RETURN_BACK; } - if (floppy_dev) - count += 1; ptr = medias = malloc((count + 1) * sizeof(char *)); ptr_models =medias_models = malloc((count + 1) * sizeof(char *)); @@ -107,31 +104,24 @@ static enum return_type third_party_choose_device(char ** device, char *mount_lo ptr[0] = NULL; ptr_models[0] = NULL; - results = ask_from_list_comments("If you want to insert third-party kernel modules, " - "please select the disk containing the modules.", - medias, medias_models, device); - if (results != RETURN_OK) - return results; - + if (count == 1) { + *device = medias[0]; + } else { + results = ask_from_list_comments("If you want to insert third-party kernel modules, " + "please select the disk containing the modules.", + medias, medias_models, device); + if (results != RETURN_OK) + return results; + } + /* a floppy is selected, don't try to list partitions */ if (streq(*device, floppy_dev)) { - if (try_mount(floppy_dev, mount_location) == -1) { - stg1_error_message("I can't mount the selected floppy."); - return RETURN_ERROR; - } return RETURN_OK; } #ifndef DISABLE_CDROM - /* a cdrom is selected, mount it as iso9660 */ + /* a cdrom is selected, don't try to list partitions */ if (device >= cdrom_medias) { - char device_fullname[50]; - strcpy(device_fullname, "/dev/"); - strcat(device_fullname, *device); - if (my_mount(device_fullname, mount_location, "iso9660", 0)) { - stg1_error_message("I can't mount the selected cdrom."); - return RETURN_ERROR; - } return RETURN_OK; } #endif @@ -157,69 +147,150 @@ static enum return_type third_party_choose_device(char ** device, char *mount_lo results = ask_from_list_comments("Please select the partition containing " "the third party modules.", parts, parts_comments, device); - if (results == RETURN_OK) { - if (try_mount(*device, mount_location) == -1) { - stg1_error_message("I can't mount the selected partition."); - return RETURN_ERROR; - } + if (results == RETURN_OK) return RETURN_OK; - } #endif - stg1_error_message("I can't mount the selected device."); + stg1_error_message("Sorry, no third party device can be used."); - return RETURN_ERROR; + return RETURN_BACK; } -void thirdparty_load_modules(void) + +static enum return_type thirdparty_mount_device(char * device) +{ + log_message("third party : trying to mount device %s", device); + if (try_mount(device, THIRDPARTY_MOUNT_LOCATION) == -1) { + stg1_error_message("I can't mount the selected device (%s).", device); + return RETURN_ERROR; + } + return RETURN_OK; +} + + +static enum return_type thirdparty_prompt_modules(char ** modules_list) { enum return_type results; - char * mount_location = "/tmp/thirdparty"; - char ** modules; char final_name[500]; - char * choice; + char *module_name; int rc; char * questions[] = { "Options", NULL }; static char ** answers = NULL; - do { - results = third_party_choose_device(&choice, mount_location); - if (results == RETURN_BACK) - return; - } while (results == RETURN_ERROR); + while (1) { + results = ask_from_list("Which driver would you like to insmod?", modules_list, &module_name); + if (results != RETURN_OK) + break; - log_message("third party : using device %s", choice); + sprintf(final_name, "%s/%s", THIRDPARTY_MOUNT_LOCATION, module_name); - modules = list_directory(mount_location); + results = ask_from_entries("Please enter the options:", questions, &answers, 24, NULL); + if (results != RETURN_OK) + continue; - if (!modules || !*modules) { - stg1_error_message("No modules found on disk."); - umount(mount_location); - return thirdparty_load_modules(); + rc = insmod_local_file(final_name, answers[0]); + if (rc) { + log_message("\tfailed"); + stg1_error_message("Insmod failed."); + } } + return RETURN_OK; +} - results = ask_from_list("Which driver would you like to insmod?", modules, &choice); - if (results != RETURN_OK) { - umount(mount_location); - return thirdparty_load_modules(); + +static enum return_type thirdparty_autoload_modules(char ** modules_list, FILE *f) +{ + while (1) { + char final_name[500]; + char module[500]; + char * options; + char ** entry = modules_list; + + if (!fgets(module, sizeof(module), f)) break; + if (module[0] == '#' || strlen(module) == 0) + continue; + + while (module[strlen(module)-1] == '\n') + module[strlen(module)-1] = '\0'; + options = strchr(module, ' '); + if (options) { + options[0] = '\0'; + options++; + } + + log_message("updatemodules: (%s) (%s)", module, options); + while (entry && *entry) { + if (!strncmp(*entry, module, strlen(module)) && (*entry)[strlen(module)] == '.') { + sprintf(final_name, "%s/%s", THIRDPARTY_MOUNT_LOCATION, *entry); + if (insmod_local_file(final_name, options)) { + log_message("\t%s (floppy): failed", *entry); + stg1_error_message("Insmod %s (floppy) failed.", *entry); + } + break; + } + entry++; + } + if (!entry || !*entry) { + enum insmod_return ret = my_insmod(module, ANY_DRIVER_TYPE, options, 0); + if (ret != INSMOD_OK) { + log_message("\t%s (marfile): failed", module); + stg1_error_message("Insmod %s (marfile) failed.", module); + } + } } + fclose(f); - sprintf(final_name, "%s/%s", mount_location, choice); + return RETURN_OK; +} - results = ask_from_entries("Please enter the options:", questions, &answers, 24, NULL); - if (results != RETURN_OK) { - umount(mount_location); - return thirdparty_load_modules(); + +void thirdparty_load_modules(void) +{ + enum return_type results; + char * device = NULL; + char ** modules_list; + char toload_name[500]; + FILE * f; + + if (IS_AUTOMATIC) { + device = get_auto_value("thirdparty"); + 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); + if (results == RETURN_BACK) + return; + if (thirdparty_mount_device(device) != RETURN_OK) + device = NULL; } - rc = insmod_local_file(final_name, answers[0]); - umount(mount_location); + log_message("third party : using device %s", device); + + modules_list = list_directory(THIRDPARTY_MOUNT_LOCATION); - if (rc) { - log_message("\tfailed"); - stg1_error_message("Insmod failed."); + if (!modules_list || !*modules_list) { + stg1_error_message("No modules found on disk."); + umount(THIRDPARTY_MOUNT_LOCATION); + return thirdparty_load_modules(); } - return thirdparty_load_modules(); -} + sprintf(toload_name, "%s/to_load", THIRDPARTY_MOUNT_LOCATION); + f = fopen(toload_name, "rb"); + if (f) { + results = thirdparty_autoload_modules(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("No \"to_load\" file, prompting for modules"); + results = thirdparty_prompt_modules(modules_list); + } + umount(THIRDPARTY_MOUNT_LOCATION); + if (results == RETURN_OK) + return; + else + return thirdparty_load_modules(); +} diff --git a/mdk-stage1/tools.c b/mdk-stage1/tools.c index d2ace065c..4f4bff8bb 100644 --- a/mdk-stage1/tools.c +++ b/mdk-stage1/tools.c @@ -102,7 +102,8 @@ void process_cmdline(void) params[param_number].value = value; param_number++; if (!strcmp(name, "changedisk")) set_param(MODE_CHANGEDISK); - if (!strcmp(name, "updatemodules")) set_param(MODE_UPDATEMODULES); + if (!strcmp(name, "updatemodules") || + !strcmp(name, "thirdparty")) set_param(MODE_THIRDPARTY); if (!strcmp(name, "rescue")) set_param(MODE_RESCUE); if (!strcmp(name, "keepmounted")) set_param(MODE_KEEP_MOUNTED); if (!strcmp(name, "noauto")) set_param(MODE_NOAUTO); @@ -452,7 +453,8 @@ int try_mount(char * dev, char * location) if (my_mount(device_fullname, location, "ext2", 0) == -1 && my_mount(device_fullname, location, "vfat", 0) == -1 && my_mount(device_fullname, location, "ntfs", 0) == -1 && - my_mount(device_fullname, location, "reiserfs", 0) == -1) { + my_mount(device_fullname, location, "reiserfs", 0) == -1 && + my_mount(device_fullname, location, "iso9660", 0) == -1) { return 1; } |