Subject: Re: disklabel(8) and machdep on-disk structures issues
To: David Laight <david@l8s.co.uk>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: tech-kern
Date: 10/31/2003 12:39:55
On Fri, Oct 31, 2003 at 12:25:07AM +0000, David Laight wrote:
> I think that disklabel(8) ought to be able to write the label in all
> formats on any format without requiring any kernel code. 

With a -m flag, like installboot.
It's probably something we should look at, but it's more work than I want
to put into this for now.

> It should
> probably overwrite any old label by default as well.
> Then the kernel can be changed to play 'hunt the disklabel' for reading
> and have the code that writes labels removed entirely.
> (The 'write label' code would need to be in (say) libutil, so other
> programs can use it.)

Hum
Is there any other programs using DIOCWDINFO ?

Also, I notice that in the sparc case, we always use DIOCWDINFO.
disklabel(5) says:
[...] Finally, the
     DIOCWDINFO ioctl(2) operation sets the in-core label and then updates the
     on-disk label; there must be an existing label on the disk for this oper-
     ation to succeed.  Thus, the initial label for a disk or disk pack must
     be installed by writing to the raw disk.  All of these operations are
     normally done using disklabel(8).

For sparc, and next68k too, DIOCWDINFO can write a label even if
no label is initially present on disk.

I also looked at the sun3 case: LABELSECTOR=0, LABELOFFSET=64.
When it writes the disklabel, it always convert to sun disklabel (which
starts at sector 0, offsert 0). I what happens here is that on a unlabelled
disk, disklabel(8) will write directly to disk a NetBSD disklabel,
which will then be converted to sun disklabel by the next DIOCWDINFO.

For sparc, the NetBSD disklabel is embeded in the sun disklabel in some
free space (sun3 could probably do it as well), and DIOCWDINFO always write
a sun disklabel and a NetBSD disklabel.

My conclusions are:
- sun3 should probably write a NetBSD disklabel inside the sun disklabel,
  just as sparc does. BTW, sun3 and sparc could probably share the same
  disksubr.c (I didn't look at sparc64 and sun2 yet).
- the #ifdef __sparc__ in disklabel(8) can probably go away, as sun3 works
  without it.
- next68k should do the same, i.e. DIOCWDINFO always write a NeXT disklabel.
 If there is enouth space in the first sector, we may be able to keep a
  NetBSD disklabel in there too.

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