I'm afraid I haven't studied the format very thoroughly, but couldn't it
do something like this:
Write a header block and leave spaces for file size and checksum. Leave
these as some constant value that indicates that they are placeholders.
Then start writing the data, keeping track of the size of the file as we
go. Once we've written all of it, seek back to the header block and fill
in the size, and finally compute the checksum.
If we have a stdin file at the time that we create the tar, make sure it
goes last. If we are appending, we know it goes last. That way, if the
tar crashes or is interrupted, we only lose the last file, and don't lose
our place so we can't find subsequent files.
Future 'append' operations can detect that we've written the "I don't know
yet" value in the header, and can either write over the last file as
though it never happened, or can fix the size and checksum as though the
data we've written is the entirety of the file.
Listing the archive, we can either ignore files we never finished writing,
or we can heal it in the same way that append does.
Does that not work? Is the format more complicated than I thought? Are
we avoiding seeks?
Okay, thanks.
--Ryan
On Tue, 14 Oct 2008, Sergey Poznyakoff wrote:
Ryan Jud Hughes <[EMAIL PROTECTED]> ha escrit:
I would rather be able to add it directly to the tar archive from the
stream:
% create_data | tar -rf existing_tar_archive.tar -
There is a serious obstacle to this: tar needs to know beforehand the
size of the file it is archiving.
If not, would this be a friendly addition to tar?
It would, certainly. But I don't think it is possible to implement due
to above restriction.
Regards,
Sergey