cvs commit: src/lib/libarchive Makefile archive_write_set_format_pax.c archive_write_set_format_ustar.c src/lib/libarchive/test Makefile test_tar_filenames.c

Tim Kientzle kientzle at
Sat Apr 14 18:51:26 UTC 2007

>>  Conventionally, tar archives have always included a trailing '/'
>>  for directories.  bsdtar used to add this, but that recently got
>>  lost somehow.  So now I'm adding it back in libarchive.
> Is that really a good idea?  Shouldn't this just be fixed in bsdtar's
> display code?

It's not a display problem, it's an archive creation problem.
Very old tar implementations didn't recognize dirs stored in
archives, but could actually extract them correctly as long
as the name ended in '/'.

>>  The only odd part of doing this in libarchive:  Adding a directory to
>>  a tar archive and then reading it back again can yield a different name.
> I can imagine how this might trip up other (hypothetical) libarchive
> consumers...

You may be right.  But not all archive formats
necessarily require trailing '/' on directories and
I've (so far) done pretty well at keeping format-specific
knowledge out of bsdtar.

I could force trailing '/' when creating archives from
bsdtar or ensure the trailing '/' in libarchive for
those formats that require it.  Neither solution is

I think I'll stick with it in libarchive, though
I'll change it so that libarchive actually edits the
name in the entry; that way, the client will see the
changed name immediately after writing the header.
(There's precedent for this; some libarchive formats
edit the file size field to indicate how much data
they expect; this allows clients to function
efficiently with formats that do or don't store
duplicate bodies for hard links.)

Thanks for the comments.


More information about the cvs-src mailing list