summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/modules.c
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-07-26 11:05:32 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-07-26 11:05:32 +0000
commitbfdaf6ccfabb2a53c27be23c5bb8c7339aecb30a (patch)
tree030848f77706115156d224173d3ccc81a2f0e7eb /mdk-stage1/modules.c
parentda0892b3071b9ddaaa4cdf80728413d2396c474d (diff)
downloaddrakx-backup-do-not-use-bfdaf6ccfabb2a53c27be23c5bb8c7339aecb30a.tar
drakx-backup-do-not-use-bfdaf6ccfabb2a53c27be23c5bb8c7339aecb30a.tar.gz
drakx-backup-do-not-use-bfdaf6ccfabb2a53c27be23c5bb8c7339aecb30a.tar.bz2
drakx-backup-do-not-use-bfdaf6ccfabb2a53c27be23c5bb8c7339aecb30a.tar.xz
drakx-backup-do-not-use-bfdaf6ccfabb2a53c27be23c5bb8c7339aecb30a.zip
- add "changedisk" feature
- add "updatemodules" feature
Diffstat (limited to 'mdk-stage1/modules.c')
-rw-r--r--mdk-stage1/modules.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/mdk-stage1/modules.c b/mdk-stage1/modules.c
index 31d20bbaa..fac10ba47 100644
--- a/mdk-stage1/modules.c
+++ b/mdk-stage1/modules.c
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/mount.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
@@ -30,6 +31,7 @@
#include "log.h"
#include "mar/mar-extract-only.h"
#include "frontend.h"
+#include "mount.h"
#include "modules_descr.h"
#include "modules.h"
@@ -375,3 +377,67 @@ 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 disk.");;
+
+ my_insmod("floppy", ANY_DRIVER_TYPE, NULL);
+
+ if (my_mount("/dev/fd0", floppy_mount_location, "ext2") == -1) {
+ stg1_error_message("I can't find a Linux ext2 floppy in first floppy drive.");
+ return update_modules();
+ }
+
+ 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_call(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);
+ if (ret != INSMOD_OK) {
+ log_message("\t%s (marfile): failed", module);
+ stg1_error_message("Insmod %s (marfile) failed.", module);
+ }
+ }
+ }
+ fclose(f);
+}