summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2000-12-18 21:16:09 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2000-12-18 21:16:09 +0000
commit890d160fcee9258d6079c64b51a67cccc596cc95 (patch)
tree7de458e05dcd401773f7918d30f6a6140d8c3941 /mdk-stage1
parent478632060840a9dd32a64325d59819bd2025217a (diff)
downloaddrakx-890d160fcee9258d6079c64b51a67cccc596cc95.tar
drakx-890d160fcee9258d6079c64b51a67cccc596cc95.tar.gz
drakx-890d160fcee9258d6079c64b51a67cccc596cc95.tar.bz2
drakx-890d160fcee9258d6079c64b51a67cccc596cc95.tar.xz
drakx-890d160fcee9258d6079c64b51a67cccc596cc95.zip
add disk install support
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/Makefile2
-rw-r--r--mdk-stage1/disk.c96
-rw-r--r--mdk-stage1/mount.c10
-rw-r--r--mdk-stage1/newt-frontend.c2
-rw-r--r--mdk-stage1/probing.c12
-rw-r--r--mdk-stage1/stage1.c4
6 files changed, 103 insertions, 23 deletions
diff --git a/mdk-stage1/Makefile b/mdk-stage1/Makefile
index 55fe0a071..d4a3f2798 100644
--- a/mdk-stage1/Makefile
+++ b/mdk-stage1/Makefile
@@ -108,7 +108,7 @@ LDFLAGS_STAGE1 = -static
endif
-BINS = init stage1-full stage1-cdrom stage1-network
+BINS = init stage1-full stage1-cdrom stage1-network stage1-disk
#ifeq (i386, $(ARCH))
diff --git a/mdk-stage1/disk.c b/mdk-stage1/disk.c
index e539b146a..42943e324 100644
--- a/mdk-stage1/disk.c
+++ b/mdk-stage1/disk.c
@@ -21,19 +21,108 @@
#include <stdlib.h>
#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/mount.h>
#include "stage1.h"
#include "frontend.h"
#include "modules.h"
#include "probing.h"
#include "log.h"
+#include "mount.h"
#include "disk.h"
+
static enum return_type try_with_device(char *dev_name)
{
+ char * questions_location[] = { "Directory", NULL };
+ char ** answers_location;
+ char device_fullname[50];
+ char location_full[50];
+
+ int major, minor, blocks;
+ char name[100];
+
+ char buf[512];
+ FILE * f;
+ char * parts[50];
+ char * parts_comments[50];
+ int i = 0;
+ enum return_type results;
+ char * choice;
+
+ if (!(f = fopen("/proc/partitions", "rb")) || !fgets(buf, sizeof(buf), f) || !fgets(buf, sizeof(buf), f)) {
+ log_perror(dev_name);
+ error_message("Could not read partitions information");
+ return RETURN_ERROR;
+ }
- /* I have to do the partition check here */
+ while (fgets(buf, sizeof(buf), f)) {
+ sscanf(buf, " %d %d %d %s", &major, &minor, &blocks, name);
+ if ((strstr(name, dev_name) == name) && (blocks > 1) && (name[strlen(dev_name)] != '\0')) {
+ parts[i] = strdup(name);
+ parts_comments[i] = (char *) malloc(sizeof(char) * 25);
+ snprintf(parts_comments[i], 24, "size: %d blocks", blocks);
+ i++;
+ }
+ }
+ parts[i] = NULL;
+ fclose(f);
+
+ results = ask_from_list_comments("Please choose the partition to use for the installation.", parts, parts_comments, &choice);
+ if (results != RETURN_OK)
+ return results;
+
+ strcpy(device_fullname, "/dev/");
+ strcat(device_fullname, choice);
+
+ if (my_mount(device_fullname, "/tmp/disk", "ext2") == -1 &&
+ my_mount(device_fullname, "/tmp/disk", "vfat") == -1 &&
+ my_mount(device_fullname, "/tmp/disk", "reiserfs") == -1) {
+ error_message("I can't find a valid filesystem.");
+ return try_with_device(dev_name);
+ }
+ results = ask_from_entries("Please enter the directory containing the Linux-Mandrake installation.",
+ questions_location, &answers_location, 24);
+ if (results != RETURN_OK) {
+ umount("/tmp/disk");
+ return try_with_device(dev_name);
+ }
+
+ strcpy(location_full, "/tmp/disk/");
+ strcat(location_full, answers_location[0]);
+
+ if (access(location_full, R_OK)) {
+ umount("/tmp/disk");
+ error_message("Directory could not be found on partition.");
+ return try_with_device(dev_name);
+ }
+
+ unlink("/tmp/image");
+ symlink(location_full, "/tmp/image");
+
+ if (access("/tmp/image/Mandrake/mdkinst", R_OK)) {
+ umount("/tmp/disk");
+ unlink("/tmp/image");
+ error_message("I can't find the Linux-Mandrake installation in the specified directory.");
+ return try_with_device(dev_name);
+ }
+
+ log_message("found the Linux-Mandrake Installation, good news!");
+
+ if (IS_SPECIAL_STAGE2) {
+ if (load_ramdisk() != RETURN_OK) {
+ error_message("Could not load program into memory");
+ return try_with_device(dev_name);
+ }
+ }
+
+ if (IS_RESCUE)
+ umount("/tmp/image"); /* TOCHECK */
+
+ method_name = strdup("disk");
return RETURN_OK;
}
@@ -44,12 +133,7 @@ enum return_type disk_prepare(void)
int i, count = 0;
enum return_type results;
- error_message("Currently unsupported");
- return RETURN_ERROR;
-
my_insmod("sd_mod");
- my_insmod("vfat");
- my_insmod("reiserfs");
get_medias(DISK, &medias, &medias_models);
diff --git a/mdk-stage1/mount.c b/mdk-stage1/mount.c
index ade92adf5..93500a34f 100644
--- a/mdk-stage1/mount.c
+++ b/mdk-stage1/mount.c
@@ -120,17 +120,17 @@ int my_mount(char *dev, char *location, char *fs)
if (stat(location, &buf)) {
if (mkdir(location, 0755)) {
- log_message("could not create location dir");
+ log_perror("could not create location dir");
return -1;
}
} else if (!S_ISDIR(buf.st_mode)) {
log_message("not a dir %s, will unlink and mkdir", location);
if (unlink(location)) {
- log_message("could not unlink %s", location);
+ log_perror("could not unlink");
return -1;
}
if (mkdir(location, 0755)) {
- log_message("could not create location dir");
+ log_perror("could not create location dir");
return -1;
}
}
@@ -143,6 +143,10 @@ int my_mount(char *dev, char *location, char *fs)
opts = "check=relaxed";
}
+ if (!strcmp(fs, "reiserfs")) {
+ my_insmod("reiserfs");
+ }
+
if (!strcmp(fs, "iso9660")) {
my_insmod("isofs");
flags |= MS_RDONLY;
diff --git a/mdk-stage1/newt-frontend.c b/mdk-stage1/newt-frontend.c
index d44911c61..f0a373357 100644
--- a/mdk-stage1/newt-frontend.c
+++ b/mdk-stage1/newt-frontend.c
@@ -157,7 +157,7 @@ enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_
i = 0;
while (elems && *elems) {
- items[i] = malloc(sizeof(char) * (strlen(*elems) + strlen(*elems_comments) + 3));
+ items[i] = malloc(sizeof(char) * (strlen(*elems) + strlen(*elems_comments) + 4));
strcpy(items[i], *elems);
strcat(items[i], " (");
strcat(items[i], *elems_comments);
diff --git a/mdk-stage1/probing.c b/mdk-stage1/probing.c
index 83257ae39..16f9ebb06 100644
--- a/mdk-stage1/probing.c
+++ b/mdk-stage1/probing.c
@@ -55,19 +55,11 @@ void probe_that_type(enum driver_type type)
ask_insmod(type);
else {
/* ---- PCI probe */
- char * mytype;
FILE * f;
int len = 0;
char buf[200];
struct pci_module_map * pcidb = NULL;
- if (type == SCSI_ADAPTERS)
- mytype = "SCSI";
- else if (type == NETWORK_DEVICES)
- mytype = "NET";
- else
- return;
-
f = fopen("/proc/bus/pci/devices", "rb");
if (!f) {
@@ -105,7 +97,7 @@ void probe_that_type(enum driver_type type)
#ifndef DISABLE_MEDIAS
if (type == SCSI_ADAPTERS) {
/* insmod takes time, let's use the wait message */
- wait_message("Installing %s driver for %s", mytype, pcidb[i].name);
+ wait_message("Installing %s", pcidb[i].name);
my_insmod(pcidb[i].module);
remove_wait_message();
}
@@ -113,7 +105,7 @@ void probe_that_type(enum driver_type type)
#ifndef DISABLE_NETWORK
if (type == NETWORK_DEVICES) {
/* insmod is quick, let's use the info message */
- info_message("Found %s driver for %s", mytype, pcidb[i].name);
+ info_message("Found %s", pcidb[i].name);
my_insmod(pcidb[i].module);
}
#endif
diff --git a/mdk-stage1/stage1.c b/mdk-stage1/stage1.c
index 50f04ad53..93aae9338 100644
--- a/mdk-stage1/stage1.c
+++ b/mdk-stage1/stage1.c
@@ -145,7 +145,7 @@ enum return_type method_select_and_prepare(void)
results = ask_from_list_auto("Please choose the mean of installation.", means, &choice, "method", means_auto);
if (results != RETURN_OK)
- return results;
+ return method_select_and_prepare();
results = RETURN_ERROR;
@@ -171,7 +171,7 @@ enum return_type method_select_and_prepare(void)
#endif
if (results != RETURN_OK)
- method_select_and_prepare();
+ return method_select_and_prepare();
return RETURN_OK;
}