4.2BSD installation mystery ...

Steven Bellovin smb at ulysses.UUCP
Mon Dec 5 10:59:55 AEST 1983


I've seen a similar problem, and I believe it to be a bug in the kernel
and/or fsck.  In my case, the block number that fsck couldn't read was
291344.  By a curious non-coincidence, the slice in question (the
'h' slice on an RM05) has 291346 blocks.  Thus, there are only 2 blocks
available before the end of the file system, and an attempt to read
a full block will fail.  Worse yet, it will behave differently with
the cooked and raw devices.  Try this program -- on the cooked device,
*all three* reads fail, even though the first two should work!  On the
raw device, the first two work (512 and 1024 bytes), but the third fails.
My own opinion is that the third read (of 4096 bytes) should return a short
block.
--------------------
#include <ctype.h>
extern int errno;

main(argc, argv) int argc; char *argv[];
{
	extern long lseek();
	char buf[4096]; int i, fd;

	chdir("/dev");
	fd = open (argv[1], 0);
	if (fd < 0) {
		perror("open");
		exit(1);
	}

	if (lseek(fd, 291344L*512L, 0) < 0) {
		perror("lseek 1");
		exit(1);
	}
	i = read(fd, buf, 512);
	printf("512 %d %d\n", i, errno);

	if (lseek(fd, 291344L*512, 0) < 0) {
		perror("lseek 2");
		exit(1);
	}
	i = read(fd, buf, 1024);
	printf("1024 %d %d\n", i, errno);

	if (lseek(fd, 291344L*512L, 0) < 0) {
		perror("lseek 3");
		exit(1);
	}
	i = read(fd, buf, 4096);
	printf("4096 %d %d\n", i, errno);
}



More information about the Comp.bugs.4bsd.ucb-fixes mailing list