diff options
author | Kenji Aoyama <aoyama@cvs.openbsd.org> | 2019-04-09 14:21:33 +0000 |
---|---|---|
committer | Kenji Aoyama <aoyama@cvs.openbsd.org> | 2019-04-09 14:21:33 +0000 |
commit | 86b7c4353cb652e1e7582cc88b050fe1a03c9519 (patch) | |
tree | 9ebf11dcf95cd0c3c786ea3514f8230f81253c0a /sys/arch | |
parent | 1fc85b6f61d7860b6955d71989454727251dd2b0 (diff) |
Detect /bsd.upgrade kernel and boot it if present instead of default /bsd,
same as recent change in MI boot.
"If it works, sure you can commit it" deraadt@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/luna88k/stand/boot/init_main.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/sys/arch/luna88k/stand/boot/init_main.c b/sys/arch/luna88k/stand/boot/init_main.c index b3f64d3033a..f7b5abc7d9d 100644 --- a/sys/arch/luna88k/stand/boot/init_main.c +++ b/sys/arch/luna88k/stand/boot/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.7 2017/03/16 18:08:58 miod Exp $ */ +/* $OpenBSD: init_main.c,v 1.8 2019/04/09 14:21:32 aoyama Exp $ */ /* $NetBSD: init_main.c,v 1.6 2013/03/05 15:34:53 tsutsui Exp $ */ /* @@ -98,6 +98,10 @@ */ #include <sys/param.h> +#define _KERNEL +#include <sys/fcntl.h> +#undef _KERNEL +#include <lib/libkern/libkern.h> #include <machine/board.h> #include <luna88k/stand/boot/samachdep.h> #include <luna88k/stand/boot/status.h> @@ -112,6 +116,7 @@ static const char *nvram_by_symbol(char *); int cpuspeed; /* for DELAY() macro */ int machtype; char default_file[64]; +char upgrade_file[64]; uint16_t dipswitch = 0; int nplane; @@ -133,6 +138,8 @@ static const char prompt[] = "boot> "; int debug; +int exist(const char *); + /* * FUSE ROM and NVRAM data */ @@ -181,7 +188,7 @@ main(void) nplane = get_plane_numbers(); cninit(); - printf("\nOpenBSD/" MACHINE " (%s) boot 0.5\n\n", machstr); + printf("\nOpenBSD/" MACHINE " (%s) boot 0.6\n\n", machstr); #ifdef SUPPORT_ETHERNET try_bootp = 1; @@ -205,6 +212,13 @@ main(void) snprintf(default_file, sizeof(default_file), "%s(%d,%d)%s", nvv != NULL ? nvv : "sd", unit, part, "bsd"); + snprintf(upgrade_file, sizeof(upgrade_file), + "%s(%d,%d)%s", nvv != NULL ? nvv : "sd", unit, part, "bsd.upgrade"); + + if (exist(upgrade_file)) { + strlcpy(default_file, upgrade_file, sizeof(default_file)); + printf("upgrade detected: switching to %s\n", default_file); + } /* auto-boot? (SW1) */ if ((dipswitch & 0x8000) != 0) { @@ -241,6 +255,20 @@ main(void) /* NOTREACHED */ } +/* Check file existence with "device(unit, part)filename" format */ + +int +exist(const char *name) +{ + int fd; + + fd = open(name, O_RDONLY); + if (fd == -1) + return 0; + close(fd); + return 1; +} + int get_plane_numbers(void) { |