]> git.wh0rd.org - dump.git/commitdiff
Store dumpdates with timezone
authorStelian Pop <stelian@popies.net>
Thu, 6 Mar 2003 14:35:48 +0000 (14:35 +0000)
committerStelian Pop <stelian@popies.net>
Thu, 6 Mar 2003 14:35:48 +0000 (14:35 +0000)
CHANGES
dump/dump.8.in
dump/itime.c
dump/unctime.c

diff --git a/CHANGES b/CHANGES
index d31eb69245afdb9a528459a02d2ee2943f036fc9..f48efa33334a749a6905a96c9cc88e09ed4f6f98 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,4 @@
-$Id: CHANGES,v 1.218 2003/02/25 14:06:47 stelian Exp $
+$Id: CHANGES,v 1.219 2003/03/06 14:35:48 stelian Exp $
 
 Changes between versions 0.4b33 and 0.4b34 (released ?????????????????)
 =======================================================================
 
 Changes between versions 0.4b33 and 0.4b34 (released ?????????????????)
 =======================================================================
@@ -32,6 +32,11 @@ Changes between versions 0.4b33 and 0.4b34 (released ?????????????????)
        a label exactly 16 bytes in length. Thanks to <minduni@ti-edu.ch>
        for reporting the bug.
 
        a label exactly 16 bytes in length. Thanks to <minduni@ti-edu.ch>
        for reporting the bug.
 
+8.     Made dump store dump dates using explicit timezones, fixing a
+       problem with incremental dumps if the timezone is modified 
+       between the dumps. Thanks to Philippe Troin <phil@fifi.org> for
+       the bug report and the patch.
+
 Changes between versions 0.4b32 and 0.4b33 (released February 10, 2003)
 =======================================================================
 
 Changes between versions 0.4b32 and 0.4b33 (released February 10, 2003)
 =======================================================================
 
index 23243bc27828b8683e574d969af09389770c969a..13fae882b4e12d8c631817a732a4f38d23ad6495 100644 (file)
@@ -30,7 +30,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\"    $Id: dump.8.in,v 1.49 2003/02/04 12:24:40 stelian Exp $
+.\"    $Id: dump.8.in,v 1.50 2003/03/06 14:35:51 stelian Exp $
 .\"
 .TH DUMP 8 "version __VERSION__ of __DATE__" BSD "System management commands"
 .SH NAME
 .\"
 .TH DUMP 8 "version __VERSION__ of __DATE__" BSD "System management commands"
 .SH NAME
@@ -367,7 +367,15 @@ determined from looking in
 The format of
 .I date
 is the same as that of
 The format of
 .I date
 is the same as that of
-.BR ctime (3).
+.BR ctime (3)
+followed by an rfc822 timezone specification: either a plus or minus sign
+followed by two digits for the number of hours and two digits for the minutes.
+For example, -0800 for eight hours west of Greenwich or +0230 for two hours
+and a half east of Greenwich. This timezone offset takes into account
+daylight savings time (if applicable to the timezone): UTC offsets
+when daylight savings time is in effect will be different than offsets
+when daylight savings time is not in effect. For backward
+compatibility, if no timezone is specified, a local time is assumed.
 This option is useful for automated dump scripts that wish to dump over a 
 specific period of time. The
 .B \-T
 This option is useful for automated dump scripts that wish to dump over a 
 specific period of time. The
 .B \-T
@@ -383,8 +391,12 @@ after a successful dump. The format of
 is readable by people, consisting of one free format record per line:
 filesystem name, increment level and
 .BR ctime (3)
 is readable by people, consisting of one free format record per line:
 filesystem name, increment level and
 .BR ctime (3)
-format dump date. There may be only one entry per filesystem at each level. The
-file
+format dump date followed by a rfc822 timezone specification (see the
+.B \-u
+option for details). If no timezone offset is specified, times are interpreted 
+as local. Whenever the file is written, all dates in the file are converted 
+to the local time zone, without changing the UTC times. There
+may be only one entry per filesystem at each level. The file
 .I __DUMPDATES__
 may be edited to change any of the fields, if necessary.
 .TP
 .I __DUMPDATES__
 may be edited to change any of the fields, if necessary.
 .TP
@@ -551,6 +563,15 @@ to find group
 .BR rmt (8)
 .SH DIAGNOSTICS
 Many, and verbose.
 .BR rmt (8)
 .SH DIAGNOSTICS
 Many, and verbose.
