summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-01-12 22:46:50 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-01-12 22:46:50 +0000
commita22c56359677c75d8671d53c9d1c9a63409b7a19 (patch)
tree4b81e2aca13f67e44a095dffd1b01a6b732f33e6 /mdk-stage1
parent337771650fe20f2661eed86c7594f5fe17503397 (diff)
downloaddrakx-backup-do-not-use-a22c56359677c75d8671d53c9d1c9a63409b7a19.tar
drakx-backup-do-not-use-a22c56359677c75d8671d53c9d1c9a63409b7a19.tar.gz
drakx-backup-do-not-use-a22c56359677c75d8671d53c9d1c9a63409b7a19.tar.bz2
drakx-backup-do-not-use-a22c56359677c75d8671d53c9d1c9a63409b7a19.tar.xz
drakx-backup-do-not-use-a22c56359677c75d8671d53c9d1c9a63409b7a19.zip
- add load of third party modules in Expert mode (PS rulz)
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/disk.c32
-rw-r--r--mdk-stage1/modules.c2
-rw-r--r--mdk-stage1/modules.h1
-rw-r--r--mdk-stage1/stage1.c63
-rw-r--r--mdk-stage1/tools.c21
-rw-r--r--mdk-stage1/tools.h1
6 files changed, 97 insertions, 23 deletions
diff --git a/mdk-stage1/disk.c b/mdk-stage1/disk.c
index 7c8f2406c..9e0946313 100644
--- a/mdk-stage1/disk.c
+++ b/mdk-stage1/disk.c
@@ -24,8 +24,6 @@
#include <stdio.h>
#include <string.h>
#include <sys/mount.h>
-#include <dirent.h>
-#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "stage1.h"
@@ -38,22 +36,18 @@
#include "disk.h"
-
-static char * list_directory(char * direct)
+static char * disk_extract_list_directory(char * direct)
{
- char tmp[500] = "";
- int nb = 0;
- struct dirent *ep;
- DIR *dp = opendir(direct);
- while (dp && nb < 5 && (ep = readdir(dp))) {
- if (strcmp(ep->d_name, ".") && strcmp(ep->d_name, "..")) {
- strcat(tmp, strdup(ep->d_name));
- strcat(tmp, "\n");
- nb++;
- }
+ char ** full = list_directory(direct);
+ char tmp[2000] = "";
+ int i;
+ for (i=0; i<5 ; i++) {
+ if (!full || !*full)
+ break;
+ strcat(tmp, *full);
+ strcat(tmp, "\n");
+ full++;
}
- if (dp)
- closedir(dp);
return strdup(tmp);
}
@@ -129,7 +123,7 @@ static enum return_type try_with_device(char *dev_name)
if (access(location_full, R_OK)) {
error_message("Directory or ISO image file could not be found on partition.\n"
"Here's a short extract of the files in the root of the partition:\n"
- "%s", list_directory(disk_own_mount));
+ "%s", disk_extract_list_directory(disk_own_mount));
umount(disk_own_mount);
return try_with_device(dev_name);
}
@@ -152,7 +146,7 @@ static enum return_type try_with_device(char *dev_name)
error_message("I can't find the " DISTRIB_NAME " Distribution in the specified directory. "
"(I need the subdirectory " RAMDISK_LOCATION ")\n"
"Here's a short extract of the files in the directory:\n"
- "%s", list_directory(IMAGE_LOCATION));
+ "%s", disk_extract_list_directory(IMAGE_LOCATION));
umount(disk_own_mount);
return try_with_device(dev_name);
}
@@ -168,7 +162,7 @@ static enum return_type try_with_device(char *dev_name)
error_message("I can't find the " DISTRIB_NAME " Distribution in the specified directory. "
"(I need the subdirectory " LIVE_LOCATION ")\n"
"Here's a short extract of the files in the directory:\n"
- "%s", list_directory(IMAGE_LOCATION));
+ "%s", disk_extract_list_directory(IMAGE_LOCATION));
umount(disk_own_mount);
return try_with_device(dev_name);
}
diff --git a/mdk-stage1/modules.c b/mdk-stage1/modules.c
index ee99374da..f73972e62 100644
--- a/mdk-stage1/modules.c
+++ b/mdk-stage1/modules.c
@@ -294,7 +294,7 @@ static enum return_type insmod_with_options(char * mod, enum driver_type type)
error_message("Insmod failed.");
return RETURN_ERROR;
}
-
+
add_modules_conf(options);
return RETURN_OK;
diff --git a/mdk-stage1/modules.h b/mdk-stage1/modules.h
index 74ecc8a57..b1c921b01 100644
--- a/mdk-stage1/modules.h
+++ b/mdk-stage1/modules.h
@@ -22,7 +22,6 @@ void init_modules_insmoding(void);
int my_insmod(const char * mod_name, enum driver_type type, char * options);
enum return_type ask_insmod(enum driver_type);
-
struct module_deps_elem {
char * name;
char ** deps;
diff --git a/mdk-stage1/stage1.c b/mdk-stage1/stage1.c
index 6da2b5ad6..9ed4cc492 100644
--- a/mdk-stage1/stage1.c
+++ b/mdk-stage1/stage1.c
@@ -43,6 +43,8 @@
#include "modules.h"
#include "tools.h"
#include "automatic.h"
+#include "mount.h"
+#include "insmod-busybox/insmod.h"
#ifndef DISABLE_CDROM
#include "cdrom.h"
@@ -71,7 +73,7 @@ void fatal_error(char *msg)
/* spawns a shell on console #2 */
-void spawn_shell(void)
+static void spawn_shell(void)
{
int fd;
pid_t pid;
@@ -109,7 +111,61 @@ void spawn_shell(void)
}
-enum return_type method_select_and_prepare(void)
+static void expert_third_party_modules(void)
+{
+ enum return_type results;
+ char * floppy_mount_location = "/tmp/floppy";
+ char ** modules;
+ char final_name[500] = "/tmp/floppy/";
+ char * choice;
+ int rc;
+ char * questions[] = { "Options", NULL };
+ char ** answers;
+
+ 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("/dev/fd0", floppy_mount_location, "ext2") == -1) {
+ error_message("I can't find a Linux ext2 floppy in first floppy drive.");
+ return expert_third_party_modules();
+ }
+
+ modules = list_directory("/tmp/floppy");
+
+ if (!modules || !*modules) {
+ 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;
+ }
+
+ strcat(final_name, choice);
+
+ results = ask_from_entries("Please enter the options:", questions, &answers, 24);
+ if (results != RETURN_OK) {
+ umount(floppy_mount_location);
+ return expert_third_party_modules();
+ }
+
+ rc = insmod_call(final_name, answers[0]);
+ umount(floppy_mount_location);
+
+ if (rc) {
+ log_message("\tfailed.");
+ error_message("Insmod failed.");
+ }
+
+ return expert_third_party_modules();
+}
+
+static enum return_type method_select_and_prepare(void)
{
enum return_type results;
char * choice;
@@ -194,6 +250,9 @@ int main(int argc, char **argv, char **env)
init_modules_insmoding();
init_frontend();
+ if (IS_EXPERT)
+ expert_third_party_modules();
+
ret = method_select_and_prepare();
finish_frontend();
diff --git a/mdk-stage1/tools.c b/mdk-stage1/tools.c
index 7266409c5..2a50c0ee4 100644
--- a/mdk-stage1/tools.c
+++ b/mdk-stage1/tools.c
@@ -27,6 +27,8 @@
#include <string.h>
#include <ctype.h>
#include <stdio.h>
+#include <dirent.h>
+#include <sys/types.h>
#include <zlib.h>
#include "stage1.h"
#include "log.h"
@@ -337,3 +339,22 @@ void add_to_env(char * name, char * value)
env_size++;
my_env[env_size] = NULL;
}
+
+
+char ** list_directory(char * direct)
+{
+ char * tmp[500];
+ int i = 0;
+ struct dirent *ep;
+ DIR *dp = opendir(direct);
+ while (dp && (ep = readdir(dp))) {
+ if (strcmp(ep->d_name, ".") && strcmp(ep->d_name, "..")) {
+ tmp[i] = strdup(ep->d_name);
+ i++;
+ }
+ }
+ if (dp)
+ closedir(dp);
+ tmp[i] = NULL;
+ return memdup(tmp, sizeof(char*) * (i+1));
+}
diff --git a/mdk-stage1/tools.h b/mdk-stage1/tools.h
index 5efe5a64f..8ec084451 100644
--- a/mdk-stage1/tools.h
+++ b/mdk-stage1/tools.h
@@ -38,6 +38,7 @@ void * memdup(void *src, size_t size);
void add_to_env(char * name, char * value);
void handle_env(char ** env);
char ** grab_env(void);
+char ** list_directory(char * direct);
struct param_elem
{