summaryrefslogtreecommitdiff
path: root/sys/arch/alpha/alpha/disksubr.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/alpha/alpha/disksubr.c')
-rw-r--r--sys/arch/alpha/alpha/disksubr.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/sys/arch/alpha/alpha/disksubr.c b/sys/arch/alpha/alpha/disksubr.c
index 82b7687c203..ad31b6d365a 100644
--- a/sys/arch/alpha/alpha/disksubr.c
+++ b/sys/arch/alpha/alpha/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.44 2006/06/11 21:15:35 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.45 2006/07/01 16:50:32 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -335,7 +335,7 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly)
dospartoff = 0;
cyl = I386_LABELSECTOR / lp->d_secpercyl;
if (dp) {
- daddr_t part_blkno = DOSBBSECTOR;
+ daddr_t part_blkno = DOSBBSECTOR;
unsigned long extoff = 0;
int wander = 1, n = 0, loop = 0;
@@ -344,7 +344,7 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly)
* Map the partitions to disklabel entries i-p
*/
while (wander && n < 8 && loop < 8) {
- loop++;
+ loop++;
wander = 0;
if (part_blkno < extoff)
part_blkno = extoff;
@@ -355,7 +355,7 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly)
bp->b_flags = B_BUSY | B_READ;
bp->b_cylinder = part_blkno / lp->d_secpercyl;
(*strat)(bp);
-
+
/* if successful, wander through dos partition table */
if (biowait(bp)) {
msg = "dos partition I/O error";
@@ -368,19 +368,19 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly)
if (ourpart == -1) {
/* Search for our MBR partition */
- for (dp2=dp, i=0;
- i < NDOSPART && ourpart == -1; i++, dp2++)
- if (dp2->dp_size &&
+ for (dp2=dp, i=0; i < NDOSPART && ourpart == -1;
+ i++, dp2++)
+ if (letoh32(dp2->dp_size) &&
dp2->dp_typ == DOSPTYP_OPENBSD)
ourpart = i;
- for (dp2=dp, i=0;
- i < NDOSPART && ourpart == -1; i++, dp2++)
- if (dp2->dp_size &&
+ for (dp2=dp, i=0; i < NDOSPART && ourpart == -1;
+ i++, dp2++)
+ if (letoh32(dp2->dp_size) &&
dp2->dp_typ == DOSPTYP_FREEBSD)
ourpart = i;
- for (dp2=dp, i=0;
- i < NDOSPART && ourpart == -1; i++, dp2++)
- if (dp2->dp_size &&
+ for (dp2=dp, i=0; i < NDOSPART && ourpart == -1;
+ i++, dp2++)
+ if (letoh32(dp2->dp_size) &&
dp2->dp_typ == DOSPTYP_NETBSD)
ourpart = i;
if (ourpart == -1)
@@ -391,13 +391,13 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly)
* ESDI/ST506/RLL
*/
dp2 = &dp[ourpart];
- dospartoff = dp2->dp_start + part_blkno;
+ dospartoff = letoh32(dp2->dp_start) + part_blkno;
cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect);
/* XXX build a temporary disklabel */
- lp->d_partitions[0].p_size = dp2->dp_size;
- lp->d_partitions[0].p_offset = dp2->dp_start +
- part_blkno;
+ lp->d_partitions[0].p_size = letoh32(dp2->dp_size);
+ lp->d_partitions[0].p_offset =
+ letoh32(dp2->dp_start) + part_blkno;
if (lp->d_ntracks == 0)
lp->d_ntracks = dp2->dp_ehd + 1;
if (lp->d_nsectors == 0)
@@ -416,11 +416,13 @@ donot:
if (dp2->dp_typ == DOSPTYP_OPENBSD)
continue;
- if (dp2->dp_size)
- pp->p_size = dp2->dp_size;
- if (dp2->dp_start)
+ if (letoh32(dp2->dp_size) > lp->d_secperunit)
+ continue;
+ if (letoh32(dp2->dp_size))
+ pp->p_size = letoh32(dp2->dp_size);
+ if (letoh32(dp2->dp_start))
pp->p_offset =
- dp2->dp_start + part_blkno;
+ letoh32(dp2->dp_start) + part_blkno;
switch (dp2->dp_typ) {
case DOSPTYP_UNUSED:
@@ -455,9 +457,12 @@ donot:
break;
case DOSPTYP_EXTEND:
case DOSPTYP_EXTENDL:
- part_blkno = dp2->dp_start + extoff;
- if (!extoff)
- extoff = dp2->dp_start;
+ part_blkno =
+ letoh32(dp2->dp_start) + extoff;
+ if (!extoff) {
+ extoff = letoh32(dp2->dp_start);
+ part_blkno = 0;
+ }
wander = 1;
break;
default: