X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=dump%2Fitime.c;h=f2cc76307eaf68d3e15b6569fc5760ba76598864;hp=7b20ca216bd08908576b1cd96f46e9c23ef8096a;hb=4a9a33ef6c2f09149c5ab3f89e42572ef38801e1;hpb=3458b64d0f4e9c6b5bf43ba51c964bab8b716127 diff --git a/dump/itime.c b/dump/itime.c index 7b20ca2..f2cc763 100644 --- a/dump/itime.c +++ b/dump/itime.c @@ -18,11 +18,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -41,7 +37,7 @@ #ifndef lint static const char rcsid[] = - "$Id: itime.c,v 1.24 2003/03/06 14:35:51 stelian Exp $"; + "$Id: itime.c,v 1.28 2004/06/17 09:01:15 stelian Exp $"; #endif /* not lint */ #include @@ -56,7 +52,6 @@ static const char rcsid[] = #include #include #include -#include #ifdef __linux__ #ifdef HAVE_EXT2FS_EXT2_FS_H #include @@ -168,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) @@ -190,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); } } @@ -230,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; } @@ -243,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) { @@ -267,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,12 +283,14 @@ getrecord(FILE *df, struct dumpdates *ddatep) if (fgets(tbuf, sizeof (tbuf), df) == NULL) return(-1); recno++; - if (makedumpdate(ddatep, tbuf) < 0) - msg("Unknown intermediate format in %s, line %d\n", + if (makedumpdate(ddatep, tbuf) < 0) { + msg("Unknown format in %s, line %d\n", dumpdates, recno); + return(-1); + } #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); @@ -303,11 +300,10 @@ static int makedumpdate(struct dumpdates *ddp, char *tbuf) { char *tok; - /* device name */ if ( NULL == (tok = strsep( &tbuf, " ")) ) return(-1); - if ( strlen(tok) > MAXPATHLEN ) + if ( !tbuf || strlen(tok) > MAXPATHLEN ) return(-1); strcpy(ddp->dd_name, tok); @@ -315,8 +311,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++);