From 4f5cc6fac1bf6bcbc06381464eb57b18b36600cf Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 28 Mar 1996 21:53:35 +0000 Subject: [PATCH] Drop in a more interlligent version check. --- .../atari/stand/installboot/installboot.c | 51 +++++++++++++++---- .../atari/stand/installboot/installboot.h | 25 +++++++-- 2 files changed, 63 insertions(+), 13 deletions(-) diff --git a/sys/arch/atari/stand/installboot/installboot.c b/sys/arch/atari/stand/installboot/installboot.c index 3ba860bef17d..12292a086f59 100644 --- a/sys/arch/atari/stand/installboot/installboot.c +++ b/sys/arch/atari/stand/installboot/installboot.c @@ -1,4 +1,4 @@ -/* $NetBSD: installboot.c,v 1.1.1.1 1996/02/29 11:35:47 leo Exp $ */ +/* $NetBSD: installboot.c,v 1.2 1996/03/28 21:53:35 leo Exp $ */ /* * Copyright (c) 1995 Waldi Ravens @@ -43,6 +43,13 @@ #include #include +/* + * Small reminder for myself ;-) + */ +#if NetBSD != 199511 +#error New NetBSD version! Update OS_LIST in installboot.h +#endif + #define DKTYPENAMES #include #include @@ -160,19 +167,43 @@ 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 () { - int mib[2], rev; - char *type, *rel; + /* ideally, this would be a nested function... */ + static char *lststr __P((char *, char *, char *)); + static const char os_list[] = OS_LIST; + + 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 (strcmp(type, OS_TYPE)) + if ((list = lststr(list, type, BRA_TYPE)) == NULL) errx(EXIT_FAILURE, "%s: OS type not supported", type); @@ -181,17 +212,19 @@ oscheck () sysctl(mib, 2, NULL, &len, NULL, 0); rel = alloca(len); sysctl(mib, 2, rel, &len, NULL, 0); - if (strcmp(rel, OS_RELEASE)) + 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(rev); - sysctl(mib, 2, &rev, &len, NULL, 0); - if (rev != atoi(OS_REVISION)) + 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 %d: OS revision not supported", type, rel, rev); + "%s %s %s: OS revision not supported", type, rel, rev); } static void diff --git a/sys/arch/atari/stand/installboot/installboot.h b/sys/arch/atari/stand/installboot/installboot.h index 9f3fd5c77436..4eb681f4c23c 100644 --- a/sys/arch/atari/stand/installboot/installboot.h +++ b/sys/arch/atari/stand/installboot/installboot.h @@ -1,4 +1,4 @@ -/* $NetBSD: installboot.h,v 1.1.1.1 1996/02/29 11:35:47 leo Exp $ */ +/* $NetBSD: installboot.h,v 1.2 1996/03/28 21:53:46 leo Exp $ */ /* * Copyright (c) 1995 Waldi Ravens @@ -38,9 +38,26 @@ #define BOOTPREF_SYSV 0x40 #define BOOTPREF_TOS 0x80 -#define OS_TYPE "NetBSD" -#define OS_RELEASE "1.1A" -#define OS_REVISION "199306" +/* + * 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'). + */ +#define OS_LIST "{NetBSD}[1.1A]<199306>[1.1B]<199306>" +#define BRA_TYPE "{}" +#define BRA_RELEASE "[]" +#define BRA_REVISION "<>" u_int dkcksum __P((struct disklabel *)); daddr_t readdisklabel __P((char *, struct disklabel *));