fix debugging across tapes; account for dumpmap at start of every tape
[unix-history] / usr / src / sbin / restore / main.c
index dfbb58e..0b551fc 100644 (file)
@@ -1,7 +1,7 @@
 /* Copyright (c) 1983 Regents of the University of California */
 
 #ifndef lint
 /* Copyright (c) 1983 Regents of the University of California */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     3.3     (Berkeley)      83/02/27";
+static char sccsid[] = "@(#)main.c     3.5     (Berkeley)      83/03/05";
 #endif
 
 /*
 #endif
 
 /*
@@ -45,6 +45,7 @@ main(argc, argv)
        char *inputdev = "/dev/rmt8";
        char *symtbl = "./restoresymtable";
        char *dirmodefile = "./dirmodes";
        char *inputdev = "/dev/rmt8";
        char *symtbl = "./restoresymtable";
        char *dirmodefile = "./dirmodes";
+       char name[BUFSIZ];
        int (*signal())();
        extern int onintr();
 
        int (*signal())();
        extern int onintr();
 
@@ -84,6 +85,10 @@ usage:
                        yflag++;
                        break;
                case 'f':
                        yflag++;
                        break;
                case 'f':
+                       if (argc < 1) {
+                               fprintf(stderr, "missing device specifier\n");
+                               done(1);
+                       }
                        inputdev = *argv++;
                        argc--;
                        break;
                        inputdev = *argv++;
                        argc--;
                        break;
@@ -91,6 +96,10 @@ usage:
                        /*
                         * dumpnum (skip to) for multifile dump tapes
                         */
                        /*
                         * dumpnum (skip to) for multifile dump tapes
                         */
+                       if (argc < 1) {
+                               fprintf(stderr, "missing dump number\n");
+                               done(1);
+                       }
                        dumpnum = atoi(*argv++);
                        if (dumpnum <= 0) {
                                fprintf(stderr, "Dump number must be a positive integer\n");
                        dumpnum = atoi(*argv++);
                        if (dumpnum <= 0) {
                                fprintf(stderr, "Dump number must be a positive integer\n");
@@ -99,40 +108,16 @@ usage:
                        argc--;
                        break;
                case 't':
                        argc--;
                        break;
                case 't':
-                       if (command != '\0') {
-                               fprintf(stderr,
-                                       "t and %c are mutually exclusive\n",
-                                       command);
-                               goto usage;
-                       }
-                       command = 't';
-                       break;
                case 'R':
                case 'R':
-                       if (command != '\0') {
-                               fprintf(stderr,
-                                       "R and %c are mutually exclusive\n",
-                                       command);
-                               goto usage;
-                       }
-                       command = 'R';
-                       break;
                case 'r':
                case 'r':
-                       if (command != '\0') {
-                               fprintf(stderr,
-                                       "r and %c are mutually exclusive\n",
-                                       command);
-                               goto usage;
-                       }
-                       command = 'r';
-                       break;
                case 'x':
                        if (command != '\0') {
                                fprintf(stderr,
                case 'x':
                        if (command != '\0') {
                                fprintf(stderr,
-                                       "x and %c are mutually exclusive\n",
-                                       command);
+                                       "%c and %c are mutually exclusive\n",
+                                       *cp, command);
                                goto usage;
                        }
                                goto usage;
                        }
-                       command = 'x';
+                       command = *cp;
                        break;
                default:
                        fprintf(stderr, "Bad key character %c\n", *cp);
                        break;
                default:
                        fprintf(stderr, "Bad key character %c\n", *cp);
@@ -154,12 +139,16 @@ usage:
                setup();
                extractdirs((char *)0);
                while (argc--) {
                setup();
                extractdirs((char *)0);
                while (argc--) {
-                       if ((ino = psearch(*argv)) == 0 ||
+                       canon(*argv++, name);
+                       if ((ino = psearch(name)) == 0 ||
                            BIT(ino, dumpmap) == 0) {
                            BIT(ino, dumpmap) == 0) {
-                               fprintf(stderr, "%s: not on tape\n", *argv++);
+                               fprintf(stderr, "%s: not on tape\n", name);
                                continue;
                        }
                                continue;
                        }
-                       treescan(*argv++, ino, listfile);
+                       if (hflag)
+                               treescan(name, ino, listfile);
+                       else
+                               listfile(name, ino, inodetype(ino));
                }
                done(0);
 
                }
                done(0);
 
@@ -172,19 +161,19 @@ usage:
                        panic("no memory for entry table\n");
                (void)addentry(".", ROOTINO, NODE);
                while (argc--) {
                        panic("no memory for entry table\n");
                (void)addentry(".", ROOTINO, NODE);
                while (argc--) {
-                       if ((ino = psearch(*argv)) == 0 ||
+                       canon(*argv++, name);
+                       if ((ino = psearch(name)) == 0 ||
                            BIT(ino, dumpmap) == 0) {
                            BIT(ino, dumpmap) == 0) {
-                               fprintf(stderr, "%s: not on tape\n", *argv++);
+                               fprintf(stderr, "%s: not on tape\n", name);
                                continue;
                        }
                        if (mflag)
                                continue;
                        }
                        if (mflag)
-                               pathcheck(*argv, NEW);
+                               pathcheck(name, NULL);
                        if (hflag)
                        if (hflag)
-                               treescan(*argv++, ino, addfile);
+                               treescan(name, ino, addfile);
                        else
                        else
-                               addfile(*argv++, ino, LEAF);
+                               addfile(name, ino, inodetype(ino));
                }
                }
-               createnodes();
                createfiles();
                createlinks();
                setdirmodes(dirmodefile);
                createfiles();
                createlinks();
                setdirmodes(dirmodefile);
@@ -228,6 +217,8 @@ usage:
 
        case 'R':
                initsymtable(symtbl);
 
        case 'R':
                initsymtable(symtbl);
+               skipmaps();
+               skipdirs();
                createleaves(symtbl);
                createlinks();
                setdirmodes(dirmodefile);
                createleaves(symtbl);
                createlinks();
                setdirmodes(dirmodefile);