From cb03d0d71ecf6972a7bbca09782a54430f482431 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Thu, 29 Nov 2018 22:33:59 +0200 Subject: 10446 loader: split panic routine Reviewed by: Andy Fiddaman Reviewed by: Andy Stormont Reviewed by: Gergő Doma Reviewed by: John Levon Approved by: Richard Lowe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usr/src/boot/Makefile.version | 2 +- usr/src/boot/lib/libstand/panic.c | 19 +++++++++++++------ usr/src/boot/lib/libstand/stand.h | 2 ++ usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version index c5bcb01763..46d94fffb8 100644 --- a/usr/src/boot/Makefile.version +++ b/usr/src/boot/Makefile.version @@ -33,4 +33,4 @@ LOADER_VERSION = 1.1 # Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes. # The version is processed from left to right, the version number can only # be increased. -BOOT_VERSION = $(LOADER_VERSION)-2019.02.23.1 +BOOT_VERSION = $(LOADER_VERSION)-2019.02.26.1 diff --git a/usr/src/boot/lib/libstand/panic.c b/usr/src/boot/lib/libstand/panic.c index 14a7c4d8dd..8a3730ce6b 100644 --- a/usr/src/boot/lib/libstand/panic.c +++ b/usr/src/boot/lib/libstand/panic.c @@ -38,7 +38,18 @@ #include #include -extern void exit(int) __dead2; +/* + * Boot loaders and other standalone programs that wish to have a + * different panic policy can provide their own panic_action rotuine. + */ +__weak_symbol void +panic_action(void) +{ + printf("--> Press a key on the console to reboot <--\n"); + getchar(); + printf("Rebooting...\n"); + exit(1); +} void panic(const char *fmt, ...) @@ -50,9 +61,5 @@ panic(const char *fmt, ...) vprintf(fmt, ap); va_end(ap); printf("\n"); - - printf("--> Press a key on the console to reboot <--\n"); - getchar(); - printf("Rebooting...\n"); - exit(1); + panic_action(); } diff --git a/usr/src/boot/lib/libstand/stand.h b/usr/src/boot/lib/libstand/stand.h index 5039803d6d..b2cdcc18e0 100644 --- a/usr/src/boot/lib/libstand/stand.h +++ b/usr/src/boot/lib/libstand/stand.h @@ -377,12 +377,14 @@ extern int null_readdir(struct open_file *f, struct dirent *d); * Machine dependent functions and data, must be provided or stubbed by * the consumer */ +extern void exit(int) __dead2; extern int getchar(void); extern int ischar(void); extern void putchar(int); extern int devopen(struct open_file *, const char *, const char **); extern int devclose(struct open_file *f); extern void panic(const char *, ...) __dead2 __printflike(1, 2); +extern void panic_action(void) __weak_symbol __dead2; extern time_t getsecs(void); extern struct fs_ops *file_system[]; extern struct fs_ops *exclusive_file_system; diff --git a/usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c b/usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c index 5d57d909ce..6c52d8e279 100644 --- a/usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c +++ b/usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c @@ -107,7 +107,6 @@ static char *heap_top; static char *heap_bottom; static void i386_zfs_probe(void); -void exit(int); static void load(void); static int parse_cmd(void); @@ -272,6 +271,7 @@ main(void) void exit(int x) { + while (1); } static void -- cgit v1.2.3