struct extent {
	unsigned short	checkSum;
	short		kind;
	unsigned short	extno;
	char		label[20];
	char		secTiiScat;
	char		secTiiIcat;
	unsigned short	secTiiScom[2];
	unsigned short	secTiiOwner;
	unsigned short	secTiiGroup;
	unsigned short	secTiiDa;
	unsigned short	secTiiPriv[2];
	char		secSubNsp;
	char		secSubId0;
	unsigned short	secSubId1;
	unsigned short	firstblock[2];
	unsigned short	lastblock[2];
	unsigned short	extSize[2];
	char		filler[44];
	};

int	fd;

main()
{
if ((fd = open("/dev/ksos", 0)) < 0) {
	perror("/dev/ksos");
	exit(1);
	}
show(0);
show(1);
show(2);
show(3);
show(4);
show(5);
show(6);
show(7);
show(8);
show(9);
show(10);
close(fd);
}

show(index)
register int	index;
{
struct extent	map;
	
lseek(fd, 512 * (5 + index / 5) + ((index % 5) * sizeof (struct extent)), 0);
read(fd, &map, sizeof (struct extent));
printf("index = %d, number = %u, name = %s, size = %ld\n", index, map.extno, map.label, *(long *)map.extSize);
printf("\tfirst block = %ld, last block = %ld\n", *(long *)map.firstblock, *(long *)map.lastblock);
printf("\tsec cat = %d, int cat = %d, sec comp = 0%lo, owner = %d\n", map.secTiiScat, map.secTiiIcat, *(long *)map.secTiiScom, map.secTiiOwner);
printf("\tgroup = %d, da = 0%o, privs = 0%lo, subtype = %d/%d/%d\n", map.secTiiGroup, map.secTiiDa, *(long *)map.secTiiPriv, map.secSubNsp, map.secSubId0, map.secSubId1);
if (calc(&map) != map.checkSum)
	printf("\tcalculated checksum %u differs from actual %u\n", calc(&map), map.checkSum);
}

calc(area)
register unsigned short	*area;
{
register unsigned short	sum, size;

sum = 31415;
size = sizeof (struct extent) / 2 - 1;
do {
	sum += *++area;
	} while (--size != 0);
return(sum);
}
