Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site watmath.UUCP Path: utzoo!watmath!srradia From: srradia@watmath.UUCP (sanjay Radia) Newsgroups: net.bugs.4bsd Subject: Bug in dump Message-ID: <8132@watmath.UUCP> Date: Mon, 25-Jun-84 08:16:59 EDT Article-I.D.: watmath.8132 Posted: Mon Jun 25 08:16:59 1984 Date-Received: Tue, 26-Jun-84 00:21:49 EDT Organization: U of Waterloo, Ontario Lines: 96 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