summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>1997-10-26 02:41:20 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>1997-10-26 02:41:20 +0000
commit4c022f2e1506aa8a03b34e65a1d054a6d0b06013 (patch)
tree6da38ee668690e10721fe087f7c055c268d46175 /sys/arch
parentf1606bab5adbc6e937e2450f476562e2e1c454d5 (diff)
don't freak out on old kernels
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/i386/stand/installboot/installboot.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/sys/arch/i386/stand/installboot/installboot.c b/sys/arch/i386/stand/installboot/installboot.c
index afbea9d6e9c..9d46a2128b3 100644
--- a/sys/arch/i386/stand/installboot/installboot.c
+++ b/sys/arch/i386/stand/installboot/installboot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: installboot.c,v 1.24 1997/10/25 23:42:37 mickey Exp $ */
+/* $OpenBSD: installboot.c,v 1.25 1997/10/26 02:41:19 mickey Exp $ */
/* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */
/*
@@ -187,22 +187,24 @@ main(argc, argv)
mib[1] = CPU_CHR2BLK;
mib[2] = sb.st_rdev;
size = sizeof(devno);
- if(sysctl(mib, 3, &devno, &size, NULL, 0) < 0)
- err(1, "mapping device number");
- devno = MAKEBOOTDEV(major(devno), 0, 0, DISKUNIT(devno), 0);
-
- mib[0] = CTL_MACHDEP;
- mib[1] = CPU_BIOS;
- mib[2] = BIOS_DISKINFO;
- mib[3] = devno;
- size = sizeof(di);
- if(sysctl(mib, 4, &di, &size, NULL, 0) < 0)
- errx(1, "Unable to get BIOS geometry, "
- "must specify -h and -s");
- nheads = di.bios_heads;
- nsectors = di.bios_sectors;
+ if(sysctl(mib, 3, &devno, &size, NULL, 0) >= 0) {
+ devno = MAKEBOOTDEV(major(devno),0,0,DISKUNIT(devno),0);
+
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_BIOS;
+ mib[2] = BIOS_DISKINFO;
+ mib[3] = devno;
+ size = sizeof(di);
+ if(sysctl(mib, 4, &di, &size, NULL, 0) >= 0) {
+ nheads = di.bios_heads;
+ nsectors = di.bios_sectors;
+ }
+ }
}
+ if (nheads == -1 || nsectors == -1)
+ errx(1, "Unable to get BIOS geometry, must specify -h and -s");
+
/* Extract and load block numbers */
if (loadblocknums(boot, devfd, &dl) != 0)
exit(1);
@@ -405,14 +407,15 @@ loadblocknums(boot, devfd, dl)
if (fstat(devfd, &sb) != 0)
err(1, "fstat: %s", realdev);
+
+ /* check devices */
mib[0] = CTL_MACHDEP;
mib[1] = CPU_CHR2BLK;
mib[2] = sb.st_rdev;
size = sizeof(dev);
- if (sysctl(mib, 3, &dev, &size, NULL, 0) < 0)
- err(1, "can't map device number");
- if (statbuf.st_dev / MAXPARTITIONS != dev / MAXPARTITIONS)
- errx(1, "cross-device install");
+ if (sysctl(mib, 3, &dev, &size, NULL, 0) >= 0)
+ if (statbuf.st_dev / MAXPARTITIONS != dev / MAXPARTITIONS)
+ errx(1, "cross-device install");
pl = &dl->d_partitions[DISKPART(statbuf.st_dev)];
close(fd);