4.3 Tahoe dump bug

Dave Lamkin dave at acorn.co.uk
Wed Dec 21 04:39:39 AEST 1988


BSD 4.3 file systems ensured that a directory length was a multiple of
DEV_BSIZE, this is not the case on NFS 3.2 versions of BSD. This causes
problems with fsck and dump.

fsck will find (&hence fix) "errors" with directory lengths from time to
time.

dump when encountering a directory which is not a multiple of 512 bytes long
will fail to read it with the errors as described.  The fix is to round up
the request length to the bread routine to a multiple of DEV_BSIZE. This is
done in the routine dsrch in dumptraverse.c as below. A workaround is to fsck
the disc prior to dumping.

------------------------------------------------------------------------------
dsrch(d, size, filesize)
	daddr_t d;
	int size, filesize;
{
	register struct direct *dp;
	long loc;
	char dblk[MAXBSIZE];

	if(dadded)
		return;
	if (filesize > size)
		filesize = size;
/* +++++++++++++ Fix start ++++++++++
 * Extend the length of the directory.
 * NFS 3.2 no longer ensures multiple of DEV_BSIZE
 */
	filesize = (filesize + DEV_BSIZE - 1) & ~(DEV_BSIZE - 1);
/* ------------- Fix end ----------- */

	bread(fsbtodb(sblock, d), dblk, filesize);
	for (loc = 0; loc < filesize; ) {
		dp = (struct direct *)(dblk + loc);
		if (dp->d_reclen == 0) {
			msg("corrupted directory, inumber %d\n", ino);
			break;
		}
		loc += dp->d_reclen;
		if(dp->d_ino == 0)
			continue;
		if(dp->d_name[0] == '.') {
			if(dp->d_name[1] == '\0')
				continue;
			if(dp->d_name[1] == '.' && dp->d_name[2] == '\0')
				continue;
		}
		if(BIT(dp->d_ino, nodmap)) {
			dadded++;
			return;
		}
		if(BIT(dp->d_ino, dirmap))
			nsubdir++;
	}
}



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