add Nflag to request not to do any writes
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Sat, 14 May 1988 05:51:59 +0000 (21:51 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Sat, 14 May 1988 05:51:59 +0000 (21:51 -0800)
SCCS-vsn: sbin/restore/tape.c 5.14
SCCS-vsn: sbin/restore/restore.h 5.2
SCCS-vsn: sbin/restore/dirs.c 5.5
SCCS-vsn: sbin/restore/main.c 5.4
SCCS-vsn: sbin/restore/symtab.c 5.2
SCCS-vsn: sbin/restore/utilities.c 5.3
SCCS-vsn: sbin/restore/main.c 5.4

usr/src/sbin/restore/dirs.c
usr/src/sbin/restore/main.c
usr/src/sbin/restore/restore.h
usr/src/sbin/restore/symtab.c
usr/src/sbin/restore/tape.c
usr/src/sbin/restore/utilities.c

index c8c16f7..059594b 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)dirs.c     5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)dirs.c     5.5 (Berkeley) %G%";
 #endif not lint
 
 #include "restore.h"
 #endif not lint
 
 #include "restore.h"
@@ -515,7 +515,7 @@ genliteraldir(name, ino)
                        perror("read");
                        done(1);
                }
                        perror("read");
                        done(1);
                }
-               if (write(ofile, buf, (int) size) == -1) {
+               if (!Nflag && write(ofile, buf, (int) size) == -1) {
                        fprintf(stderr,
                                "write error extracting inode %d, name %s\n",
                                curfile.ino, curfile.name);
                        fprintf(stderr,
                                "write error extracting inode %d, name %s\n",
                                curfile.ino, curfile.name);
index 9a90e64..47370fb 100644 (file)
@@ -11,7 +11,7 @@ char copyright[] =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.4 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -37,7 +37,7 @@ static char sccsid[] = "@(#)main.c    5.3 (Berkeley) %G%";
 #include <signal.h>
 
 int    bflag = 0, cvtflag = 0, dflag = 0, vflag = 0, yflag = 0;
 #include <signal.h>
 
 int    bflag = 0, cvtflag = 0, dflag = 0, vflag = 0, yflag = 0;
-int    hflag = 1, mflag = 1;
+int    hflag = 1, mflag = 1, Nflag = 0;
 char   command = '\0';
 long   dumpnum = 1;
 long   volno = 0;
 char   command = '\0';
 long   dumpnum = 1;
 long   volno = 0;
@@ -95,6 +95,9 @@ usage:
                case 'm':
                        mflag = 0;
                        break;
                case 'm':
                        mflag = 0;
                        break;
+               case 'N':
+                       Nflag++;
+                       break;
                case 'v':
                        vflag++;
                        break;
                case 'v':
                        vflag++;
                        break;
index 2a2215c..4ab8713 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)restore.h   5.1 (Berkeley) %G%
+ *     @(#)restore.h   5.2 (Berkeley) %G%
  */
 
 #include <stdio.h>
  */
 
 #include <stdio.h>
@@ -20,6 +20,7 @@ extern int    bflag;          /* set input block size */
 extern int     dflag;          /* print out debugging info */
 extern int     hflag;          /* restore heirarchies */
 extern int     mflag;          /* restore by name instead of inode number */
 extern int     dflag;          /* print out debugging info */
 extern int     hflag;          /* restore heirarchies */
 extern int     mflag;          /* restore by name instead of inode number */
+extern int     Nflag;          /* do not write the disk */
 extern int     vflag;          /* print out actions taken */
 extern int     yflag;          /* always try to recover from tape errors */
 /*
 extern int     vflag;          /* print out actions taken */
 extern int     yflag;          /* always try to recover from tape errors */
 /*
index 849ffb8..66a67d5 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)symtab.c   5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)symtab.c   5.2 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -408,6 +408,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",
index 3079002..efa31ba 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)tape.c     5.13 (Berkeley) %G%";
+static char sccsid[] = "@(#)tape.c     5.14 (Berkeley) %G%";
 #endif not lint
 
 #include "restore.h"
 #endif not lint
 
 #include "restore.h"
@@ -418,6 +418,10 @@ extractfile(name)
        case IFCHR:
        case IFBLK:
                vprintf(stdout, "extract special file %s\n", name);
        case IFCHR:
        case IFBLK:
                vprintf(stdout, "extract special file %s\n", name);
+               if (Nflag) {
+                       skipfile();
+                       return (GOOD);
+               }
                if (mknod(name, mode, (int)curfile.dip->di_rdev) < 0) {
                        fprintf(stderr, "%s: ", name);
                        (void) fflush(stderr);
                if (mknod(name, mode, (int)curfile.dip->di_rdev) < 0) {
                        fprintf(stderr, "%s: ", name);
                        (void) fflush(stderr);
@@ -433,6 +437,10 @@ extractfile(name)
 
        case IFREG:
                vprintf(stdout, "extract file %s\n", name);
 
        case IFREG:
                vprintf(stdout, "extract file %s\n", name);
+               if (Nflag) {
+                       skipfile();
+                       return (GOOD);
+               }
                if ((ofile = creat(name, 0666)) < 0) {
                        fprintf(stderr, "%s: ", name);
                        (void) fflush(stderr);
                if ((ofile = creat(name, 0666)) < 0) {
                        fprintf(stderr, "%s: ", name);
                        (void) fflush(stderr);
@@ -541,6 +549,8 @@ xtrfile(buf, size)
        long    size;
 {
 
        long    size;
 {
 
+       if (Nflag)
+               return;
        if (write(ofile, buf, (int) size) == -1) {
                fprintf(stderr, "write error extracting inode %d, name %s\n",
                        curfile.ino, curfile.name);
        if (write(ofile, buf, (int) size) == -1) {
                fprintf(stderr, "write error extracting inode %d, name %s\n",
                        curfile.ino, curfile.name);
index 5cf208b..323139b 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)utilities.c        5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)utilities.c        5.3 (Berkeley) %G%";
 #endif not lint
 
 #include "restore.h"
 #endif not lint
 
 #include "restore.h"
@@ -80,7 +80,7 @@ gentempname(ep)
 renameit(from, to)
        char *from, *to;
 {
 renameit(from, to)
        char *from, *to;
 {
-       if (rename(from, to) < 0) {
+       if (!Nflag && rename(from, to) < 0) {
                fprintf(stderr, "Warning: cannot rename %s to %s", from, to);
                (void) fflush(stderr);
                perror("");
                fprintf(stderr, "Warning: cannot rename %s to %s", from, to);
                (void) fflush(stderr);
                perror("");
@@ -100,7 +100,7 @@ newnode(np)
        if (np->e_type != NODE)
                badentry(np, "newnode: not a node");
        cp = myname(np);
        if (np->e_type != NODE)
                badentry(np, "newnode: not a node");
        cp = myname(np);
-       if (mkdir(cp, 0777) < 0) {
+       if (!Nflag && mkdir(cp, 0777) < 0) {
                np->e_flags |= EXISTED;
                fprintf(stderr, "Warning: ");
                (void) fflush(stderr);
                np->e_flags |= EXISTED;
                fprintf(stderr, "Warning: ");
                (void) fflush(stderr);
@@ -125,7 +125,7 @@ removenode(ep)
        ep->e_flags |= REMOVED;
        ep->e_flags &= ~TMPNAME;
        cp = myname(ep);
        ep->e_flags |= REMOVED;
        ep->e_flags &= ~TMPNAME;
        cp = myname(ep);
-       if (rmdir(cp) < 0) {
+       if (!Nflag && rmdir(cp) < 0) {
                fprintf(stderr, "Warning: ");
                (void) fflush(stderr);
                perror(cp);
                fprintf(stderr, "Warning: ");
                (void) fflush(stderr);
                perror(cp);
@@ -147,7 +147,7 @@ removeleaf(ep)
        ep->e_flags |= REMOVED;
        ep->e_flags &= ~TMPNAME;
        cp = myname(ep);
        ep->e_flags |= REMOVED;
        ep->e_flags &= ~TMPNAME;
        cp = myname(ep);
-       if (unlink(cp) < 0) {
+       if (!Nflag && unlink(cp) < 0) {
                fprintf(stderr, "Warning: ");
                (void) fflush(stderr);
                perror(cp);
                fprintf(stderr, "Warning: ");
                (void) fflush(stderr);
                perror(cp);
@@ -165,7 +165,7 @@ linkit(existing, new, type)
 {
 
        if (type == SYMLINK) {
 {
 
        if (type == SYMLINK) {
-               if (symlink(existing, new) < 0) {
+               if (!Nflag && symlink(existing, new) < 0) {
                        fprintf(stderr,
                                "Warning: cannot create symbolic link %s->%s: ",
                                new, existing);
                        fprintf(stderr,
                                "Warning: cannot create symbolic link %s->%s: ",
                                new, existing);
@@ -174,7 +174,7 @@ linkit(existing, new, type)
                        return (FAIL);
                }
        } else if (type == HARDLINK) {
                        return (FAIL);
                }
        } else if (type == HARDLINK) {
-               if (link(existing, new) < 0) {
+               if (!Nflag && link(existing, new) < 0) {
                        fprintf(stderr,
                                "Warning: cannot create hard link %s->%s: ",
                                new, existing);
                        fprintf(stderr,
                                "Warning: cannot create hard link %s->%s: ",
                                new, existing);