Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/fdisk When fetching the disk's hardware geometry, first...



details:   https://anonhg.NetBSD.org/src/rev/cca1969dcf8a
branches:  trunk
changeset: 494462:cca1969dcf8a
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jul 06 17:22:43 2000 +0000

description:
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.

diffstat:

 sbin/fdisk/fdisk.c |  13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diffs (34 lines):

diff -r 5fe2a34887a1 -r cca1969dcf8a sbin/fdisk/fdisk.c
--- a/sbin/fdisk/fdisk.c        Thu Jul 06 17:22:25 2000 +0000
+++ b/sbin/fdisk/fdisk.c        Thu Jul 06 17:22:43 2000 +0000
@@ -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 @@
 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;



Home | Main Index | Thread Index | Old Index