Subject: Re: Why my life is sucking.
To: Dean Huxley <dean@huxley.org>
From: enami tsugutomo <enami@sm.sony.co.jp>
List: current-users
Date: 01/17/2001 13:01:46
Dean Huxley <dean@huxley.org> writes:

> oops.  my mistake.  I had a printf after the line:
>         last = upperbnd(maxino - 1);
> 
> It reported last was 11190289.  As I was writing up the email I was
> thinking the line was "last = (maxino - 1);" so I incorrectly reported
> that maxino was 11190290.

Thanks.  So, my assumption was wrong.  The highest inode number on the
tape is 11190289 and it actually exists.

Instead, what actually doesn't exists is

	first=2642949

and i guess it was the very first missing inode.  If so, after
extracting the inode just before this, curfile.ino become next inode
on the tape (i.e., greater than 2642949).  And restore won't ignore
it.  If the next inode is also not found on the tape, restore will
warn it.

I guess appended *UNTESTED* patch will make restore warn and ignore
those files.  Please someone reveiw it.

Even with this patch, if the last inode was missed or one of multiple
dump tapes is missed, restore will prompt for the next tape.  So, i
guess we need to ask user as christos says.

enami.
Index: restore.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/restore/restore.c,v
retrieving revision 1.12
diff -u -r1.12 restore.c
--- restore.c	1997/09/15 08:04:35	1.12
+++ restore.c	2001/01/17 03:42:48
@@ -699,6 +699,12 @@
 	skipdirs();
 	first = lowerbnd(ROOTINO);
 	last = upperbnd(maxino - 1);
+
+again:
+	/*
+	 * Decide on the next inode needed in this volume.
+	 */
+	next = lowerbnd(curfile.ino);
 	for (;;) {
 		first = lowerbnd(first);
 		last = upperbnd(last);
@@ -711,19 +717,20 @@
 		 * Reject any volumes with inodes greater
 		 * than the last one needed
 		 */
-		while (curfile.ino > last) {
-			curfile.action = SKIP;
-			getvol((long)0);
-			skipmaps();
-			skipdirs();
+		if (curfile.ino > last) {
+			do {
+				curfile.action = SKIP;
+				getvol((long)0);
+				skipmaps();
+				skipdirs();
+			} while (curfile.ino > last);
+			goto again;
 		}
 		/*
-		 * Decide on the next inode needed.
-		 * Skip across the inodes until it is found
+		 * Skip across the inodes until the next inode is found
 		 * or an out of order volume change is encountered
 		 */
-		next = lowerbnd(curfile.ino);
-		do	{
+		do {
 			curvol = volno;
 			while (next > curfile.ino && volno == curvol)
 				skipfile();
@@ -735,7 +742,7 @@
 		 * current state must be recalculated
 		 */
 		if (volno != curvol)
-			continue;
+			goto again;
 		/*
 		 * If the current inode is greater than the one we were
 		 * looking for then we missed the one we were looking for.
@@ -764,8 +771,15 @@
 				panic("corrupted symbol table\n");
 			(void) extractfile(myname(ep));
 			ep->e_flags &= ~NEW;
-			if (volno != curvol)
+			if (volno != curvol) {
 				skipmaps();
+				goto again;
+			}
+			/*
+			 * Decide the next inode.  Note that curfile.ino
+			 * may skip us and thus we can't use it.
+			 */
+			next = lowerbnd(next);
 		}
 	}
 }