diff --git a/ChangeLog b/ChangeLog index 7985a530d..8621d06ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +1999-09-01 OKUJI Yoshinori + + * grub/asmstub.c (env_for_exit): New variable. + (grub_stage2): Do a setjmp in doit, and when it returns + non-zero, set STATUS to 1 if ERRNUM is non-zero. + (stop): Call longjmp instead of exit. + 1999-08-31 Pavel Roskin * stage2/boot.c [GRUB_UTIL] (bsd_boot_entry): New function. diff --git a/grub/asmstub.c b/grub/asmstub.c index 9e6fece56..5f744c946 100644 --- a/grub/asmstub.c +++ b/grub/asmstub.c @@ -40,6 +40,7 @@ int grub_stage2 (void); #include #include #include +#include #ifdef __linux__ # include /* ioctl */ @@ -75,6 +76,9 @@ static struct geometry *disks = 0; /* The map between BIOS drives and UNIX device file names. */ char **device_map = 0; +/* The jump buffer for exiting correctly. */ +static jmp_buf env_for_exit; + /* The main entry point into this mess. */ int grub_stage2 (void) @@ -93,17 +97,18 @@ grub_stage2 (void) asm volatile ("movl %%esp, %0\n\tmovl %1, %%esp\n" : "=&r" (realstack) : "r" (simstack)); - /* FIXME: Do a setjmp here for the stop command. */ - if (1) + /* Do a setjmp here for the stop command. */ + if (! setjmp (env_for_exit)) { - /* Actually enter the generic stage2 code. */ + /* Actually enter the generic stage2 code. */ status = 0; init_bios_info (); } else { - /* Somebody aborted. */ - status = 1; + /* If ERRNUM is non-zero, then set STATUS to non-zero. */ + if (errnum) + status = 1; } /* Replace our stack before we use any local variables. */ @@ -275,9 +280,9 @@ stop (void) if (use_curses) endwin (); #endif - /* FIXME: If we don't exit, then we need to free our data areas. */ - fprintf (stderr, "grub: aborting...\n"); - exit (1); + + /* Jump to doit. */ + longjmp (env_for_exit, 1); }