Subject: port-i386/4773: fdisk translated geometry
To: None <gnats-bugs@gnats.netbsd.org>
From: None <ghudson@MIT.EDU>
List: netbsd-bugs
Date: 01/03/1998 23:13:50
>Number: 4773
>Category: port-i386
>Synopsis: fdisk trusts the disklabel geometry a bit too much
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: gnats-admin (GNATS administrator)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jan 3 20:20:02 1998
>Last-Modified:
>Originator: Greg Hudson
>Organization:
MIT
>Release: 1.3
>Environment:
System: NetBSD the-light-fantastic 1.2 NetBSD 1.2 (LIGHT) #2: Mon Apr 7 17:36:19 EDT 1997 root@the-light-fantastic:/u1/marthag/src/sys/arch/i386/compile/LIGHT i386
(This bug has existed for quite a while, and still exists.)
>Description:
fdisk's intuit_translated_geometry estimates the number of cylinders with the
following formula (currently on line 391):
cylinders = dos_cylinders * dos_cylindersectors / heads / sectors;
where dos_cylinders and dos_cylindersectors are (at that point) geometry
values obtained from the disklabel. Multiplying out the disklabel geometry
is a suboptimal way of determining the number of sectors on the drive;
disklabel.d_secperunit is more precise and less likely to reflect any prior
frobbing having to do with translated geometries.
(jhawk points out that there is no kernel interface for getting the raw
geometry or sectors per unit value from the driver; you always have to go
through the disklabel, which might have been corrupted by the user or by
something else. I am not as concerned by this weakness in the interface,
but it is a problem.)
Incidentally, because of this problem and my previous PR, some sysinst
developer noticed that the fdisk BIOS geometry values were often wrong and
adjusted for it at the end of distrib/utils/sysinst/arch/i386/fdisk.c. If
you fix either this problem or the previous one, you can get rid of that
hack.
>How-To-Repeat:
>Fix:
*** fdisk.c.orig Sat Jan 3 23:09:02 1998
--- fdisk.c Sat Jan 3 23:09:57 1998
***************
*** 575,581 ****
return;
/* Estimate the number of cylinders. */
! cylinders = dos_cylinders * dos_cylindersectors / heads / sectors;
/* Now verify consistency with each of the partition table entries.
* Be willing to shove cylinders up a little bit to make things work,
--- 575,581 ----
return;
/* Estimate the number of cylinders. */
! cylinders = disklabel.d_secperunit / heads / sectors;
/* Now verify consistency with each of the partition table entries.
* Be willing to shove cylinders up a little bit to make things work,
>Audit-Trail:
>Unformatted: