[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-tar] delete/append corruption on busybox tarfiles
From: |
Philip Rowlands |
Subject: |
Re: [Bug-tar] delete/append corruption on busybox tarfiles |
Date: |
Fri, 17 Aug 2007 19:47:39 +0100 (BST) |
On Fri, 17 Aug 2007, Philip Rowlands wrote:
At the end of the file, the only difference is the number of appended
null blocks. The final member requires 352 bytes of null-padding to
complete the 512-byte block, after which busybox appends 1024 bytes (2
blocks) of further nulls, whereas GNU tar appends 2048 bytes (4
blocks) to bring the archive output up to a total size of 512*20*261,
in line with the default --blocking-factor.
So now knowing the cause, I find this caution in the documentation:
"If you use a non-default blocking factor when you create an archive,
you must specify the same blocking factor when you modify that archive."
I don't know if it's appropriate to wave the standard around, given that
GNU tar knows at least six different flavours, but citing "ustar
Interchange format" from the opengroup docs:
http://www.opengroup.org/onlinepubs/009695399/utilities/pax.html#tag_04_100_13_06
"... At the end of the archive file there shall be two 512-octet logical
records filled with binary zeros, interpreted as an end-of-archive
indicator."
"ustar
The tar interchange format; see the EXTENDED DESCRIPTION section.
The default blocksize for this format for character special archive
files shall be 10240."
"The default block value of 10240 bytes for tar was selected because
that is the standard block-size value for BSD tar. ... Also, default
block sizes for any file type other than character special file has been
deleted from this volume of IEEE Std 1003.1-2001 as unimportant and not
likely to affect the structure of the resulting archive."
Also from busybox's archival/tar.c:
572 /* Write two empty blocks to the end of the archive */
573 memset(bb_common_bufsiz1, 0, 2*TAR_BLOCK_SIZE);
574 xwrite(tbInfo.tarFd, bb_common_bufsiz1, 2*TAR_BLOCK_SIZE);
575
576 /* To be pedantically correct, we would check if the tarball
577 * is smaller than 20 tar blocks, and pad it if it was smaller,
578 * but that isn't necessary for GNU tar interoperability, and
579 * so is considered a waste of space */
I defer to the greater knowledge of the maintainers whether this is a
real bug in busybox, a real bug in GNU tar, or an unfortunate silent
corruption because last week I didn't know --blocking-factor existed.
Cheers,
Phil