From d1c73b9a3cd598653eb8b13531e8ca3c5c740d90 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Sun, 21 Nov 1999 16:01:47 +0000 Subject: [PATCH] Implemented a -M(ulti volume) option for dump. --- dump/dump.h | 14 ++++++++------ dump/main.c | 38 ++++++++++++++++++++++++-------------- dump/tape.c | 17 ++++++++++++----- 3 files changed, 44 insertions(+), 25 deletions(-) diff --git a/dump/dump.h b/dump/dump.h index 148e656..5b2ab08 100644 --- a/dump/dump.h +++ b/dump/dump.h @@ -4,7 +4,7 @@ * Remy Card , 1994-1997 * Stelian Pop , 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 $ */ /*- @@ -43,6 +43,10 @@ #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. diff --git a/dump/main.c b/dump/main.c index 1ccbf36..5e8f79f 100644 --- a/dump/main.c +++ b/dump/main.c @@ -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 @@ -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); diff --git a/dump/tape.c b/dump/tape.c index a0cc7e3..7790cc4 100644 --- a/dump/tape.c +++ b/dump/tape.c @@ -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 -- 2.39.2