summaryrefslogtreecommitdiffstats
path: root/contrib/libarchive/tar/read.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libarchive/tar/read.c')
-rw-r--r--contrib/libarchive/tar/read.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/contrib/libarchive/tar/read.c b/contrib/libarchive/tar/read.c
index 87ee735..67a6600 100644
--- a/contrib/libarchive/tar/read.c
+++ b/contrib/libarchive/tar/read.c
@@ -125,8 +125,8 @@ progress_func(void *cookie)
if (bsdtar->verbose)
fprintf(stderr, "\n");
if (a != NULL) {
- comp = archive_position_compressed(a);
- uncomp = archive_position_uncompressed(a);
+ comp = archive_filter_bytes(a, -1);
+ uncomp = archive_filter_bytes(a, 0);
if (comp > uncomp)
compression = 0;
else
@@ -155,6 +155,7 @@ read_archive(struct bsdtar *bsdtar, char mode, struct archive *writer)
FILE *out;
struct archive *a;
struct archive_entry *entry;
+ const char *reader_options;
int r;
while (*bsdtar->argv) {
@@ -173,14 +174,35 @@ read_archive(struct bsdtar *bsdtar, char mode, struct archive *writer)
archive_error_string(bsdtar->matching));
a = archive_read_new();
- if (bsdtar->compress_program != NULL)
- archive_read_support_filter_program(a, bsdtar->compress_program);
- else
+ if (cset_read_support_filter_program(bsdtar->cset, a) == 0)
archive_read_support_filter_all(a);
archive_read_support_format_all(a);
+
+ reader_options = getenv(ENV_READER_OPTIONS);
+ if (reader_options != NULL) {
+ char *p;
+ /* Set default read options. */
+ p = malloc(sizeof(IGNORE_WRONG_MODULE_NAME)
+ + strlen(reader_options) + 1);
+ if (p == NULL)
+ lafe_errc(1, errno, "Out of memory");
+ /* Prepend magic code to ignore options for
+ * a format or modules which are not added to
+ * the archive read object. */
+ strncpy(p, IGNORE_WRONG_MODULE_NAME,
+ sizeof(IGNORE_WRONG_MODULE_NAME) -1);
+ strcpy(p + sizeof(IGNORE_WRONG_MODULE_NAME) -1, reader_options);
+ r = archive_read_set_options(a, p);
+ free(p);
+ if (r == ARCHIVE_FATAL)
+ lafe_errc(1, 0, "%s", archive_error_string(a));
+ else
+ archive_clear_error(a);
+ }
if (ARCHIVE_OK != archive_read_set_options(a, bsdtar->option_options))
lafe_errc(1, 0, "%s", archive_error_string(a));
- if (archive_read_open_file(a, bsdtar->filename, bsdtar->bytes_per_block))
+ if (archive_read_open_filename(a, bsdtar->filename,
+ bsdtar->bytes_per_block))
lafe_errc(1, 0, "Error opening archive: %s",
archive_error_string(a));
@@ -338,7 +360,7 @@ read_archive(struct bsdtar *bsdtar, char mode, struct archive *writer)
if (bsdtar->verbose > 2)
fprintf(stdout, "Archive Format: %s, Compression: %s\n",
- archive_format_name(a), archive_compression_name(a));
+ archive_format_name(a), archive_filter_name(a, 0));
archive_read_free(a);
}
OpenPOWER on IntegriCloud