+.SH COMPATIBILITY
+The format of the
+.I __DUMPDATES__
+file has changed in release 0.4b34, however, the file will be read
+correctly with either pre-0.4b34 or 0.4b34 and later versions of
+.B dump
+provided that the machine on which
+.B dump
+is run did not change timezones (which should be a fairly rare occurence).
 .SH EXIT STATUS
 .B Dump
 exits with zero status on success. Startup errors are indicated with an exit
 .SH EXIT STATUS
 .B Dump
 exits with zero status on success. Startup errors are indicated with an exit
index aeaaec01f8f9ee8c92ed88d717b398956cc4cdf4..7b20ca216bd08908576b1cd96f46e9c23ef8096a 100644 (file)
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static const char rcsid[] =
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: itime.c,v 1.23 2002/08/01 10:23:26 stelian Exp $";
+       "$Id: itime.c,v 1.24 2003/03/06 14:35:51 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
 #endif /* not lint */
 
 #include <config.h>
@@ -259,11 +259,21 @@ putdumptime(void)
 static void
 dumprecout(FILE *file, struct dumpdates *what)
 {
 static void
 dumprecout(FILE *file, struct dumpdates *what)
 {
+       char buf[26];
+       struct tm *tms;
 
 
-       if (fprintf(file, "%s %c %s",
+       tms = localtime(&what->dd_ddate);
+       strncpy(buf, asctime(tms), sizeof(buf));
+       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",
                    what->dd_name,
                    what->dd_level,
                    what->dd_name,
                    what->dd_level,
-                   ctime(&what->dd_ddate)) < 0)
+                   buf,
+                   (tms->tm_gmtoff < 0 ? '-' : '+'),
+                   abs(tms->tm_gmtoff) / 3600,
+                   abs(tms->tm_gmtoff) % 3600 / 60) < 0)
                quit("%s: %s\n", dumpdates, strerror(errno));
 }
 
                quit("%s: %s\n", dumpdates, strerror(errno));
 }
 
index 7f20c346052b21165ce323f81b6cc6448e8f5a21..733081a63a165cc1dc216f5eee93c17f2491666f 100644 (file)
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static const char rcsid[] =
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: unctime.c,v 1.14 2002/01/25 15:08:59 stelian Exp $";
+       "$Id: unctime.c,v 1.15 2003/03/06 14:35:51 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
 #endif /* not lint */
 
 #include <config.h>
@@ -84,6 +84,7 @@ static const char rcsid[] =
 #define        E_MINUTE        14
 #define        E_SECOND        17
 #define        E_YEAR          20
 #define        E_MINUTE        14
 #define        E_SECOND        17
 #define        E_YEAR          20
+#define E_TZOFFSET      25
 
 static int lookup __P((const char *));
 
 
 static int lookup __P((const char *));
 
@@ -92,7 +93,9 @@ time_t
 unctime(const char *str)
 {
        struct tm then;
 unctime(const char *str)
 {
        struct tm then;
-       char dbuf[26];
+       char dbuf[32];
+       time_t rtime;
+       int tzoffset;
 
        (void) strncpy(dbuf, str, sizeof(dbuf) - 1);
        dbuf[sizeof(dbuf) - 1] = '\0';
 
        (void) strncpy(dbuf, str, sizeof(dbuf) - 1);
        dbuf[sizeof(dbuf) - 1] = '\0';
@@ -105,7 +108,15 @@ unctime(const char *str)
        then.tm_sec = atoi(&dbuf[E_SECOND]);
        then.tm_year = atoi(&dbuf[E_YEAR]) - 1900;
        then.tm_isdst = -1;
        then.tm_sec = atoi(&dbuf[E_SECOND]);
        then.tm_year = atoi(&dbuf[E_YEAR]) - 1900;
        then.tm_isdst = -1;
-       return(mktime(&then));
+       if (strlen(str) >= E_TZOFFSET+5) {
+               rtime = timegm(&then);
+               /* add timezone offset */
+               tzoffset = atoi(&dbuf[E_TZOFFSET]);
+               rtime -= (tzoffset / 100 * 3600) + (tzoffset % 100) * 60;
+       } else {
+               rtime = timelocal(&then);
+       }
+       return(rtime);
 }
 
 static char months[] =
 }
 
 static char months[] =