]> git.wh0rd.org - dump.git/commitdiff
Implemented a -M(ulti volume) option for dump.
authorStelian Pop <stelian@popies.net>
Sun, 21 Nov 1999 16:01:47 +0000 (16:01 +0000)
committerStelian Pop <stelian@popies.net>
Sun, 21 Nov 1999 16:01:47 +0000 (16:01 +0000)
dump/dump.h
dump/main.c
dump/tape.c

index 148e656660bdcdeda377485f75d476b10509c178..5b2ab0809a79a3fe5435290e1dcdca86d229b63a 100644 (file)
@@ -4,7 +4,7 @@
  *     Remy Card <card@Linux.EU.Org>, 1994-1997
  *     Stelian Pop <pop@cybercable.fr>, 1999
  *
- *     $Id: dump.h,v 1.7 1999/11/21 02:24:47 tiniou Exp $
+ *     $Id: dump.h,v 1.8 1999/11/21 16:01:47 tiniou Exp $
  */
 
 /*-
 #define MAXINOPB       (MAXBSIZE / sizeof(struct dinode))
 #define MAXNINDIR      (MAXBSIZE / sizeof(daddr_t))
 
+#ifndef NAME_MAX
+#define NAME_MAX 255
+#endif
+
 /*
  * Dump maps used to describe what is to be dumped.
  */
@@ -64,12 +68,14 @@ char        *dumpinomap;    /* map of files to be dumped */
  *     All calculations done in 0.1" units!
  */
 char   *disk;          /* name of the disk file */
-char   *tape;          /* name of the tape file */
+char   tape[NAME_MAX]; /* name of the tape file */
+char   *tapeprefix;    /* prefix of the tape file */
 char   *dumpdates;     /* name of the file containing dump date information*/
 char   *temp;          /* name of the file for doing rewrite of dumpdates */
 char   lastlevel;      /* dump level of previous dump */
 char   level;          /* dump level of this dump */
 int    uflag;          /* update flag */
+int    Mflag;          /* multi-volume flag */
 int    diskfd;         /* disk file descriptor */
 int    tapefd;         /* tape file descriptor */
 int    pipeout;        /* true => output to standard output */
@@ -186,10 +192,6 @@ struct     fstab *fstabsearch __P((const char *key));      /* search fs_file and fs_spec
 struct fstab *fstabsearchdir __P((const char *key, char *dir));        /* search fs_file and fs_spec */
 #endif
 
-#ifndef NAME_MAX
-#define NAME_MAX 255
-#endif
-
 /*
  *     The contents of the file _PATH_DUMPDATES is maintained both on
  *     a linked list, and then (eventually) arrayified.
index 1ccbf367840438179d24dcca53c7ae5d86a22126..5e8f79f2a45bb7fe19b889456191453cb09acd55 100644 (file)
@@ -40,7 +40,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: main.c,v 1.7 1999/11/21 02:24:47 tiniou Exp $";
+       "$Id: main.c,v 1.8 1999/11/21 16:01:47 tiniou Exp $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -137,8 +137,8 @@ main(int argc, char *argv[])
 #endif
 
        tsize = 0;      /* Default later, based on 'c' option for cart tapes */
-       if ((tape = getenv("TAPE")) == NULL)
-               tape = _PATH_DEFTAPE;
+       if ((tapeprefix = getenv("TAPE")) == NULL)
+               tapeprefix = _PATH_DEFTAPE;
        dumpdates = _PATH_DUMPDATES;
        temp = _PATH_DTMP;
        strcpy(labelstr, "none");       /* XXX safe strcpy. */
@@ -151,9 +151,9 @@ main(int argc, char *argv[])
 
        obsolete(&argc, &argv);
 #ifdef KERBEROS
-#define optstring "0123456789aB:b:cd:f:h:kL:ns:T:uWw"
+#define optstring "0123456789aB:b:cd:f:h:kL:Mns:T:uWw"
 #else
-#define optstring "0123456789aB:b:cd:f:h:L:ns:T:uWw"
+#define optstring "0123456789aB:b:cd:f:h:L:Mns:T:uWw"
 #endif
        while ((ch = getopt(argc, argv, optstring)) != -1)
 #undef optstring
@@ -195,7 +195,7 @@ main(int argc, char *argv[])
                        break;
 
                case 'f':               /* output file */
