Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/makefs Provide a -T option to set timestamps to a c...
details: https://anonhg.NetBSD.org/src/rev/f43bd0d061a5
branches: trunk
changeset: 341827:f43bd0d061a5
user: christos <christos%NetBSD.org@localhost>
date: Wed Nov 25 00:48:49 2015 +0000
description:
Provide a -T option to set timestamps to a consistent value for MKREPRO
diffstat:
usr.sbin/makefs/cd9660.c | 6 +++-
usr.sbin/makefs/makefs.8 | 20 ++++++++++++++-
usr.sbin/makefs/makefs.c | 58 ++++++++++++++++++++++++++++++++++++++++++-----
usr.sbin/makefs/makefs.h | 3 +-
usr.sbin/makefs/walk.c | 18 +++++++++++++-
5 files changed, 91 insertions(+), 14 deletions(-)
diffs (243 lines):
diff -r 2aa2235ef9f3 -r f43bd0d061a5 usr.sbin/makefs/cd9660.c
--- a/usr.sbin/makefs/cd9660.c Tue Nov 24 23:33:46 2015 +0000
+++ b/usr.sbin/makefs/cd9660.c Wed Nov 25 00:48:49 2015 +0000
@@ -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 @@
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 */
diff -r 2aa2235ef9f3 -r f43bd0d061a5 usr.sbin/makefs/makefs.8
--- a/usr.sbin/makefs/makefs.8 Tue Nov 24 23:33:46 2015 +0000
+++ b/usr.sbin/makefs/makefs.8 Wed Nov 25 00:48:49 2015 +0000
@@ -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 @@
.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
diff -r 2aa2235ef9f3 -r f43bd0d061a5 usr.sbin/makefs/makefs.c
--- a/usr.sbin/makefs/makefs.c Tue Nov 24 23:33:46 2015 +0000
+++ b/usr.sbin/makefs/makefs.c Wed Nov 25 00:48:49 2015 +0000
@@ -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 @@
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 @@
fstype->prepare_options(&fsoptions);
specfile = NULL;
- if (gettimeofday(&start, NULL) == -1)
+#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");
- start_time.tv_sec = start.tv_sec;
- start_time.tv_nsec = start.tv_usec * 1000;
- 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 @@
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 @@
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: %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) {
diff -r 2aa2235ef9f3 -r f43bd0d061a5 usr.sbin/makefs/makefs.h
--- a/usr.sbin/makefs/makefs.h Tue Nov 24 23:33:46 2015 +0000
+++ b/usr.sbin/makefs/makefs.h Wed Nov 25 00:48:49 2015 +0000
@@ -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 @@
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
diff -r 2aa2235ef9f3 -r f43bd0d061a5 usr.sbin/makefs/walk.c
--- a/usr.sbin/makefs/walk.c Tue Nov 24 23:33:46 2015 +0000
+++ b/usr.sbin/makefs/walk.c Wed Nov 25 00:48:49 2015 +0000
@@ -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 @@
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);
}
Home |
Main Index |
Thread Index |
Old Index