shouldn't tar quit at end of archive?

Glenn L. McGrath bug1 at ihug.co.nz
Fri Mar 31 14:33:36 PST 2006


On Fri, 31 Mar 2006 17:15:03 -0500
Paul Fox <pgf at brightstareng.com> wrote:

>  > > second, it causes tar to exit when it detects the first occurence
>  > > of a null header in the archive, rather than waiting for the
>  > > second such header.  not all tar archives are terminated with two
>  > > null headers.
>  > 
>  > 
>  > hmm, i thought it one of tar's "features" was that you can have
>  > random multiples of zero'ed 512 bytes blocks in the middle of archives.
> 
> definitely not.

Fair enough, i guess was my design flaw then.

>  > > one thing i don't understand about the current code is the comment
>  > > regarding emptying the gz or bz2 pipe.  when or why would this be
>  > > an issue?
>  > 
>  > gzip and bzip count the number of bytes that are in the archive, so
>  > when you get to the trailer it will ocompare the number of bytes we
>  > read (or intentionaly skipped over) and compare them to the number
>  > stored in the trailer of the comrpessor.
> 
> but gunzip has already done that by the time the data gets to tar, no?
> 
>  > Also, we need to read all data to compute the checksum, if we dont read
>  > all the zero headers the checksum will fail.
> 
> whose checksum?  again, that's a gzip/gunzip thing, right?  not
> tar?  i'm confused.

The way it works is that busybox forks (in open_transformer.c), it
creates one process which is decompressing and sending data into a pipe
to the second, tar, process which is reading data out of the pipe.

writing into the pipe blocks when the pipe is full, so effectively gzip
is being driven by tar.

If we dont read all the data from the pipe (using tar) we cant be sure
gzip|bzip have written all their data into the pipe.

Currently open_transformer() expects the decomrpession process to exit
normally, if the decompressor couldnt finish writing its data into the
pipe there are 2 problems
1) we would have to kill the process ourselves.
2) the decompressor wouldnt see the checksum or bytecount as tar has
not allowed it finish decompressing.

Glenn


More information about the busybox mailing list