summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2003-10-22 22:34:33 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2003-10-22 22:34:33 +0000
commit09724beb3ec13988de95fed30e51935ef9f0f436 (patch)
treeb73b2ed850bf4141d656d7c3a997bec53e971bbc /mdk-stage1
parent080a042d018b681a0007c18f5656a384a99689e3 (diff)
downloaddrakx-09724beb3ec13988de95fed30e51935ef9f0f436.tar
drakx-09724beb3ec13988de95fed30e51935ef9f0f436.tar.gz
drakx-09724beb3ec13988de95fed30e51935ef9f0f436.tar.bz2
drakx-09724beb3ec13988de95fed30e51935ef9f0f436.tar.xz
drakx-09724beb3ec13988de95fed30e51935ef9f0f436.zip
copy boot live tree into memory to much speed up startup time in cdrom mode
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/stage1.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/mdk-stage1/stage1.c b/mdk-stage1/stage1.c
index 21bfb3a6d..2989386d9 100644
--- a/mdk-stage1/stage1.c
+++ b/mdk-stage1/stage1.c
@@ -397,7 +397,8 @@ int mandrake_move_post(void)
char rootdev[] = "0x0100";
int boot__real_is_symlink_to_raw = 0;
int main__real_is_symlink_to_raw = 0;
- char* clp = IMAGE_LOCATION "/live_tree_boot.clp";
+ char* clp = IMAGE_LOCATION "/live_tree_boot.clp";
+ char* clp_tmpfs = SLASH_LOCATION "/live_tree_boot.clp";
char* live = IMAGE_LOCATION "/live_tree_boot/usr/bin/runstage2.pl";
if (IS_LIVE || access(clp, R_OK)) {
@@ -412,8 +413,43 @@ int mandrake_move_post(void)
return RETURN_ERROR;
}
- if (lomount(clp, BOOT_LOCATION, NULL, 1))
- stg1_error_message("Could not mount boot compressed loopback :(.");
+ {
+ FILE * from, * to;
+ size_t quantity __attribute__((aligned(16)));
+ size_t overall __attribute__((aligned(16))) = 0;
+ char buf[4096] __attribute__((aligned(4096)));
+
+ log_message("move: copying live_tree_boot.clp to tmpfs");
+ if (scall(!(from = fopen(clp, "rb")), "fopen"))
+ return RETURN_ERROR;
+ if (scall(!(to = fopen(clp_tmpfs, "w")), "fopen"))
+ return RETURN_ERROR;
+
+ init_progression("Loading startup program into memory...", file_size(clp));
+
+ do {
+ if ((quantity = fread(buf, 1, sizeof(buf), from)) > 0) {
+ if (fwrite(buf, 1, quantity, to) != quantity) {
+ log_message("short write (%s)", strerror(errno));
+ return RETURN_ERROR;
+ }
+ }
+ overall += quantity;
+ update_progression(overall);
+ } while (!feof(from) && !ferror(from) && !ferror(to));
+
+ end_progression();
+
+ if (ferror(from) || ferror(to)) {
+ log_message("an error occured while copying live_tree_boot.clp (%s)", strerror(errno));
+ return RETURN_ERROR;
+ }
+ fclose(from);
+ fclose(to);
+
+ if (lomount(clp_tmpfs, BOOT_LOCATION, NULL, 1))
+ stg1_error_message("Could not mount boot compressed loopback :(.");
+ }
live_tree_clp:
clp = IMAGE_LOCATION "/live_tree.clp";