Page MenuHomeFreeBSD

D51077.id.diff
No OneTemporary

D51077.id.diff

diff --git a/usr.bin/mkimg/mkimg.h b/usr.bin/mkimg/mkimg.h
--- a/usr.bin/mkimg/mkimg.h
+++ b/usr.bin/mkimg/mkimg.h
@@ -29,9 +29,9 @@
#include <sys/queue.h>
#include <sys/types.h>
-#include <stdbool.h>
+#include <time.h>
-extern bool reproducible; /* Generate reproducible output. */
+extern time_t timestamp;
struct part {
TAILQ_ENTRY(part) link;
diff --git a/usr.bin/mkimg/mkimg.1 b/usr.bin/mkimg/mkimg.1
--- a/usr.bin/mkimg/mkimg.1
+++ b/usr.bin/mkimg/mkimg.1
@@ -41,7 +41,7 @@
.Op Fl f Ar format
.Op Fl o Ar outfile
.Op Fl a Ar active
-.Op Fl R
+.Op Fl t Ar timestamp
.Op Fl v
.Op Fl y
.Op Fl s Ar scheme Op Fl p Ar partition ...
@@ -139,9 +139,9 @@
same time.
.Pp
The
-.Fl R
-option enables reproducible mode: any timestamps or random identifiers will
-be fixed so as to ensure consistent output.
+.Fl t
+option causes any timestamps embedded in the output file to be set to the
+given time, specified in seconds since the epoch.
.Pp
The
.Fl v
diff --git a/usr.bin/mkimg/mkimg.c b/usr.bin/mkimg/mkimg.c
--- a/usr.bin/mkimg/mkimg.c
+++ b/usr.bin/mkimg/mkimg.c
@@ -61,7 +61,8 @@
static uint64_t min_capacity = 0;
static uint64_t max_capacity = 0;
-bool reproducible = false;
+/* Fixed timestamp for reproducible builds. */
+time_t timestamp = (time_t)-1;
struct partlisthead partlist = TAILQ_HEAD_INITIALIZER(partlist);
u_int nparts = 0;
@@ -563,7 +564,7 @@
bcfd = -1;
outfd = 1; /* Write to stdout by default */
- while ((c = getopt_long(argc, argv, "a:b:c:C:f:o:p:s:vyH:P:RS:T:",
+ while ((c = getopt_long(argc, argv, "a:b:c:C:f:o:p:s:t:vyH:P:S:T:",
longopts, NULL)) != -1) {
switch (c) {
case 'a': /* ACTIVE PARTITION, if supported */
@@ -608,9 +609,6 @@
if (error)
errc(EX_DATAERR, error, "partition");
break;
- case 'R':
- reproducible = true;
- break;
case 's': /* SCHEME */
if (scheme_selected() != NULL)
usage("multiple schemes given");
@@ -618,6 +616,19 @@
if (error)
errc(EX_DATAERR, error, "scheme");
break;
+ case 't': {
+ char *ep;
+ long long val;
+
+ errno = 0;
+ val = strtoll(optarg, &ep, 0);
+ if (ep == optarg || *ep != '\0')
+ errno = EINVAL;
+ if (errno != 0)
+ errc(EX_DATAERR, errno, "timestamp");
+ timestamp = (time_t)val;
+ break;
+ }
case 'y':
unit_testing++;
break;
@@ -680,9 +691,6 @@
if (max_capacity != 0 && min_capacity > max_capacity)
usage("minimum capacity cannot be larger than the maximum one");
- if (reproducible)
- srandom(42);
-
if (secsz > blksz) {
if (blksz != 0)
errx(EX_DATAERR, "the physical block size cannot "
diff --git a/usr.bin/mkimg/uuid.c b/usr.bin/mkimg/uuid.c
--- a/usr.bin/mkimg/uuid.c
+++ b/usr.bin/mkimg/uuid.c
@@ -57,9 +57,10 @@
u_int i;
uint16_t seq;
- if (reproducible)
- memset(&tv, 0, sizeof(tv));
- else if (gettimeofday(&tv, NULL) == -1)
+ if (timestamp != (time_t)-1) {
+ tv.tv_sec = timestamp;
+ tv.tv_usec = 0;
+ } else if (gettimeofday(&tv, NULL) == -1)
abort();
time += (uint64_t)tv.tv_sec * 10000000LL;
diff --git a/usr.bin/mkimg/vhd.c b/usr.bin/mkimg/vhd.c
--- a/usr.bin/mkimg/vhd.c
+++ b/usr.bin/mkimg/vhd.c
@@ -188,7 +188,7 @@
time_t t;
if (!unit_testing) {
- t = time(NULL);
+ t = timestamp != (time_t)-1 ? timestamp : time(NULL);
return (t - 0x386d4380);
}

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 15, 11:20 PM (9 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29740852
Default Alt Text
D51077.id.diff (3 KB)

Event Timeline