Module Name:    src
Committed By:   christos
Date:           Wed Feb  8 21:33:12 UTC 2017

Modified Files:
        src/usr.sbin/makefs: udf.c
        src/usr.sbin/makefs/cd9660: cd9660_conversion.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/makefs/udf.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/makefs/cd9660/cd9660_conversion.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/udf.c
diff -u src/usr.sbin/makefs/udf.c:1.17 src/usr.sbin/makefs/udf.c:1.18
--- src/usr.sbin/makefs/udf.c:1.17	Tue Jun 16 19:04:14 2015
+++ src/usr.sbin/makefs/udf.c	Wed Feb  8 16:33:12 2017
@@ -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 @@ udf_update_trackinfo(struct mmc_discinfo
 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 @@ udf_prep_opts(fsinfo_t *fsopts)
 	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;

Index: src/usr.sbin/makefs/cd9660/cd9660_conversion.c
diff -u src/usr.sbin/makefs/cd9660/cd9660_conversion.c:1.4 src/usr.sbin/makefs/cd9660/cd9660_conversion.c:1.5
--- src/usr.sbin/makefs/cd9660/cd9660_conversion.c:1.4	Wed Mar 14 10:11:17 2007
+++ src/usr.sbin/makefs/cd9660/cd9660_conversion.c	Wed Feb  8 16:33:12 2017
@@ -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 @@ cd9660_pad_string_spaces(char *str, int 
 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 @@ cd9660_time_8426(unsigned char *buf, tim
 	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 @@ cd9660_time_915(unsigned char *buf, time
 {
 	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;

Reply via email to