Introduce 'bootversion' in locore.s. Check this to decide if installing
a bootstrap with the running installboot makes sense.
This commit is contained in:
parent
b4ab2c89f5
commit
89325630dd
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: locore.s,v 1.44 1997/07/05 20:51:14 leo Exp $ */
|
||||
/* $NetBSD: locore.s,v 1.45 1997/07/09 14:32:09 leo Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
|
@ -755,9 +755,10 @@ _esym: .long 0
|
|||
.globl _etext,_end
|
||||
.globl start
|
||||
|
||||
.word 0x0002 | XXX: loadbsd version required
|
||||
| 2: needs a4 = esym
|
||||
| XXX should be a symbol?
|
||||
_bootversion:
|
||||
.globl _bootversion
|
||||
.word 0x0002 | Glues kernel/installboot/loadbsd
|
||||
| and other bootcode together.
|
||||
start:
|
||||
movw #PSL_HIGHIPL,sr | No interrupts
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
# $NetBSD: Makefile,v 1.2 1997/06/22 05:48:18 mrg Exp $
|
||||
# $NetBSD: Makefile,v 1.3 1997/07/09 14:31:12 leo Exp $
|
||||
|
||||
PROG= installboot
|
||||
NOMAN= yes
|
||||
SRCS= installboot.c disklabel.c
|
||||
BINDIR= /usr/mdec
|
||||
LDADD= -lkvm
|
||||
|
||||
CFLAGS+=-Wall
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: installboot.c,v 1.6 1997/01/08 12:55:41 leo Exp $ */
|
||||
/* $NetBSD: installboot.c,v 1.7 1997/07/09 14:31:13 leo Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 Waldi Ravens
|
||||
|
@ -42,13 +42,9 @@
|
|||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <err.h>
|
||||
|
||||
/*
|
||||
* Small reminder for myself ;-)
|
||||
*/
|
||||
#if NetBSD != 199611
|
||||
#error New NetBSD version! Update OS_LIST in installboot.h
|
||||
#endif
|
||||
#include <limits.h>
|
||||
#include <nlist.h>
|
||||
#include <kvm.h>
|
||||
|
||||
#define DKTYPENAMES
|
||||
#include <sys/disklabel.h>
|
||||
|
@ -99,7 +95,7 @@ main (argc, argv)
|
|||
char *dn;
|
||||
int fd, c;
|
||||
|
||||
/* check OS type, release and revision */
|
||||
/* check OS bootversion */
|
||||
oscheck();
|
||||
|
||||
/* parse options */
|
||||
|
@ -168,64 +164,28 @@ main (argc, argv)
|
|||
return(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static char *
|
||||
lststr (lst, str, bra)
|
||||
char *lst, *str, *bra;
|
||||
{
|
||||
char *p;
|
||||
|
||||
while ((p = strchr(lst, bra[0])) != NULL) {
|
||||
lst = strchr(++p, bra[1]);
|
||||
if (strncmp(str, p, lst - p))
|
||||
continue;
|
||||
if ((p = strchr(lst, bra[0])))
|
||||
*p = 0;
|
||||
return(++lst);
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
oscheck ()
|
||||
{
|
||||
/* ideally, this would be a nested function... */
|
||||
static char *lststr __P((char *, char *, char *));
|
||||
static const char os_list[] = OS_LIST;
|
||||
struct nlist kbv[] = { { "_bootversion" }, { NULL } };
|
||||
kvm_t *kd_kern;
|
||||
char errbuf[_POSIX2_LINE_MAX];
|
||||
u_short kvers;
|
||||
|
||||
char *list, *type, *rel, *rev;
|
||||
int mib[2], rvi;
|
||||
size_t len;
|
||||
|
||||
list = alloca(sizeof(os_list));
|
||||
strcpy(list, os_list);
|
||||
|
||||
mib[0] = CTL_KERN;
|
||||
mib[1] = KERN_OSTYPE;
|
||||
sysctl(mib, 2, NULL, &len, NULL, 0);
|
||||
type = alloca(len);
|
||||
sysctl(mib, 2, type, &len, NULL, 0);
|
||||
if ((list = lststr(list, type, BRA_TYPE)) == NULL)
|
||||
errx(EXIT_FAILURE,
|
||||
"%s: OS type not supported", type);
|
||||
|
||||
mib[0] = CTL_KERN;
|
||||
mib[1] = KERN_OSRELEASE;
|
||||
sysctl(mib, 2, NULL, &len, NULL, 0);
|
||||
rel = alloca(len);
|
||||
sysctl(mib, 2, rel, &len, NULL, 0);
|
||||
if ((list = lststr(list, rel, BRA_RELEASE)) == NULL)
|
||||
errx(EXIT_FAILURE,
|
||||
"%s %s: OS release not supported", type, rel);
|
||||
|
||||
mib[0] = CTL_KERN;
|
||||
mib[1] = KERN_OSREV;
|
||||
len = sizeof(rvi);
|
||||
sysctl(mib, 2, &rvi, &len, NULL, 0);
|
||||
rev = alloca(3 * sizeof(rvi));
|
||||
sprintf(rev, "%u", rvi);
|
||||
if ((list = lststr(list, rev, BRA_REVISION)) == NULL)
|
||||
errx(EXIT_FAILURE,
|
||||
"%s %s %s: OS revision not supported", type, rel, rev);
|
||||
kd_kern = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
|
||||
if (kd_kern == NULL)
|
||||
errx(EXIT_FAILURE, "kvm_openfiles: %s", errbuf);
|
||||
if (kvm_nlist(kd_kern, kbv) == -1)
|
||||
errx(EXIT_FAILURE, "kvm_nlist: %s", kvm_geterr(kd_kern));
|
||||
if (kbv[0].n_value == 0)
|
||||
errx(EXIT_FAILURE, "%s not in namelist", kbv[0].n_name);
|
||||
if (kvm_read(kd_kern, kbv[0].n_value, (char *)&kvers,
|
||||
sizeof(kvers)) == -1)
|
||||
errx(EXIT_FAILURE, "kvm_read: %s", kvm_geterr(kd_kern));
|
||||
kvm_close(kd_kern);
|
||||
if (kvers != BOOTVERSION)
|
||||
errx(EXIT_FAILURE, "Kern bootversion: %d, expected: %d\n",
|
||||
kvers, BOOTVERSION);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: installboot.h,v 1.4 1996/10/25 20:05:04 leo Exp $ */
|
||||
/* $NetBSD: installboot.h,v 1.5 1997/07/09 14:31:14 leo Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 Waldi Ravens
|
||||
|
@ -39,25 +39,9 @@
|
|||
#define BOOTPREF_TOS 0x80
|
||||
|
||||
/*
|
||||
* OS_LIST contains all possible combinations of OS-type,
|
||||
* OS-release and OS-revision that are supported by this
|
||||
* version of installboot.
|
||||
*
|
||||
* Syntax of OS_LIST: (ostype(osrelease(osrevision)..)..)..
|
||||
*
|
||||
* Where the parentheses indicate grouping and the double
|
||||
* dots indicate repetition (each group must appear at
|
||||
* least once).
|
||||
*
|
||||
* Ostype, osrelease and osrevision are strings surrounded
|
||||
* resp. by braces, square brackets and angle brackets. It
|
||||
* should be obvious that those delimeters can not be part
|
||||
* of the strings, nor can the EOS marker ('\0').
|
||||
* Should match 'bootversion' in locore.s to make installboot work.
|
||||
*/
|
||||
#define OS_LIST "{NetBSD}[1.2]<199306>[1.2A]<199306>"
|
||||
#define BRA_TYPE "{}"
|
||||
#define BRA_RELEASE "[]"
|
||||
#define BRA_REVISION "<>"
|
||||
#define BOOTVERSION 0x02
|
||||
|
||||
u_int dkcksum __P((struct disklabel *));
|
||||
daddr_t readdisklabel __P((char *, struct disklabel *));
|
||||
|
|
Loading…
Reference in New Issue