summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2002-07-24 14:05:11 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2002-07-24 14:05:11 +0000
commit59255c556db6a1fbb94458d87f798a58d39a056f (patch)
treef4615fc18a1373a7dbcee6d3c0055a3221c3025f
parent84d0ecb2c7f8a0191118b8f14140a209b660ccbd (diff)
downloaddrakx-59255c556db6a1fbb94458d87f798a58d39a056f.tar
drakx-59255c556db6a1fbb94458d87f798a58d39a056f.tar.gz
drakx-59255c556db6a1fbb94458d87f798a58d39a056f.tar.bz2
drakx-59255c556db6a1fbb94458d87f798a58d39a056f.tar.xz
drakx-59255c556db6a1fbb94458d87f798a58d39a056f.zip
enhance (complicate? ;p) device detection so that scsi and usb
detection are done only when no ide cdrom with mandrake install is detected (speed up), have usb keyboard modules installed before any interactive question, honour "noauto" (skip usb detection and insmod'ing)
-rw-r--r--mdk-stage1/cdrom.c102
-rw-r--r--mdk-stage1/disk.c2
-rw-r--r--mdk-stage1/frontend.h1
-rw-r--r--mdk-stage1/newt-frontend.c10
-rw-r--r--mdk-stage1/probing.c61
-rw-r--r--mdk-stage1/probing.h6
-rw-r--r--mdk-stage1/stage1.h2
-rw-r--r--mdk-stage1/stdio-frontend.c9
-rw-r--r--mdk-stage1/tools.c1
-rw-r--r--mdk-stage1/tools.h2
10 files changed, 130 insertions, 66 deletions
diff --git a/mdk-stage1/cdrom.c b/mdk-stage1/cdrom.c
index c3ff2e802..a4f9f2e84 100644
--- a/mdk-stage1/cdrom.c
+++ b/mdk-stage1/cdrom.c
@@ -97,6 +97,39 @@ static enum return_type try_with_device(char * dev_name, char * dev_model)
return do_with_device(dev_name, dev_model);
}
+int try_automatic(char ** medias, char ** medias_models)
+{
+ static char * already_tried[50] = { NULL };
+ char ** model = medias_models;
+ char ** ptr = medias;
+ int i = 0;
+ while (ptr && *ptr) {
+ char ** p;
+ for (p = already_tried; p && *p; p++)
+ if (streq(*p, *ptr))
+ goto try_automatic_already_tried;
+ *p = strdup(*ptr);
+ *(p+1) = NULL;
+
+ wait_message("Trying to access " DISTRIB_NAME " CDROM disc (drive %s)", *model);
+ if (mount_that_cd_device(*ptr) != -1) {
+ if (!test_that_cd()) {
+ remove_wait_message();
+ return i;
+ }
+ else
+ umount(IMAGE_LOCATION);
+ }
+ remove_wait_message();
+
+ try_automatic_already_tried:
+ ptr++;
+ model++;
+ i++;
+ }
+ return 0;
+}
+
enum return_type cdrom_prepare(void)
{
char ** medias, ** ptr, ** medias_models;
@@ -105,15 +138,32 @@ enum return_type cdrom_prepare(void)
enum return_type results;
my_insmod("ide-cd", ANY_DRIVER_TYPE, NULL);
- my_insmod("sr_mod", ANY_DRIVER_TYPE, NULL);
-
- get_medias(CDROM, &medias, &medias_models);
- ptr = medias;
- while (ptr && *ptr) {
- count++;
- ptr++;
- }
+ if (IS_AUTOMATIC) {
+ get_medias(CDROM, &medias, &medias_models, BUS_IDE);
+ if ((i = try_automatic(medias, medias_models)))
+ return do_with_device(medias[i], medias_models[i]);
+
+ my_insmod("sr_mod", ANY_DRIVER_TYPE, NULL);
+ get_medias(CDROM, &medias, &medias_models, BUS_SCSI);
+ if ((i = try_automatic(medias, medias_models)))
+ return do_with_device(medias[i], medias_models[i]);
+
+ get_medias(CDROM, &medias, &medias_models, BUS_USB);
+ if ((i = try_automatic(medias, medias_models)))
+ return do_with_device(medias[i], medias_models[i]);
+
+ unset_param(MODE_AUTOMATIC);
+ } else
+ my_insmod("sr_mod", ANY_DRIVER_TYPE, NULL);
+
+
+ get_medias(CDROM, &medias, &medias_models, BUS_ANY);
+ ptr = medias;
+ while (ptr && *ptr) {
+ count++;
+ ptr++;
+ }
if (count == 0) {
stg1_error_message("No CDROM device found.");
@@ -133,41 +183,19 @@ enum return_type cdrom_prepare(void)
return cdrom_prepare();
}
- if (IS_AUTOMATIC) {
+ results = ask_from_list_comments("Please choose the CDROM drive to use for the installation.", medias, medias_models, &choice);
+ if (results == RETURN_OK) {
char ** model = medias_models;
ptr = medias;
- while (ptr && *ptr) {
- wait_message("Trying to access " DISTRIB_NAME " CDROM disc (drive %s)", *model);
- if (mount_that_cd_device(*ptr) != -1) {
- if (!test_that_cd()) {
- remove_wait_message();
- return do_with_device(*ptr, *model);
- }
- else
- umount(IMAGE_LOCATION);
- }
- remove_wait_message();
+ while (ptr && *ptr && model && *model) {
+ if (!strcmp(*ptr, choice))
+ break;
ptr++;
model++;
}
- unset_param(MODE_AUTOMATIC);
- return cdrom_prepare();
- }
- else {
- results = ask_from_list_comments("Please choose the CDROM drive to use for the installation.", medias, medias_models, &choice);
- if (results == RETURN_OK) {
- char ** model = medias_models;
- ptr = medias;
- while (ptr && *ptr && model && *model) {
- if (!strcmp(*ptr, choice))
- break;
- ptr++;
- model++;
- }
results = try_with_device(choice, *model);
- } else
- return results;
- }
+ } else
+ return results;
if (results == RETURN_OK)
return RETURN_OK;
diff --git a/mdk-stage1/disk.c b/mdk-stage1/disk.c
index 8488a767e..0f764c749 100644
--- a/mdk-stage1/disk.c
+++ b/mdk-stage1/disk.c
@@ -300,7 +300,7 @@ enum return_type disk_prepare(void)
my_insmod("sd_mod", ANY_DRIVER_TYPE, NULL);
- get_medias(DISK, &medias, &medias_models);
+ get_medias(DISK, &medias, &medias_models, BUS_ANY);
ptr = medias;
while (ptr && *ptr) {
diff --git a/mdk-stage1/frontend.h b/mdk-stage1/frontend.h
index 9c2609281..4f2d112b7 100644
--- a/mdk-stage1/frontend.h
+++ b/mdk-stage1/frontend.h
@@ -48,5 +48,4 @@ void verror_message(char *msg, va_list ap);
void vinfo_message(char *msg, va_list ap);
void vwait_message(char *msg, va_list ap);
-
#endif
diff --git a/mdk-stage1/newt-frontend.c b/mdk-stage1/newt-frontend.c
index f50defee1..9d14dfc84 100644
--- a/mdk-stage1/newt-frontend.c
+++ b/mdk-stage1/newt-frontend.c
@@ -33,6 +33,8 @@
#include <sys/time.h>
#include "newt/newt.h"
+#include <probing.h>
+
#include "frontend.h"
void init_frontend(char * welcome_msg)
@@ -175,6 +177,8 @@ enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_
char ** sav_elems = elems;
int i;
+ probe_that_type(USB_CONTROLLERS, BUS_USB); // we'd need the keyboard for interactions so...
+
i = 0;
while (elems && *elems) {
int j = (*elems_comments) ? strlen(*elems_comments) : 0;
@@ -206,6 +210,8 @@ enum return_type ask_from_list(char *msg, char ** elems, char ** choice)
{
int answer = 0, rc;
+ probe_that_type(USB_CONTROLLERS, BUS_USB); // we'd need the keyboard for interactions so...
+
rc = newtWinMenu("Please choose...", msg, 52, 5, 5, 7, elems, &answer, "Ok", "Cancel", NULL);
if (rc == 2)
@@ -221,6 +227,8 @@ enum return_type ask_yes_no(char *msg)
{
int rc;
+ probe_that_type(USB_CONTROLLERS, BUS_USB); // we'd need the keyboard for interactions so...
+
rc = newtWinTernary("Please answer...", "Yes", "No", "Back", msg);
if (rc == 1)
@@ -358,6 +366,8 @@ enum return_type ask_from_entries(char *msg, char ** questions, char *** answers
int rc;
char ** already_answers = NULL;
+ probe_that_type(USB_CONTROLLERS, BUS_USB); // we'd need the keyboard for interactions so...
+
while (questions && *questions) {
entries[i].text = *questions;
entries[i].flags = NEWT_FLAG_SCROLL | (!strcmp(*questions, "Password") ? NEWT_FLAG_PASSWORD : 0);
diff --git a/mdk-stage1/probing.c b/mdk-stage1/probing.c
index 713d269e9..077a664d3 100644
--- a/mdk-stage1/probing.c
+++ b/mdk-stage1/probing.c
@@ -120,14 +120,12 @@ char * get_net_intf_description(char * intf_name)
}
#endif
-void probe_that_type(enum driver_type type)
+#ifdef ENABLE_USB
+void probe_that_type(enum driver_type type, enum media_bus bus)
+#else
+void probe_that_type(enum driver_type type, enum media_bus bus __attribute__ ((unused)))
+#endif
{
- if (IS_EXPERT) {
- ask_insmod(type);
- return;
- }
-
-
/* ---- PCI probe ---------------------------------------------- */
{
FILE * f;
@@ -138,7 +136,11 @@ void probe_that_type(enum driver_type type)
switch (type) {
#ifndef DISABLE_PCIADAPTERS
#ifndef DISABLE_MEDIAS
+ static int already_probed_scsi_adapters = 0;
case SCSI_ADAPTERS:
+ if (already_probed_scsi_adapters)
+ goto end_pci_probe;
+ already_probed_scsi_adapters = 1;
pcidb = medias_pci_ids;
len = medias_num_ids;
break;
@@ -151,7 +153,11 @@ void probe_that_type(enum driver_type type)
#endif
#endif
#ifdef ENABLE_USB
+ static int already_probed_usb_controllers = 0;
case USB_CONTROLLERS:
+ if (already_probed_usb_controllers || IS_NOAUTO)
+ goto end_pci_probe;
+ already_probed_usb_controllers = 1;
pcidb = usb_pci_ids;
len = usb_num_ids;
break;
@@ -160,6 +166,11 @@ void probe_that_type(enum driver_type type)
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;
@@ -216,7 +227,7 @@ void probe_that_type(enum driver_type type)
#ifdef ENABLE_USB
/* ---- USB probe ---------------------------------------------- */
- {
+ if ((bus == BUS_USB || bus == BUS_ANY) && !(IS_NOAUTO)) {
static int already_probed_usb_controllers = 0;
static int already_mounted_usbdev = 0;
@@ -227,7 +238,7 @@ void probe_that_type(enum driver_type type)
if (!already_probed_usb_controllers) {
already_probed_usb_controllers = 1;
- probe_that_type(USB_CONTROLLERS);
+ probe_that_type(USB_CONTROLLERS, BUS_ANY);
}
if (!already_mounted_usbdev) {
@@ -239,6 +250,8 @@ void probe_that_type(enum driver_type type)
}
wait_message("Detecting USB devices.");
sleep(4); /* sucking background work */
+ my_insmod("usbkbd", ANY_DRIVER_TYPE, NULL);
+ my_insmod("keybdev", ANY_DRIVER_TYPE, NULL);
remove_wait_message();
}
@@ -261,11 +274,6 @@ void probe_that_type(enum driver_type type)
if (!fgets(buf, sizeof(buf), f)) break;
- if (strstr(buf, "Keyboard")) {
- my_insmod("usbkbd", ANY_DRIVER_TYPE, NULL);
- my_insmod("keybdev", ANY_DRIVER_TYPE, NULL);
- }
-
if (sscanf(buf, "P: Vendor=%x ProdID=%x", &vendor, &id) != 2)
continue;
@@ -295,23 +303,25 @@ void probe_that_type(enum driver_type type)
#ifndef DISABLE_MEDIAS
static struct media_info * medias = NULL;
-static void find_media(void)
+static void find_media(enum media_bus bus)
{
char b[50];
char buf[5000];
struct media_info tmp[50];
- int count;
+ int count = 0;
int fd;
- if (!medias)
- probe_that_type(SCSI_ADAPTERS);
- else
+ 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_IDE && bus != BUS_ANY)
+ goto find_media_after_ide;
log_message("looking for ide media");
- count = 0;
strcpy(b, "/proc/ide/hd");
for (b[12] = 'a'; b[12] <= 'h'; b[12]++) {
int i;
@@ -378,8 +388,10 @@ static void find_media(void)
count++;
}
-
+ find_media_after_ide:
/* ----------------------------------------------- */
+ if (bus != BUS_SCSI && bus != BUS_USB && bus != BUS_ANY)
+ goto find_media_after_scsi;
log_message("looking for scsi media");
fd = open("/proc/scsi/scsi", O_RDONLY);
@@ -563,6 +575,7 @@ static void find_media(void)
fclose(f);
}
}
+ find_media_after_scsi:
/* ----------------------------------------------- */
tmp[count].name = NULL;
@@ -573,14 +586,14 @@ static void find_media(void)
/* Finds by media */
-void get_medias(enum media_type media, char *** names, char *** models)
+void get_medias(enum media_type media, char *** names, char *** models, enum media_bus bus)
{
struct media_info * m;
char * tmp_names[50];
char * tmp_models[50];
int count;
- find_media();
+ find_media(bus);
m = medias;
@@ -641,7 +654,7 @@ char ** get_net_devices(void)
if (!already_probed) {
already_probed = 1; /* cut off loop brought by: probe_that_type => my_insmod => get_net_devices */
- probe_that_type(NETWORK_DEVICES);
+ probe_that_type(NETWORK_DEVICES, BUS_ANY);
}
while (ptr && *ptr) {
diff --git a/mdk-stage1/probing.h b/mdk-stage1/probing.h
index d2bf1e567..ce107b752 100644
--- a/mdk-stage1/probing.h
+++ b/mdk-stage1/probing.h
@@ -26,11 +26,13 @@ enum media_type { CDROM, DISK, FLOPPY, TAPE, UNKNOWN_MEDIA };
enum driver_type { SCSI_ADAPTERS, NETWORK_DEVICES, USB_CONTROLLERS, ANY_DRIVER_TYPE };
-void get_medias(enum media_type media, char *** names, char *** models);
+enum media_bus { BUS_IDE, BUS_SCSI, BUS_USB, BUS_ANY };
+
+void get_medias(enum media_type media, char *** names, char *** models, enum media_bus bus);
char ** get_net_devices(void);
void net_discovered_interface(char * intf_name);
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);
#endif
diff --git a/mdk-stage1/stage1.h b/mdk-stage1/stage1.h
index f92c45c41..8b26fd947 100644
--- a/mdk-stage1/stage1.h
+++ b/mdk-stage1/stage1.h
@@ -40,6 +40,7 @@ extern char * stage2_kickstart;
#define MODE_RAMDISK (1 << 9)
#define MODE_CHANGEDISK (1 << 10)
#define MODE_UPDATEMODULES (1 << 11)
+#define MODE_NOAUTO (1 << 12)
#define IS_TESTING (get_param(MODE_TESTING))
#define IS_EXPERT (get_param(MODE_EXPERT))
@@ -49,6 +50,7 @@ extern char * stage2_kickstart;
#define IS_RAMDISK (get_param(MODE_RAMDISK))
#define IS_CHANGEDISK (get_param(MODE_CHANGEDISK))
#define IS_UPDATEMODULES (get_param(MODE_UPDATEMODULES))
+#define IS_NOAUTO (get_param(MODE_NOAUTO))
void fatal_error(char *msg) __attribute__ ((noreturn));
diff --git a/mdk-stage1/stdio-frontend.c b/mdk-stage1/stdio-frontend.c
index 83e8fd76d..3fbed999a 100644
--- a/mdk-stage1/stdio-frontend.c
+++ b/mdk-stage1/stdio-frontend.c
@@ -27,6 +27,8 @@
#include <sys/ioctl.h>
#include <termios.h>
+#include <probing.h>
+
#include "frontend.h"
@@ -249,6 +251,8 @@ enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_
int i = 1;
int j = 0;
+ probe_that_type(USB_CONTROLLERS, BUS_USB); // we'd need the keyboard for interactions so...
+
while (elems && *elems) {
elems++;
i++;
@@ -303,6 +307,7 @@ enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_
enum return_type ask_from_list(char *msg, char ** elems, char ** choice)
{
+ probe_that_type(USB_CONTROLLERS, BUS_USB); // we'd need the keyboard for interactions so...
return ask_from_list_comments(msg, elems, NULL, choice);
}
@@ -311,6 +316,8 @@ enum return_type ask_yes_no(char *msg)
{
int j;
+ probe_that_type(USB_CONTROLLERS, BUS_USB); // we'd need the keyboard for interactions so...
+
printf("> %s\n[0] Yes [1] No [2] Back\n? ", msg);
j = get_int_response();
@@ -328,6 +335,8 @@ enum return_type ask_from_entries(char *msg, char ** questions, char *** answers
int j, i = 0;
char ** already_answers = NULL;
+ probe_that_type(USB_CONTROLLERS, BUS_USB); // we'd need the keyboard for interactions so...
+
printf("> %s\n", msg);
while (questions && *questions) {
diff --git a/mdk-stage1/tools.c b/mdk-stage1/tools.c
index e5d37f28b..a921883a8 100644
--- a/mdk-stage1/tools.c
+++ b/mdk-stage1/tools.c
@@ -90,6 +90,7 @@ void process_cmdline(void)
if (!strcmp(name, "changedisk")) set_param(MODE_CHANGEDISK);
if (!strcmp(name, "updatemodules")) set_param(MODE_UPDATEMODULES);
if (!strcmp(name, "rescue")) set_param(MODE_RESCUE);
+ if (!strcmp(name, "noauto")) set_param(MODE_NOAUTO);
if (!strcmp(name, "special_stage2")) set_param(MODE_SPECIAL_STAGE2);
if (!strcmp(name, "automatic")) {
set_param(MODE_AUTOMATIC);
diff --git a/mdk-stage1/tools.h b/mdk-stage1/tools.h
index 5d38b0364..e168ebe9f 100644
--- a/mdk-stage1/tools.h
+++ b/mdk-stage1/tools.h
@@ -48,6 +48,6 @@ struct param_elem
};
#define ptr_begins_static_str(pointer,static_str) (!strncmp(pointer,static_str,sizeof(static_str)-1))
-#define streq !strcmp
+#define streq(a,b) (!strcmp(a,b))
#endif