From owner-freebsd-hackers@FreeBSD.ORG Sun Oct 10 18:38:40 2010 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D31921065670 for ; Sun, 10 Oct 2010 18:38:40 +0000 (UTC) (envelope-from erik@cederstrand.dk) Received: from csmtp1.one.com (csmtp1.one.com [195.47.247.21]) by mx1.freebsd.org (Postfix) with ESMTP id 575108FC14 for ; Sun, 10 Oct 2010 18:38:40 +0000 (UTC) Received: from [192.168.10.202] (0x573b9942.cpe.ge-1-2-0-1101.ronqu1.customer.tele.dk [87.59.153.66]) by csmtp1.one.com (Postfix) with ESMTP id B5CB91BC00EE5 for ; Sun, 10 Oct 2010 18:38:38 +0000 (UTC) From: Erik Cederstrand Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: multipart/signed; boundary=Apple-Mail-2077--808926872; protocol="application/pkcs7-signature"; micalg=sha1 Date: Sun, 10 Oct 2010 20:38:38 +0200 In-Reply-To: References: <52C32EA5-A380-4237-A27C-9E2DF2D4E022@cederstrand.dk> <20101005135906.GA3430@owl.midgard.homeip.net> <140AD250-ECD1-4BCF-806B-F5901B3BFD87@kientzle.com> Message-Id: <72C0D832-283B-4D81-89E8-7614B49DB8E7@cederstrand.dk> X-Mailer: Apple Mail (2.1081) X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: FreeBSD Hackers Subject: Re: Timestamps in static libraries X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Oct 2010 18:38:40 -0000 --Apple-Mail-2077--808926872 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Den 06/10/2010 kl. 14.35 skrev Erik Cederstrand: > Den 06/10/2010 kl. 13.07 skrev Erik Cederstrand: >=20 >> Is something like the following acceptable? Without risking changes = to buildworld/distribution just now, this would allow me to dump = contents of an archive and re-insert them with '0' for mtime, uid and = gid before checking checksums, without affecting normal ar behaviour. >=20 > Great, I didn't even see the discussion on this list recently: = http://lists.freebsd.org/pipermail/freebsd-hackers/2010-September/033005.h= tml >=20 > Anyway, I added file mode to the patch. Apparently recent binutils = also added this feature. I haven't looked at their patch, but chance has = it I used the same option '-D'. >=20 > I'm sure the file mode I'm setting in line 175 of write.c is wrong = (obj->md =3D 100644), but I couldn't quite figure out how to set the = value to rw-r--r--. Here's the new patch: >=20 > Index: ar.1 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- ar.1 (revision 213478) > +++ ar.1 (working copy) > @@ -62,6 +62,7 @@ > .Op Fl a Ar position-after > .Op Fl b Ar position-before > .Op Fl c > +.Op Fl D > .Op Fl i Ar position-before > .Op Fl j > .Op Fl s > @@ -179,6 +180,14 @@ > .Ar archive . > The archive's symbol table, if present, is updated to reflect > the new contents of the archive. > +.It Fl D > +When used in combination with the=20 > +.Fl r > +option, insterts 0's instead of the real mtime, uid and gid values=20 > +and 644 instead of file mode from the members named by arguments > +.Ar files ... . > +This ensures that checksums on the resulting archives are = reproducible > +when member contents are identical. > .It Fl f > Synonymous with option > .Fl T . > Index: ar.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- ar.c (revision 213478) > +++ ar.c (working copy) > @@ -154,7 +154,7 @@ > } > } >=20 > - while ((opt =3D getopt_long(argc, argv, = "abCcdfijlMmopqrSsTtuVvxz", > + while ((opt =3D getopt_long(argc, argv, = "abCcdDfijlMmopqrSsTtuVvxz", > longopts, NULL)) !=3D -1) { > switch(opt) { > case 'a': > @@ -173,6 +173,9 @@ > case 'd': > set_mode(bsdar, opt); > break; > + case 'D': > + bsdar->options |=3D AR_D; > + break; > case 'f': > case 'T': > bsdar->options |=3D AR_TR; > @@ -357,8 +360,8 @@ > (void)fprintf(stderr, "\tar -m [-Tabijsvz] position archive file = ...\n"); > (void)fprintf(stderr, "\tar -p [-Tv] archive [file ...]\n"); > (void)fprintf(stderr, "\tar -q [-Tcjsvz] archive file ...\n"); > - (void)fprintf(stderr, "\tar -r [-Tcjsuvz] archive file ...\n"); > - (void)fprintf(stderr, "\tar -r [-Tabcijsuvz] position archive = file ...\n"); > + (void)fprintf(stderr, "\tar -r [-TcDjsuvz] archive file ...\n"); > + (void)fprintf(stderr, "\tar -r [-TabcDijsuvz] position archive = file ...\n"); > (void)fprintf(stderr, "\tar -s [-jz] archive\n"); > (void)fprintf(stderr, "\tar -t [-Tv] archive [file ...]\n"); > (void)fprintf(stderr, "\tar -x [-CTouv] archive [file ...]\n"); > Index: ar.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- ar.h (revision 213478) > +++ ar.h (working copy) > @@ -43,6 +43,7 @@ > #define AR_U 0x0200 /* only extract or update newer = members.*/ > #define AR_V 0x0400 /* verbose mode */ > #define AR_Z 0x0800 /* gzip compression */ > +#define AR_D 0x1000 /* insert members with dummy mode, = mtime, uid and gid */ >=20 > #define DEF_BLKSZ 10240 /* default block size */ >=20 > Index: write.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- write.c (revision 213478) > +++ write.c (working copy) > @@ -163,11 +163,23 @@ > if (mtime !=3D 0 && bsdar->options & AR_U && sb.st_mtime <=3D = mtime) > goto giveup; >=20 > - obj->uid =3D sb.st_uid; > - obj->gid =3D sb.st_gid; > - obj->md =3D sb.st_mode; > + /* > + * When option '-D' is specified, mtime and UID / GID from the = file > + * will be replaced with 0, and file mode with 644. This ensures = that=20 > + * checksums will match for two archives containing the exact = same files. > + */ > + if (bsdar->options & AR_D) { > + obj->uid =3D 0; > + obj->gid =3D 0; > + obj->mtime =3D 0; > + obj->md =3D 100644; > + } else { > + obj->uid =3D sb.st_uid; > + obj->gid =3D sb.st_gid; > + obj->mtime =3D sb.st_mtime; > + obj->md =3D sb.st_mode; > + } > obj->size =3D sb.st_size; > - obj->mtime =3D sb.st_mtime; > obj->dev =3D sb.st_dev; > obj->ino =3D sb.st_ino; >=20 > @@ -621,7 +633,10 @@ > bsdar->options & AR_S) { > entry =3D archive_entry_new(); > archive_entry_copy_pathname(entry, "/"); > - archive_entry_set_mtime(entry, time(NULL), 0); > + if (bsdar->options & AR_O) > + archive_entry_set_mtime(entry, 0, 0); > + else > + archive_entry_set_mtime(entry, time(NULL), 0); > archive_entry_set_size(entry, (bsdar->s_cnt + 1) * > sizeof(uint32_t) + bsdar->s_sn_sz); > AC(archive_write_header(a, entry)); For the record, a correct version of this patch was applied in r213643. Erik= --Apple-Mail-2077--808926872--