[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-tar] mtime in x header
From: |
Michael D. Adams |
Subject: |
[Bug-tar] mtime in x header |
Date: |
Wed, 30 Sep 2009 02:27:52 -0400 |
Running tar over the exact same file at two different time isn't
producing the exact same tar file.
I've tracked this down to the mtime field in the header that has
typeflag=x. Specifically the mtime field is storing modified time of
the *tar* file and not the mtime of the files inside the tar. Below
is an example showing this happening.
Questions:
(1) Is this behavior in conformance with the POSIX-2001 spec? I
haven't seen anywhere that says what the mtime field should be when
there is an mtime extended header, but other tar/pax implementations
just fill it with zeros. (If the spec doesn't specify either way then
maybe it isn't technically a bug.)
(2) Is there a way to work around this? It is causing havoc with my
backups. I had been using "tar" as a cheap way to serialize all the
info about a file (e.g. ctime, owner, acls, etc.). However if "tar"
embeds the time that the tar command *ran* in the tar file, then it
will generate all sorts of spurious differences.
For example:
$ tar --version # I've also tested this with 1.22 with the same results
tar (GNU tar) 1.15.1
$
$ echo test >test.txt
$ sleep 5
$
$ tar --pax-option=exthdr.name=%d/PaxHeaders/%f -cf test1.tar test.txt
$ sleep 5
$
$ tar --pax-option=exthdr.name=%d/PaxHeaders/%f -cf test2.tar test.txt
$
$ printf '%o\n' `stat --format=%Y test.txt` # Print modification time
in octal (the format "tar" uses)
11260565716
$ printf '%o\n' `stat --format=%Y test1.tar` # Print modification time
in octal (the format "tar" uses)
11260565726
$
$ printf '%o\n' `stat --format=%Y test2.tar` # Print modification time
in octal (the format "tar" uses)
11260565740
$
$ diff test1.tar test2.tar
Binary files test1.tar and test2.tar differ
$ hexdump -C test1.tar >test1.tar.hex
$ hexdump -C test2.tar >test2.tar.hex
$ diff -u test1.tar.hex test2.tar.hex
--- test1.tar.hex 2009-09-30 01:25:57.000000000 -0400
+++ test2.tar.hex 2009-09-30 01:26:01.000000000 -0400
@@ -5,7 +5,7 @@
00000060 00 00 00 00 30 30 30 30 36 34 34 00 30 30 32 33 |....0000644.0023|
00000070 35 31 32 00 30 30 30 37 36 34 32 00 30 30 30 30 |512.0007642.0000|
00000080 30 30 30 30 30 37 34 00 31 31 32 36 30 35 36 35 |0000074.11260565|
-00000090 37 32 36 00 30 31 33 33 33 30 00 20 78 00 00 00 |726.013330. x...|
+00000090 37 34 30 00 30 31 33 33 32 34 00 20 78 00 00 00 |740.013324. x...|
000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000100 00 75 73 74 61 72 00 30 30 00 00 00 00 00 00 00 |.ustar.00.......|
- [Bug-tar] mtime in x header,
Michael D. Adams <=