If we have successfully found and read in the disk block we expect
to hold the OpenBSD disklabel, then what is there must be treated
as the disklabel. If it is currently invalid (e.g. all zeros) we
still want to write the new label in this MD location, and thus
should pass the spoofed label back up the stack. We DON'T want
to put the label in the readdoslabel() location.

This fixes the easy arches with read<MD>label() functions so they
can (again?) be formatted using the native tools and OpenBSD can
put its disklabel in the expected place.

This also fixes the boundstart/boundend values returned so the
OpenBSD 'area' is initialized to the specificied area of disk.

Alpha/mac68k/sparc/sparc64 fixes will follow.

ok?

.... Ken

Index: hppa/hppa/disksubr.c
===================================================================
RCS file: /cvs/src/sys/arch/hppa/hppa/disksubr.c,v
retrieving revision 1.82
diff -u -p -r1.82 disksubr.c
--- hppa/hppa/disksubr.c        8 Jul 2011 00:08:00 -0000       1.82
+++ hppa/hppa/disksubr.c        8 Jul 2011 20:22:12 -0000
@@ -234,8 +234,15 @@ finished:
                goto done;
        }
 
-       error = checkdisklabel(bp->b_data + LABELOFFSET, lp, openbsdstart,
-           DL_GETDSIZE(lp));   /* XXX */
+       /*
+        * Do OpenBSD disklabel validation/adjustment.
+        *
+        * N.B: No matter what the bits are on the disk, we now have the
+        * OpenBSD disklabel for this lif disk. DO NOT proceed to
+        * readdoslabel(), iso_spooflabel(), etc.
+        */
+       checkdisklabel(bp->b_data, lp, openbsdstart, DL_GETDSIZE(lp));
+       error = 0;
 
 done:
        if (dbp) {
Index: hppa64/hppa64/disksubr.c
===================================================================
RCS file: /cvs/src/sys/arch/hppa64/hppa64/disksubr.c,v
retrieving revision 1.66
diff -u -p -r1.66 disksubr.c
--- hppa64/hppa64/disksubr.c    8 Jul 2011 00:08:00 -0000       1.66
+++ hppa64/hppa64/disksubr.c    8 Jul 2011 20:46:56 -0000
@@ -234,8 +234,15 @@ finished:
                goto done;
        }
 
-       error = checkdisklabel(bp->b_data + LABELOFFSET, lp, openbsdstart,
-           DL_GETDSIZE(lp));   /* XXX */
+       /*
+        * Do OpenBSD disklabel validation/adjustment.
+        *
+        * N.B: No matter what the bits are on the disk, we now have the
+        * OpenBSD disklabel for this lif disk. DO NOT proceed to
+        * readdoslabel(), iso_spooflabel(), etc.
+        */
+       checkdisklabel(bp->b_data, lp, openbsdstart, DL_GETDSIZE(lp));
+       error = 0;
 
 done:
        if (dbp) {
Index: macppc/macppc/disksubr.c
===================================================================
RCS file: /cvs/src/sys/arch/macppc/macppc/disksubr.c,v
retrieving revision 1.74
diff -u -p -r1.74 disksubr.c
--- macppc/macppc/disksubr.c    8 Jul 2011 00:08:00 -0000       1.74
+++ macppc/macppc/disksubr.c    8 Jul 2011 20:50:19 -0000
@@ -183,8 +183,16 @@ readdpmelabel(struct buf *bp, void (*str
        if (biowait(bp))
                return(bp->b_error);
 
-       return checkdisklabel(bp->b_data + LABELOFFSET, lp, hfspartoff,
-           hfspartend);
+       /*
+        * Do OpenBSD disklabel validation/adjustment.
+        *
+        * N.B: No matter what the bits are on the disk, we now have the
+        * disklabel for this dpme disk. DO NOT proceed to readdoslabel(),
+        * iso_spooflabel(), * etc.
+        */
+       checkdisklabel(bp->b_data + LABELOFFSET, lp, openbsdstart,
+           DL_GETDSIZE(lp));
+       return (0);
 }
 
 /*
Index: sgi/sgi/disksubr.c
===================================================================
RCS file: /cvs/src/sys/arch/sgi/sgi/disksubr.c,v
retrieving revision 1.24
diff -u -p -r1.24 disksubr.c
--- sgi/sgi/disksubr.c  8 Jul 2011 00:08:00 -0000       1.24
+++ sgi/sgi/disksubr.c  8 Jul 2011 20:50:49 -0000
@@ -206,7 +206,16 @@ finished:
        if (biowait(bp))
                return (bp->b_error);
 
-       return checkdisklabel(bp->b_data + offset, lp, fsoffs, fsend);
+       /*
+        * Do OpenBSD disklabel validation/adjustment.
+        *
+        * N.B: No matter what the bits are on the disk, we now have the
+        * OpenBSD disklabel for this sgi disk. DO NOT proceed to
+        * readdoslabel(), iso_spooflabel(), etc.
+        */
+       checkdisklabel(bp->b_data + LABELOFFSET, lp, openbsdstart,
+           DL_GETDSIZE(lp));
+       return (0);
 }
 
 /*

Reply via email to