summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/disk.c
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/disk.c
parent478632060840a9dd32a64325d59819bd2025217a (diff)
downloaddrakx-backup-do-not-use-890d160fcee9258d6079c64b51a67cccc596cc95.tar
drakx-backup-do-not-use-890d160fcee9258d6079c64b51a67cccc596cc95.tar.gz
drakx-backup-do-not-use-890d160fcee9258d6079c64b51a67cccc596cc95.tar.bz2
drakx-backup-do-not-use-890d160fcee9258d6079c64b51a67cccc596cc95.tar.xz
drakx-backup-do-not-use-890d160fcee9258d6079c64b51a67cccc596cc95.zip
add disk install support
Diffstat (limited to 'mdk-stage1/disk.c')
-rw-r--r--mdk-stage1/disk.c96
1 files changed, 90 insertions, 6 deletions
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);