diff options
author | Olivier Blin <oblin@mandriva.org> | 2006-02-09 11:12:25 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2006-02-09 11:12:25 +0000 |
commit | 38e85ac42ac6483781f24bc920fe67e4e12431cf (patch) | |
tree | 03173f673079006983f429e79ea8db99ed7145a5 | |
parent | c10291702388dbb4325b6e8ac3626c856a99e8bc (diff) | |
download | drakx-38e85ac42ac6483781f24bc920fe67e4e12431cf.tar drakx-38e85ac42ac6483781f24bc920fe67e4e12431cf.tar.gz drakx-38e85ac42ac6483781f24bc920fe67e4e12431cf.tar.bz2 drakx-38e85ac42ac6483781f24bc920fe67e4e12431cf.tar.xz drakx-38e85ac42ac6483781f24bc920fe67e4e12431cf.zip |
backport thirdparty support
-rw-r--r-- | mdk-stage1/Makefile | 4 | ||||
-rw-r--r-- | mdk-stage1/disk.c | 165 | ||||
-rw-r--r-- | mdk-stage1/partition.c | 4 | ||||
-rw-r--r-- | mdk-stage1/probing.c | 152 | ||||
-rw-r--r-- | mdk-stage1/probing.h | 13 | ||||
-rw-r--r-- | mdk-stage1/stage1.c | 82 | ||||
-rw-r--r-- | mdk-stage1/stage1.h | 6 | ||||
-rw-r--r-- | mdk-stage1/tools.c | 73 | ||||
-rw-r--r-- | mdk-stage1/tools.h | 7 |
9 files changed, 241 insertions, 265 deletions
diff --git a/mdk-stage1/Makefile b/mdk-stage1/Makefile index 457f289e6..db509e6e8 100644 --- a/mdk-stage1/Makefile +++ b/mdk-stage1/Makefile @@ -120,9 +120,9 @@ MOVE_ADDSRC = endif #- stage1 itself -STAGE1SRC = stage1.c log.c tools.c modules.c probing.c mount.c automatic.c frontend-common.c +STAGE1SRC = stage1.c log.c tools.c modules.c probing.c mount.c automatic.c frontend-common.c thirdparty.c CDROMSRC = cdrom.c $(MOVE_ADDSRC) -DISKSRC = disk.c lomount.c +DISKSRC = disk.c lomount.c partition.c NETWORKSRC = network.c nfsmount.c dhcp.c url.c dns.c adsl.c $(MOVE_ADDSRC) ALLSRC = $(INITSRC) $(STAGE1SRC) $(CDROMSRC) $(DISKSRC) $(NETWORKSRC) diff --git a/mdk-stage1/disk.c b/mdk-stage1/disk.c index 3cd2da6a4..8f11935a8 100644 --- a/mdk-stage1/disk.c +++ b/mdk-stage1/disk.c @@ -35,104 +35,8 @@ #include "mount.h" #include "lomount.h" #include "automatic.h" - #include "disk.h" - -struct partition_detection_anchor { - off_t offset; - const char * anchor; -}; - -static int seek_and_compare(int fd, struct partition_detection_anchor anch) -{ - char buf[500]; - size_t count; - if (lseek(fd, anch.offset, SEEK_SET) == (off_t)-1) { - log_perror("seek failed"); - return -1; - } - count = read(fd, buf, strlen(anch.anchor)); - if (count != strlen(anch.anchor)) { - log_perror("read failed"); - return -1; - } - buf[count] = '\0'; - if (strcmp(anch.anchor, buf)) - return 1; - return 0; -} - -static const char * detect_partition_type(char * dev) -{ - struct partition_detection_info { - const char * name; - struct partition_detection_anchor anchor0; - struct partition_detection_anchor anchor1; - struct partition_detection_anchor anchor2; - }; - struct partition_detection_info partitions_signatures[] = { - { "Linux Swap", { 4086, "SWAP-SPACE" }, { 0, NULL }, { 0, NULL } }, - { "Linux Swap", { 4086, "SWAPSPACE2" }, { 0, NULL }, { 0, NULL } }, - { "Ext2", { 0x438, "\x53\xEF" }, { 0, NULL }, { 0, NULL } }, - { "ReiserFS", { 0x10034, "ReIsErFs" }, { 0, NULL }, { 0, NULL } }, - { "ReiserFS", { 0x10034, "ReIsEr2Fs" }, { 0, NULL }, { 0, NULL } }, - { "XFS", { 0, "XFSB" }, { 0x200, "XAGF" }, { 0x400, "XAGI" } }, - { "JFS", { 0x8000, "JFS1" }, { 0, NULL }, { 0, NULL } }, - { "NTFS", { 0x1FE, "\x55\xAA" }, { 0x3, "NTFS" }, { 0, NULL } }, - { "FAT32", { 0x1FE, "\x55\xAA" }, { 0x52, "FAT32" }, { 0, NULL } }, - { "FAT", { 0x1FE, "\x55\xAA" }, { 0x36, "FAT" }, { 0, NULL } }, - { "Linux LVM", { 0, "HM\1\0" }, { 0, NULL }, { 0, NULL } } - }; - int partitions_signatures_nb = sizeof(partitions_signatures) / sizeof(struct partition_detection_info); - int i; - int fd; - const char *part_type = NULL; - - char device_fullname[50]; - strcpy(device_fullname, "/dev/"); - strcat(device_fullname, dev); - - if (ensure_dev_exists(device_fullname)) - return NULL; - log_message("guessing type of %s", device_fullname); - - if ((fd = open(device_fullname, O_RDONLY, 0)) < 0) { - log_perror("open"); - return NULL; - } - - for (i=0; i<partitions_signatures_nb; i++) { - int results = seek_and_compare(fd, partitions_signatures[i].anchor0); - if (results == -1) - goto detect_partition_type_end; - if (results == 1) - continue; - if (!partitions_signatures[i].anchor1.anchor) - goto detect_partition_found_it; - - results = seek_and_compare(fd, partitions_signatures[i].anchor1); - if (results == -1) - goto detect_partition_type_end; - if (results == 1) - continue; - if (!partitions_signatures[i].anchor2.anchor) - goto detect_partition_found_it; - - results = seek_and_compare(fd, partitions_signatures[i].anchor2); - if (results == -1) - goto detect_partition_type_end; - if (results == 1) - continue; - - detect_partition_found_it: - part_type = partitions_signatures[i].name; - break; - } - - detect_partition_type_end: - close(fd); - return part_type; -} +#include "partition.h" static char * disk_extract_list_directory(char * direct) { @@ -149,55 +53,6 @@ static char * disk_extract_list_directory(char * direct) return strdup(tmp); } -static int list_partitions(char * dev_name, char ** parts, char ** comments) -{ - int major, minor, blocks; - char name[100]; - FILE * f; - int i = 0; - char buf[512]; - - if (!(f = fopen("/proc/partitions", "rb")) || !fgets(buf, sizeof(buf), f) || !fgets(buf, sizeof(buf), f)) { - log_perror(dev_name); - return 1; - } - - while (fgets(buf, sizeof(buf), f)) { - memset(name, 0, sizeof(name)); - sscanf(buf, " %d %d %d %s", &major, &minor, &blocks, name); - if ((strstr(name, dev_name) == name) && (blocks > 1) && (name[strlen(dev_name)] != '\0')) { - const char * partition_type = detect_partition_type(name); - parts[i] = strdup(name); - comments[i] = (char *) malloc(sizeof(char) * 100); - sprintf(comments[i], "size: %d Mbytes", blocks >> 10); - if (partition_type) { - strcat(comments[i], ", type: "); - strcat(comments[i], partition_type); - } - i++; - } - } - parts[i] = NULL; - fclose(f); - - return 0; -} - -static int try_mount(char * dev, char * location) -{ - char device_fullname[50]; - strcpy(device_fullname, "/dev/"); - strcat(device_fullname, dev); - - if (my_mount(device_fullname, location, "ext2", 0) == -1 && - my_mount(device_fullname, location, "vfat", 0) == -1 && - my_mount(device_fullname, location, "reiserfs", 0) == -1) { - return 1; - } - - return 0; -} - static enum return_type try_with_device(char *dev_name) { char * questions_location[] = { "Directory or ISO image", NULL }; @@ -331,24 +186,6 @@ static enum return_type try_with_device(char *dev_name) return RETURN_OK; } -static int get_disks(char *** names, char *** models) -{ - char ** ptr; - int count = 0; - - my_insmod("sd_mod", ANY_DRIVER_TYPE, NULL, 0); - - get_medias(DISK, names, models, BUS_ANY); - - ptr = *names; - while (ptr && *ptr) { - count++; - ptr++; - } - - return count; -} - enum return_type disk_prepare(void) { char ** medias, ** medias_models; diff --git a/mdk-stage1/partition.c b/mdk-stage1/partition.c index 8fd581017..3b99c65a3 100644 --- a/mdk-stage1/partition.c +++ b/mdk-stage1/partition.c @@ -45,7 +45,7 @@ struct partition_detection_anchor { const char * anchor; }; -static int seek_and_compare(int fd, struct partition_detection_anchor anch) +int seek_and_compare(int fd, struct partition_detection_anchor anch) { char buf[500]; size_t count; @@ -64,7 +64,7 @@ static int seek_and_compare(int fd, struct partition_detection_anchor anch) return 0; } -static const char * detect_partition_type(char * dev) +const char * detect_partition_type(char * dev) { struct partition_detection_info { const char * name; diff --git a/mdk-stage1/probing.c b/mdk-stage1/probing.c index aed9862c4..259937027 100644 --- a/mdk-stage1/probing.c +++ b/mdk-stage1/probing.c @@ -121,31 +121,144 @@ char * get_net_intf_description(char * intf_name) } #endif +struct pcitable_entry detected_devices[50]; +int detected_devices_len = 0; + +/* FIXME: factorize with probe_that_type() */ + +static void add_detected_device(unsigned short vendor, unsigned short device, const char *name, const char *module) +{ + struct pcitable_entry *dev = &detected_devices[detected_devices_len++]; + dev->vendor = vendor; + dev->device = device; + strncpy(dev->module, module, 19); + dev->module[19] = '\0'; + strncpy(dev->description, name, 99); + dev->description[99] = '\0'; + log_message("detected device (%x, %x, %s, %s)", vendor, device, name, module); +} + +static int check_device_full(struct pci_module_map_full * pcidb_full, unsigned int len_full, + unsigned short vendor, unsigned short device, + unsigned short subvendor, unsigned short subdevice) +{ + int i; + for (i = 0; i < len_full; i++) + if (pcidb_full[i].vendor == vendor && pcidb_full[i].device == device) { + if (pcidb_full[i].subvendor == subvendor && pcidb_full[i].subdevice == subdevice) { + add_detected_device(pcidb_full[i].vendor, pcidb_full[i].device, + pcidb_full[i].name, pcidb_full[i].module); + return 1; + } + } + return 0; +} + +static int check_device(struct pci_module_map * pcidb, unsigned int len, + unsigned short vendor, unsigned short device) { + int i; + for (i = 0; i < len; i++) + if (pcidb[i].vendor == vendor && pcidb[i].device == device) { + add_detected_device(pcidb[i].vendor, pcidb[i].device, + pcidb[i].name, pcidb[i].module); + return 1; + } + return 0; +} + +void probing_detect_devices() +{ + FILE * f = NULL; + char buf[200]; + static int already_detected_devices = 0; + + if (already_detected_devices) + return; + + if (!(f = fopen("/proc/bus/pci/devices", "rb"))) { + log_message("PCI: could not open proc file"); + return; + } + + while (1) { + unsigned int i; + unsigned short vendor, device, subvendor, subdevice, devbusfn; + if (!fgets(buf, sizeof(buf), f)) break; + sscanf(buf, "%hx %x", &devbusfn, &i); + device = i; + vendor = i >> 16; + { + int bus = devbusfn >> 8; + int device_p = (devbusfn & 0xff) >> 3; + int function = (devbusfn & 0xff) & 0x07; + char file[100]; + int sf; + sprintf(file, "/proc/bus/pci/%02x/%02x.%d", bus, device_p, function); + if ((sf = open(file, O_RDONLY)) == -1) { + log_message("PCI: could not open file for full probe (%s)", file); + continue; + } + if (read(sf, buf, 48) == -1) { + log_message("PCI: could not read 48 bytes from %s", file); + close(sf); + continue; + } + close(sf); + memcpy(&subvendor, buf+44, 2); + memcpy(&subdevice, buf+46, 2); + } + + +#ifndef DISABLE_PCIADAPTERS +#ifndef DISABLE_MEDIAS + if (check_device_full(medias_pci_ids_full, medias_num_ids_full, vendor, device, subvendor, subdevice)) + continue; + if (check_device(medias_pci_ids, medias_num_ids, vendor, device)) + continue; +#endif + +#ifndef DISABLE_NETWORK + if (check_device_full(network_pci_ids_full, network_num_ids_full, vendor, device, subvendor, subdevice)) + continue; + if (check_device(network_pci_ids, network_num_ids, vendor, device)) + continue; +#endif +#endif + +#ifdef ENABLE_USB + if (check_device(usb_pci_ids, usb_num_ids, vendor, device)) + continue; +#endif + + /* device can't be found in built-in pcitables, but keep it */ + add_detected_device(vendor, device, "", ""); + } + + fclose(f); + already_detected_devices = 1; +} + void discovered_device(enum driver_type type, unsigned short vendor, unsigned short device, unsigned short subvendor, unsigned short subdevice, const char * description, const char * driver) { + enum insmod_return failed = INSMOD_FAILED; log_message("PCI: device %04x %04x %04x %04x is \"%s\", driver is %s", vendor, device, subvendor, subdevice, description, driver); #ifndef DISABLE_MEDIAS if (type == SCSI_ADAPTERS) { - int wait_msg = 0; - enum insmod_return failed; - if (IS_AUTOMATIC) { - wait_message("Loading driver for SCSI adapter:\n \n%s", description); - wait_msg = 1; - } else - stg1_info_message("About to load driver for SCSI adapter:\n \n%s", description); + wait_message("Loading driver for SCSI adapter:\n \n%s", description); failed = my_insmod(driver, SCSI_ADAPTERS, NULL, 1); - if (wait_msg) - remove_wait_message(); + remove_wait_message(); warning_insmod_failed(failed); } #endif #ifndef DISABLE_NETWORK if (type == NETWORK_DEVICES) { - stg1_info_message("About to load driver for network device:\n \n%s", description); + wait_message("Loading driver for network device:\n \n%s", description); prepare_intf_descr(description); - warning_insmod_failed(my_insmod(driver, NETWORK_DEVICES, NULL, 1)); + failed = my_insmod(driver, NETWORK_DEVICES, NULL, 1); + warning_insmod_failed(failed); + remove_wait_message(); if (intf_descr_for_discover) /* for modules providing more than one net intf */ net_discovered_interface(NULL); } @@ -153,7 +266,7 @@ void discovered_device(enum driver_type type, #ifdef ENABLE_USB if (type == USB_CONTROLLERS) /* we can't allow additional modules floppy since we need usbkbd for keystrokes of usb keyboards */ - my_insmod(driver, USB_CONTROLLERS, NULL, 0); + failed = my_insmod(driver, USB_CONTROLLERS, NULL, 0); #endif } @@ -212,11 +325,6 @@ void probe_that_type(enum driver_type type, enum media_bus bus __attribute__ ((u goto end_pci_probe; } - if (IS_EXPERT && type != USB_CONTROLLERS) { - ask_insmod(type); - return; - } - if (!(f = fopen("/proc/bus/pci/devices", "rb"))) { log_message("PCI: could not open proc file"); goto end_pci_probe; @@ -385,6 +493,9 @@ void probe_that_type(enum driver_type type, enum media_bus bus __attribute__ ((u my_insmod("usb-storage", SCSI_ADAPTERS, NULL, 0); if (module_already_present("ieee1394")) my_insmod("sbp2", SCSI_ADAPTERS, NULL, 0); + wait_message("Detecting USB mass-storage devices."); + sleep(10); /* sucking background work */ + remove_wait_message(); } } @@ -402,9 +513,10 @@ static void find_media(enum media_bus bus) if (medias) free(medias); /* that does not free the strings, by the way */ - if (bus == BUS_SCSI || bus == BUS_USB || bus == BUS_ANY) - probe_that_type(SCSI_ADAPTERS, bus); - + if (bus == BUS_SCSI || bus == BUS_USB || bus == BUS_ANY) { + log_message("looking for SCSI adapters"); + probe_that_type(SCSI_ADAPTERS, bus); + } /* ----------------------------------------------- */ if (bus != BUS_IDE && bus != BUS_ANY) goto find_media_after_ide; diff --git a/mdk-stage1/probing.h b/mdk-stage1/probing.h index ce107b752..e6d506817 100644 --- a/mdk-stage1/probing.h +++ b/mdk-stage1/probing.h @@ -35,4 +35,17 @@ char * get_net_intf_description(char * intf_name); void prepare_intf_descr(const char * intf_descr); void probe_that_type(enum driver_type type, enum media_bus bus); +struct pcitable_entry { + /* some bits stolen from pci-resource/pci-ids.h + * FIXME: split pci-ids.h into pci-ids.c and pci-ids.h so that the header can be re-used + */ + unsigned short vendor; /* PCI vendor id */ + unsigned short device; /* PCI device id */ + char module[20]; /* module to load */ + char description[100]; /* PCI human readable description */ +}; +extern struct pcitable_entry detected_devices[50]; +extern int detected_devices_len; +void probing_detect_devices(); + #endif diff --git a/mdk-stage1/stage1.c b/mdk-stage1/stage1.c index 7977a95d2..0062955ee 100644 --- a/mdk-stage1/stage1.c +++ b/mdk-stage1/stage1.c @@ -47,6 +47,7 @@ _syscall2(int,pivot_root,const char *,new_root,const char *,put_old) #include "mount.h" #include "lomount.h" #include "insmod.h" +#include "thirdparty.h" #ifdef ENABLE_PCMCIA #include "pcmcia_/pcmcia.h" @@ -209,64 +210,6 @@ static void spawn_interactive(void) } -/************************************************************ - */ - -static void expert_third_party_modules(void) -{ - enum return_type results; - char * floppy_mount_location = "/tmp/floppy"; - char ** modules; - char final_name[500]; - char * choice; - int rc; - char * questions[] = { "Options", NULL }; - static char ** answers = NULL; - - results = ask_yes_no("If you want to insert third-party kernel modules, insert " - "a Linux (ext2fs) formatted floppy containing the modules and confirm. Otherwise, select \"no\".");; - if (results != RETURN_OK) - return; - - if (my_mount(floppy_device(), floppy_mount_location, "ext2", 0) == -1) { - stg1_error_message("I can't find a Linux ext2 floppy in first floppy drive."); - return expert_third_party_modules(); - } - - modules = list_directory(floppy_mount_location); - - if (!modules || !*modules) { - stg1_error_message("No modules found on floppy disk."); - umount(floppy_mount_location); - return expert_third_party_modules(); - } - - results = ask_from_list("Which driver would you like to insmod?", modules, &choice); - if (results != RETURN_OK) { - umount(floppy_mount_location); - return; - } - - sprintf(final_name, "%s/%s", floppy_mount_location, choice); - - results = ask_from_entries("Please enter the options:", questions, &answers, 24, NULL); - if (results != RETURN_OK) { - umount(floppy_mount_location); - return expert_third_party_modules(); - } - - rc = insmod_local_file(final_name, answers[0]); - umount(floppy_mount_location); - - if (rc) { - log_message("\tfailed"); - stg1_error_message("Insmod failed."); - } - - return expert_third_party_modules(); -} - - #ifdef ENABLE_PCMCIA static void handle_pcmcia(char ** pcmcia_adapter) { @@ -288,9 +231,6 @@ static void handle_pcmcia(char ** pcmcia_adapter) wait_message("Enabling PCMCIA extension cards..."); log_message("cardmgr rc: %d", cardmgr_call()); remove_wait_message(); - - if (IS_EXPERT) - expert_third_party_modules(); } #endif @@ -318,6 +258,7 @@ static void method_select_and_prepare(void) char * network_ka_install = "KA server"; char * network_ka_install_auto = "ka"; #endif + char * thirdparty_install = "Load third party modules"; char * thirdparty_install_auto = "thirdparty"; i = 0; #ifndef DISABLE_NETWORK @@ -334,6 +275,7 @@ static void method_select_and_prepare(void) means[i] = disk_install; means_auto[i++] = disk_install_auto; allow_additional_modules_floppy = 0; #endif + means[i] = thirdparty_install; means_auto[i++] = thirdparty_install_auto; means[i] = NULL; results = ask_from_list_auto("Please choose the installation method.", means, &choice, "method", means_auto); @@ -365,9 +307,16 @@ static void method_select_and_prepare(void) results = http_prepare(); #endif + if (!strcmp(choice, thirdparty_install)) { + thirdparty_load_modules(); + return method_select_and_prepare(); + } + if (results != RETURN_OK) return method_select_and_prepare(); + /* try to find third party modules on the install media */ + thirdparty_load_media_modules(); } #ifdef MANDRAKE_MOVE @@ -576,19 +525,16 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)) #endif __DATE__ " " __TIME__); - if (IS_EXPERT) - expert_third_party_modules(); + /* 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) handle_pcmcia(&pcmcia_adapter); #endif - - /* load usb interface as soon as possible, helps usb mouse detection in stage2 */ - probe_that_type(USB_CONTROLLERS, BUS_USB); if (IS_CHANGEDISK) stg1_info_message("You are starting the installation with an alternate booting method. " diff --git a/mdk-stage1/stage1.h b/mdk-stage1/stage1.h index 94f9c6bfc..db8818d46 100644 --- a/mdk-stage1/stage1.h +++ b/mdk-stage1/stage1.h @@ -33,28 +33,26 @@ extern char * interactive_fifo; extern char * stage2_kickstart; #define MODE_TESTING (1 << 0) -#define MODE_EXPERT (1 << 1) #define MODE_RESCUE (1 << 3) #define MODE_AUTOMATIC (1 << 4) #define MODE_DEBUGSTAGE1 (1 << 6) #define MODE_SPECIAL_STAGE2 (1 << 8) #define MODE_RAMDISK (1 << 9) #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) #define KA_MAX_RETRY 5 #define IS_TESTING (get_param(MODE_TESTING)) -#define IS_EXPERT (get_param(MODE_EXPERT)) #define IS_RESCUE (get_param(MODE_RESCUE)) #define IS_AUTOMATIC (get_param(MODE_AUTOMATIC)) #define IS_DEBUGSTAGE1 (get_param(MODE_DEBUGSTAGE1)) #define IS_SPECIAL_STAGE2 (get_param(MODE_SPECIAL_STAGE2)) #define IS_RAMDISK (get_param(MODE_RAMDISK)) #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/tools.c b/mdk-stage1/tools.c index 59d4a1ddf..ef7d10d6f 100644 --- a/mdk-stage1/tools.c +++ b/mdk-stage1/tools.c @@ -91,9 +91,10 @@ void process_cmdline(void) params[param_number].name = name; params[param_number].value = value; param_number++; - if (!strcmp(name, "expert")) set_param(MODE_EXPERT); + if (!strcmp(name, "expert")) set_param(MODE_THIRDPARTY); 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, "noauto")) set_param(MODE_NOAUTO); if (!strcmp(name, "netauto")) set_param(MODE_NETAUTO); @@ -108,7 +109,11 @@ void process_cmdline(void) break; i++; } - + + if (IS_AUTOMATIC && strcmp(get_auto_value("thirdparty"), "")) { + set_param(MODE_THIRDPARTY); + } + log_message("\tgot %d args", param_number); } @@ -135,13 +140,13 @@ int get_param(int i) buf[nb] = '\0'; ptr = buf; while ((ptr = strstr(ptr, "+ "))) { - if (!strncmp(ptr+2, "expert", 6)) set_param(MODE_EXPERT); + if (!strncmp(ptr+2, "expert", 6)) set_param(MODE_THIRDPARTY); if (!strncmp(ptr+2, "rescue", 6)) set_param(MODE_RESCUE); ptr++; } ptr = buf; while ((ptr = strstr(ptr, "- "))) { - if (!strncmp(ptr+2, "expert", 6)) unset_param(MODE_EXPERT); + if (!strncmp(ptr+2, "expert", 6)) unset_param(MODE_THIRDPARTY); if (!strncmp(ptr+2, "rescue", 6)) unset_param(MODE_RESCUE); ptr++; } @@ -478,7 +483,65 @@ int kernel_version(void) return -1; } return charstar_to_int(val.release + 2); + +} + +int try_mount(char * dev, char * location) +{ + char device_fullname[50]; + strcpy(device_fullname, "/dev/"); + strcat(device_fullname, dev); + + if (my_mount(device_fullname, location, "ext2", 0) == -1 && + my_mount(device_fullname, location, "vfat", 0) == -1 && + my_mount(device_fullname, location, "reiserfs", 0) == -1 && + my_mount(device_fullname, location, "iso9660", 0) == -1) { + return 1; + } + + return 0; +} + +#ifndef DISABLE_DISK +int get_disks(char *** names, char *** models) +{ + char ** ptr; + int count = 0; + + my_insmod("sd_mod", ANY_DRIVER_TYPE, NULL, 0); + + get_medias(DISK, names, models, BUS_ANY); + + ptr = *names; + while (ptr && *ptr) { + count++; + ptr++; + } + + return count; +} +#endif + +#ifndef DISABLE_CDROM +int get_cdroms(char *** names, char *** models) +{ + char ** ptr; + int count = 0; + + my_insmod("ide-cd", ANY_DRIVER_TYPE, NULL, 0); + my_insmod("sr_mod", ANY_DRIVER_TYPE, NULL, 0); + + get_medias(CDROM, names, models, BUS_ANY); + + ptr = *names; + while (ptr && *ptr) { + count++; + ptr++; + } + + return count; } +#endif char * floppy_device(void) { diff --git a/mdk-stage1/tools.h b/mdk-stage1/tools.h index d5668c4d0..4e9a0f900 100644 --- a/mdk-stage1/tools.h +++ b/mdk-stage1/tools.h @@ -43,6 +43,13 @@ char ** grab_env(void); char ** list_directory(char * direct); int string_array_length(char ** a); int kernel_version(void); +int try_mount(char * dev, char * location); +#ifndef DISABLE_DISK +int get_disks(char *** names, char *** models); +#endif +#ifndef DISABLE_CDROM +int get_cdroms(char *** names, char *** models); +#endif char * floppy_device(void); char * asprintf_(const char *msg, ...); int scall_(int retval, char * msg, char * file, int line); |