diff options
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/arc/arc/disksubr.c | 32 | ||||
-rw-r--r-- | sys/arch/arc/include/disklabel.h | 16 |
2 files changed, 31 insertions, 17 deletions
diff --git a/sys/arch/arc/arc/disksubr.c b/sys/arch/arc/arc/disksubr.c index b85a15e73a1..bec7bfd0c0c 100644 --- a/sys/arch/arc/arc/disksubr.c +++ b/sys/arch/arc/arc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.15 1997/08/08 21:46:36 niklas Exp $ */ +/* $OpenBSD: disksubr.c,v 1.16 1997/09/23 12:46:38 pefo Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -142,12 +142,12 @@ readdisklabel(dev, strat, lp, osdep) /* Search for our MBR partition */ for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (dp2->dp_size && + if (get_le(&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 && + if (get_le(&dp2->dp_size) && dp2->dp_typ == DOSPTYP_386BSD) ourpart = i; if (ourpart == -1) @@ -157,13 +157,13 @@ readdisklabel(dev, strat, lp, osdep) * for SCSI/IDE, cylinder for ESDI/ST506/RLL */ dp2 = &dp[ourpart]; - dospartoff = dp2->dp_start + part_blkno; + dospartoff = get_le(&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 = get_le(&dp2->dp_size); + lp->d_partitions[0].p_offset = + get_le(&dp2->dp_start) + part_blkno; if (lp->d_ntracks == 0) lp->d_ntracks = dp2->dp_ehd + 1; if (lp->d_nsectors == 0) @@ -180,11 +180,11 @@ donot: for (dp2=dp, i=0; i < NDOSPART && n < 8; i++, dp2++) { struct partition *pp = &lp->d_partitions[8+n]; - if (dp2->dp_size) - pp->p_size = dp2->dp_size; - if (dp2->dp_start) + if (get_le(&dp2->dp_size)) + pp->p_size = get_le(&dp2->dp_size); + if (get_le(&dp2->dp_start)) pp->p_offset = - dp2->dp_start + part_blkno; + get_le(&dp2->dp_start) + part_blkno; switch (dp2->dp_typ) { case DOSPTYP_UNUSED: @@ -216,9 +216,9 @@ donot: n++; break; case DOSPTYP_EXTEND: - part_blkno = dp2->dp_start + extoff; + part_blkno = get_le(&dp2->dp_start) + extoff; if (!extoff) - extoff = dp2->dp_start; + extoff = get_le(&dp2->dp_start); wander = 1; break; default: @@ -408,10 +408,10 @@ writedisklabel(dev, strat, lp, osdep) NDOSPART * sizeof(*dp)); for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (dp2->dp_size && dp2->dp_typ == DOSPTYP_OPENBSD) + if (get_le(&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 && dp2->dp_typ == DOSPTYP_386BSD) + if (get_le(&dp2->dp_size) && dp2->dp_typ == DOSPTYP_386BSD) ourpart = i; if (ourpart != -1) { @@ -421,7 +421,7 @@ writedisklabel(dev, strat, lp, osdep) * need sector address for SCSI/IDE, * cylinder for ESDI/ST506/RLL */ - dospartoff = dp2->dp_start; + dospartoff = get_le(&dp2->dp_start); cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect); } } diff --git a/sys/arch/arc/include/disklabel.h b/sys/arch/arc/include/disklabel.h index 5e46f7005b9..61e2c024655 100644 --- a/sys/arch/arc/include/disklabel.h +++ b/sys/arch/arc/include/disklabel.h @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.h,v 1.7 1997/08/08 21:46:37 niklas Exp $ */ +/* $OpenBSD: disklabel.h,v 1.8 1997/09/23 12:46:40 pefo Exp $ */ /* $NetBSD: disklabel.h,v 1.3 1996/03/09 20:52:54 ghudson Exp $ */ /* @@ -82,4 +82,18 @@ struct cpu_disklabel { #define DPSECT(s) ((s) & 0x3f) #define DPCYL(c, s) ((c) + (((s) & 0xc0) << 2)) +static __inline u_int32_t +get_le(p) + void *p; +{ + u_int32_t c; + u_int8_t *_p = (u_int8_t *)p; + int x; + x = _p[0]; + x |= _p[1] << 8; + x |= _p[2] << 16; + x |= _p[3] << 24; + return x; +} + #endif /* _MACHINE_DISKLABEL_H_ */ |