Index: kern/err.c =================================================================== --- kern/err.c (Revision 1802) +++ kern/err.c (Arbeitskopie) @@ -113,6 +113,7 @@ grub_error_pop (void) } } +#ifndef GRUB_UTIL void grub_print_error (void) { @@ -132,3 +133,4 @@ grub_print_error (void) grub_error_stack_assert = 0; } } +#endif Index: include/grub/err.h =================================================================== --- include/grub/err.h (Revision 1802) +++ include/grub/err.h (Arbeitskopie) @@ -63,6 +63,9 @@ grub_err_t EXPORT_FUNC(grub_error) (grub void EXPORT_FUNC(grub_fatal) (const char *fmt, ...) __attribute__ ((noreturn)); void EXPORT_FUNC(grub_error_push) (void); int EXPORT_FUNC(grub_error_pop) (void); + +#ifndef GRUB_UTIL void EXPORT_FUNC(grub_print_error) (void); +#endif #endif /* ! GRUB_ERR_HEADER */ Index: include/grub/util/misc.h =================================================================== --- include/grub/util/misc.h (Revision 1802) +++ include/grub/util/misc.h (Arbeitskopie) @@ -55,4 +55,5 @@ void grub_util_write_image_at (const voi FILE *out); char *grub_util_get_disk_name (int disk, char *name); +void grub_print_error (void); #endif /* ! GRUB_UTIL_MISC_HEADER */ Index: util/misc.c =================================================================== --- util/misc.c (Revision 1802) +++ util/misc.c (Arbeitskopie) @@ -300,3 +300,23 @@ grub_arch_sync_caches (void *address __a grub_size_t len __attribute__ ((unused))) { } + +void +grub_print_error (void) +{ + /* Print error messages in reverse order. First print active error message + and then empty error stack. */ + do + { + if (grub_errno != GRUB_ERR_NONE) + fprintf (stderr ,"error: %s\n", grub_errmsg); + } + while (grub_error_pop ()); + + /* If there was an assert while using error stack, report about it. */ + if (grub_error_stack_assert) + { + fprintf (stderr, "assert: error stack overflow detected!\n"); + grub_error_stack_assert = 0; + } +}