diff options
author | bde <bde@FreeBSD.org> | 1996-11-04 17:40:43 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1996-11-04 17:40:43 +0000 |
commit | 681d5cbae48a5ea6f09d02077955a4d2bfdf85c7 (patch) | |
tree | 138165b6e9c251bb3a08c526b9aa4999e423a674 /sys | |
parent | e19880111bda8a3feb3b48618fce5bec0bee7537 (diff) | |
download | FreeBSD-src-681d5cbae48a5ea6f09d02077955a4d2bfdf85c7.zip FreeBSD-src-681d5cbae48a5ea6f09d02077955a4d2bfdf85c7.tar.gz |
Don't clobber max_ncyls, ending up guessing thetotal number of cylinders as
the number in the 4th slot.
Fixes PR 1893.
Should be in 2.1.5 and 2.2.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/i386/isa/diskslice_machdep.c | 16 | ||||
-rw-r--r-- | sys/kern/subr_diskmbr.c | 16 |
2 files changed, 20 insertions, 12 deletions
diff --git a/sys/i386/isa/diskslice_machdep.c b/sys/i386/isa/diskslice_machdep.c index 595898c..509b05a 100644 --- a/sys/i386/isa/diskslice_machdep.c +++ b/sys/i386/isa/diskslice_machdep.c @@ -35,7 +35,7 @@ * * from: @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91 * from: ufs_disksubr.c,v 1.8 1994/06/07 01:21:39 phk Exp $ - * $Id: diskslice_machdep.c,v 1.20 1996/04/07 17:32:09 bde Exp $ + * $Id: diskslice_machdep.c,v 1.21 1996/09/20 17:39:11 bde Exp $ */ #include <stddef.h> @@ -246,12 +246,13 @@ reread_mbr: max_nsectors = 0; max_ntracks = 0; for (dospart = 0, dp = dp0; dospart < NDOSPART; dospart++, dp++) { + int ncyls; int nsectors; int ntracks; - max_ncyls = DPCYL(dp->dp_ecyl, dp->dp_esect); - if (max_ncyls < max_ncyls) - max_ncyls = max_ncyls; + ncyls = DPCYL(dp->dp_ecyl, dp->dp_esect) + 1; + if (max_ncyls < ncyls) + max_ncyls = ncyls; nsectors = DPSECT(dp->dp_esect); if (max_nsectors < nsectors) max_nsectors = nsectors; @@ -260,7 +261,10 @@ reread_mbr: max_ntracks = ntracks; } - /* Check the geometry. */ + /* + * Check that we have guessed the geometry right by checking the + * partition entries. + */ /* * TODO: * As above. @@ -268,7 +272,6 @@ reread_mbr: * Check against d_secperunit if the latter is reliable. */ error = 0; - secpercyl = (u_long)max_nsectors * max_ntracks; for (dospart = 0, dp = dp0; dospart < NDOSPART; dospart++, dp++) { if (dp->dp_scyl == 0 && dp->dp_shd == 0 && dp->dp_ssect == 0 && dp->dp_start == 0 && dp->dp_size == 0) @@ -294,6 +297,7 @@ reread_mbr: * First adjust the label (we have been careful not to change it * before we can guarantee success). */ + secpercyl = (u_long)max_nsectors * max_ntracks; if (secpercyl != 0) { u_long secperunit; diff --git a/sys/kern/subr_diskmbr.c b/sys/kern/subr_diskmbr.c index 595898c..509b05a 100644 --- a/sys/kern/subr_diskmbr.c +++ b/sys/kern/subr_diskmbr.c @@ -35,7 +35,7 @@ * * from: @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91 * from: ufs_disksubr.c,v 1.8 1994/06/07 01:21:39 phk Exp $ - * $Id: diskslice_machdep.c,v 1.20 1996/04/07 17:32:09 bde Exp $ + * $Id: diskslice_machdep.c,v 1.21 1996/09/20 17:39:11 bde Exp $ */ #include <stddef.h> @@ -246,12 +246,13 @@ reread_mbr: max_nsectors = 0; max_ntracks = 0; for (dospart = 0, dp = dp0; dospart < NDOSPART; dospart++, dp++) { + int ncyls; int nsectors; int ntracks; - max_ncyls = DPCYL(dp->dp_ecyl, dp->dp_esect); - if (max_ncyls < max_ncyls) - max_ncyls = max_ncyls; + ncyls = DPCYL(dp->dp_ecyl, dp->dp_esect) + 1; + if (max_ncyls < ncyls) + max_ncyls = ncyls; nsectors = DPSECT(dp->dp_esect); if (max_nsectors < nsectors) max_nsectors = nsectors; @@ -260,7 +261,10 @@ reread_mbr: max_ntracks = ntracks; } - /* Check the geometry. */ + /* + * Check that we have guessed the geometry right by checking the + * partition entries. + */ /* * TODO: * As above. @@ -268,7 +272,6 @@ reread_mbr: * Check against d_secperunit if the latter is reliable. */ error = 0; - secpercyl = (u_long)max_nsectors * max_ntracks; for (dospart = 0, dp = dp0; dospart < NDOSPART; dospart++, dp++) { if (dp->dp_scyl == 0 && dp->dp_shd == 0 && dp->dp_ssect == 0 && dp->dp_start == 0 && dp->dp_size == 0) @@ -294,6 +297,7 @@ reread_mbr: * First adjust the label (we have been careful not to change it * before we can guarantee success). */ + secpercyl = (u_long)max_nsectors * max_ntracks; if (secpercyl != 0) { u_long secperunit; |