Module Name: src
Committed By: christos
Date: Wed Nov 25 00:48:49 UTC 2015
Modified Files:
src/usr.sbin/makefs: cd9660.c makefs.8 makefs.c makefs.h walk.c
Log Message:
Provide a -T option to set timestamps to a consistent value for MKREPRO
To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/usr.sbin/makefs/cd9660.c
cvs rdiff -u -r1.53 -r1.54 src/usr.sbin/makefs/makefs.8
cvs rdiff -u -r1.50 -r1.51 src/usr.sbin/makefs/makefs.c
cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/makefs/makefs.h
cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/makefs/walk.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/cd9660.c
diff -u src/usr.sbin/makefs/cd9660.c:1.49 src/usr.sbin/makefs/cd9660.c:1.50
--- src/usr.sbin/makefs/cd9660.c:1.49 Tue Jun 16 21:05:41 2015
+++ src/usr.sbin/makefs/cd9660.c Tue Nov 24 19:48:49 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: cd9660.c,v 1.49 2015/06/17 01:05:41 christos Exp $ */
+/* $NetBSD: cd9660.c,v 1.50 2015/11/25 00:48:49 christos Exp $ */
/*
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660.c,v 1.49 2015/06/17 01:05:41 christos Exp $");
+__RCSID("$NetBSD: cd9660.c,v 1.50 2015/11/25 00:48:49 christos Exp $");
#endif /* !__lint */
#include <string.h>
@@ -1281,6 +1281,8 @@ cd9660_rrip_move_directory(iso9660_disk
diskStructure->rootNode, dir);
if (diskStructure->rr_moved_dir == NULL)
return 0;
+ cd9660_time_915(diskStructure->rr_moved_dir->isoDirRecord->date,
+ stampst.st_ino ? stampst.st_mtime : start_time.tv_sec);
}
/* Create a file with the same ORIGINAL name */
Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.53 src/usr.sbin/makefs/makefs.8:1.54
--- src/usr.sbin/makefs/makefs.8:1.53 Tue Aug 6 16:16:54 2013
+++ src/usr.sbin/makefs/makefs.8 Tue Nov 24 19:48:49 2015
@@ -1,4 +1,4 @@
-.\" $NetBSD: makefs.8,v 1.53 2013/08/06 20:16:54 wiz Exp $
+.\" $NetBSD: makefs.8,v 1.54 2015/11/25 00:48:49 christos Exp $
.\"
.\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
.\" All rights reserved.
@@ -33,7 +33,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd August 6, 2013
+.Dd November 23, 2015
.Dt MAKEFS 8
.Os
.Sh NAME
@@ -54,6 +54,7 @@
.Op Fl o Ar fs-options
.Op Fl S Ar sector-size
.Op Fl s Ar image-size
+.Op Fl T Ar timestamp
.Op Fl t Ar fs-type
.Ar image-file
.Ar directory
@@ -199,6 +200,21 @@ Defaults to 512.
.It Fl s Ar image-size
Set the size of the file system image to
.Ar image-size .
+.It Fl T Ar timestamp
+Specify a timestamp to be set for all filesystem files and directories
+created so that repeatable builds are possible.
+The
+.Ar timestamp
+can be a
+.Pa pathname ,
+where the timestamps are derived from that file, a parseable date
+for
+.Xr parsedate 3
+(this option is not yet available in the tools build), or an integer
+value interpreted as the number of seconds from the Epoch.
+Note that timestamps specified in an
+.Xr mtree 5
+spec file, override the default timestamp.
.It Fl t Ar fs-type
Create an
.Ar fs-type
Index: src/usr.sbin/makefs/makefs.c
diff -u src/usr.sbin/makefs/makefs.c:1.50 src/usr.sbin/makefs/makefs.c:1.51
--- src/usr.sbin/makefs/makefs.c:1.50 Mon Aug 5 10:41:57 2013
+++ src/usr.sbin/makefs/makefs.c Tue Nov 24 19:48:49 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: makefs.c,v 1.50 2013/08/05 14:41:57 reinoud Exp $ */
+/* $NetBSD: makefs.c,v 1.51 2015/11/25 00:48:49 christos Exp $ */
/*
* Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: makefs.c,v 1.50 2013/08/05 14:41:57 reinoud Exp $");
+__RCSID("$NetBSD: makefs.c,v 1.51 2015/11/25 00:48:49 christos Exp $");
#endif /* !__lint */
#include <assert.h>
@@ -87,8 +87,10 @@ static fstype_t fstypes[] = {
u_int debug;
struct timespec start_time;
+struct stat stampst;
static fstype_t *get_fstype(const char *);
+static int get_tstamp(const char *, struct stat *);
static void usage(fstype_t *, fsinfo_t *) __dead;
int
@@ -116,13 +118,18 @@ main(int argc, char *argv[])
fstype->prepare_options(&fsoptions);
specfile = NULL;
- if (gettimeofday(&start, NULL) == -1)
- err(1, "Unable to get system time");
-
+#ifdef CLOCK_REALTIME
+ ch = clock_gettime(CLOCK_REALTIME, &start_time);
+#else
+ ch = gettimeofday(&start, NULL);
start_time.tv_sec = start.tv_sec;
start_time.tv_nsec = start.tv_usec * 1000;
+#endif
+ if (ch == -1)
+ err(1, "Unable to get system time");
- while ((ch = getopt(argc, argv, "B:b:d:f:F:M:m:N:O:o:rs:S:t:xZ")) != -1) {
+
+ while ((ch = getopt(argc, argv, "B:b:d:f:F:M:m:N:O:o:rs:S:t:T:xZ")) != -1) {
switch (ch) {
case 'B':
@@ -240,6 +247,12 @@ main(int argc, char *argv[])
fstype->prepare_options(&fsoptions);
break;
+ case 'T':
+ if (get_tstamp(optarg, &stampst) == -1)
+ errx(1, "Cannot get timestamp from `%s'",
+ optarg);
+ break;
+
case 'x':
fsoptions.onlyspec = 1;
break;
@@ -409,6 +422,36 @@ copy_opts(const option_t *o)
return memcpy(ecalloc(i, sizeof(*o)), o, i * sizeof(*o));
}
+static int
+get_tstamp(const char *b, struct stat *st)
+{
+ time_t when;
+ char *eb;
+ long long l;
+
+ if (stat(b, st) != -1)
+ return 0;
+
+#ifndef HAVE_NBTOOL_CONFIG_H
+ errno = 0;
+ if (parsedate(b, &when, NULL) == -1 && errno != 0)
+#endif
+ {
+ errno = 0;
+ l = strtoll(b, &eb, 0);
+ if (b == eb || *eb || errno)
+ return -1;
+ when = (time_t)l;
+ }
+
+ st->st_ino = 1;
+#if HAVE_STRUCT_STAT_BIRTHTIME
+ st->st_birthtime =
+#endif
+ st->st_mtime = st->st_ctime = st->st_atime = when;
+ return 0;
+}
+
static void
usage(fstype_t *fstype, fsinfo_t *fsoptions)
{
@@ -419,7 +462,8 @@ usage(fstype_t *fstype, fsinfo_t *fsopti
"Usage: %s [-rxZ] [-B endian] [-b free-blocks] [-d debug-mask]\n"
"\t[-F mtree-specfile] [-f free-files] [-M minimum-size] [-m maximum-size]\n"
"\t[-N userdb-dir] [-O offset] [-o fs-options] [-S sector-size]\n"
-"\t[-s image-size] [-t fs-type] image-file directory [extra-directory ...]\n",
+"\t[-s image-size] [-t fs-type] [-T <timestamp/file>]"
+" image-file directory [extra-directory ...]\n",
prog);
if (fstype) {
Index: src/usr.sbin/makefs/makefs.h
diff -u src/usr.sbin/makefs/makefs.h:1.35 src/usr.sbin/makefs/makefs.h:1.36
--- src/usr.sbin/makefs/makefs.h:1.35 Mon Aug 5 10:41:57 2013
+++ src/usr.sbin/makefs/makefs.h Tue Nov 24 19:48:49 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: makefs.h,v 1.35 2013/08/05 14:41:57 reinoud Exp $ */
+/* $NetBSD: makefs.h,v 1.36 2015/11/25 00:48:49 christos Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -199,6 +199,7 @@ DECLARE_FUN(udf);
extern u_int debug;
extern struct timespec start_time;
+extern struct stat stampst;
/*
* If -x is specified, we want to exclude nodes which do not appear
Index: src/usr.sbin/makefs/walk.c
diff -u src/usr.sbin/makefs/walk.c:1.28 src/usr.sbin/makefs/walk.c:1.29
--- src/usr.sbin/makefs/walk.c:1.28 Sun Feb 3 01:16:53 2013
+++ src/usr.sbin/makefs/walk.c Tue Nov 24 19:48:49 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: walk.c,v 1.28 2013/02/03 06:16:53 christos Exp $ */
+/* $NetBSD: walk.c,v 1.29 2015/11/25 00:48:49 christos Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: walk.c,v 1.28 2013/02/03 06:16:53 christos Exp $");
+__RCSID("$NetBSD: walk.c,v 1.29 2015/11/25 00:48:49 christos Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -252,6 +252,20 @@ create_fsnode(const char *root, const ch
cur->type = stbuf->st_mode & S_IFMT;
cur->inode->nlink = 1;
cur->inode->st = *stbuf;
+ if (stampst.st_ino) {
+ cur->inode->st.st_atime = stampst.st_atime;
+ cur->inode->st.st_mtime = stampst.st_mtime;
+ cur->inode->st.st_ctime = stampst.st_ctime;
+#if HAVE_STRUCT_STAT_ST_MTIMENSEC
+ cur->inode->st.st_atimensec = stampst.st_atimensec;
+ cur->inode->st.st_mtimensec = stampst.st_mtimensec;
+ cur->inode->st.st_ctimensec = stampst.st_ctimensec;
+#endif
+#if HAVE_STRUCT_STAT_BIRTHTIME
+ cur->inode->st.st_birthtime = stampst.st_birthtime;
+ cur->inode->st.st_birthtimensec = stampst.st_birthtimensec;
+#endif
+ }
return (cur);
}