Subject: disklabel exercises
To: None <port-mac68k@NetBSD.ORG>
From: Taras Ivanenko <ivanenko@ctpa03.mit.edu>
List: port-mac68k
Date: 07/14/1998 14:43:45
Here is the setup:
I had to share the SyJet cartridge among SunOS, NetBSD/sparc, MacOS
and NetBSD/mac68k. The cartridge was originally formatted on SunOS
with some space reserved for other uses. (It was compatible with
NetBSD/sparc by virtue of SunOS compatibility code).
To make the cartridge compatible with MacOS and NetBSD/mac68k I needed
the MacOS - style labels on it. Unfortunately, looking around my MacOS
disk I could not find any formatting program good enough to write
partition map exactly the way I wanted without creating the file
systems. What I really wanted was the label similar to the existing
SunOS label already on the disk. So, I wrote a small program which
created the partition map (after examining presumably good partition
maps on my other disks). The only value which I could not find was the
pmPartStatus field which was always 55 in the partition maps on the
other disks. So, I let it be 55 in my fake partition too. Since I did
not have a MacOS driver, I left the driver info in sector 0 empty.
I had to reserve the whole cylinder (in SunOS geometry) for Mac
partition map.
Of course, NetBSD/mac68k was happy with my fake labels and I am sure
of it because I know everything about it disk access code
(/sys/arch/mac68k/mac68k/disksubr.c). What is interesting, MacOS also
accepted the label after some magic clicking on "PC Exchange" and
"Silverlining Lite" control panels.
Why NetBSD/mac68k still can not write MacOS-style disklabels? I am not
sure if I want to see all the code go into the kernel but at least we
can have a small utility which could write the specified labels onto
the disk (#ifdef mac68k code in disklabel.c?) I do not like much of
the Mac formatting utilities and they tend to support A/UX less and
less with time.
As a final step I put SunOS-style label into sector 0, upper 128
bytes. NetBSD/mac68k does not care about anything in sector 0
(signature 'ER'), MacOS seemed to survive extra bits in that sector,
and NetBSD/sparc+SunOS do not care about lower 128 bytes of sector
0. I did not put in BSD-style label because I did not need to,
although there was some space.
I also noticed that /sys/arch/mac68k/include/disklabel defines
#define LABELOFFSET 64 /* offset of label in sector */
Does it mean that someone has already thought of putting BSD label
along with MacOS driver information into sector 0? On the other hand,
the relevant code in disksubr.c does something strange:
(around line 510)
if (*sbSigp == 0x4552) {
msg = read_mac_label(dev, strat, lp, osdep);
} else {
dlp = (struct disklabel *)(bp->b_un.b_addr + 0);
if (dlp->d_magic == DISKMAGIC) {
*lp = *dlp;
} else {
msg = "no disk label--NetBSD or Macintosh";
}
}
Is zero on the line 4 above actually the value of LABELOFFSET before
it was changed to 64 and left there and a number "0" for compatibility
only? Then it should be marked /* XXX */ as I understand KNF.
Also, the value of 128 will make the disks compatible with
NetBSD/sparc.
I have my own reasons to want extra SunOS compatibility from
NetBSD/mac68k (I do have both Mac and Sun) but NetBSD partitioning
utility compatible with MacOS would be nice. I can integrate my code
into disklabel.c and submit it by send-pr, it is not much and not a
very complicated code.
Taras Ivanenko.