From owner-freebsd-hackers@freebsd.org Mon Jun 13 18:10:02 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BC27AAF2BBD for ; Mon, 13 Jun 2016 18:10:02 +0000 (UTC) (envelope-from steven@pyro.eu.org) Received: from manchester-1.man.uk.cluster.ok24.net (manchester-1.man.uk.cluster.ok24.net [IPv6:2001:41c8:51:40::1]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 505FA20E2; Mon, 13 Jun 2016 18:10:02 +0000 (UTC) (envelope-from steven@pyro.eu.org) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/simple; d=pyro.eu.org; s=06.2016; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=GJ2C/DC5cBQoryZMEYj1TvxHzZQVOpoL3RIKZnjgGA4=; b=gYkNzvBD5uz8An0gxx5mf42yu9ze6UhraAJD9MDB3b8WeRicvFnVPRDf9bBFfgkIkFpn7HEioLFDwCPbQsxoW9BUiv6IL4BBpJjf4KgIHnE88FuKNGgpecViKMfJS59Y/iMeXpPAwGorqj5isL/dqHJRxbAn5FPHf+9ejKNYiv8=; X-Spam-Status: No, score=-1.5 required=2.0 tests=BAYES_00, DKIM_ADSP_DISCARD, RP_MATCHES_RCVD Received: from guisborough-1.rcc.uk.cluster.ok24.net ([217.155.40.118] helo=smtp.ok24.net) by manchester-1.man.uk.cluster.ok24.net with esmtp (Exim 4.80) (envelope-from ) id 1bCWJA-0001Of-Iq; Mon, 13 Jun 2016 19:09:58 +0100 Received: from kfreebsd-amd64.pyro.eu.org (kfreebsd-amd64.pyro.eu.org [IPv6:2a00:14f0:e033:2000::1]) by smtp.ok24.net (Postfix) with ESMTP id 6E4571E2D41; Mon, 13 Jun 2016 19:09:56 +0100 (BST) Received: by kfreebsd-amd64.pyro.eu.org (Postfix, from userid 1000) id 64E001171; Mon, 13 Jun 2016 19:09:56 +0100 (BST) Date: Mon, 13 Jun 2016 19:09:56 +0100 From: Steven Chamberlain 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> References: <20160611154703.GB929@pyro.eu.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="bKyqfOwhbdpXa4YI" Content-Disposition: inline In-Reply-To: <20160611154703.GB929@pyro.eu.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 18:10:02 -0000 --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 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--