Subject: Re: disklabel(8) and machdep on-disk structures issues
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: tech-kern
Date: 10/31/2003 17:07:04
On Sat, Nov 01, 2003 at 12:09:37AM +0900, Izumi Tsutsui wrote:
> 
> LABELOFFSET on sparc was changed to 128 to make space of BSD disklabel:
> http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/sparc/include/disklabel.h#rev1.5
> 
> i.e. sparc and sun3 have different disklabel structure on NetBSD.
> (see port-sparc/6325 for details)

From what I see the NetBSD disklabel is stored in some free sparce in
the Sun disklabel (sl_bsdlabel) (for both sun3 and sparc/sparc64):
struct sun_disklabel {                  /* total size = 512 bytes */
        char    sl_text[128];
        char    sl_xxx1[292];
#define sl_bsdlabel     sl_xxx1         /* Embedded NetBSD label */

So LABELOFFSET set to 128 looks right to me.
Sun3 using 64 for labeloffset is wrong (and doesn't use it anyway, see
sys/sun3/sun3/disksubr.c).

So I propose:
- fix next68k disksubr.c to always write a next-compatible disklabel
  in addition to the NetBSD disklabel (need to find some space for
  the NetBSD disklabel first, shouldn't be too hard).
- Fix the sun3 LABELOFFSET, and factor out disksubr.c between sun3, sparc and
  sparc64 (with some compat code to look for a NetBSD disklabel at
  LABELOFFSET=64 in the sun3 case)
- remove #ifdef __sparc__ hack from disklabel(8), and change it to issue
  a DIOCWDINFO after writing the disklabel to the raw partition in the
  -r/-I case (so that the kernel can convert the label if needed)

--
Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
     NetBSD: 24 ans d'experience feront toujours la difference
--