diff options
author | Guillaume Cottenceau <gc@mandriva.com> | 2003-10-22 19:17:52 +0000 |
---|---|---|
committer | Guillaume Cottenceau <gc@mandriva.com> | 2003-10-22 19:17:52 +0000 |
commit | 287245dab721c6049a946dffb32152fc2839c015 (patch) | |
tree | 30f930d553eef13c637ad93daac3b44414a2155b | |
parent | a10fa197aa09ed22806d4677093d5ce44c5ec266 (diff) | |
download | drakx-287245dab721c6049a946dffb32152fc2839c015.tar drakx-287245dab721c6049a946dffb32152fc2839c015.tar.gz drakx-287245dab721c6049a946dffb32152fc2839c015.tar.bz2 drakx-287245dab721c6049a946dffb32152fc2839c015.tar.xz drakx-287245dab721c6049a946dffb32152fc2839c015.zip |
handle "boot" clp and "main" clp. passing argument "live" can force to not use the clp in favor of live tree.
-rw-r--r-- | mdk-stage1/Makefile | 2 | ||||
-rw-r--r-- | mdk-stage1/config-stage1.h | 1 | ||||
-rw-r--r-- | mdk-stage1/log.c | 2 | ||||
-rw-r--r-- | mdk-stage1/log.h | 2 | ||||
-rw-r--r-- | mdk-stage1/network.c | 2 | ||||
-rw-r--r-- | mdk-stage1/stage1.c | 63 | ||||
-rw-r--r-- | mdk-stage1/stage1.h | 2 | ||||
-rw-r--r-- | mdk-stage1/tools.c | 3 | ||||
-rw-r--r-- | mdk-stage1/tools.h | 2 |
9 files changed, 57 insertions, 22 deletions
diff --git a/mdk-stage1/Makefile b/mdk-stage1/Makefile index bb63f5c07..d04c176e5 100644 --- a/mdk-stage1/Makefile +++ b/mdk-stage1/Makefile @@ -57,7 +57,7 @@ ifeq (i386, $(ARCH)) INITSRC = minilibc.c init.c INIT_DEFS = -DINIT_HEADERS=\"minilibc.h\" -fno-builtin INIT_DEFS_ADD = -DBINARY=\"/sbin/stage1\" -INIT_DEFS_ADD_MANDRAKE_MOVE = -DBINARY=\"/usr/bin/runstage2\" +INIT_DEFS_ADD_MANDRAKE_MOVE = -DBINARY=\"/usr/bin/runstage2.pl\" else ifeq (x86_64, $(ARCH)) INITSRC = minilibc.c init.c diff --git a/mdk-stage1/config-stage1.h b/mdk-stage1/config-stage1.h index 57041bfa5..68ffbff2a 100644 --- a/mdk-stage1/config-stage1.h +++ b/mdk-stage1/config-stage1.h @@ -38,6 +38,7 @@ #define SLASH_LOCATION "/sysroot" #define RAW_LOCATION_REL "/image_raw" #define LIVE_LOCATION_REL "/image" +#define BOOT_LOCATION "/sysroot/image_boot" #else #define DISTRIB_NAME "Mandrake Linux" #define IMAGE_LOCATION "/tmp/image" diff --git a/mdk-stage1/log.c b/mdk-stage1/log.c index 0404ba46b..e41653305 100644 --- a/mdk-stage1/log.c +++ b/mdk-stage1/log.c @@ -67,7 +67,7 @@ void log_message(const char * s, ...) return; } -void log_perror(char *msg) +void log_perror(const char *msg) { log_message("%s: %s", msg, strerror(errno)); } diff --git a/mdk-stage1/log.h b/mdk-stage1/log.h index 90aa3f6e6..ca4f54ebc 100644 --- a/mdk-stage1/log.h +++ b/mdk-stage1/log.h @@ -27,7 +27,7 @@ void log_message(const char * s, ...) __attribute__ ((format (printf, 1, 2))); void vlog_message(const char * s, va_list args); -void log_perror(char *msg); +void log_perror(const char *msg); void open_log(void); void close_log(void); diff --git a/mdk-stage1/network.c b/mdk-stage1/network.c index f6834c55b..ca438736b 100644 --- a/mdk-stage1/network.c +++ b/mdk-stage1/network.c @@ -661,7 +661,7 @@ enum return_type nfs_prepare(void) } #ifdef MANDRAKE_MOVE - if (access(IMAGE_LOCATION "/usr/bin/runstage2", R_OK) && access(IMAGE_LOCATION "/live_tree.clp", R_OK)) { + if (access(IMAGE_LOCATION "/live_tree/etc/fstab", R_OK) && access(IMAGE_LOCATION "/live_tree.clp", R_OK)) { #else if (access(IMAGE_LOCATION LIVE_LOCATION, R_OK)) { #endif diff --git a/mdk-stage1/stage1.c b/mdk-stage1/stage1.c index 46b08be2c..21bfb3a6d 100644 --- a/mdk-stage1/stage1.c +++ b/mdk-stage1/stage1.c @@ -388,29 +388,53 @@ int mandrake_move_pre(void) return RETURN_OK; } + int mandrake_move_post(void) { FILE *f; char buf[5000]; int fd; char rootdev[] = "0x0100"; - int real_is_symlink_to_raw = 0; + 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* live = IMAGE_LOCATION "/live_tree_boot/usr/bin/runstage2.pl"; + + if (IS_LIVE || access(clp, R_OK)) { + log_message("no %s found (or disabled), trying to fallback on plain tree", clp); + if (!access(live, R_OK)) { + if (scall(symlink(IMAGE_LOCATION "/live_tree_boot", BOOT_LOCATION), "symlink")) + return RETURN_ERROR; + boot__real_is_symlink_to_raw = 1; + goto live_tree_clp; + } + log_message("move: panic, can't find %s nor %s", clp, live); + return RETURN_ERROR; + } - if (!access(IMAGE_LOCATION "/move/symlinks", R_OK)) { - log_message("move: seems we don't use a gzloop since " IMAGE_LOCATION "/move/symlinks is here"); - if (scall(symlink(IMAGE_LOCATION, IMAGE_LOCATION_REAL), "symlink")) - return RETURN_ERROR; - real_is_symlink_to_raw = 1; - } else { - if (access(IMAGE_LOCATION "/live_tree.clp", R_OK)) { - log_message("move: panic, " IMAGE_LOCATION "/move/symlinks isn't here but " IMAGE_LOCATION "/live_tree.clp neither"); - return RETURN_ERROR; - } else { - if (lomount(IMAGE_LOCATION "/live_tree.clp", IMAGE_LOCATION_REAL, 1)) - stg1_error_message("Could not mount compressed loopback :(."); + if (lomount(clp, BOOT_LOCATION, NULL, 1)) + stg1_error_message("Could not mount boot compressed loopback :(."); + + live_tree_clp: + clp = IMAGE_LOCATION "/live_tree.clp"; + live = IMAGE_LOCATION "/live_tree/etc/fstab"; + if (IS_LIVE || access(clp, R_OK)) { + log_message("no %s found (or disabled), trying to fallback on plain tree", clp); + if (!access(live, R_OK)) { + if (scall(symlink(IMAGE_LOCATION "/live_tree", IMAGE_LOCATION_REAL), "symlink")) + return RETURN_ERROR; + main__real_is_symlink_to_raw = 1; + goto live_tree_ok; } + log_message("move: panic, can't find %s nor %s", clp, live); + return RETURN_ERROR; } + if (lomount(clp, IMAGE_LOCATION_REAL, NULL, 1)) + stg1_error_message("Could not mount main compressed loopback :(."); + + +live_tree_ok: if (scall(!(f = fopen(IMAGE_LOCATION_REAL "/move/symlinks", "rb")), "fopen")) return RETURN_ERROR; while (fgets(buf, sizeof(buf), f)) { @@ -441,13 +465,20 @@ int mandrake_move_post(void) } fclose(f); - if (real_is_symlink_to_raw) { + if (boot__real_is_symlink_to_raw) { + if (scall(unlink(BOOT_LOCATION), "unlink")) + return RETURN_ERROR; + if (scall(symlink(RAW_LOCATION_REL "/live_tree_boot", BOOT_LOCATION), "symlink")) + return RETURN_ERROR; + } + + if (main__real_is_symlink_to_raw) { if (scall(unlink(IMAGE_LOCATION_REAL), "unlink")) return RETURN_ERROR; - if (scall(symlink(RAW_LOCATION_REL, IMAGE_LOCATION_REAL), "symlink")) + if (scall(symlink(RAW_LOCATION_REL "/live_tree", IMAGE_LOCATION_REAL), "symlink")) return RETURN_ERROR; } - + log_message("move: pivot_rooting"); // trick so that kernel won't try to mount the root device when initrd exits if (scall((fd = open("/proc/sys/kernel/real-root-dev", O_WRONLY)) < 0, "open")) diff --git a/mdk-stage1/stage1.h b/mdk-stage1/stage1.h index 94f99e7c7..0b47b7b93 100644 --- a/mdk-stage1/stage1.h +++ b/mdk-stage1/stage1.h @@ -36,6 +36,7 @@ extern char * stage2_kickstart; #define MODE_EXPERT (1 << 1) #define MODE_RESCUE (1 << 3) #define MODE_AUTOMATIC (1 << 4) +#define MODE_LIVE (1 << 5) #define MODE_SPECIAL_STAGE2 (1 << 8) #define MODE_RAMDISK (1 << 9) #define MODE_CHANGEDISK (1 << 10) @@ -48,6 +49,7 @@ extern char * stage2_kickstart; #define IS_EXPERT (get_param(MODE_EXPERT)) #define IS_RESCUE (get_param(MODE_RESCUE)) #define IS_AUTOMATIC (get_param(MODE_AUTOMATIC)) +#define IS_LIVE (get_param(MODE_LIVE)) #define IS_SPECIAL_STAGE2 (get_param(MODE_SPECIAL_STAGE2)) #define IS_RAMDISK (get_param(MODE_RAMDISK)) #define IS_CHANGEDISK (get_param(MODE_CHANGEDISK)) diff --git a/mdk-stage1/tools.c b/mdk-stage1/tools.c index 89c87fbd1..aa9be8f83 100644 --- a/mdk-stage1/tools.c +++ b/mdk-stage1/tools.c @@ -94,6 +94,7 @@ void process_cmdline(void) if (!strcmp(name, "netauto")) set_param(MODE_NETAUTO); if (!strcmp(name, "recovery")) set_param(MODE_RECOVERY); if (!strcmp(name, "special_stage2")) set_param(MODE_SPECIAL_STAGE2); + if (!strcmp(name, "live")) set_param(MODE_LIVE); if (!strcmp(name, "automatic")) { set_param(MODE_AUTOMATIC); grab_automatic_params(value); @@ -180,7 +181,7 @@ void unset_param(int i) // warning, many things rely on the fact that: // - when failing it returns 0 // - it stops on first non-digit char -int charstar_to_int(char * s) +int charstar_to_int(const char * s) { int number = 0; while (*s && isdigit(*s)) { diff --git a/mdk-stage1/tools.h b/mdk-stage1/tools.h index c6c9aea14..9da8c3445 100644 --- a/mdk-stage1/tools.h +++ b/mdk-stage1/tools.h @@ -28,7 +28,7 @@ void process_cmdline(void); int get_param(int i); void set_param(int i); void unset_param(int i); -int charstar_to_int(char * s); +int charstar_to_int(const char * s); int total_memory(void); int ramdisk_possible(void); char * get_ramdisk_realname(void); |