Bug in dump

sanjay Radia srradia at watmath.UUCP
Mon Jun 25 22:16:59 AEST 1984


Index: dump 4.2 Fix

Description:
	A serious bug exists in dump.
Dump makes a pass through all the inodes and marks the inodes to be
dumped in dirmap & nodmap. However, if the system is busy the inodes
can be deleted and possibly reallocated for other files.
In the next pass, when dumping inodes, dump does not bother to check to see if
the inodes are still allocated and in the case of directories does not check to
see the inode is still a directory.

	Now, the dump tape has a bunch of directories (directory-zone) followed
by non-directories and as soon as restore sees a non-directory it thinks it has
scanned the directory-zone. Thus if a directory inode is delelted (and maybe
realloced to a file) between the 1st & 2nd passes of dump, the dump tape
will not be correctly read by restore (you will loose some (a lot) of the
directory information).

Repeated-By:
	Create about 3 directories and start a dump on the file system.
When dump asks you to mount the tape delete one of the three
directories (the one with the lowest inode #). Now continue with the
dump. 
	Do a "/etc/restore ivd". You will see that restore will not
know of any directories with inodes greater than the the one you deleted
(ie they will be marked as regular files and not as directories). You
can check this out by doing a "lc" in restore's interactive mode.


Fix:
	The following is a fix to dump. Since our dump has changed, the line
numbers might not match.
Note that restore can be fixed to ignore free inodes (in function
dirextract() in dirs.c) but there is no nice way to by-pass file-inodes
in the directory-zone. There should have been a special record between
the directory-zone and the file-zone (if you put this in, your old & new tapes
will not be compatible).



****** dumpmain.c
>change the line marked with ! (the context and old/new versions given
OLD *** 265,271
  	bitmap(clrmap, TS_CLRI);
  
  	msg("dumping (Pass III) [directories]\n");
! 	pass(dump, dirmap);
  
  	msg("dumping (Pass IV) [regular files]\n");
  	pass(dump, nodmap);

NEW --- 288,295 -----
  	bitmap(clrmap, TS_CLRI);
  
  	msg("dumping (Pass III) [directories]\n");
! 	pass(dirdump, dirmap);
  
  	msg("dumping (Pass IV) [regular files]\n");
  	pass(dump, nodmap);






--- dumptraverse.c
> add the function dirdump() (marked with +) (add an extern in dump.h)
> and add the lines marked with '+' in dump() (the context is given)
  
+ dirdump(ip)
+ 	struct dinode *ip;
+ {
+ 	/* watchout for dir inodes deleted and maybe reallocated */
+ 	if ((ip->di_mode & IFMT) != IFDIR)
+ 		return;
+ 	dump(ip);
+ }
+ 
+ 
  dump(ip)
 	struct dinode *ip;
  {
	........
	......
	.....
  	i = ip->di_mode & IFMT;
+ 
+ 	if (i == 0) /* free inode */
+ 		return;
+ 
  	if ((i != IFDIR && i != IFREG && i != IFLNK) || ip->di_size == 0) {
  		spclrec();
  		return;
-- 
			sanjay
			{allegra,decvax}!watmath!srradia



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