summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/disk.c
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1/disk.c')
-rw-r--r--mdk-stage1/disk.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/mdk-stage1/disk.c b/mdk-stage1/disk.c
index b1de270d4..51a033639 100644
--- a/mdk-stage1/disk.c
+++ b/mdk-stage1/disk.c
@@ -1,5 +1,5 @@
/*
- * Guillaume Cottenceau (gc@mandriva.com)
+ * Guillaume Cottenceau (gc)
*
* Copyright 2000 Mandriva
*
@@ -19,14 +19,14 @@
*
*/
+#define _GNU_SOURCE /* We want the non segfaulting my_dirname() -- See dirname(3) */
+#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
-#include <string.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <string.h>
#include <libgen.h>
#include "stage1.h"
#include "frontend.h"
@@ -45,6 +45,13 @@
static enum return_type try_automatic_with_partition(char *dev) {
enum return_type results;
int mounted;
+ char *dir= get_auto_value("directory");
+ char location_full[500];
+ strcpy(location_full, MEDIA_LOCATION);
+ if (dir) {
+ strcat(location_full, "/");
+ strcat(location_full, dir);
+ }
wait_message("Trying to access " DISTRIB_NAME " disk (partition %s)", dev);
mounted = !try_mount(dev, MEDIA_LOCATION);
remove_wait_message();
@@ -52,11 +59,13 @@ static enum return_type try_automatic_with_partition(char *dev) {
create_IMAGE_LOCATION(MEDIA_LOCATION);
if (image_has_stage2()) {
results = try_with_directory(MEDIA_LOCATION, "disk", "disk-iso");
- if (results == RETURN_OK) {
- if (!KEEP_MOUNTED)
- umount(MEDIA_LOCATION);
- return RETURN_OK;
- }
+ } else {
+ results = try_with_directory(location_full, "disk", "disk-iso");
+ }
+ if (results == RETURN_OK) {
+ if (!KEEP_MOUNTED)
+ umount(MEDIA_LOCATION);
+ return RETURN_OK;
}
}
if (mounted)
@@ -69,6 +78,7 @@ static enum return_type try_automatic_with_disk(char *disk, char *model) {
char * parts_comments[50];
enum return_type results;
char **dev;
+ char *part = get_auto_value("partition");
wait_message("Trying to access " DISTRIB_NAME " disk (drive %s)", model);
if (list_partitions(disk, parts, parts_comments)) {
stg1_error_message("Could not read partitions information.");
@@ -77,10 +87,13 @@ static enum return_type try_automatic_with_disk(char *disk, char *model) {
remove_wait_message();
dev = parts;
while (dev && *dev) {
+ if (part && strcmp(part, *dev) != 0)
+ goto next;
results = try_automatic_with_partition(*dev);
if (results == RETURN_OK) {
return RETURN_OK;
}
+ next:
dev++;
}
return RETURN_ERROR;
@@ -90,11 +103,15 @@ static enum return_type try_automatic(char ** medias, char ** medias_models)
{
char ** model = medias_models;
char ** ptr = medias;
+ char *disk = get_auto_value("disk");
while (ptr && *ptr) {
enum return_type results;
+ if (disk && strcmp(disk, *ptr) != 0)
+ goto next;
results = try_automatic_with_disk(*ptr, *model);
if (results == RETURN_OK)
return RETURN_OK;
+ next:
ptr++;
model++;
}
@@ -134,7 +151,7 @@ static enum return_type try_with_device(char *dev_name)
/* in testing mode, assume the partition is already mounted on MEDIA_LOCATION */
if (!IS_TESTING && try_mount(choice, MEDIA_LOCATION)) {
- stg1_error_message("I can't find a valid filesystem (tried: ext2, vfat, ntfs, reiserfs). "
+ stg1_error_message("I can't find a valid filesystem (tried: ext4, vfat, ntfs, reiserfs). "
"Make sure the partition has been cleanly unmounted.");
return try_with_device(dev_name);
}
@@ -155,7 +172,7 @@ static enum return_type try_with_device(char *dev_name)
char * path = strdup(answers_location[0]);
stg1_error_message("Directory or ISO image file could not be found on partition.\n"
"Here's a short extract of the files in the directory %s:\n"
- "%s", dirname(path), extract_list_directory(dirname(location_full)));
+ "%s", my_dirname(path), extract_list_directory(my_dirname(location_full)));
free(path);
goto ask_dir;
}
@@ -191,7 +208,7 @@ enum return_type disk_prepare(void)
if (count == 0) {
if (!already_probed_ide_generic) {
already_probed_ide_generic = 1;
- my_insmod("ide_generic", ANY_DRIVER_TYPE, NULL, 0);
+ my_modprobe("ide_generic", ANY_DRIVER_TYPE, NULL);
return disk_prepare();
}
stg1_error_message("No DISK drive found.");