Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Jun 2016 19:09:56 +0100
From:      Steven Chamberlain <steven@pyro.eu.org>
To:        freebsd-hackers@freebsd.org
Cc:        bapt@freebsd.org, rb-general@lists.reproducible-builds.org
Subject:   Re: makefs: -T maximum-time argument
Message-ID:  <20160613180956.GB75666@pyro.eu.org>
In-Reply-To: <20160611154703.GB929@pyro.eu.org>
References:  <20160611154703.GB929@pyro.eu.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--bKyqfOwhbdpXa4YI
Content-Type: multipart/mixed; boundary="DKU6Jbt7q3WqK7+M"
Content-Disposition: inline


--DKU6Jbt7q3WqK7+M
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Steven Chamberlain wrote:
> I've attached it, rebased for FreeBSD but I'm afraid I've not tested it
> there at all.  Hopefully someone can check it and consider merging.

Oops... remembering to attach this time.

Regards,
--=20
Steven Chamberlain
steven@pyro.eu.org

--DKU6Jbt7q3WqK7+M
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="makefs.patch"
Content-Transfer-Encoding: quoted-printable

=46rom: Steven Chamberlain <steven@pyro.eu.org>
Subject: Implement -T maximum-time argument
Date: Tue, 17 Nov 2015 01:19:39 +0000

