Make the protocol/dumprestore.h header match restore's idea of the dump
header for the case where sizeof(time_t) != sizeof(int). dumprestore.h was embedding time_t when it should have been embedding int32_t. Use time_to_time32() and time32_to_time() to convert between the protocoll/file-format time and time_t.
This commit is contained in:
parent
237c4e3a9e
commit
5b3817c60b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=85635
@ -36,6 +36,8 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)dumprestore.h 8.2 (Berkeley) 1/21/94
|
* @(#)dumprestore.h 8.2 (Berkeley) 1/21/94
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PROTOCOLS_DUMPRESTORE_H_
|
#ifndef _PROTOCOLS_DUMPRESTORE_H_
|
||||||
@ -68,8 +70,8 @@ union u_spcl {
|
|||||||
char dummy[TP_BSIZE];
|
char dummy[TP_BSIZE];
|
||||||
struct s_spcl {
|
struct s_spcl {
|
||||||
int32_t c_type; /* record type (see below) */
|
int32_t c_type; /* record type (see below) */
|
||||||
time_t c_date; /* date of this dump */
|
int32_t c_date; /* date of this dump */
|
||||||
time_t c_ddate; /* date of previous dump */
|
int32_t c_ddate; /* date of previous dump */
|
||||||
int32_t c_volume; /* dump volume number */
|
int32_t c_volume; /* dump volume number */
|
||||||
daddr_t c_tapea; /* logical block of this record */
|
daddr_t c_tapea; /* logical block of this record */
|
||||||
ino_t c_inumber; /* number of inode */
|
ino_t c_inumber; /* number of inode */
|
||||||
|
@ -162,9 +162,9 @@ getdumptime()
|
|||||||
continue;
|
continue;
|
||||||
if (ddp->dd_level >= level)
|
if (ddp->dd_level >= level)
|
||||||
continue;
|
continue;
|
||||||
if (ddp->dd_ddate <= spcl.c_ddate)
|
if (ddp->dd_ddate <= time32_to_time(spcl.c_ddate))
|
||||||
continue;
|
continue;
|
||||||
spcl.c_ddate = ddp->dd_ddate;
|
spcl.c_ddate = time_to_time32(ddp->dd_ddate);
|
||||||
lastlevel = ddp->dd_level;
|
lastlevel = ddp->dd_level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -177,6 +177,7 @@ putdumptime()
|
|||||||
register int i;
|
register int i;
|
||||||
int fd;
|
int fd;
|
||||||
char *fname;
|
char *fname;
|
||||||
|
char *tmsg;
|
||||||
|
|
||||||
if(uflag == 0)
|
if(uflag == 0)
|
||||||
return;
|
return;
|
||||||
@ -211,7 +212,7 @@ putdumptime()
|
|||||||
found:
|
found:
|
||||||
(void) strncpy(dtwalk->dd_name, fname, sizeof (dtwalk->dd_name));
|
(void) strncpy(dtwalk->dd_name, fname, sizeof (dtwalk->dd_name));
|
||||||
dtwalk->dd_level = level;
|
dtwalk->dd_level = level;
|
||||||
dtwalk->dd_ddate = spcl.c_date;
|
dtwalk->dd_ddate = time32_to_time(spcl.c_date);
|
||||||
|
|
||||||
ITITERATE(i, dtwalk) {
|
ITITERATE(i, dtwalk) {
|
||||||
dumprecout(df, dtwalk);
|
dumprecout(df, dtwalk);
|
||||||
@ -221,8 +222,13 @@ putdumptime()
|
|||||||
if (ftruncate(fd, ftell(df)))
|
if (ftruncate(fd, ftell(df)))
|
||||||
quit("ftruncate (%s): %s\n", dumpdates, strerror(errno));
|
quit("ftruncate (%s): %s\n", dumpdates, strerror(errno));
|
||||||
(void) fclose(df);
|
(void) fclose(df);
|
||||||
msg("level %c dump on %s", level,
|
if (spcl.c_date == 0) {
|
||||||
spcl.c_date == 0 ? "the epoch\n" : ctime(&spcl.c_date));
|
tmsg = "the epoch\n";
|
||||||
|
} else {
|
||||||
|
time_t t = time32_to_time(spcl.c_date);
|
||||||
|
tmsg = ctime(&t);
|
||||||
|
}
|
||||||
|
msg("level %c dump on %s", level, tmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -105,9 +105,10 @@ main(argc, argv)
|
|||||||
register int ch;
|
register int ch;
|
||||||
int i, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1;
|
int i, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1;
|
||||||
ino_t maxino;
|
ino_t maxino;
|
||||||
|
char *tmsg;
|
||||||
|
time_t t;
|
||||||
|
|
||||||
spcl.c_date = 0;
|
spcl.c_date = time_to_time32(time(NULL));
|
||||||
(void)time((time_t *)&spcl.c_date);
|
|
||||||
|
|
||||||
tsize = 0; /* Default later, based on 'c' option for cart tapes */
|
tsize = 0; /* Default later, based on 'c' option for cart tapes */
|
||||||
if ((tape = getenv("TAPE")) == NULL)
|
if ((tape = getenv("TAPE")) == NULL)
|
||||||
@ -313,10 +314,20 @@ main(argc, argv)
|
|||||||
if (!Tflag)
|
if (!Tflag)
|
||||||
getdumptime(); /* /etc/dumpdates snarfed */
|
getdumptime(); /* /etc/dumpdates snarfed */
|
||||||
|
|
||||||
msg("Date of this level %c dump: %s", level,
|
if (spcl.c_date == 0) {
|
||||||
spcl.c_date == 0 ? "the epoch\n" : ctime(&spcl.c_date));
|
tmsg = "the epoch\n";
|
||||||
msg("Date of last level %c dump: %s", lastlevel,
|
} else {
|
||||||
spcl.c_ddate == 0 ? "the epoch\n" : ctime(&spcl.c_ddate));
|
time_t t = time32_to_time(spcl.c_date);
|
||||||
|
tmsg = ctime(&t);
|
||||||
|
}
|
||||||
|
msg("Date of this level %c dump: %s", level, tmsg);
|
||||||
|
if (spcl.c_ddate == 0) {
|
||||||
|
tmsg = "the epoch\n";
|
||||||
|
} else {
|
||||||
|
time_t t = time32_to_time(spcl.c_ddate);
|
||||||
|
tmsg = ctime(&t);
|
||||||
|
}
|
||||||
|
msg("Date of last level %c dump: %s", lastlevel, tmsg);
|
||||||
msg("Dumping %s ", disk);
|
msg("Dumping %s ", disk);
|
||||||
if (dt != NULL)
|
if (dt != NULL)
|
||||||
msgtail("(%s) ", dt->fs_file);
|
msgtail("(%s) ", dt->fs_file);
|
||||||
|
@ -232,8 +232,8 @@ setup()
|
|||||||
}
|
}
|
||||||
if (vflag || command == 't')
|
if (vflag || command == 't')
|
||||||
printdumpinfo();
|
printdumpinfo();
|
||||||
dumptime = spcl.c_ddate;
|
dumptime = time32_to_time(spcl.c_ddate);
|
||||||
dumpdate = spcl.c_date;
|
dumpdate = time32_to_time(spcl.c_date);
|
||||||
if (stat(".", &stbuf) < 0) {
|
if (stat(".", &stbuf) < 0) {
|
||||||
fprintf(stderr, "cannot stat .: %s\n", strerror(errno));
|
fprintf(stderr, "cannot stat .: %s\n", strerror(errno));
|
||||||
done(1);
|
done(1);
|
||||||
@ -404,9 +404,10 @@ getvol(nextvol)
|
|||||||
volno = 0;
|
volno = 0;
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
if (tmpbuf.c_date != dumpdate || tmpbuf.c_ddate != dumptime) {
|
if (time32_to_time(tmpbuf.c_date) != dumpdate ||
|
||||||
fprintf(stderr, "Wrong dump date\n\tgot: %s",
|
time32_to_time(tmpbuf.c_ddate) != dumptime) {
|
||||||
ctime(&tmpbuf.c_date));
|
time_t t = time32_to_time(tmpbuf.c_date);
|
||||||
|
fprintf(stderr, "Wrong dump date\n\tgot: %s", ctime(&t));
|
||||||
fprintf(stderr, "\twanted: %s", ctime(&dumpdate));
|
fprintf(stderr, "\twanted: %s", ctime(&dumpdate));
|
||||||
volno = 0;
|
volno = 0;
|
||||||
goto again;
|
goto again;
|
||||||
@ -508,9 +509,12 @@ setdumpnum()
|
|||||||
void
|
void
|
||||||
printdumpinfo()
|
printdumpinfo()
|
||||||
{
|
{
|
||||||
fprintf(stdout, "Dump date: %s", ctime(&spcl.c_date));
|
time_t t;
|
||||||
|
t = time32_to_time(spcl.c_date);
|
||||||
|
fprintf(stdout, "Dump date: %s", ctime(&t));
|
||||||
|
t = time32_to_time(spcl.c_ddate);
|
||||||
fprintf(stdout, "Dumped from: %s",
|
fprintf(stdout, "Dumped from: %s",
|
||||||
(spcl.c_ddate == 0) ? "the epoch\n" : ctime(&spcl.c_ddate));
|
(spcl.c_ddate == 0) ? "the epoch\n" : ctime(&t));
|
||||||
if (spcl.c_host[0] == '\0')
|
if (spcl.c_host[0] == '\0')
|
||||||
return;
|
return;
|
||||||
fprintf(stderr, "Level %ld dump of %s on %s:%s\n",
|
fprintf(stderr, "Level %ld dump of %s on %s:%s\n",
|
||||||
@ -1227,7 +1231,7 @@ findinode(header)
|
|||||||
if (header->c_magic != NFS_MAGIC) {
|
if (header->c_magic != NFS_MAGIC) {
|
||||||
skipcnt++;
|
skipcnt++;
|
||||||
while (gethead(header) == FAIL ||
|
while (gethead(header) == FAIL ||
|
||||||
header->c_date != dumpdate)
|
time32_to_time(header->c_date) != dumpdate)
|
||||||
skipcnt++;
|
skipcnt++;
|
||||||
}
|
}
|
||||||
switch (header->c_type) {
|
switch (header->c_type) {
|
||||||
@ -1240,7 +1244,7 @@ findinode(header)
|
|||||||
if (header->c_addr[i])
|
if (header->c_addr[i])
|
||||||
readtape(buf);
|
readtape(buf);
|
||||||
while (gethead(header) == FAIL ||
|
while (gethead(header) == FAIL ||
|
||||||
header->c_date != dumpdate)
|
time32_to_time(header->c_date) != dumpdate)
|
||||||
skipcnt++;
|
skipcnt++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user