When fetching the disk's hardware geometry, first attempt the

DIOCGDEFLABEL ioctl, then fall back onto the DIOCGDINFO ioctl
if that fails.  This ensures that we will get the actual hardware
geometry info rather than any bogus info that might have been
previously written to the disk's label area.
This commit is contained in:
thorpej 2000-07-06 17:22:43 +00:00
parent a4d6bdac79
commit 6d78b8c024
1 changed files with 8 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: fdisk.c,v 1.41 2000/06/14 19:35:50 wiz Exp $ */
/* $NetBSD: fdisk.c,v 1.42 2000/07/06 17:22:43 thorpej Exp $ */
/*
* Mach Operating System
@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: fdisk.c,v 1.41 2000/06/14 19:35:50 wiz Exp $");
__RCSID("$NetBSD: fdisk.c,v 1.42 2000/07/06 17:22:43 thorpej Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -1277,9 +1277,12 @@ int
get_params()
{
if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
warn("DIOCGDINFO");
return (-1);
if (ioctl(fd, DIOCGDEFLABEL, &disklabel) == -1) {
warn("DIOCGDEFLABEL");
if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
warn("DIOCGDINFO");
return (-1);
}
}
dos_cylinders = cylinders = disklabel.d_ncylinders;