/*
* Ported to Linux's Second Extended File System as part of the
* dump and restore backup suit
- * Remy Card <card@Linux.EU.Org>, 1994, 1995, 1996
+ * Remy Card <card@Linux.EU.Org>, 1994-1997
+ * Stelian Pop <pop@cybercable.fr>, 1999
*
*/
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)restore.c 8.3 (Berkeley) 9/13/94";
+#endif
+static const char rcsid[] =
+ "$Id: restore.c,v 1.2 1999/10/11 12:53:24 stelian Exp $";
#endif /* not lint */
#include <sys/types.h>
-#include <sys/stat.h>
#ifdef __linux__
#include <sys/time.h>
if (TSTINO(ino, dumpmap) == 0)
return (descend);
vprintf(stdout, "%s", type == LEAF ? "leaf" : "dir ");
- fprintf(stdout, "%10d\t%s\n", ino, name);
+ fprintf(stdout, "%10ld\t%s\n", ino, name);
return (descend);
}
if (ino == WINO && command == 'i' && !vflag)
return (descend);
if (!mflag) {
- (void) sprintf(buf, "./%u", ino);
+ (void) sprintf(buf, "./%lu", ino);
name = buf;
if (type == NODE) {
(void) genliteraldir(name, ino);
return (descend);
}
-/*
+/*
* The following four routines implement the incremental
* restore algorithm. The first removes old entries, the second
* does renames and calculates the extraction list, the third
*
* Directories cannot be immediately deleted, as they may have
* other files in them which need to be moved out first. As
- * directories to be deleted are found, they are put on the
+ * directories to be deleted are found, they are put on the
* following deletion list. After all deletions and renames
* are done, this list is actually deleted.
*/
register ino_t i, mydirino;
vprintf(stdout, "Mark entries to be removed.\n");
- if (ep = lookupino(WINO)) {
+ if ((ep = lookupino(WINO))) {
vprintf(stdout, "Delete whiteouts\n");
for ( ; ep != NULL; ep = nextep) {
nextep = ep->e_links;
# define MODECHG 0x8 /* mode of inode changed */
/*
- * This routine is called once for each element in the
+ * This routine is called once for each element in the
* directory hierarchy, with a full path name.
* The "type" value is incorrectly specified as LEAF for
* directories that are not on the dump tape.
* that we need to rename, so we delete it from the symbol
* table, and put it on the list to be deleted eventually.
* Conversely if a directory is to be created, it must be
- * done immediately, rather than waiting until the
+ * done immediately, rather than waiting until the
* extraction phase.
*/
case ONTAPE|INOFND|MODECHG:
}
if (ip->e_type == LEAF) {
/* changing from leaf to node */
- removeleaf(ip);
- freeentry(ip);
+ for (ip = lookupino(ino); ip != NULL; ip = ip->e_links) {
+ if (ip->e_type != LEAF)
+ badentry(ip, "NODE and LEAF links to same inode");
+ removeleaf(ip);
+ freeentry(ip);
+ }
ip = addentry(name, ino, type);
newnode(ip);
} else {
break;
/*
- * A hard link to a diirectory that has been removed.
+ * A hard link to a directory that has been removed.
* Ignore it.
*/
case NAMEFND:
*/
case NULL:
if (compare_ignore_not_found) break;
- fprintf(stderr, "%s: (inode %d) not found on tape\n",
+ fprintf(stderr, "%s: (inode %ld) not found on tape\n",
name, ino);
break;
default:
panic("[%s] %s: impossible state\n", keyval(key), name);
break;
- }
+ }
return (descend);
}
/* current copy of this file on disk. If do_compare is 0, then just */
/* make our caller think we did it--this is used to handle hard links */
/* to files and devices. */
+void
compare_entry(struct entry *ep, int do_compare)
{
if ((ep->e_flags & (NEW|EXTRACT)) == 0)
* on the next incremental tape.
*/
if (first != curfile.ino) {
- fprintf(stderr, "expected next file %d, got %d\n",
+ fprintf(stderr, "expected next file %ld, got %ld\n",
first, curfile.ino);
skipfile();
goto next;
/*
* If we find files on the tape that have no corresponding
* directory entries, then we must have found a file that
- * was created while the dump was in progress. Since we have
+ * was created while the dump was in progress. Since we have
* no name for it, we discard it knowing that it will be
* on the next incremental tape.
*/
if (first != curfile.ino) {
- fprintf(stderr, "expected next file %d, got %d\n",
+ fprintf(stderr, "expected next file %ld, got %ld\n",
first, curfile.ino);
skipfile();
goto next;
/*
* If the file is to be extracted, then the old file must
* be removed since its type may change from one leaf type
- * to another (eg "file" to "character special").
+ * to another (e.g. "file" to "character special").
*/
if ((ep->e_flags & EXTRACT) != 0) {
removeleaf(ep);
ep->e_flags &= ~(NEW|EXTRACT);
/*
* We checkpoint the restore after every tape reel, so
- * as to simplify the amount of work re quired by the
+ * as to simplify the amount of work required by the
* 'R' command.
*/
next:
register ino_t i;
char name[BUFSIZ];
- if (ep = lookupino(WINO)) {
+ if ((ep = lookupino(WINO))) {
vprintf(stdout, "Add whiteouts\n");
for ( ; ep != NULL; ep = ep->e_links) {
if ((ep->e_flags & NEW) == 0)
ep->e_flags &= ~KEEP;
if (ep->e_type == NODE)
ep->e_flags &= ~(NEW|EXISTED);
- if (ep->e_flags /* != NULL */)
+ if (ep->e_flags != 0)
badentry(ep, "incomplete operations");
}
}