From: Stelian Pop <stelian@popies.net>
Date: Fri, 14 Jan 2005 13:04:07 +0000 (+0000)
Subject: Fix restore -C to handle correctly directories containing a file with the same name... 
X-Git-Tag: release_0_4b39~2
X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=684154694394c35b594ca101b15796898888ebde;p=dump.git

Fix restore -C to handle correctly directories containing a file with the same name (bug in the new hashdir code).
---

diff --git a/CHANGES b/CHANGES
index f56eb80..cdeb396 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,4 @@
-$Id: CHANGES,v 1.266 2005/01/14 13:01:32 stelian Exp $
+$Id: CHANGES,v 1.267 2005/01/14 13:04:07 stelian Exp $
 
 Changes between versions 0.4b38 and 0.4b39 (released ???????????????)
 =====================================================================
@@ -17,6 +17,13 @@ Changes between versions 0.4b38 and 0.4b39 (released ???????????????)
 3.	Silenced the failure to call fgetflags() when comparing an
 	entry which has no ext2 attributes (as in lsattr()).
 
+4.	Fix a brown paper bug in restore -C which broke restore and
+	caused modifications on the filesystem being compared
+	(directories containing a file with the same name as the
+	directory get renamed to RSTTMP...). Thanks to Kenneth Porter
+	<shiva@sewingwitch.com> for finding the bug and helping me
+	reproduce it.
+
 Changes between versions 0.4b37 and 0.4b38 (released January 7, 2005)
 =====================================================================
 
diff --git a/restore/symtab.c b/restore/symtab.c
index 8cd384c..4a2e1ab 100644
--- a/restore/symtab.c
+++ b/restore/symtab.c
@@ -37,7 +37,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-	"$Id: symtab.c,v 1.23 2004/12/14 14:07:58 stelian Exp $";
+	"$Id: symtab.c,v 1.24 2005/01/14 13:04:07 stelian Exp $";
 #endif /* not lint */
 
 /*
@@ -189,9 +189,16 @@ lookupname(char *name)
 	char *np, *cp;
 	char buf[MAXPATHLEN];
 
+	ep = lookupino(ROOTINO);
+
 	cp = name;
+	if (*cp == '.')
+		++cp;
+	if (*cp == '/')
+		++cp;
+	if (*cp == '\0')
+		return ep;
 
-	ep = lookupino(ROOTINO);
 	while (ep != NULL) {
 		for (np = buf; *cp != '/' && *cp != '\0' &&
 				np < &buf[sizeof(buf)]; )
@@ -202,8 +209,7 @@ lookupname(char *name)
 
 		oldep = ep;
 
-		if (strcmp(ep->e_name, buf) != 0 &&
-		    ep->e_entries != NULL) {
+		if (ep->e_entries != NULL) {
 
 			ep = ep->e_entries[dir_hash(buf)];
 			for ( ; ep != NULL; ep = ep->e_sibling)