[Toybox] [PATCH] tar: fix tvf for sparse extension headers.

Rob Landley rob at landley.net
Fri Sep 13 18:17:34 PDT 2019


On 9/13/19 2:55 PM, enh wrote:
> On Fri, Sep 13, 2019 at 12:08 PM Rob Landley <rob at landley.net> wrote:
>>
>> On 9/12/19 6:20 PM, enh via Toybox wrote:
>>> This doesn't fix xvf, but I've run out of time for now and wanted to
>>> show what I'd found so far.
>>
>> Ah sorry, I just hadn't gotten around to it yet. (New job, terrible cold, and I
>> was working on -newerXY and shell...)
>>
>> I'll take a look,
> 
> i've found the issue in the meantime. literally the last place i
> looked (for obvious reasons when you see the fix).

Things are always in the last place you look because you stop looking when you
find them.

> new patch attached...

Um, 2 issues here: missing truncate we end with a hole (I thought I had a test
for that?) but if we missed that, sure. I prefer not to call a NOP truncate() on
a file we don't need to (that wasn't sparse), but I can add a test.

But "realsize" is blocks *512 except I don't remember anything else being listed
in blocks? The file length isn't guaranteed to be a multiple of 512, and the
sparse segments are in byte lengths. The _last_ one can certainly be something
other than 512...)

$ dd if=/dev/zero of=blah bs=1 count=1 seek=$((1<<20))
$ tar cf blah.tar --sparse blah
$ tar tvf blah.tar
-rw-r--r-- landley/landley 1048577 2019-09-13 18:45 blah
$ ls -l blah.tar
-rw-r--r-- 1 landley landley 10240 Sep 13 20:10 blah.tar

Whereas the new one is doing:

$ ./tar tvf blah.tar
-rw-r--r-- landley/landley   1048576  2019-09-13 18:45 blah

I think what we need to do is add up the segments. (Which is what I thought it
_was_ doing, but my head cold has turned into dizzy+headache and I has a tired.)

I can fix this when I feel better if you don't get to it.

>> By the way, do you have a test tarball with xattrs in it? I want to add xattr
>> support, but devuan seem to doesn't use xattrs anywhere I can spot. (I didn't
>> install selinux support.)
> 
> no, but i'll make one. (i need to write a test for this tar fix too.)

Yay. Thank you.

>> Rob

Rob



More information about the Toybox mailing list