/*
 *	Program to compare the code found in the
 *	current /unix file with either a core dump
 *	or the current kernel memory - helps
 *	when getting store corruptions of some sort
 */
int ccbuf[256];
int ubuf[256];
char *core "/usr/sys/core";
char kmem[] "/dev/kmem";
int tsize;
main(argc, argv)
char **argv;
{	int cfd, ufd;
	register int *s, *d, ch;
	int addr;
	addr = 0;
	argv++;
	if(argc != 1) core = *argv;
	if((ufd = open("/unix", 0)) < 0)
	{	printf("can't open /unix\n");
		exit();
	}
	if((cfd = open(core, 0)) < 0)
	{	printf("Can't open: %s\n", core);
		exit();
	}

	seek(ufd, 2, 0);
	read(ufd, &tsize, 2);
	seek(ufd, 16, 0);
	while(tsize > 0)
	{	if(tsize >= 512)
		{	ch = 512;
			tsize =- 512;
		}
		else
		{	ch = tsize;
			tsize = 0;
		}
		read(ufd, ubuf, ch);
		ch =read(cfd, ccbuf, ch);
		s = ubuf;
		ch =/ 2;
		for(d = ccbuf; d < &ccbuf[ch]; d++)
		{	if(*d != *s++)
				printf("Mismatch at %6o old %6o new %6o\n", addr, s[-1], *d);
			addr =+ 2;
		}
	}
}
