From 806cedc647e42ec6ccd1ff567bdce38683132cd3 Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Thu, 12 Feb 2004 16:14:20 +0000 Subject: try to detect regular floppy drives --- mdk-stage1/modules.c | 3 --- mdk-stage1/stage1.c | 2 -- mdk-stage1/tools.c | 22 ++++++++++++++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/mdk-stage1/modules.c b/mdk-stage1/modules.c index 719e98ca1..201302603 100644 --- a/mdk-stage1/modules.c +++ b/mdk-stage1/modules.c @@ -104,7 +104,6 @@ static enum return_type ensure_additional_modules_available(void) retry: stg1_info_message("Please insert the Additional Drivers floppy.");; - my_insmod("floppy", ANY_DRIVER_TYPE, NULL, 0); while (my_mount(floppy_device(), floppy_mount_location, "ext2", 0) == -1) { enum return_type results = ask_yes_no(errno == ENXIO ? @@ -537,8 +536,6 @@ void update_modules(void) stg1_info_message("Please insert the Update Modules floppy.");; - my_insmod("floppy", ANY_DRIVER_TYPE, NULL, 0); - 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?"); diff --git a/mdk-stage1/stage1.c b/mdk-stage1/stage1.c index c5452ce90..fe933684c 100644 --- a/mdk-stage1/stage1.c +++ b/mdk-stage1/stage1.c @@ -230,8 +230,6 @@ static void expert_third_party_modules(void) if (results != RETURN_OK) return; - my_insmod("floppy", ANY_DRIVER_TYPE, NULL, 0); - 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(); diff --git a/mdk-stage1/tools.c b/mdk-stage1/tools.c index e3a0fa479..dbbd45772 100644 --- a/mdk-stage1/tools.c +++ b/mdk-stage1/tools.c @@ -35,6 +35,8 @@ #include #include #include +#include +#include #include "stage1.h" #include "log.h" #include "mount.h" @@ -480,6 +482,26 @@ int kernel_version(void) char * floppy_device(void) { char ** names, ** models; + my_insmod("floppy", ANY_DRIVER_TYPE, NULL, 0); + int fd = open("/dev/fd0", O_RDONLY|O_NONBLOCK); + if (fd != -1) { + char drivtyp[17]; + if (!ioctl(fd, FDGETDRVTYP, (void *)drivtyp)) { + struct floppy_drive_struct ds; + log_message("/dev/fd0 type: %s", drivtyp); + if (!ioctl(fd, FDPOLLDRVSTAT, &ds)) { + log_message("\ttrack: %d", ds.track); + if (ds.track >= 0) { + close(fd); + return "/dev/fd0"; + } + } + } else { + log_perror("can't FDGETDRVTYP /dev/fd0"); + } + close(fd); + } + log_message("seems that you don't have a regular floppy drive"); my_insmod("sd_mod", ANY_DRIVER_TYPE, NULL, 0); get_medias(FLOPPY, &names, &models, BUS_ANY); if (names && *names) -- cgit v1.2.1