BSD 4 release
[unix-history] / usr / src / cmd / restor.c
index 2b6db17..59be2f7 100644 (file)
@@ -1,6 +1,8 @@
+static char *sccsid = "@(#)restor.c    4.1 (Berkeley) 10/1/80";
+
 #define MAXINO 3000
 #define BITS   8
 #define MAXINO 3000
 #define BITS   8
-#define MAXXTR 60
+#define MAXXTR 600
 #define NCACHE 3
 
 #ifndef STANDALONE
 #define NCACHE 3
 
 #ifndef STANDALONE
@@ -27,7 +29,7 @@ int   fi;
 ino_t  ino, maxi, curino;
 
 int    mt;
 ino_t  ino, maxi, curino;
 
 int    mt;
-char   tapename[] = "/dev/rmt1";
+char   tapename[] = "/dev/rmt8";
 char   *magtape = tapename;
 #ifdef STANDALONE
 char   mbuf[50];
 char   *magtape = tapename;
 #ifdef STANDALONE
 char   mbuf[50];
@@ -780,6 +782,8 @@ clri(ip)
 struct dinode *ip;
 {
        int i, *p;
 struct dinode *ip;
 {
        int i, *p;
+       if (ip->di_mode&IFMT)
+               sblock.s_tinode++;
        i = sizeof(struct dinode)/sizeof(int);
        p = (int *)ip;
        do
        i = sizeof(struct dinode)/sizeof(int);
        p = (int *)ip;
        do
@@ -857,16 +861,18 @@ daddr_t   bn;
        union {
                char    data[BSIZE];
                struct  fblk frees;
        union {
                char    data[BSIZE];
                struct  fblk frees;
-       } fbuf;
+       } fbun;
+#define        fbuf fbun.frees
 
        if(sblock.s_nfree >= NICFREE) {
                fbuf.df_nfree = sblock.s_nfree;
                for(i=0;i<NICFREE;i++)
                        fbuf.df_free[i] = sblock.s_free[i];
                sblock.s_nfree = 0;
 
        if(sblock.s_nfree >= NICFREE) {
                fbuf.df_nfree = sblock.s_nfree;
                for(i=0;i<NICFREE;i++)
                        fbuf.df_free[i] = sblock.s_free[i];
                sblock.s_nfree = 0;
-               dwrite(bn, fbuf.data);
+               dwrite(bn, fbun.data);
        }
        sblock.s_free[sblock.s_nfree++] = bn;
        }
        sblock.s_free[sblock.s_nfree++] = bn;
+       sblock.s_tfree++;
 }
 
 /*
 }
 
 /*
@@ -881,7 +887,9 @@ balloc()
        union {
                char    data[BSIZE];
                struct  fblk frees;
        union {
                char    data[BSIZE];
                struct  fblk frees;
-       } fbuf;
+       } fbun;
+#undef fbuf
+#define        fbuf fbun.frees
 
        if(sblock.s_nfree == 0 || (bno=sblock.s_free[--sblock.s_nfree]) == 0) {
 #ifdef STANDALONE
 
        if(sblock.s_nfree == 0 || (bno=sblock.s_free[--sblock.s_nfree]) == 0) {
 #ifdef STANDALONE
@@ -892,12 +900,13 @@ balloc()
                exit(1);
        }
        if(sblock.s_nfree == 0) {
                exit(1);
        }
        if(sblock.s_nfree == 0) {
-               dread(bno, fbuf.data, BSIZE);
+               dread(bno, (char *)&fbuf, BSIZE);
                sblock.s_nfree = fbuf.df_nfree;
                for(i=0;i<NICFREE;i++)
                        sblock.s_free[i] = fbuf.df_free[i];
        }
        dwrite(bno, zeroes);
                sblock.s_nfree = fbuf.df_nfree;
                for(i=0;i<NICFREE;i++)
                        sblock.s_free[i] = fbuf.df_free[i];
        }
        dwrite(bno, zeroes);
+       sblock.s_tfree--;
        return(bno);
 }
 
        return(bno);
 }
 
@@ -1114,6 +1123,8 @@ struct    dinode *b;
        daddr_t bno;
        char buf[BSIZE];
 
        daddr_t bno;
        char buf[BSIZE];
 
+       if (b->di_mode&IFMT)
+               sblock.s_tinode--;
        bno = ((ino - 1)/INOPB) + 2;
        dread(bno, buf, BSIZE);
        copy((char *) b, &buf[((inum-1)%INOPB)*sizeof(struct dinode)], sizeof(struct dinode));
        bno = ((ino - 1)/INOPB) + 2;
        dread(bno, buf, BSIZE);
        copy((char *) b, &buf[((inum-1)%INOPB)*sizeof(struct dinode)], sizeof(struct dinode));
@@ -1140,6 +1151,8 @@ short     *m;
 
 done()
 {
 
 done()
 {
+#ifndef STANDALONE
        unlink(dirfile);
        unlink(dirfile);
+#endif
        exit(0);
 }
        exit(0);
 }