From c199c141b529a18a734f543c7c4ba1cfee1a4734 Mon Sep 17 00:00:00 2001 From: Sergey Bolshakov Date: Thu, 3 Feb 2005 15:38:15 +0000 Subject: [PATCH] - do not die when couldn't open console rw - losetup tweaks --- cdrom.c | 8 ++------ config-stage1.h | 4 ---- disk.c | 1 - init.c | 15 +++++++-------- network.c | 1 - tools.c | 5 +++-- 6 files changed, 12 insertions(+), 22 deletions(-) diff --git a/cdrom.c b/cdrom.c index cf02d1b..a3da6ec 100644 --- a/cdrom.c +++ b/cdrom.c @@ -72,12 +72,9 @@ static enum return_type do_with_device(char * dev_name, char * dev_model) umount(IMAGE_LOCATION); } - insmod_compressed(); do_losetup(LIVE_DEVICE,get_ramdisk_path(NULL)); - if(IS_LIVE) - my_mount(LIVE_DEVICE,STAGE2_LOCATION,LIVEFS, 0); - else - my_mount(LIVE_DEVICE,STAGE2_LOCATION,STAGE2FS, 0); + my_mount(LIVE_DEVICE, STAGE2_LOCATION, (IS_LIVE) ? LIVEFS : STAGE2FS, 0); + method_name = strdup("cdrom"); add_to_env("METHOD", method_name); add_to_env("PREFIX", "/"); @@ -115,7 +112,6 @@ enum return_type cdrom_prepare(void) my_insmod("ide-cd", ANY_DRIVER_TYPE, NULL); my_insmod("sr_mod", ANY_DRIVER_TYPE, NULL); - insmod_compressed(); get_medias(CDROM, &medias, &medias_models); diff --git a/config-stage1.h b/config-stage1.h index fc20558..718d8bf 100644 --- a/config-stage1.h +++ b/config-stage1.h @@ -24,8 +24,6 @@ /* If we have more than that amount of memory (in Mbytes), we assume we can load the rescue as a ramdisk */ #define MEM_LIMIT_RESCUE 56 -// #define DISTRIB_NAME "ALT Linux Junior 2.2" - #define RAMDISK_COMPRESSION_RATIO 1.95 #define VERSION_FILE "/.VERSION" @@ -38,8 +36,6 @@ #ifndef STAGE2_BINNAME #define STAGE2_BINNAME "/sbin/init" #endif -#define insmod_compressed() { my_insmod("zlib_inflate", ANY_DRIVER_TYPE, NULL); my_insmod("cloop", ANY_DRIVER_TYPE, NULL); } - /* user-definable (in Makefile): DISABLE_NETWORK, DISABLE_DISK, DISABLE_CDROM, DISABLE_PCMCIA */ diff --git a/disk.c b/disk.c index ac852a8..a575a6b 100644 --- a/disk.c +++ b/disk.c @@ -271,7 +271,6 @@ static enum return_type try_with_device(char *dev_name) log_message("found the " DISTRIB_NAME " Installation, good news!"); } - insmod_compressed(); do_losetup(LIVE_DEVICE, get_ramdisk_path(iso ? NULL : location_full)); my_mount(LIVE_DEVICE,STAGE2_LOCATION, (IS_LIVE) ? LIVEFS : STAGE2FS, 0); diff --git a/init.c b/init.c index 4582a23..2006883 100644 --- a/init.c +++ b/init.c @@ -543,17 +543,16 @@ int main(int argc, char **argv) fatal_error("overmounting root"); /* chroot, chdir */ - if ( chroot(".") || chdir("/") ) + if (chroot(".") || chdir("/")) fatal_error("chroot"); /* Open /dev/console */ - if ( (fd = open("/dev/console", O_RDWR)) < 0 ) - fatal_error("opening console"); - - dup2(fd, 0); - dup2(fd, 1); - dup2(fd, 2); - close(fd); + if ((fd = open("/dev/console", O_RDWR)) != -1) { + dup2(fd, 0); + dup2(fd, 1); + dup2(fd, 2); + close(fd); + } /* Check for given init */ if (stat(stage2_argv[0], &ist) || !S_ISREG(ist.st_mode)) diff --git a/network.c b/network.c index 81fadee..17cf8a3 100644 --- a/network.c +++ b/network.c @@ -672,7 +672,6 @@ enum return_type nfs_prepare(void) if (S_ISDIR(st.st_mode)) { mount(ramdisk_path, STAGE2_LOCATION, NULL, MS_BIND, NULL); } else { - insmod_compressed(); do_losetup(LIVE_DEVICE,ramdisk_path); my_mount(LIVE_DEVICE, STAGE2_LOCATION, (IS_LIVE) ? LIVEFS : STAGE2FS, 0); } diff --git a/tools.c b/tools.c index 7612fc2..551fa81 100644 --- a/tools.c +++ b/tools.c @@ -292,8 +292,6 @@ enum return_type load_ramdisk_fd(int source_fd, int size) close(ram_fd); - insmod_compressed(); - if (do_losetup(LIVE_DEVICE, ramdisk) == -1) fatal_error("could not setup loopback for loaded second stage"); @@ -457,6 +455,9 @@ int do_losetup(char * device, char * target) { int loopfd, targfd; struct loop_info loopInfo; + + my_insmod("cloop", ANY_DRIVER_TYPE, NULL); + loopfd = open( device, O_RDONLY ); if ( loopfd < 0 ) {