diff options
author | Guillaume Cottenceau <gc@mandriva.com> | 2003-10-09 12:48:38 +0000 |
---|---|---|
committer | Guillaume Cottenceau <gc@mandriva.com> | 2003-10-09 12:48:38 +0000 |
commit | 741ef0405d4b1a177908fb62c9c2ff7c28e77502 (patch) | |
tree | 960b4700bc32c91d0fb0e0d06ed9740f483d1598 /mdk-stage1 | |
parent | df47ba0b2a1d3586dae2ffe55b93dab47ee3f1d3 (diff) | |
download | drakx-741ef0405d4b1a177908fb62c9c2ff7c28e77502.tar drakx-741ef0405d4b1a177908fb62c9c2ff7c28e77502.tar.gz drakx-741ef0405d4b1a177908fb62c9c2ff7c28e77502.tar.bz2 drakx-741ef0405d4b1a177908fb62c9c2ff7c28e77502.tar.xz drakx-741ef0405d4b1a177908fb62c9c2ff7c28e77502.zip |
we need to have an 'init' for stage2 as well, because if we exec directly runinstall2 and it fails/stops for any reason, this will immediately block the kernel ('Attempted to kill init'), making debugging more difficult
Diffstat (limited to 'mdk-stage1')
-rw-r--r-- | mdk-stage1/.cvsignore | 1 | ||||
-rw-r--r-- | mdk-stage1/Makefile | 14 | ||||
-rw-r--r-- | mdk-stage1/init.c | 32 | ||||
-rw-r--r-- | mdk-stage1/minilibc.h | 1 |
4 files changed, 29 insertions, 19 deletions
diff --git a/mdk-stage1/.cvsignore b/mdk-stage1/.cvsignore index d6a8a8434..4594eb719 100644 --- a/mdk-stage1/.cvsignore +++ b/mdk-stage1/.cvsignore @@ -1,4 +1,5 @@ init +init-move stage1-full stage1-cdrom stage1-disk diff --git a/mdk-stage1/Makefile b/mdk-stage1/Makefile index 727c1e2dc..6e5fac7bf 100644 --- a/mdk-stage1/Makefile +++ b/mdk-stage1/Makefile @@ -56,6 +56,8 @@ COMPILE = $(CC) $(DEFS) $(CFLAGS) ifeq (i386, $(ARCH)) INITSRC = minilibc.c init.c INIT_DEFS = -DINIT_HEADERS=\"minilibc.h\" -fno-builtin +INIT_DEFS_ADD = -DBINARY=\"/sbin/stage1\" -DDO_KLOG +INIT_DEFS_ADD_MANDRAKE_MOVE = -DBINARY=\"/usr/bin/install2\" else ifeq (x86_64, $(ARCH)) INITSRC = minilibc.c init.c @@ -71,6 +73,7 @@ endif endif INITOBJS = $(subst .c,.o,$(INITSRC)) +INITOBJS-MANDRAKE_MOVE = $(subst .c,-MOVE.o,$(INITSRC)) #- frontends @@ -161,7 +164,7 @@ endif endif -BINS = init stage1-full +BINS = init init-move stage1-full ifeq (i386, $(ARCH)) BINS += stage1-cdrom stage1-disk stage1-network stage1-network-usb stage1-medias-usb @@ -204,6 +207,10 @@ init: $(INITOBJS) $(INIT_LIBC) $(CC) $(LDFLAGS_INIT) -o $@ $^ $(STRIPCMD) $@ +init-move: $(INITOBJS-MANDRAKE_MOVE) $(INIT_LIBC) + $(CC) $(LDFLAGS_INIT) -o $@ $^ + $(STRIPCMD) $@ + stage1-cdrom: $(STAGE1OBJS-CDROM) $(STAGE1_OWN_LIBS) $(FRONTEND_LINK) $(STAGE1_LIBC) $(DIET) $(CC) $(LDFLAGS_STAGE1) -o $@ $^ $(STRIPCMD) $@ @@ -230,7 +237,10 @@ stage1-full: $(STAGE1OBJS-FULL) $(STAGE1_OWN_LIBS) $(STAGE1_NETWORK_LIBS) $(FRON $(INITOBJS): %.o: %.c - $(COMPILE) $(INIT_DEFS) -c $< + $(COMPILE) $(INIT_DEFS) $(INIT_DEFS_ADD) -c $< + +$(INITOBJS-MANDRAKE_MOVE): %-MOVE.o: %.c + $(COMPILE) $(INIT_DEFS) $(INIT_DEFS_ADD_MANDRAKE_MOVE) -c $< -o $@ $(STAGE1OBJS-CDROM): %-CDROM.o: %.c $(DIET) $(COMPILE) $(INCLUDES) $(CDROM_DEFS) -c $< -o $@ diff --git a/mdk-stage1/init.c b/mdk-stage1/init.c index 943d755d4..078bb4ef0 100644 --- a/mdk-stage1/init.c +++ b/mdk-stage1/init.c @@ -102,13 +102,13 @@ void print_str_init(int fd, char * string) write(fd, string, strlen(string)); } - /* fork to: * (1) watch /proc/kmsg and copy the stuff to /dev/tty4 * (2) listens to /dev/log and copy also this stuff (log from programs) */ void doklog() { +#ifdef DO_KLOG fd_set readset, unixs; int in, out, i; int log; @@ -232,6 +232,7 @@ void doklog() FD_SET(readfd, &unixs); } } +#endif } @@ -355,9 +356,8 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)) printf("*** TESTING MODE *** (pid is %d)\n", getpid()); - printf("\n\t\t\t\033[1;40mWelcome to \033[1;36mMandrake\033[0;39m Linux\n\n"); - if (!testing) { + mkdir("/proc", 0755); if (mount("/proc", "/proc", "proc", 0, NULL)) fatal_error("Unable to mount proc filesystem"); } @@ -369,13 +369,9 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)) if (!testing) { - fd = open("/dev/tty1", O_RDWR, 0); + fd = open("/dev/console", O_RDWR, 0); if (fd < 0) - /* try with devfs */ - fd = open("/dev/vc/1", O_RDWR, 0); - - if (fd < 0) - fatal_error("failed to open /dev/tty1 and /dev/vc/1"); + fatal_error("failed to open /dev/console"); dup2(fd, 0); dup2(fd, 1); @@ -386,8 +382,8 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)) /* I set me up as session leader (probably not necessary?) */ setsid(); - if (ioctl(0, TIOCSCTTY, NULL)) - print_error("could not set new controlling tty"); +// if (ioctl(0, TIOCSCTTY, NULL)) +// print_error("could not set new controlling tty"); if (!testing) { char my_hostname[] = "localhost.localdomain"; @@ -407,18 +403,16 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)) 2) we receive a SIGHUP */ - printf("Moltes ! MOLTES !\n"); - printf("\n"); - printf("Running install...\n"); + printf("init: running %s\n", BINARY); if (!(installpid = fork())) { /* child */ char * child_argv[2]; - child_argv[0] = "/sbin/stage1"; + child_argv[0] = BINARY; child_argv[1] = NULL; execve(child_argv[0], child_argv, env); - printf("error in exec of stage1 :-(\n"); + printf("error in exec of %s :-(\n", BINARY); return 0; } @@ -429,7 +423,7 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)) } if (!WIFEXITED(wait_status) || (WEXITSTATUS(wait_status) != 0 && WEXITSTATUS(wait_status) != exit_value_proceed)) { - printf("install exited abnormally :-( "); + printf("exited abnormally :-( "); if (WIFSIGNALED(wait_status)) printf("-- received signal %d", WTERMSIG(wait_status)); printf("\n"); @@ -446,6 +440,10 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)) sync(); sync(); +#ifndef DO_KLOG + while (1); +#endif + printf("sending termination signals..."); kill(-1, 15); sleep(2); diff --git a/mdk-stage1/minilibc.h b/mdk-stage1/minilibc.h index 741298ee2..cb38d0bd2 100644 --- a/mdk-stage1/minilibc.h +++ b/mdk-stage1/minilibc.h @@ -79,6 +79,7 @@ static inline _syscall2(int,chmod,const char * ,path,mode_t,mode) static inline _syscall2(int,sethostname,const char *,name,int,len) static inline _syscall2(int,setdomainname,const char *,name,int,len) static inline _syscall2(int,setpgid,int,name,int,len) +static inline _syscall2(int,mkdir,const char *,pathname,mode_t,mode) #ifdef __x86_64__ extern __sighandler_t signal(int signum, __sighandler_t handler); #else |