Subject: Re: bug #1
To: Charles Carvalho <carvalho@cisco.com>
From: Jake Luck <netbsd@10k.org>
List: port-macppc
Date: 03/14/2000 21:34:26
> OK, I had assumed it was the ddPad size that was the reported problem.
> But counting carefully, there are 7 shorts and 3 longs, for a total of
> 13*2 bytes if the compiler inserts no padding; ddPad[243] would make 256*2
> bytes.  But the macppc architecture aligns 32-bit elements to 32-bit
> boundaries (yes?), so 2 bytes of padding is inserted to align ddBlock,
> bringing the structure size to 514 bytes, which is then padded to 516
> bytes because the structure requires a 32-bit alignment.  So, adding
> the packed attribute to the structure, and leaving the size of ddPad
> at 243, should result in a 512-byte structure.

aaaaah, so this should make it nice and snug. thanks 

typedef struct
{
	u_int16_t	sbSig;		/* device signature */	
	u_int16_t	sbBlockSize;	/* block size of device */
	u_int32_t	sbBlkCount;	/* number of blocks on device */
	u_int16_t	sbDevType;	/* reserved */
	u_int16_t	sbDevID;	/* reserved */
	u_int32_t	sbData;		/* reserved */
	u_int16_t	sbDrvrCount;	/* number of driver descriptors */
	u_int32_t	ddBlock;	/* 1st driver's starting block */
	u_int16_t	ddSize;		/* size of 1st driver (512-byte blks) */
    	u_int16_t	ddType;		/* OS system type (MacOS = 1) */
	u_int16_t 	ddPad[243];	/* additional drivers, if any */
} __attribute__ ((packed)) BlockZ;