[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-tar] tar -tf quits before EOF?
From: |
Paul Eggert |
Subject: |
Re: [Bug-tar] tar -tf quits before EOF? |
Date: |
Sat, 07 Aug 2010 23:12:38 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11) Gecko/20100713 Thunderbird/3.0.6 |
On 08/06/10 22:42, Dustin J. Mitchell wrote:
> My understanding is that tar should keep running until it gets EOF on
> its input - that there's no explicit indication within a tarfile that
> would cause tar to exit normally without reading to EOF.
That's incorrect. A tar file ends with two blocks full of zeros; tar
doesn't need to keep reading after that. This is documented, for
example, in the POSIX standard for tar format
<http://www.opengroup.org/onlinepubs/9699919799/utilities/pax.html>.
> A bit of
> experimentation with /dev/zero on my own systems lends credence to
> this understanding, but of course does not prove it:
> (tar -cf - ChangeLog; cat /dev/zero) | tar -tf -
> ChangeLog
> (this hangs forever here, and truss or strace shows tar reading a lot
> of 0's without any _exit(0) action..)
You must be using Solaris /bin/tar for that. I believe it reads past
the two zero blocks. GNU tar doesn't do that. On my Solaris 10 host:
$ cd /etc
$ (/usr/sfw/bin/gtar -cf - passwd; cat /dev/zero) | /usr/sfw/bin/gtar -tf -
passwd
$ /usr/sfw/bin/gtar --version | head -1
tar (GNU tar) 1.23
Notice that /bin/tar, even though it reads past the zero blocks, doesn't
do anything useful after that:
$ cd /etc
$ (/bin/tar -cf - passwd; /bin/tar -cf - motd) | /bin/tar -tf -
passwd
so arguably GNU tar's behavior is more useful. Anyway, Amanda
shouldn't rely on either behavior, obviously, if it wants to be
portable.