How to archive several files with tar?

Geoff Clare gwc at root.co.uk
Fri Jun 14 22:26:42 AEST 1991


In article <2740 at root44.co.uk>, I wrote:
> Although many utilities will fill the disk if made to read their output
> file, this is not true of tar (unless you have a broken tar).  In the tar
> output format the size of each file is contained in a header which
> precedes the file's contents.  Hence the amount of data which tar will
> read from its own output file is limited to its size when tar starts
> reading it.  If the output file is the last input file, it will
> approximately double in size when tar reads it.
> 
> Any decent version of tar will warn you if an input file changes in size.

In <16978 at darkstar.ucsc.edu> jik at cats.ucsc.edu (Jonathan I. Kamens) writes:

>I have *used* a version of tar which does not do proper version checking, and
>which therefore creates a tar archive that fills the disk.  I would not have
>mentioned it if I hadn't used it.

Jonathan has completely missed my main point and picked up on an aside.
It is not "version checking" that stops tar from filling the disk, it is
the fundamental fact that the tar output format contains each archived
file's size before its contents.  Once tar has written out the size of
the file in a header block, it must write exactly that many bytes of data
as the file's contents, even if the file changes size.  Otherwise the
output tar archive will be corrupt and unusable.

My comment that "any decent version of tar will warn you if an input
file changes in size" was an afterthought, intended to reassure people
who deduced (correctly) that, since tar is forced to write the number of
bytes it said it was going to write rather than the number of bytes it
is able to read from the file, if a file changes in size the archived
data may not correspond to either the old or the new version of the
file, but something in between.

>Now, perhaps my recollection is wrong, and I didn't actually ever use such a
>tar.  But unless you're willing to make the categorical claim that such a tar
>does not exist (which you appear to be unwilling to do, since you said "unless
>you have a broken tar" and later "Any decent version of tar"), saying that I
>am "wrong" is unwarranted.

>I was talking about the "worst case," i.e. a poor version of tar.

I claim categorically that such a tar is broken.

-- 
Geoff Clare <gwc at root.co.uk>  (Dumb American mailers: ...!uunet!root.co.uk!gwc)
UniSoft Limited, London, England.   Tel: +44 71 729 3773   Fax: +44 71 729 3273



More information about the Comp.unix.questions mailing list