Subject: Solution to "illegal AHDI partition table"?
To: None <port-atari@NetBSD.ORG>
From: Waldi Ravens <waldi@moacs.indiv.nl.net>
List: port-atari
Date: 11/19/1995 23:41:06
Hi everyone,

I think, I got wat I wrote in the subject. But first a couple of
comments for those who wonder "What the heck is going on? Why
can't NetBSD behave the same as my TOS harddisk driver or
Linux/Atari?".

[ quoting myself from private e-mail: ]
| Extended partitions (XGM) do seem to be the culprit, but they
| are recognized and dealt with by NetBSD. The problem seems to
| be that some partitioning tools under TOS are doing a `sloppy'
| job.
| 
| Even SCSI-tools, which I consider good software, did miscalculate
| the size of the extended partitions on my own drives (I send a bug
| report to Julian). TOS drivers (both HuSHI and HDDriver) nor Linux
| spotted this minor error in the AHDI partition table, but NetBSD is
| rather strict in this respect.
| 
| The problem is that the AHDI partition table is not protected by
| a magic nuber or a checksum (the NetBSD partition table is pro-
| tected by both). Therefore NetBSD has to perform lots of sanity
| checks to not, by accident, misinterprete the identity of the
| partition table
| 
| NetBSD is a multi-platform OS, so you might have SunOS, OSF or
| whatever formatted disks connected to your computer. Such disks
| have a different partition table, which must not be confused with
| the AHDI partition table.
| 
| Note that currently NetBSD/Atari only recognizes two kind of disk
| labels, the AHDI label and a NetBSD/Atari specific label (not
| recognized by TOS drivers). Support for other formats will be
| added later, presumably as a kernel config option.

The solution is hidden in the third paragraph. "As the cause of all
evil is the lack of protection", I thought to myself, "why not simply
invent some sort of protection?".

So what I suggest, is to use the only possibility offered by the AHDI
format, which is the checksum field in the last word of the root sector.
If we declare that a root sector checksum of either 0x1234 (bootable) or
else 0x4321 means that the root sector contains a valid AHDI partition
table, then the kernel wouldn't have to get involved in extensive
sanity checks.

Now I hear Leo think, "What about my bootable NetBSD/Atari disk? Won't
the kernel think it's has an AHDI label?". No, it won't, NetBSD checks
for a normal label first; only if it cannot find a normal label, it
will look for the AHDI stuff.

Any comments, objections or improvements?


Regards,
Waldi