-                       tape = optarg;
+                       tapeprefix = optarg;
                        break;
 
                case 'h':
@@ -225,6 +225,10 @@ main(int argc, char *argv[])
                        }
                        break;
 
+               case 'M':               /* multi-volume flag */
+                       Mflag = 1;
+                       break;
+
                case 'n':               /* notify operators */
                        notify = 1;
                        break;
@@ -277,9 +281,9 @@ main(int argc, char *argv[])
                    "You cannot use the T and u flags together.\n");
                exit(X_STARTUP);
        }
-       if (strcmp(tape, "-") == 0) {
+       if (strcmp(tapeprefix, "-") == 0) {
                pipeout++;
-               tape = "standard output";
+               tapeprefix = "standard output";
        }
 
        if (blocksperfile)
@@ -301,12 +305,12 @@ main(int argc, char *argv[])
                        tsize = cartridge ? 1700L*120L : 2300L*120L;
        }
 
-       if (strchr(tape, ':')) {
-               host = tape;
-               tape = strchr(host, ':');
-               *tape++ = '\0';
+       if (strchr(tapeprefix, ':')) {
+               host = tapeprefix;
+               tapeprefix = strchr(host, ':');
+               *tapeprefix++ = '\0';
 #ifdef RDUMP
-               if (index(tape, '\n')) {
+               if (index(tapeprefix, '\n')) {
                    (void)fprintf(stderr, "invalid characters in tape\n");
                    exit(X_STARTUP);
                }
@@ -392,6 +396,12 @@ main(int argc, char *argv[])
                spcl.c_level = 0;
        }
 
+       if (Mflag)
+               snprintf(tape, NAME_MAX, "%s%03d", tapeprefix, tapeno + 1);
+       else
+               strncpy(tape, tapeprefix, NAME_MAX);
+       tape[NAME_MAX - 1] = '\0';
+
        msg("Date of this level %c dump: %s", level,
 #ifdef __linux__
                spcl.c_date == 0 ? "the epoch\n" : ctime4(&spcl.c_date));
@@ -656,7 +666,7 @@ usage(void)
 #ifdef KERBEROS
                "k"
 #endif
-               "nu] [-B records] [-b blocksize] [-d density]\n"
+               "Mnu] [-B records] [-b blocksize] [-d density]\n"
                "\t%s [-f file] [-h level] [-s feet] [-T date] filesystem\n"
                "\t%s [-W | -w]\n", __progname, white, __progname);
        exit(X_STARTUP);
index a0cc7e32b18629b83fb7c2d5dafec246cc4280ac..7790cc4e4bd6a30b8a8d6791699383265493195c 100644 (file)
@@ -40,7 +40,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.8 1999/11/21 02:24:47 tiniou Exp $";
+       "$Id: tape.c,v 1.9 1999/11/21 16:01:47 tiniou Exp $";
 #endif /* not lint */
 
 #ifdef __linux__
@@ -458,7 +458,7 @@ close_rewind(void)
 {
        trewind();
        (void)do_stats();
-       if (nexttape)
+       if (nexttape || Mflag)
                return;
        if (!nogripe) {
                msg("Change Volumes: Mount volume #%d\n", tapeno+1);
@@ -712,14 +712,21 @@ restore_check_point:
                 * the remaining names for subsequent volumes.
                 */
                tapeno++;               /* current tape sequence */
-               if (nexttape || strchr(tape, ',')) {
+               if (Mflag) {
+                       snprintf(tape, NAME_MAX, "%s%03d", tapeprefix, tapeno);
+                       tape[NAME_MAX - 1] = '\0';
+                       msg("Dumping volume %d on %s\n", tapeno, tape);
+               }
+               else if (nexttape || strchr(tapeprefix, ',')) {
                        if (nexttape && *nexttape)
-                               tape = nexttape;
-                       if ((p = strchr(tape, ',')) != NULL) {
+                               tapeprefix = nexttape;
+                       if ((p = strchr(tapeprefix, ',')) != NULL) {
                                *p = '\0';
                                nexttape = p + 1;
                        } else
                                nexttape = NULL;
+                       strncpy(tape, tapeprefix, NAME_MAX);
+                       tape[NAME_MAX - 1] = '\0';
                        msg("Dumping volume %d on %s\n", tapeno, tape);
                }
 #ifdef RDUMP