Subject: Re: disklabel compatibility between platforms?
To: Kevin P. Neal <kpneal@pobox.com>
From: Bill Studenmund <wrstuden@zembu.com>
List: port-alpha
Date: 12/15/2000 11:22:48
On Fri, 15 Dec 2000, Kevin P. Neal wrote:

> On Thu, Dec 14, 2000 at 10:50:43PM -0500, packet ninja wrote:
> > 
> > hey.
> > 
> > my multia died today for reasons as-yet unknown (could be heat stroke :))
> > but when i plugged the 4 gig SCSI from the multia into my netbsd macppc
> > machine, it refuses to see a disklabel.  (this is *really* bad since i
> > have a mail spool and ~/mail tree i *need* to jank off the disk.)
> 
> NetBSD has this feature where every platform uses the native disk partitioning
> scheme of the native (vendor-supplied) operating system. Typically this is
> because the firmware for most platforms already understands partitions. The
> up side is that NetBSD partitions are always recognized by the regular
> tools for that platform. The down side is that every platform has different
> partitioning schemes, so disks can't be taken from one platform and put
> on another without difficulty. 
> 
> You are going to have to recreate the disklabel on the Mac. If you have
> a copy of the old (Alpha) disklabel you can probably use macppc's disklabel
> to put it back on the disk Mac-style. 

This is not quite correct. While you are correct about supporting
different formats being hit & miss, the problem that our ninja is
encountering is different. macppc does support NetBSD disklabels, which
the Alpha uses (we're trying to move away from them, but that is a
different discussion). What we DON'T support is cross-endian disklabels.
Alpha is little-endian, and macppc is big-endian. Thus the problem.

> It is probably best for you to dd the disk into a file on another drive,
> so you can be sure you won't corrupt the filesystems with a Mac disklabel.
> 
> If you don't have a copy of the disklabel then you need to pull the
> find_ffs utility out of the list archives and locate the beginning of each
> filesystem on the disk. Then you can recreate a disklabel (see above).

Actually there is an easier way. It requires a bit of hacking, but not
much. Get the source for mbrlabel, and the disklabel reading code
(sys/arch/alpha/alpha/disksubr.c I think). Change it so that instead of
calling getparts(), it calls the disksubr.c disklabel reading code. You'll
need to make two changes to the disklabel reading code. One is to read
from a file discriptor instead of the buffer cache system (getparts() will
show you how to do this), the other is to do byte swapping. Whenever you
copy from the read buffer into the global named label, convert from LE to
BE. getlong() does the right thing for ints (int32_t) (it is not named
right), and you might need the equivalent for shorts (int16_t).

You might want to comment out the setlabel() routine, and printf what you
get while debugging.

Take care,

Bill