file reorg, pathnames.h, paths.h
[unix-history] / usr / src / sbin / restore / main.c
index 70b4e7a..d883092 100644 (file)
@@ -1,8 +1,29 @@
-/* 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
+char copyright[] =
+"@(#) Copyright (c) 1983 The Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif /* not lint */
 
 #ifndef lint
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     3.11    (Berkeley)      83/06/19";
-#endif
+static char sccsid[] = "@(#)main.c     5.6 (Berkeley) %G%";
+#endif /* not lint */
 
 /*
  *     Modified to recursively extract all files within a subtree
 
 /*
  *     Modified to recursively extract all files within a subtree
@@ -23,13 +44,16 @@ static char sccsid[] = "@(#)main.c  3.11    (Berkeley)      83/06/19";
  */
 
 #include "restore.h"
  */
 
 #include "restore.h"
-#include <signal.h>
+#include <protocols/dumprestore.h>
+#include <sys/signal.h>
+#include "pathnames.h"
 
 
-int    cvtflag = 0, dflag = 0, vflag = 0, yflag = 0;
-int    hflag = 1, mflag = 1;
+int    bflag = 0, cvtflag = 0, dflag = 0, vflag = 0, yflag = 0;
+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;
+long   ntrec;
 char   *dumpmap;
 char   *clrimap;
 ino_t  maxino;
 char   *dumpmap;
 char   *clrimap;
 ino_t  maxino;
@@ -43,7 +67,7 @@ main(argc, argv)
 {
        register char *cp;
        ino_t ino;
 {
        register char *cp;
        ino_t ino;
-       char *inputdev = "/dev/rmt8";
+       char *inputdev = _PATH_DEFTAPE;
        char *symtbl = "./restoresymtable";
        char name[MAXPATHLEN];
        int (*signal())();
        char *symtbl = "./restoresymtable";
        char name[MAXPATHLEN];
        int (*signal())();
@@ -83,6 +107,9 @@ usage:
                case 'm':
                        mflag = 0;
                        break;
                case 'm':
                        mflag = 0;
                        break;
+               case 'N':
+                       Nflag++;
+                       break;
                case 'v':
                        vflag++;
                        break;
                case 'v':
                        vflag++;
                        break;
@@ -97,6 +124,22 @@ usage:
                        inputdev = *argv++;
                        argc--;
                        break;
                        inputdev = *argv++;
                        argc--;
                        break;
+               case 'b':
+                       /*
+                        * change default tape blocksize
+                        */
+                       bflag++;
+                       if (argc < 1) {
+                               fprintf(stderr, "missing block size\n");
+                               done(1);
+                       }
+                       ntrec = atoi(*argv++);
+                       if (ntrec <= 0) {
+                               fprintf(stderr, "Block size must be a positive integer\n");
+                               done(1);
+                       }
+                       argc--;
+                       break;
                case 's':
                        /*
                         * dumpnum (skip to) for multifile dump tapes
                case 's':
                        /*
                         * dumpnum (skip to) for multifile dump tapes
@@ -205,6 +248,7 @@ usage:
        case 't':
                setup();
                extractdirs(0);
        case 't':
                setup();
                extractdirs(0);
+               initsymtable((char *)0);
                while (argc--) {
                        canon(*argv++, name);
                        ino = dirlookup(name);
                while (argc--) {
                        canon(*argv++, name);
                        ino = dirlookup(name);
@@ -237,144 +281,3 @@ usage:
                done(0);
        }
 }
                done(0);
        }
 }
-
-/*
- * Read and execute commands from the terminal.
- */
-runcmdshell()
-{
-       register struct entry *np;
-       ino_t ino;
-       char curdir[MAXPATHLEN];
-       char name[MAXPATHLEN];
-       char cmd[BUFSIZ];
-
-       canon("/", curdir);
-loop:
-       getcmd(curdir, cmd, name);
-       switch (cmd[0]) {
-       /*
-        * Add elements to the extraction list.
-        */
-       case 'a':
-               ino = dirlookup(name);
-               if (ino == 0)
-                       break;
-               if (mflag)
-                       pathcheck(name);
-               treescan(name, ino, addfile);
-               break;
-       /*
-        * Change working directory.
-        */
-       case 'c':
-               ino = dirlookup(name);
-               if (ino == 0)
-                       break;
-               if (inodetype(ino) == LEAF) {
-                       fprintf(stderr, "%s: not a directory\n", name);
-                       break;
-               }
-               (void) strcpy(curdir, name);
-               break;
-       /*
-        * Delete elements from the extraction list.
-        */
-       case 'd':
-               np = lookupname(name);
-               if (np == NIL || (np->e_flags & NEW) == 0) {
-                       fprintf(stderr, "%s: not on extraction list\n", name);
-                       break;
-               }
-               treescan(name, np->e_ino, deletefile);
-               break;
-       /*
-        * Extract the requested list.
-        */
-       case 'e':
-               createfiles();
-               createlinks();
-               setdirmodes();
-               if (dflag)
-                       checkrestore();
-               volno = 0;
-               break;
-       /*
-        * List available commands.
-        */
-       case 'h':
-       case '?':
-               fprintf(stderr, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
-                       "Available commands are:\n",
-                       "\tls [arg] - list directory\n",
-                       "\tcd arg - change directory\n",
-                       "\tpwd - print current directory\n",
-                       "\tadd [arg] - add `arg' to list of",
-                       " files to be extracted\n",
-                       "\tdelete [arg] - delete `arg' from",
-                       " list of files to be extracted\n",
-                       "\textract - extract requested files\n",
-                       "\tquit - immediately exit program\n",
-                       "\tverbose - toggle verbose flag",
-                       " (useful with ``ls'')\n",
-                       "\thelp or `?' - print this list\n",
-                       "If no `arg' is supplied, the current",
-                       " directory is used\n");
-               break;
-       /*
-        * List a directory.
-        */
-       case 'l':
-               ino = dirlookup(name);
-               if (ino == 0)
-                       break;
-               printlist(name, ino);
-               break;
-       /*
-        * Print current directory.
-        */
-       case 'p':
-               if (curdir[1] == '\0')
-                       fprintf(stderr, "/\n");
-               else
-                       fprintf(stderr, "%s\n", &curdir[1]);
-               break;
-       /*
-        * Quit.
-        */
-       case 'q':
-       case 'x':
-               return;
-       /*
-        * Toggle verbose mode.
-        */
-       case 'v':
-               if (vflag) {
-                       fprintf(stderr, "verbose mode off\n");
-                       vflag = 0;
-                       break;
-               }
-               fprintf(stderr, "verbose mode on\n");
-               vflag++;
-               break;
-       /*
-        * Turn on debugging.
-        */
-       case 'D':
-               if (dflag) {
-                       fprintf(stderr, "debugging mode off\n");
-                       dflag = 0;
-                       break;
-               }
-               fprintf(stderr, "debugging mode on\n");
-               dflag++;
-               break;
-       /*
-        * Unknown command.
-        */
-       default:
-               fprintf(stderr, "%s: unknown command; type ? for help\n", cmd);
-               break;
-       }
-       goto loop;
-}