diff options
author | Guillaume Cottenceau <gc@mandriva.com> | 2004-02-10 17:04:58 +0000 |
---|---|---|
committer | Guillaume Cottenceau <gc@mandriva.com> | 2004-02-10 17:04:58 +0000 |
commit | 09fb7bb3267367ad9e0742ff41ff7981dd21fbf0 (patch) | |
tree | c5c0c7814148a2488bc94e040a36464f39c0bd01 /mdk-stage1 | |
parent | c08ee4723676371cbb8dfa3ec024693ff07e104e (diff) | |
download | drakx-backup-do-not-use-09fb7bb3267367ad9e0742ff41ff7981dd21fbf0.tar drakx-backup-do-not-use-09fb7bb3267367ad9e0742ff41ff7981dd21fbf0.tar.gz drakx-backup-do-not-use-09fb7bb3267367ad9e0742ff41ff7981dd21fbf0.tar.bz2 drakx-backup-do-not-use-09fb7bb3267367ad9e0742ff41ff7981dd21fbf0.tar.xz drakx-backup-do-not-use-09fb7bb3267367ad9e0742ff41ff7981dd21fbf0.zip |
fake usb floppies detection by looking at blocks size of scsi disk devices, 1048575 is for 2.4 and 1440 for 2.6
Diffstat (limited to 'mdk-stage1')
-rw-r--r-- | mdk-stage1/probing.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/mdk-stage1/probing.c b/mdk-stage1/probing.c index 85d96d61a..0d2e21684 100644 --- a/mdk-stage1/probing.c +++ b/mdk-stage1/probing.c @@ -351,7 +351,6 @@ void probe_that_type(enum driver_type type, enum media_bus bus __attribute__ ((u } -#ifndef DISABLE_MEDIAS static struct media_info * medias = NULL; static void find_media(enum media_bus bus) @@ -447,6 +446,9 @@ static void find_media(enum media_bus bus) fd = open("/proc/scsi/scsi", O_RDONLY); if (fd != -1) { + FILE * f; + char buf[512]; + enum { SCSI_TOP, SCSI_HOST, SCSI_VENDOR, SCSI_TYPE } state = SCSI_TOP; char * start, * chptr, * next, * end; char scsi_disk_count = 'a'; @@ -551,6 +553,20 @@ static void find_media(enum media_bus bus) tmp[count].type = CDROM; } + if (!(f = fopen("/proc/partitions", "rb")) || !fgets(buf, sizeof(buf), f) || !fgets(buf, sizeof(buf), f)) { + log_message("Couldn't open /proc/partitions"); + } else { + while (fgets(buf, sizeof(buf), f)) { + char name[100]; + int major, minor, blocks; + memset(name, 0, sizeof(name)); + sscanf(buf, " %d %d %d %s", &major, &minor, &blocks, name); + if (streq(name, tmp_name) && ((blocks == 1048575) || (blocks == 1440))) + tmp[count].type = FLOPPY; + } + fclose(f); + } + if (*tmp_name) { tmp[count].name = strdup(tmp_name); log_message("SCSI/%d: %s is a %s", tmp[count].type, tmp[count].name, tmp[count].model); @@ -662,7 +678,6 @@ void get_medias(enum media_type media, char *** names, char *** models, enum med *names = memdup(tmp_names, sizeof(char *) * count); *models = memdup(tmp_models, sizeof(char *) * count); } -#endif /* DISABLE_MEDIAS */ #ifndef DISABLE_NETWORK |