Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/makefs If we are using a timestamp from the command...



details:   https://anonhg.NetBSD.org/src/rev/bb0eb6ddbafc
branches:  trunk
changeset: 351281:bb0eb6ddbafc
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Feb 08 21:33:12 2017 +0000

description:
If we are using a timestamp from the command line, don't pay attention to
the user timezone, use UTC instead (for reproducible builds).

diffstat:

 usr.sbin/makefs/cd9660/cd9660_conversion.c |  17 +++++++++++++----
 usr.sbin/makefs/udf.c                      |  20 ++++++++++----------
 2 files changed, 23 insertions(+), 14 deletions(-)

diffs (102 lines):

diff -r ed860c3160c5 -r bb0eb6ddbafc usr.sbin/makefs/cd9660/cd9660_conversion.c
--- a/usr.sbin/makefs/cd9660/cd9660_conversion.c        Wed Feb 08 21:27:26 2017 +0000
+++ b/usr.sbin/makefs/cd9660/cd9660_conversion.c        Wed Feb 08 21:33:12 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_conversion.c,v 1.4 2007/03/14 14:11:17 christos Exp $   */
+/*     $NetBSD: cd9660_conversion.c,v 1.5 2017/02/08 21:33:12 christos Exp $   */
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660_conversion.c,v 1.4 2007/03/14 14:11:17 christos Exp $");
+__RCSID("$NetBSD: cd9660_conversion.c,v 1.5 2017/02/08 21:33:12 christos Exp $");
 #endif  /* !__lint */
 
 
@@ -150,6 +150,9 @@
 static char
 cd9660_compute_gm_offset(time_t tim)
 {
+       if (stampst.st_ino)
+               return 0;
+
        struct tm t, gm;
 
        (void)localtime_r(&tim, &t);
@@ -173,7 +176,10 @@
        struct tm t;
        char temp[18];
 
-       (void)localtime_r(&tim, &t);
+       if (stampst.st_ino)
+               (void)gmtime_r(&tim, &t);
+       else
+               (void)localtime_r(&tim, &t);
        (void)snprintf(temp, sizeof(temp), "%04i%02i%02i%02i%02i%02i%02i",
                1900+(int)t.tm_year,
                (int)t.tm_mon+1,
@@ -192,7 +198,10 @@
 {
        struct tm t;
 
-       (void)localtime_r(&tim, &t);
+       if (stampst.st_ino)
+               (void)gmtime_r(&tim, &t);
+       else
+               (void)localtime_r(&tim, &t);
        buf[0] = t.tm_year;
        buf[1] = t.tm_mon+1;
        buf[2] = t.tm_mday;
diff -r ed860c3160c5 -r bb0eb6ddbafc usr.sbin/makefs/udf.c
--- a/usr.sbin/makefs/udf.c     Wed Feb 08 21:27:26 2017 +0000
+++ b/usr.sbin/makefs/udf.c     Wed Feb 08 21:33:12 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.c,v 1.17 2015/06/16 23:04:14 christos Exp $ */
+/* $NetBSD: udf.c,v 1.18 2017/02/08 21:33:12 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: udf.c,v 1.17 2015/06/16 23:04:14 christos Exp $");
+__RCSID("$NetBSD: udf.c,v 1.18 2017/02/08 21:33:12 christos Exp $");
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -290,9 +290,6 @@
 void
 udf_prep_opts(fsinfo_t *fsopts)
 {
-       struct tm *tm;
-       time_t now;
-
        const option_t udf_options[] = {
                OPT_STR('T', "disctype", "disc type (cdrom,dvdrom,bdrom,"
                        "dvdram,bdre,disk,cdr,dvdr,bdr,cdrw,dvdrw)"),
@@ -330,13 +327,16 @@
        context.max_udf = 0x201;        /* 0x250 and 0x260 are not ready */
 
        /* use user's time zone as default */
-       (void)time(&now);
-       tm = localtime(&now);
 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
-       context.gmtoff = tm->tm_gmtoff;
-#else
-       context.gmtoff = 0;
+       if (!stampst.st_ino)  {
+               struct tm tm;
+               time_t now;
+               (void)time(&now);
+               (void)localtime_r(&now, &tm);
+               context.gmtoff = tm.tm_gmtoff;
+       } else
 #endif
+               context.gmtoff = 0;
 
        /* return info */
        fsopts->fs_specific = NULL;



Home | Main Index | Thread Index | Old Index