summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mdk-stage1/config-stage1.h6
-rw-r--r--mdk-stage1/stage1.c50
-rw-r--r--mdk-stage1/tools.c53
-rw-r--r--mdk-stage1/tools.h3
4 files changed, 78 insertions, 34 deletions
diff --git a/mdk-stage1/config-stage1.h b/mdk-stage1/config-stage1.h
index 707672bcc..e908ff1aa 100644
--- a/mdk-stage1/config-stage1.h
+++ b/mdk-stage1/config-stage1.h
@@ -31,13 +31,19 @@
#define SLASH_LOCATION "/sysroot"
#ifdef MANDRAKE_MOVE
+
#define MEM_LIMIT_MOVE 120
#define DISTRIB_NAME "Mandrakemove"
+
#define IMAGE_LOCATION_DIR SLASH_LOCATION "/"
#define IMAGE_LOCATION_REL "cdrom"
#define IMAGE_LOCATION IMAGE_LOCATION_DIR IMAGE_LOCATION_REL
+
+#define CLP_LOCATION IMAGE_LOCATION
+
#define STAGE2_LOCATION_ROOTED "/image"
#define STAGE2_LOCATION SLASH_LOCATION STAGE2_LOCATION_ROOTED
+
#define BOOT_LOCATION SLASH_LOCATION "/image_boot"
#define ALWAYS_LOCATION SLASH_LOCATION "/image_always"
#define TOTEM_LOCATION SLASH_LOCATION "/image_totem"
diff --git a/mdk-stage1/stage1.c b/mdk-stage1/stage1.c
index 07295afb1..3f4427281 100644
--- a/mdk-stage1/stage1.c
+++ b/mdk-stage1/stage1.c
@@ -45,7 +45,6 @@ _syscall2(int,pivot_root,const char *,new_root,const char *,put_old)
#include "tools.h"
#include "automatic.h"
#include "mount.h"
-#include "lomount.h"
#include "insmod.h"
#ifdef ENABLE_PCMCIA
@@ -418,40 +417,23 @@ enum return_type create_initial_fs(char* symlinks, char* devices)
}
#ifdef MANDRAKE_MOVE
-static enum return_type handle_clp(char* clp, char* live, char* location_live, char* location_mount, int* is_symlink, char* clp_tmpfs)
+static enum return_type handle_move_clp(char* clp_name, char* live, char* location_live, char* location_mount, int* is_symlink, int preload)
{
- static int count = 0;
- if (access(clp, R_OK)) {
- log_message("no %s found (or disabled), trying to fallback on plain tree", clp);
- if (!access(live, R_OK)) {
+ if (mount_clp_may_preload(clp_name, location_mount, preload) == RETURN_OK) {
+ return RETURN_OK;
+ } else {
+ char *full_live = asprintf_("%s%s", location_live, live);
+ log_message("no %s found (or disabled), trying to fallback on plain tree", clp_name);
+ if (!access(full_live, R_OK)) {
if (scall(symlink(location_live, location_mount), "symlink"))
return RETURN_ERROR;
*is_symlink = 1;
return RETURN_OK;
} else {
- log_message("move: can't find %s nor %s, proceeding hoping files will be there", clp, live);
+ log_message("move: can't find %s nor %s, proceeding hoping files will be there", clp_name, full_live);
return RETURN_OK;
}
}
-
- if (clp_tmpfs) {
- int ret;
- char buf[5000];
- sprintf(buf, "Loading (part %d)...", ++count);
- init_progression(buf, file_size(clp));
- ret = copy_file(clp, clp_tmpfs, update_progression);
- end_progression();
- if (ret != RETURN_OK)
- return ret;
- clp = clp_tmpfs;
- }
-
- if (lomount(clp, location_mount, NULL, 1)) {
- stg1_error_message("Could not mount compressed loopback :(.");
- return RETURN_ERROR;
- }
-
- return RETURN_OK;
}
int mandrake_move_post(void)
@@ -461,24 +443,24 @@ int mandrake_move_post(void)
int totem__real_is_symlink_to_raw = 0;
int main__real_is_symlink_to_raw = 0;
- if (handle_clp(IMAGE_LOCATION "/live_tree_boot.clp", IMAGE_LOCATION "/live_tree_boot/usr/bin/runstage2.pl",
+ if (handle_move_clp("live_tree_boot.clp", "/usr/bin/runstage2.pl",
IMAGE_LOCATION "/live_tree_boot", BOOT_LOCATION,
- &boot__real_is_symlink_to_raw, SLASH_LOCATION "/live_tree_boot.clp") != RETURN_OK)
+ &boot__real_is_symlink_to_raw, 1) != RETURN_OK)
return RETURN_ERROR;
- if (handle_clp(IMAGE_LOCATION "/live_tree_always.clp", IMAGE_LOCATION "/live_tree_always/bin/bash",
+ if (handle_move_clp("live_tree_always.clp", "/bin/bash",
IMAGE_LOCATION "/live_tree_always", ALWAYS_LOCATION,
- &always__real_is_symlink_to_raw, SLASH_LOCATION "/live_tree_always.clp") != RETURN_OK)
+ &always__real_is_symlink_to_raw, 1) != RETURN_OK)
return RETURN_ERROR;
- if (handle_clp(IMAGE_LOCATION "/live_tree_totem.clp", IMAGE_LOCATION "/live_tree_totem/usr/bin/totem",
+ if (handle_move_clp("live_tree_totem.clp", "/usr/bin/totem",
IMAGE_LOCATION "/live_tree_totem", TOTEM_LOCATION,
- &totem__real_is_symlink_to_raw, SLASH_LOCATION "/live_tree_totem.clp") != RETURN_OK)
+ &totem__real_is_symlink_to_raw, 1) != RETURN_OK)
return RETURN_ERROR;
- if (handle_clp(IMAGE_LOCATION "/live_tree.clp", IMAGE_LOCATION "/live_tree/etc/fstab",
+ if (handle_move_clp("live_tree.clp", "/etc/fstab",
IMAGE_LOCATION "/live_tree", STAGE2_LOCATION,
- &main__real_is_symlink_to_raw, NULL) != RETURN_OK)
+ &main__real_is_symlink_to_raw, 0) != RETURN_OK)
return RETURN_ERROR;
// in case we didn't mount any clp, because gzloop.o is not available later in /lib/modules
diff --git a/mdk-stage1/tools.c b/mdk-stage1/tools.c
index 9b2eafe0e..49d72dd9e 100644
--- a/mdk-stage1/tools.c
+++ b/mdk-stage1/tools.c
@@ -46,6 +46,7 @@
#include "tools.h"
#include "probing.h"
#include "modules.h"
+#include "lomount.h"
static struct param_elem params[50];
static int param_number = 0;
@@ -297,6 +298,58 @@ enum return_type copy_file(char * from, char * to, void (*callback_func)(int ove
}
}
+#ifdef MANDRAKE_MOVE
+enum return_type mount_clp(char *clp, char *location_mount)
+{
+ if (lomount(clp, location_mount, NULL, 1)) {
+ stg1_error_message("Could not mount compressed loopback :(.");
+ return RETURN_ERROR;
+ }
+ return RETURN_OK;
+}
+
+enum return_type preload_mount_clp(int clp_fd, int clp_size, char *clp_name, char *location_mount)
+{
+ int ret;
+ char *clp_tmpfs = asprintf_("%s/%s", SLASH_LOCATION, clp_name);
+#ifdef MANDRAKE_MOVE
+ static int count = 0;
+ char buf[5000];
+ sprintf(buf, "Loading program into memory (part %d)...", ++count);
+#else
+ char *buf = "Loading program into memory...";
+#endif
+ init_progression(buf, clp_size);
+ ret = save_fd(clp_fd, clp_tmpfs, update_progression);
+ end_progression();
+ if (ret != RETURN_OK)
+ return ret;
+
+ return mount_clp(clp_tmpfs, location_mount);
+}
+
+enum return_type mount_clp_may_preload(char *clp_name, char *location_mount, int preload)
+{
+ char *clp = asprintf_("%s/%s", CLP_LOCATION, clp_name);
+
+ log_message("mount_clp_may_preload: %s into %s (preload = %d)", clp, location_mount, preload);
+
+ if (access(clp, R_OK) != 0) return RETURN_ERROR;
+
+ if (preload) {
+ int clp_fd = open(clp, O_RDONLY);
+ if (clp_fd != -1) {
+ return preload_mount_clp(clp_fd, file_size(clp), clp_name, location_mount);
+ } else {
+ log_perror(clp);
+ return RETURN_ERROR;
+ }
+ } else {
+ return mount_clp(clp, location_mount);
+ }
+}
+#endif
+
#ifndef MANDRAKE_MOVE
static void save_stuff_for_rescue(void)
{
diff --git a/mdk-stage1/tools.h b/mdk-stage1/tools.h
index df2910a73..19e0a4ea1 100644
--- a/mdk-stage1/tools.h
+++ b/mdk-stage1/tools.h
@@ -34,6 +34,9 @@ int total_memory(void);
int image_has_stage2();
int ramdisk_possible(void);
enum return_type copy_file(char * from, char * to, void (*callback_func)(int overall));
+#ifdef MANDRAKE_MOVE
+enum return_type mount_clp_may_preload(char *clp_name, char *location_mount, int preload);
+#endif
#ifndef MANDRAKE_MOVE
char * get_ramdisk_realname(void);
enum return_type load_ramdisk(void);