Optionally warn about missing zero blocks at the end of the archive

(In response to savannah bug #63574)

* doc/intern.texi: Document actual tar behaviour in regard to
missing end-of-file marker.
* doc/tar.texi: Rewrite the "warnings" section.  Document
--warning=missing-zero-blocks
* src/common.h (WARN_MISSING_ZERO_BLOCKS): New constant.
(WARN_ALL): Include all warning bits.
* src/list.c (read_and): If EOF is reached without seeing end-of-file
blocks and the "missing-zero-blocks" warning is requested, warn about
the fact.
* src/warning.c: New warnings: "missing-zero-blocks", "verbose".
(warning_option): Change definition to reflect changes in common.h
This commit is contained in:
Sergey Poznyakoff
2022-12-29 17:42:04 +02:00
parent 2cde05fa10
commit a65f01ac35
5 changed files with 247 additions and 101 deletions
+2 -1
View File
@@ -987,12 +987,13 @@ void checkpoint_flush_actions (void);
#define WARN_XATTR_WRITE 0x00200000
#define WARN_RECORD_SIZE 0x00400000
#define WARN_FAILED_READ 0x00800000
#define WARN_MISSING_ZERO_BLOCKS 0x01000000
/* These warnings are enabled by default in verbose mode: */
#define WARN_VERBOSE_WARNINGS (WARN_RENAME_DIRECTORY|WARN_NEW_DIRECTORY|\
WARN_DECOMPRESS_PROGRAM|WARN_EXISTING_FILE|\
WARN_RECORD_SIZE)
#define WARN_ALL (~WARN_VERBOSE_WARNINGS)
#define WARN_ALL 0xffffffff
void set_warning_option (const char *arg);
+7
View File
@@ -256,6 +256,13 @@ read_and (void (*do_something) (void))
continue;
case HEADER_END_OF_FILE:
if (!ignore_zeros_option)
{
char buf[UINTMAX_STRSIZE_BOUND];
WARNOPT (WARN_MISSING_ZERO_BLOCKS,
(0, 0, _("Terminating zero blocks missing at %s"),
STRINGIFY_BIGINT (current_block_ordinal (), buf)));
}
if (block_number_option)
{
char buf[UINTMAX_STRSIZE_BOUND];
+6 -2
View File
@@ -48,6 +48,8 @@ static char const *const warning_args[] = {
"xattr-write",
"record-size",
"failed-read",
"missing-zero-blocks",
"verbose",
NULL
};
@@ -76,12 +78,14 @@ static int warning_types[] = {
WARN_EXISTING_FILE,
WARN_XATTR_WRITE,
WARN_RECORD_SIZE,
WARN_FAILED_READ
WARN_FAILED_READ,
WARN_MISSING_ZERO_BLOCKS,
WARN_VERBOSE_WARNINGS,
};
ARGMATCH_VERIFY (warning_args, warning_types);
int warning_option = WARN_ALL;
int warning_option = WARN_ALL & ~(WARN_VERBOSE_WARNINGS|WARN_MISSING_ZERO_BLOCKS);
void
set_warning_option (const char *arg)