install correct aliases file
[unix-history] / usr / src / sbin / restore / symtab.c
index 7e19c68..83aa78e 100644 (file)
@@ -1,8 +1,23 @@
-/* Copyright (c) 1983 Regents of the University of California */
+/*
+ * Copyright (c) 1983 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
 
 #ifndef lint
 
 #ifndef lint
-static char sccsid[] = "@(#)symtab.c   3.10    (Berkeley)      83/05/03";
-#endif
+static char sccsid[] = "@(#)symtab.c   5.3 (Berkeley) %G%";
+#endif /* not lint */
 
 /*
  * These routines maintain the symbol table which tracks the state
 
 /*
  * These routines maintain the symbol table which tracks the state
@@ -15,7 +30,6 @@ static char sccsid[] = "@(#)symtab.c  3.10    (Berkeley)      83/05/03";
 
 #include "restore.h"
 #include <sys/stat.h>
 
 #include "restore.h"
 #include <sys/stat.h>
-#include <dir.h>
 
 /*
  * The following variables define the inode symbol table.
 
 /*
  * The following variables define the inode symbol table.
@@ -184,6 +198,8 @@ addentry(name, inum, type)
                bzero((char *)np, (long)sizeof(struct entry));
        } else {
                np = (struct entry *)calloc(1, sizeof(struct entry));
                bzero((char *)np, (long)sizeof(struct entry));
        } else {
                np = (struct entry *)calloc(1, sizeof(struct entry));
+               if (np == NIL)
+                       panic("no memory to extend symbol table\n");
        }
        np->e_type = type & ~LINK;
        ep = lookupparent(name);
        }
        np->e_type = type & ~LINK;
        ep = lookupparent(name);
@@ -223,6 +239,7 @@ freeentry(ep)
        register struct entry *ep;
 {
        register struct entry *np;
        register struct entry *ep;
 {
        register struct entry *np;
+       ino_t inum;
 
        if (ep->e_flags != REMOVED)
                badentry(ep, "not marked REMOVED");
 
        if (ep->e_flags != REMOVED)
                badentry(ep, "not marked REMOVED");
@@ -237,9 +254,10 @@ freeentry(ep)
                if (np == NIL)
                        badentry(ep, "lookupino failed");
                if (np == ep) {
                if (np == NIL)
                        badentry(ep, "lookupino failed");
                if (np == ep) {
-                       deleteino(ep->e_ino);
+                       inum = ep->e_ino;
+                       deleteino(inum);
                        if (ep->e_links != NIL)
                        if (ep->e_links != NIL)
-                               addino(ep->e_ino, ep->e_links);
+                               addino(inum, ep->e_links);
                } else {
                        for (; np != NIL; np = np->e_links) {
                                if (np->e_links == ep) {
                } else {
                        for (; np != NIL; np = np->e_links) {
                                if (np->e_links == ep) {
@@ -383,6 +401,7 @@ struct symtableheader {
        time_t  dumptime;
        time_t  dumpdate;
        ino_t   maxino;
        time_t  dumptime;
        time_t  dumpdate;
        ino_t   maxino;
+       long    ntrec;
 };
 
 /*
 };
 
 /*
@@ -400,6 +419,8 @@ dumpsymtable(filename, checkpt)
        struct symtableheader hdr;
 
        vprintf(stdout, "Check pointing the restore\n");
        struct symtableheader hdr;
 
        vprintf(stdout, "Check pointing the restore\n");
+       if (Nflag)
+               return;
        if ((fd = fopen(filename, "w")) == NULL) {
                perror("fopen");
                panic("cannot create save file %s for symbol table\n",
        if ((fd = fopen(filename, "w")) == NULL) {
                perror("fopen");
                panic("cannot create save file %s for symbol table\n",
@@ -460,6 +481,7 @@ dumpsymtable(filename, checkpt)
        hdr.stringsize = stroff;
        hdr.dumptime = dumptime;
        hdr.dumpdate = dumpdate;
        hdr.stringsize = stroff;
        hdr.dumptime = dumptime;
        hdr.dumpdate = dumpdate;
+       hdr.ntrec = ntrec;
        (void) fwrite((char *)&hdr, sizeof(struct symtableheader), 1, fd);
        if (ferror(fd)) {
                perror("fwrite");
        (void) fwrite((char *)&hdr, sizeof(struct symtableheader), 1, fd);
        if (ferror(fd)) {
                perror("fwrite");
@@ -504,7 +526,7 @@ initsymtable(filename)
                panic("cannot stat symbol table file %s\n", filename);
        }
        tblsize = stbuf.st_size - sizeof(struct symtableheader);
                panic("cannot stat symbol table file %s\n", filename);
        }
        tblsize = stbuf.st_size - sizeof(struct symtableheader);
-       base = calloc(sizeof(char *), (unsigned)tblsize);
+       base = calloc(sizeof(char), (unsigned)tblsize);
        if (base == NULL)
                panic("cannot allocate space for symbol table\n");
        if (read(fd, base, (int)tblsize) < 0 ||
        if (base == NULL)
                panic("cannot allocate space for symbol table\n");
        if (read(fd, base, (int)tblsize) < 0 ||
@@ -533,6 +555,8 @@ initsymtable(filename)
                curfile.action = SKIP;
                dumptime = hdr.dumptime;
                dumpdate = hdr.dumpdate;
                curfile.action = SKIP;
                dumptime = hdr.dumptime;
                dumpdate = hdr.dumpdate;
+               if (!bflag)
+                       newtapebuf(hdr.ntrec);
                getvol(hdr.volno);
                break;
        default:
                getvol(hdr.volno);
                break;
        default: