summaryrefslogtreecommitdiff
path: root/sbin/dump
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1998-02-08 19:24:10 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1998-02-08 19:24:10 +0000
commit675d856532243ac50b1c14805a74c84028d4824c (patch)
tree9c91a5a86f82fb1117fa6eb6923c0678e32a8cc0 /sbin/dump
parent09a00a853f2ba06818d25b4cc017f754e28bfcc1 (diff)
y2k fixes; netbsd & Andreas.Gunnarsson@emw.ericsson.se
Diffstat (limited to 'sbin/dump')
-rw-r--r--sbin/dump/Makefile5
-rw-r--r--sbin/dump/dump.h3
-rw-r--r--sbin/dump/itime.c18
-rw-r--r--sbin/dump/main.c12
-rw-r--r--sbin/dump/unctime.c113
5 files changed, 25 insertions, 126 deletions
diff --git a/sbin/dump/Makefile b/sbin/dump/Makefile
index b3dae071ba5..61ea7bbd5aa 100644
--- a/sbin/dump/Makefile
+++ b/sbin/dump/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.8 1997/09/21 11:36:18 deraadt Exp $
+# $OpenBSD: Makefile,v 1.9 1998/02/08 19:24:05 deraadt Exp $
# dump.h header file
# itime.c reads /etc/dumpdates
@@ -7,7 +7,6 @@
# dumprmt.c handles remote tape via rmt(8)
# tape.c handles the mag tape and opening/closing
# traverse.c traverses the file system
-# unctime.c undo ctime
#
# DEBUG use local directory to find ddate and dumpdates
# TDEBUG trace out the process forking
@@ -15,7 +14,7 @@
PROG= dump
LINKS= ${BINDIR}/dump ${BINDIR}/rdump
CFLAGS+=-DRDUMP
-SRCS= itime.c main.c optr.c dumprmt.c tape.c traverse.c unctime.c
+SRCS= itime.c main.c optr.c dumprmt.c tape.c traverse.c
MAN= dump.8
MLINKS+=dump.8 rdump.8
diff --git a/sbin/dump/dump.h b/sbin/dump/dump.h
index 6bb8d593e07..26035f5db35 100644
--- a/sbin/dump/dump.h
+++ b/sbin/dump/dump.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dump.h,v 1.5 1997/07/05 05:35:54 millert Exp $ */
+/* $OpenBSD: dump.h,v 1.6 1998/02/08 19:24:07 deraadt Exp $ */
/* $NetBSD: dump.h,v 1.11 1997/06/05 11:13:20 lukem Exp $ */
/*-
@@ -104,7 +104,6 @@ int query __P((char *question));
void quit __P((const char *fmt, ...));
void statussig __P((int));
void timeest __P((void));
-time_t unctime __P((char *str));
/* mapping routines */
struct dinode;
diff --git a/sbin/dump/itime.c b/sbin/dump/itime.c
index ce80a96c20f..ba7682a243f 100644
--- a/sbin/dump/itime.c
+++ b/sbin/dump/itime.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: itime.c,v 1.3 1997/07/05 05:35:56 millert Exp $ */
+/* $OpenBSD: itime.c,v 1.4 1998/02/08 19:24:08 deraadt Exp $ */
/* $NetBSD: itime.c,v 1.4 1997/04/15 01:09:50 lukem Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)itime.c 8.1 (Berkeley) 6/5/93";
#else
-static char rcsid[] = "$OpenBSD: itime.c,v 1.3 1997/07/05 05:35:56 millert Exp $";
+static char rcsid[] = "$OpenBSD: itime.c,v 1.4 1998/02/08 19:24:08 deraadt Exp $";
#endif
#endif /* not lint */
@@ -59,6 +59,7 @@ static char rcsid[] = "$OpenBSD: itime.c,v 1.3 1997/07/05 05:35:56 millert Exp $
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
+#include <time.h>
#ifdef __STDC__
#include <stdlib.h>
#include <string.h>
@@ -269,10 +270,17 @@ makedumpdate(ddp, tbuf)
struct dumpdates *ddp;
char *tbuf;
{
- char un_buf[128];
+ char un_buf[BUFSIZ], *str;
+ struct tm then;
- (void) sscanf(tbuf, DUMPINFMT, ddp->dd_name, &ddp->dd_level, un_buf);
- ddp->dd_ddate = unctime(un_buf);
+ if (sscanf(tbuf, DUMPINFMT, ddp->dd_name, &ddp->dd_level, un_buf) != 3)
+ return(-1);
+ str = strptime(un_buf, "%a %b %e %H:%M:%S %Y", &then);
+ then.tm_isdst = -1;
+ if (str == NULL || (*str != '\n' && *str != '\0'))
+ ddp->dd_ddate = (time_t) -1;
+ else
+ ddp->dd_ddate = mktime(&then);
if (ddp->dd_ddate < 0)
return(-1);
return(0);
diff --git a/sbin/dump/main.c b/sbin/dump/main.c
index 01c4c55da07..028d3bdbfbf 100644
--- a/sbin/dump/main.c
+++ b/sbin/dump/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.17 1997/07/05 05:35:56 millert Exp $ */
+/* $OpenBSD: main.c,v 1.18 1998/02/08 19:24:08 deraadt Exp $ */
/* $NetBSD: main.c,v 1.14 1997/06/05 11:13:24 lukem Exp $ */
/*-
@@ -110,11 +110,12 @@ main(argc, argv)
register struct fstab *dt;
register char *map;
register int ch;
+ struct tm then;
int i, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1;
ino_t maxino;
time_t tnow;
int dirlist;
- char *toplevel;
+ char *toplevel, *str;
spcl.c_date = 0;
(void)time((time_t *)&spcl.c_date);
@@ -181,7 +182,12 @@ main(argc, argv)
break;
case 'T': /* time of last dump */
- spcl.c_ddate = unctime(optarg);
+ str = strptime(optarg, "%a %b %e %H:%M:%S %Y", &then);
+ then.tm_isdst = -1;
+ if (str == NULL || (*str != '\n' && *str != '\0'))
+ spcl.c_ddate = (time_t) -1;
+ else
+ spcl.c_ddate = mktime(&then);
if (spcl.c_ddate < 0) {
(void)fprintf(stderr, "bad time \"%s\"\n",
optarg);
diff --git a/sbin/dump/unctime.c b/sbin/dump/unctime.c
deleted file mode 100644
index d1dc519253f..00000000000
--- a/sbin/dump/unctime.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/* $OpenBSD: unctime.c,v 1.3 1997/07/05 05:36:00 millert Exp $ */
-/* $NetBSD: unctime.c,v 1.10 1997/04/15 01:09:55 lukem Exp $ */
-
-/*-
- * Copyright (c) 1980, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 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
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)unctime.c 8.2 (Berkeley) 6/14/94";
-#else
-static char rcsid[] = "$OpenBSD: unctime.c,v 1.3 1997/07/05 05:36:00 millert Exp $";
-#endif
-#endif /* not lint */
-
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <time.h>
-#ifdef __STDC__
-#include <stdlib.h>
-#include <string.h>
-#endif
-
-#ifndef __P
-#include <sys/cdefs.h>
-#endif
-
-/*
- * Convert a ctime(3) format string into a system format date.
- * Return the date thus calculated.
- *
- * Return -1 if the string is not in ctime format.
- */
-
-/*
- * Offsets into the ctime string to various parts.
- */
-
-#define E_MONTH 4
-#define E_DAY 8
-#define E_HOUR 11
-#define E_MINUTE 14
-#define E_SECOND 17
-#define E_YEAR 20
-
-static int lookup __P((char *));
-
-
-time_t
-unctime(str)
- char *str;
-{
- struct tm then;
- char dbuf[26];
-
- (void) strncpy(dbuf, str, sizeof(dbuf) - 1);
- dbuf[sizeof(dbuf) - 1] = '\0';
- dbuf[E_MONTH+3] = '\0';
- if ((then.tm_mon = lookup(&dbuf[E_MONTH])) < 0)
- return (-1);
- then.tm_mday = atoi(&dbuf[E_DAY]);
- then.tm_hour = atoi(&dbuf[E_HOUR]);
- then.tm_min = atoi(&dbuf[E_MINUTE]);
- then.tm_sec = atoi(&dbuf[E_SECOND]);
- then.tm_year = atoi(&dbuf[E_YEAR]) - 1900;
- then.tm_isdst = -1;
- return(mktime(&then));
-}
-
-static char months[] =
- "JanFebMarAprMayJunJulAugSepOctNovDec";
-
-static int
-lookup(str)
- char *str;
-{
- register char *cp, *cp2;
-
- for (cp = months, cp2 = str; *cp != '\0'; cp += 3)
- if (strncmp(cp, cp2, 3) == 0)
- return((cp-months) / 3);
- return(-1);
-}