A bit of confusion crept in somewhere along the line and LABELSECTOR was being 
added
to the hfspartition offset, which caused the OpenBSD disklabel to be read from 
sector
1 on the disk, rather than sector 0. To compensate the hfspartition offset was
decremented to make the location come out as before. But this consfused the 
bounds
of the OpenBSD section of the disk and thus spread further confusion and 
defeated
the stricter bounds checking now being done.

So use LABELSECTOR as it should be (i.e. the 512-byte block number of the native
dpme disk label), leave the OpenBSD hfs partition offsets alone and put the
OpenBSD disklabel in the first block of the OpenBSD dmpe partition.

Problem noted by Mathieu Olivier a while ago on ppc@.

ok?

.... Ken

Index: disksubr.c
===================================================================
RCS file: /cvs/src/sys/arch/macppc/macppc/disksubr.c,v
retrieving revision 1.74
diff -u -p -r1.74 disksubr.c
--- disksubr.c  8 Jul 2011 00:08:00 -0000       1.74
+++ disksubr.c  8 Jul 2011 00:24:17 -0000
@@ -106,7 +106,7 @@ readdpmelabel(struct buf *bp, void (*str
        struct part_map_entry *part;
 
        /* First check for a DPME (HFS) disklabel */
-       bp->b_blkno = 1;
+       bp->b_blkno = LABELSECTOR;
        bp->b_bcount = lp->d_secsize;
        CLR(bp->b_flags, B_READ | B_WRITE | B_DONE);
        SET(bp->b_flags, B_BUSY | B_READ | B_RAW);
@@ -125,7 +125,7 @@ readdpmelabel(struct buf *bp, void (*str
                struct partition *pp;
                char *s;
 
-               bp->b_blkno = 1+i;
+               bp->b_blkno = LABELSECTOR + i;
                bp->b_bcount = lp->d_secsize;
                CLR(bp->b_flags, B_READ | B_WRITE | B_DONE);
                SET(bp->b_flags, B_BUSY | B_READ | B_RAW);
@@ -140,7 +140,7 @@ readdpmelabel(struct buf *bp, void (*str
                                *s = (*s - 'a' + 'A');
 
                if (strcmp(part->pmPartType, PART_TYPE_OPENBSD) == 0) {
-                       hfspartoff = part->pmPyPartStart - LABELSECTOR;
+                       hfspartoff = part->pmPyPartStart;
                        hfspartend = hfspartoff + part->pmPartBlkCnt;
                        if (partoffp) {
                                *partoffp = hfspartoff;
@@ -175,7 +175,7 @@ readdpmelabel(struct buf *bp, void (*str
                return (0);
 
        /* next, dig out disk label */
-       bp->b_blkno = hfspartoff + LABELSECTOR;
+       bp->b_blkno = hfspartoff;
        bp->b_bcount = lp->d_secsize;
        CLR(bp->b_flags, B_READ | B_WRITE | B_DONE);
        SET(bp->b_flags, B_BUSY | B_READ | B_RAW);
@@ -203,8 +203,8 @@ writedisklabel(dev_t dev, void (*strat)(
        bp->b_dev = dev;
 
        if (readdpmelabel(bp, strat, lp, &partoff, 1) == 0) {
-               bp->b_blkno = partoff + LABELSECTOR;
-               offset = LABELOFFSET;
+               bp->b_blkno = partoff;
+               offset = 0;
        } else if (readdoslabel(bp, strat, lp, &partoff, 1) == 0) {
                bp->b_blkno = DL_BLKTOSEC(lp, partoff + DOS_LABELSECTOR) *
                    DL_BLKSPERSEC(lp);

Reply via email to