Subject: Re: LC 475
To: Allen Briggs <briggs@puma.bevd.blacksburg.va.us>
From: Charles J. Williams <chas@ohm.nrl.navy.mil>
List: port-mac68k
Date: 10/18/1995 08:16:24
In message <199510180305.XAA15230@puma.bevd.blacksburg.va.us>,Allen Briggs writ
es:
>> tends to be driver/partition-layout specific information in some places for
>> the driver to read.

yeah but the layout is well known, try running this program on under netbsd:
(give it a pointer to the "c" partition of a particular drive)


struct DriverDescriptor
{
	short	sbSig;		/* 0x4554 */
	short	sbBlockSize;	/* blocksize of device */
	long	sbBlkCount;	/* number of blocks on device */
	short	sbDevType;	/* used internally */
	short	sbDevID;	/* used internally */
	long	sbData;		/* used internally */
	short	sbDrvrCount;	/* used internally */
	long	ddBlock;	/* first block of driver */
	short	ddSize;		/* driver size in blocks */
	short	ddType;		/* system type */
};

struct PartitionMap
{
	short	pmSig;		/* 0x504D */
	short 	pmSigPad;	/* reserved */
	long	pmMapBlkCnt;	/* number of blocks in map */
	long	pmPyPartStart;	/* first physical block of parition */
	long	pmPartBlkCnt;	/* first physical block of parition */
	char	pmPartName[32];	/* partition name */
	char 	pmPartType[32];	/* partition type */
};


#include <stdio.h>
#include <sys/fcntl.h>
#include <unistd.h>

#include "volume.h"


main(int argc, char **argv)
{
	int fd, i;
	
	struct DriverDescriptor dd;
	struct PartitionMap	pm;
	long	nPartitions;

	if ( (fd = open(argv[1], O_RDONLY)) < 0 )
	{
		perror("failed to open device:");
		exit(1);
	}

	read(fd, &dd, sizeof(struct DriverDescriptor));

	printf("sbSig = 0x%04x\n", dd.sbSig);
	printf("sbBlockSize = %d\n", dd.sbBlockSize);
	printf("sbBlkCount = %d\n", dd.sbBlkCount);
	printf("sbDrvrCount = %d\n", dd.sbDrvrCount);

	
	nPartitions = 100;	/* assume */
	for(i=1;i<=nPartitions;++i)
	{
		lseek(fd, (i*dd.sbBlockSize), SEEK_SET);

		read(fd, &pm, sizeof(struct PartitionMap));

		nPartitions = pm.pmMapBlkCnt;		/* only should come from Apple_partition_map */

#if 0
		printf("pmSig = 0x%04x\n", pm.pmSig);
		printf("pmPartName = \"%s\"\n", pm.pmPartName);
		printf("pmPartType = \"%s\"\n", pm.pmPartType);
		printf("pmPyPartStart = %d\n", pm.pmPyPartStart);
		printf("pmMapBlkCnt = %d\n", pm.pmMapBlkCnt);
		printf("pmPartBlkCnt = %d\n", pm.pmPartBlkCnt);
#endif
		printf("%-32s %d - %d (%d) %s\n",	pm.pmPartType,
			pm.pmPyPartStart, pm.pmPyPartStart + pm.pmPartBlkCnt, pm.pmPartBlkCnt,
			pm.pmPartName);
	}

	close(fd);
	
}