diff --git a/ffs.c b/ffs.c
index 70808f1..8a9f47d 100644
--- a/ffs.c
+++ b/ffs.c
@@ -661,6 +661,27 @@ ffs_build_dinode1(struct ufs1_dinode *dinp, dirbuf_t *=
dbufp, fsnode *cur,
 	dinp->di_mtimensec =3D cur->inode->st.st_mtimensec;
 	dinp->di_ctimensec =3D cur->inode->st.st_ctimensec;
 #endif
+	/* if maxtime was given, clamp all timestamps to this */
+	if (fsopts->maxtime >=3D 0) {
+		if (dinp->di_atime >=3D fsopts->maxtime) {
+			dinp->di_atime =3D fsopts->maxtime;
+#if HAVE_STRUCT_STAT_ST_MTIMENSEC
+			dinp->di_atimensec =3D 0;
+#endif
+		}
+		if (dinp->di_mtime >=3D fsopts->maxtime) {
+			dinp->di_mtime =3D fsopts->maxtime;
+#if HAVE_STRUCT_STAT_ST_MTIMENSEC
+			dinp->di_mtimensec =3D 0;
+#endif
+		}
+		if (dinp->di_ctime >=3D fsopts->maxtime) {
+			dinp->di_ctime =3D fsopts->maxtime;
+#if HAVE_STRUCT_STAT_ST_MTIMENSEC
+			dinp->di_ctimensec =3D 0;
+#endif
+		}
+	}
 #if HAVE_STRUCT_STAT_ST_FLAGS
 	dinp->di_flags =3D cur->inode->st.st_flags;
 #endif
diff --git a/makefs.8 b/makefs.8
index 968ddaa..a1ed7a2 100644
--- a/makefs.8
+++ b/makefs.8
@@ -57,6 +57,7 @@
 .Op Fl S Ar sector-size
 .Op Fl s Ar image-size
 .Op Fl t Ar fs-type
+.Op Fl T Ar maximum-time
 .Ar image-file
 .Ar directory | manifest
 .Op Ar extra-directory ...
@@ -223,6 +224,10 @@ BSD fast file system (default).
 .It Sy cd9660
 ISO 9660 file system.
 .El
+.It Fl T Ar maximum-time
+Clamp superblock and file timestamps to
+.Ar maximum-time
+seconds since the Epoch.
 .It Fl x
 Exclude file system nodes not explicitly listed in the specfile.
 .It Fl Z
diff --git a/makefs.c b/makefs.c
index 8958da6..1cac718 100644
--- a/makefs.c
+++ b/makefs.c
@@ -105,6 +105,7 @@ main(int argc, char *argv[])
 	(void)memset(&fsoptions, 0, sizeof(fsoptions));
 	fsoptions.fd =3D -1;
 	fsoptions.sectorsize =3D -1;
+	fsoptions.maxtime =3D -1;
=20
 	if (fstype->prepare_options)
 		fstype->prepare_options(&fsoptions);
@@ -116,7 +117,7 @@ main(int argc, char *argv[])
 	start_time.tv_sec =3D start.tv_sec;
 	start_time.tv_nsec =3D start.tv_usec * 1000;
=20
-	while ((ch =3D getopt(argc, argv, "B:b:Dd:f:F:M:m:N:o:pR:s:S:t:xZ")) !=3D=
 -1) {
+	while ((ch =3D getopt(argc, argv, "B:b:Dd:f:F:M:m:N:o:pR:s:S:t:T:xZ")) !=
=3D -1) {
 		switch (ch) {
=20
 		case 'B':
@@ -239,6 +240,14 @@ main(int argc, char *argv[])
 			fstype->prepare_options(&fsoptions);
 			break;
=20
+		case 'T':
+			fsoptions.maxtime =3D strtoll(optarg, NULL, 10);
+			if (start_time.tv_sec >=3D fsoptions.maxtime) {
+				start_time.tv_sec =3D fsoptions.maxtime;
+				start_time.tv_nsec =3D 0;
+			}
+			break;
+
 		case 'x':
 			fsoptions.onlyspec =3D 1;
 			break;
@@ -370,7 +379,8 @@ usage(void)
 "usage: %s [-t fs-type] [-o fs-options] [-d debug-mask] [-B endian]\n"
 "\t[-S sector-size] [-M minimum-size] [-m maximum-size] [-R roundup-size]\=
n"
 "\t[-s image-size] [-b free-blocks] [-f free-files] [-F mtree-specfile]\n"
-"\t[-xZ] [-N userdb-dir] image-file directory | manifest [extra-directory =
=2E..]\n",
+"\t[-xZ] [-N userdb-dir] [-T maximum-time] image-file directory | manifest=
\n"
+"\t[extra-directory ...]\n",
 	    prog);
 	exit(1);
 }
diff --git a/makefs.h b/makefs.h
index dbf4602..2ba8bca 100644
--- a/makefs.h
+++ b/makefs.h
@@ -131,6 +131,7 @@ typedef struct {
 	int	sectorsize;	/* sector size */
 	int	sparse;		/* sparse image, don't fill it with zeros */
 	off_t	roundup;	/* round image size up to this value */
+	time_t	maxtime;	/* maximum allowed timestamp value */
=20
 	void	*fs_specific;	/* File system specific additions. */
 } fsinfo_t;

--DKU6Jbt7q3WqK7+M--

--bKyqfOwhbdpXa4YI
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQEcBAEBCAAGBQJXXvbzAAoJELrpzbaMAu5TtisH/07Lae8jFPv49UNSgm2W2Yhx
9jlG1eVjd+dIJ0vvvudKT2zZCg2JS6yuklveIUIbtdrfWgJlPQ1O0qu1/7tYv3T9
q8X3ZLs1da7bintZxptb236890NnShuwVZ0vVYaSmjS9S8pDZmj0lq1vyYN0+Wgv
WHS5JAOykCNv3GKFnae84a2GvO6HJje1JFD7PXYjlEBuLIxQ18X2MitfOXX8OtTj
inkGDzYuhYL6F16/Vf5FJ/AkTemnkT6naRe7khD9LGz/M9+F87QBE+wrkVOkSMdX
YaC6eHHKCLGmdv5BLJhVvGt6amq48b713roUK7mt6GqNMQ6A3HKjgJ+1L2dV8Jk=
=v2mE
-----END PGP SIGNATURE-----

--bKyqfOwhbdpXa4YI--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160613180956.GB75666>