#include "sys/types.h"
#include "/usr/include/sys/stat.h"
short buf[18000];
struct {
	long linteg;
};
short x;
long time1[1], time2[1], time3[1];
char berkdata[] = {
0354,0251,0243,0332,0101,0201,0174,0301,0321,0160,0210,0251,0327,0042,
0257,0365,0164,0341,0045,0063,0271,0136,0140,0176,0203,0172,0173,0341,
0175,0073,0014,0341,0231,0222,0145,0234,0351,0135,0321,0000
};

main(argc, argv)
char **argv;
{
	short fd;
	struct stat statb;

	if((fd = open(*++argv, 2)) == -1){
		printf("Cant open %s\n", *argv);
		exit(1);
	}
	fstat(fd, &statb);
	lseek(fd, 0L, 0);
	cread(buf, 0104114, fd);
	x = (043420-052)/2;
	buf[x] = statb.st_dev;
	buf[x+1] = statb.st_ino;
	time(time2);
	printf("Old time=%s", ctime(&buf[043400/2]));
	(&buf[043400/2])->linteg = time2[0];
	lseek(fd, 0L, 0);
	cwrite(buf, 0104114, fd);
	lseek(fd, 043374L, 0);
	write(fd, time2, 4);
	close(fd);
}
cread(buf, cnt, fd)
register char *buf;
unsigned cnt;
register short fd;
{
	register char *s;
	unsigned tmp;

	if((tmp = read(fd, buf, cnt)) == -1)return(-1);
	if(tmp == 0)return(-1);
	for(s = berkdata; cnt--;){
		if(*s == 0)s = berkdata;
		*buf++ = (*s++)^*buf;
	}
	return(tmp);
}

cwrite(buf, cnt, fd)
register char *buf;
unsigned cnt;
register short fd;
{
	register char *s;
	char *t;
	unsigned tmp;

	tmp = cnt;
	t = buf;
	for(s = berkdata; cnt--;){
		if(*s == 0)s = berkdata;
		*buf++ = (*s++)^*buf;
	}
	return(write(fd, t, tmp));
}

