From: Stelian Pop Date: Wed, 21 Apr 2004 08:55:48 +0000 (+0000) Subject: Make dump understand any integer as the dump level. X-Git-Tag: release_0_4b36~2 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=28ba5caee0ed25d3b38da769967173e5710bc10c;p=dump.git Make dump understand any integer as the dump level. --- diff --git a/CHANGES b/CHANGES index 49f425a..97526a3 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.245 2004/04/13 13:03:55 stelian Exp $ +$Id: CHANGES,v 1.246 2004/04/21 08:56:24 stelian Exp $ Changes between versions 0.4b35 and 0.4b36 (released ?????????????????) ======================================================================= @@ -43,6 +43,10 @@ Changes between versions 0.4b35 and 0.4b36 (released ?????????????????) David for submitting the bug and providing a test case. +11. Made dump work with an arbitrary integer level (no more 10 + levels only limitation). Thanks to Matthew + for the patch. + Changes between versions 0.4b34 and 0.4b35 (released December 21, 2003) ======================================================================= diff --git a/dump/dump.8.in b/dump/dump.8.in index 1245d84..487302d 100644 --- a/dump/dump.8.in +++ b/dump/dump.8.in @@ -26,14 +26,15 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: dump.8.in,v 1.55 2004/02/18 16:26:41 stelian Exp $ +.\" $Id: dump.8.in,v 1.56 2004/04/21 08:55:48 stelian Exp $ .\" .TH DUMP 8 "version __VERSION__ of __DATE__" BSD "System management commands" .SH NAME dump \- ext2/3 filesystem backup .SH SYNOPSIS .B dump -[\fB\-0123456789ackMnqSuv\fR] +[\fB\-\fIlevel#\fR] +[\fB\-ackMnqSuv] [\fB\-A \fIfile\fR] [\fB\-B \fIrecords\fR] [\fB\-b \fIblocksize\fR] @@ -88,15 +89,16 @@ and all the files and directories must reside on the same filesystem. The following options are supported by .B dump: .TP -.BI \-0\-9 -Dump levels. A level 0, full backup, guarantees the entire file system is -copied (but see also the +.BI \-level# +The dump level (any integer). A level 0, full backup, guarantees the +entire file system is copied (but see also the .B \-h option below). A level number above 0, incremental backup, tells .B dump to copy all files new or modified since the last dump of a lower level. The -default level is 9. +default level is 9. Historically only levels 0 to 9 were usable in +dump, this version is able to understand any integer as a dump level. .TP .BI \-a \*(lqauto-size\*(rq. Bypass all tape length calculations, and write until an diff --git a/dump/dump.h b/dump/dump.h index 5b052c8..8960c88 100644 --- a/dump/dump.h +++ b/dump/dump.h @@ -5,7 +5,7 @@ * Stelian Pop , 1999-2000 * Stelian Pop - AlcĂ´ve , 2000-2002 * - * $Id: dump.h,v 1.47 2003/10/26 16:05:46 stelian Exp $ + * $Id: dump.h,v 1.48 2004/04/21 08:55:51 stelian Exp $ */ /*- @@ -43,6 +43,7 @@ #define MAXINOPB (MAXBSIZE / sizeof(struct dinode)) #define MAXNINDIR (MAXBSIZE / sizeof(daddr_t)) +#define NUM_STR_SIZE 32 /* a generic number buffer size */ /* * Dump maps used to describe what is to be dumped. @@ -71,8 +72,8 @@ extern const char *disk; /* name of the disk file */ extern char tape[MAXPATHLEN];/* name of the tape file */ extern char *tapeprefix; /* prefix of the tape file */ extern char *dumpdates; /* name of the file containing dump date information*/ -extern char lastlevel; /* dump level of previous dump */ -extern char level; /* dump level of this dump */ +extern char lastlevel[NUM_STR_SIZE];/* dump level of previous dump */ +extern char level[NUM_STR_SIZE];/* dump level of this dump */ extern int Afile; /* archive file descriptor */ extern int AfileActive; /* Afile flag */ extern int zipflag; /* which compression method */ @@ -226,7 +227,7 @@ struct mntent *fstabsearchdir __P((const char *key, char *dir)); /* search fs_fi struct dumpdates { char dd_name[MAXPATHLEN+3]; struct mntent *dd_fstab; - char dd_level; + int dd_level; time_t dd_ddate; }; struct dumptime { diff --git a/dump/itime.c b/dump/itime.c index 7187d00..6ea6ef9 100644 --- a/dump/itime.c +++ b/dump/itime.c @@ -37,7 +37,7 @@ #ifndef lint static const char rcsid[] = - "$Id: itime.c,v 1.26 2003/10/26 16:05:47 stelian Exp $"; + "$Id: itime.c,v 1.27 2004/04/21 08:55:51 stelian Exp $"; #endif /* not lint */ #include @@ -163,17 +163,17 @@ getdumptime(int createdumpdates) int i; #ifdef FDEBUG - msg("Looking for name %s in dumpdates = %s for level = %c\n", + msg("Looking for name %s in dumpdates = %s for level = %s\n", disk, dumpdates, level); #endif spcl.c_ddate = 0; - lastlevel = '0'; + memset(&lastlevel, 0, NUM_STR_SIZE); /* If this is a level 0 dump, and we're not updating dumpdates, there's no point in trying to read dumpdates. It may not exist yet, or may not be mounted. For incrementals, we *must* read dumpdates (fail if it's not there!) */ - if ( (level == lastlevel) && !createdumpdates) + if ( (!strcmp(level, lastlevel)) && !createdumpdates) return; initdumptimes(createdumpdates); if (ddatev == NULL) @@ -185,12 +185,12 @@ getdumptime(int createdumpdates) ITITERATE(i, ddp) { if (strncmp(disk, ddp->dd_name, sizeof (ddp->dd_name)) != 0) continue; - if (ddp->dd_level >= level) + if (ddp->dd_level >= atoi(level)) continue; if (ddp->dd_ddate <= (time_t)spcl.c_ddate) continue; spcl.c_ddate = ddp->dd_ddate; - lastlevel = ddp->dd_level; + snprintf(lastlevel, NUM_STR_SIZE, "%d", ddp->dd_level); } } @@ -225,7 +225,7 @@ putdumptime(void) if (strncmp(disk, dtwalk->dd_name, sizeof (dtwalk->dd_name)) != 0) continue; - if (dtwalk->dd_level != level) + if (dtwalk->dd_level != atoi(level)) continue; goto found; } @@ -238,7 +238,7 @@ putdumptime(void) nddates += 1; found: (void) strncpy(dtwalk->dd_name, disk, sizeof (dtwalk->dd_name)); - dtwalk->dd_level = level; + dtwalk->dd_level = atoi(level); dtwalk->dd_ddate = spcl.c_date; ITITERATE(i, dtwalk) { @@ -262,7 +262,7 @@ dumprecout(FILE *file, struct dumpdates *what) if (buf[24] != '\n' || buf[25] != '\0') quit("asctime returned an unexpected string\n"); buf[24] = 0; - if (fprintf(file, "%s %c %s %c%2.2d%2.2d\n", + if (fprintf(file, "%s %d %s %c%2.2d%2.2d\n", what->dd_name, what->dd_level, buf, @@ -288,7 +288,7 @@ getrecord(FILE *df, struct dumpdates *ddatep) dumpdates, recno); #ifdef FDEBUG - msg("getrecord: %s %c %s", ddatep->dd_name, ddatep->dd_level, + msg("getrecord: %s %d %s", ddatep->dd_name, ddatep->dd_level, ddatep->dd_ddate == 0 ? "the epoch\n" : ctime(&ddatep->dd_ddate)); #endif return(0); @@ -298,7 +298,6 @@ static int makedumpdate(struct dumpdates *ddp, char *tbuf) { char *tok; - /* device name */ if ( NULL == (tok = strsep( &tbuf, " ")) ) return(-1); @@ -310,8 +309,9 @@ makedumpdate(struct dumpdates *ddp, char *tbuf) for( ; *tbuf == ' ' ; tbuf++); /* dump level */ - ddp->dd_level = *tbuf; - ++tbuf; + ddp->dd_level = atoi(tbuf); + /* eat the rest of the numbers*/ + for( ; *tbuf >= '0' && *tbuf <= '9' ; tbuf++); /* eat whitespace */ for( ; *tbuf == ' ' ; tbuf++); diff --git a/dump/main.c b/dump/main.c index a0fa718..cecaaae 100644 --- a/dump/main.c +++ b/dump/main.c @@ -37,7 +37,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.91 2004/01/27 10:46:55 stelian Exp $"; + "$Id: main.c,v 1.92 2004/04/21 08:55:51 stelian Exp $"; #endif /* not lint */ #include @@ -103,8 +103,8 @@ const char *disk; /* name of the disk file */ char tape[MAXPATHLEN];/* name of the tape file */ char *tapeprefix; /* prefix of the tape file */ char *dumpdates; /* name of the file containing dump date information*/ -char lastlevel; /* dump level of previous dump */ -char level; /* dump level of this dump */ +char lastlevel[NUM_STR_SIZE];/* dump level of previous dump */ +char level[NUM_STR_SIZE];/* dump level of this dump */ int zipflag; /* which compression method */ int Afile = -1; /* archive file descriptor */ int AfileActive = 1;/* Afile flag */ @@ -204,7 +204,7 @@ main(int argc, char *argv[]) struct dinode *dp; struct mntent *dt; char *map; - int ch; + int ch, pch = 0; int i, anydirskipped; int aflag = 0, bflag = 0, Tflag = 0, honorlevel = 1; dump_ino_t maxino; @@ -236,7 +236,8 @@ main(int argc, char *argv[]) dumpdates = _PATH_DUMPDATES; if (TP_BSIZE / DEV_BSIZE == 0 || TP_BSIZE % DEV_BSIZE != 0) quit("TP_BSIZE must be a multiple of DEV_BSIZE\n"); - level = '0'; + memset(&lastlevel, 0, NUM_STR_SIZE); + memset(&level, 0, NUM_STR_SIZE); if (argc < 2) usage(); @@ -272,7 +273,11 @@ main(int argc, char *argv[]) /* dump level */ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - level = ch; + if ((pch >= '0') && (pch <= '9') && (strlen(level) < NUM_STR_SIZE)) + level[strlen(level)] = ch; + else + level[0] = ch; + pch = ch; break; case 'A': /* archive file */ @@ -424,7 +429,7 @@ main(int argc, char *argv[]) exit(X_STARTUP); } Tflag = 1; - lastlevel = '?'; + lastlevel[0] = '?'; lastlevel[1] = '\0'; break; case 'u': /* update dumpdates */ @@ -646,7 +651,7 @@ main(int argc, char *argv[]) } if (directory[0] != 0) { - if (level != '0') { + if (atoi(level) != 0) { msg("Only level 0 dumps are allowed on a subdirectory\n"); msg("The ENTIRE dump is aborted.\n"); exit(X_STARTUP); @@ -661,7 +666,7 @@ main(int argc, char *argv[]) spcl.c_filesys[NAMELEN-1] = '\0'; (void)gethostname(spcl.c_host, NAMELEN); spcl.c_host[NAMELEN-1] = '\0'; - spcl.c_level = level - '0'; + spcl.c_level = atoi(level); spcl.c_type = TS_TAPE; if (!Tflag) getdumptime(uflag); /* dumpdates snarfed */ @@ -669,7 +674,7 @@ main(int argc, char *argv[]) if (spcl.c_ddate == 0 && spcl.c_level) { msg("WARNING: There is no inferior level dump on this filesystem\n"); msg("WARNING: Assuming a level 0 dump by default\n"); - level = '0'; + level[0] = '0'; level[1] = '\0'; spcl.c_level = 0; } @@ -686,13 +691,13 @@ main(int argc, char *argv[]) if (!sizest) { - msg("Date of this level %c dump: %s", level, + msg("Date of this level %s dump: %s", level, ctime4(&spcl.c_date)); #ifdef USE_QFA gThisDumpDate = spcl.c_date; #endif if (spcl.c_ddate) - msg("Date of last level %c dump: %s", lastlevel, + msg("Date of last level %s dump: %s", lastlevel, ctime4(&spcl.c_ddate)); msg("Dumping %s (%s) ", disk, spcl.c_filesys); if (host) @@ -1046,7 +1051,7 @@ main(int argc, char *argv[]) spcl.c_tapea / (tend_writing - tstart_writing)); putdumptime(); - msg("Date of this level %c dump: %s", level, + msg("Date of this level %s dump: %s", level, spcl.c_date == 0 ? "the epoch\n" : ctime4(&spcl.c_date)); msg("Date this dump completed: %s", ctime(&tnow)); @@ -1085,7 +1090,7 @@ usage(void) fprintf(stderr, "%s %s\n", __progname, _DUMP_VERSION); #endif fprintf(stderr, - "usage:\t%s [-0123456789ac" + "usage:\t%s [-level#] [-ac" #ifdef KERBEROS "k" #endif diff --git a/dump/optr.c b/dump/optr.c index 2d89880..8afe500 100644 --- a/dump/optr.c +++ b/dump/optr.c @@ -37,7 +37,7 @@ #ifndef lint static const char rcsid[] = - "$Id: optr.c,v 1.37 2003/04/10 07:59:05 stelian Exp $"; + "$Id: optr.c,v 1.38 2004/04/21 08:55:51 stelian Exp $"; #endif /* not lint */ #include @@ -620,7 +620,7 @@ print_wmsg(char arg, int dumpme, const char *dev, int level, date = (char *)ctime(&ddate); d = strchr(date, '\n'); if (d) *d = '\0'; - printf("Level %c, Date %s\n", level, date); + printf("Level %d, Date %s\n", level, date); } else printf("never\n"); }