From 92460f66390ef105485b40c4dd8e98e2e2d60163 Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Fri, 31 Oct 2003 16:13:14 +0000 Subject: save /etc/resolv.conf in move mode --- mdk-stage1/stage1.c | 47 +++++++++++------------------------------------ 1 file changed, 11 insertions(+), 36 deletions(-) (limited to 'mdk-stage1/stage1.c') diff --git a/mdk-stage1/stage1.c b/mdk-stage1/stage1.c index 876c40867..88d4eaf6a 100644 --- a/mdk-stage1/stage1.c +++ b/mdk-stage1/stage1.c @@ -424,6 +424,7 @@ int mandrake_move_post(void) 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"; + int ret; if (IS_LIVE || access(clp, R_OK)) { log_message("no %s found (or disabled), trying to fallback on plain tree", clp); @@ -438,42 +439,13 @@ int mandrake_move_post(void) } } - { - FILE * from, * to; - size_t quantity __attribute__((aligned(16))), overall = 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 :(."); - } + init_progression("Loading startup program into memory...", file_size(clp)); + ret = copy_file(clp, clp_tmpfs, update_progression); + end_progression(); + if (ret != RETURN_OK) + return ret; + if (lomount(clp_tmpfs, BOOT_LOCATION, NULL, 1)) + stg1_error_message("Could not mount boot compressed loopback :(."); handle_clps: if (handle_clp(IMAGE_LOCATION "/live_tree_always.clp", IMAGE_LOCATION "/live_tree_always/bin/bash", @@ -537,6 +509,9 @@ int mandrake_move_post(void) return RETURN_ERROR; } + mkdir(SLASH_LOCATION "/etc", 0755); + copy_file("/etc/resolv.conf", SLASH_LOCATION "/etc/resolv.conf", NULL); + if (IS_DEBUGSTAGE1) while (1); -- cgit v1.2.1