Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Dec 1997 09:13:17 +0100 (CET)
From:      Andre Albsmeier <andre.albsmeier@mchp.siemens.de>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   kern/5186: bug in diskslice_machdep.c (fix included)
Message-ID:  <199712010813.JAA05947@intern>
Resent-Message-ID: <199712010820.AAA19011@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         5186
>Category:       kern
>Synopsis:       bug in diskslice_machdep.c (fix included)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec  1 00:20:01 PST 1997
>Last-Modified:
>Originator:     Andre Albsmeier
>Organization:
>Release:        FreeBSD 2.2.5-STABLE i386
>Environment:

	2.2.5-STABLE, but might be the others as well

>Description:

        Either the code or the comment above it is wrong in sys/i386/isa/diskslice_machdep.c:

        /*
         * If ssector1 is on a cylinder >= 1024, then ssector can't be right.
         * Allow the C/H/S for it to be 1023/ntracks-1/nsectors, or correct
         * apart from the cylinder being reduced modulo 1024.  Always allow
         * 1023/255/63.
         */
        if (ssector < ssector1
            && ((chs_ssect == nsectors && dp->dp_shd == ntracks - 1
                 && chs_scyl == 1023)
                || (secpercyl != 0
                    && (ssector1 - ssector) % (1024 * secpercyl) == 0))
            || (dp->dp_scyl == 255 && dp->dp_shd == 255
                && dp->dp_ssect == 255)) {

         Since we can't enter 255 for the number of sectors, I think it's the code.
         That would also match the numbers used by "disklabel -B"...
         The same applies a few lines below for the end of the partition.

>How-To-Repeat:

         Look at sys/i386/isa/diskslice_machdep.c :-)

>Fix:

--- diskslice_machdep.c.ORI	Mon Dec  1 08:23:51 1997
+++ diskslice_machdep.c	Mon Dec  1 08:57:27 1997
@@ -108,8 +108,8 @@
 		 && chs_scyl == 1023)
 		|| (secpercyl != 0
 		    && (ssector1 - ssector) % (1024 * secpercyl) == 0))
-	    || (dp->dp_scyl == 255 && dp->dp_shd == 255
-		&& dp->dp_ssect == 255)) {
+	    || (dp->dp_scyl == 1023 && dp->dp_shd == 255
+		&& dp->dp_ssect == 63)) {
 		TRACE(("%s: C/H/S start %d/%d/%d, start %lu: allow\n",
 		       sname, chs_scyl, dp->dp_shd, chs_ssect, ssector1));
 		ssector = ssector1;
@@ -127,8 +127,8 @@
 		 && chs_ecyl == 1023)
 		|| (secpercyl != 0
 		    && (esector1 - esector) % (1024 * secpercyl) == 0))
-	    || (dp->dp_ecyl == 255 && dp->dp_ehd == 255
-		&& dp->dp_esect == 255)) {
+	    || (dp->dp_ecyl == 1023 && dp->dp_ehd == 255
+		&& dp->dp_esect == 63)) {
 		TRACE(("%s: C/H/S end %d/%d/%d, end %lu: allow\n",
 		       sname, chs_ecyl, dp->dp_ehd, chs_esect, esector1));
 		esector = esector1;
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199712010813.JAA05947>