Blame tar/read.c

Packit Service 1d0348
/*-
Packit Service 1d0348
 * Copyright (c) 2003-2007 Tim Kientzle
Packit Service 1d0348
 * All rights reserved.
Packit Service 1d0348
 *
Packit Service 1d0348
 * Redistribution and use in source and binary forms, with or without
Packit Service 1d0348
 * modification, are permitted provided that the following conditions
Packit Service 1d0348
 * are met:
Packit Service 1d0348
 * 1. Redistributions of source code must retain the above copyright
Packit Service 1d0348
 *    notice, this list of conditions and the following disclaimer.
Packit Service 1d0348
 * 2. Redistributions in binary form must reproduce the above copyright
Packit Service 1d0348
 *    notice, this list of conditions and the following disclaimer in the
Packit Service 1d0348
 *    documentation and/or other materials provided with the distribution.
Packit Service 1d0348
 *
Packit Service 1d0348
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
Packit Service 1d0348
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
Packit Service 1d0348
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
Packit Service 1d0348
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
Packit Service 1d0348
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
Packit Service 1d0348
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit Service 1d0348
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit Service 1d0348
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit Service 1d0348
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
Packit Service 1d0348
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit Service 1d0348
 */
Packit Service 1d0348
Packit Service 1d0348
#include "bsdtar_platform.h"
Packit Service 1d0348
__FBSDID("$FreeBSD: src/usr.bin/tar/read.c,v 1.40 2008/08/21 06:41:14 kientzle Exp $");
Packit Service 1d0348
Packit Service 1d0348
#ifdef HAVE_SYS_TYPES_H
Packit Service 1d0348
#include <sys/types.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
#ifdef HAVE_SYS_PARAM_H
Packit Service 1d0348
#include <sys/param.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
#ifdef HAVE_SYS_STAT_H
Packit Service 1d0348
#include <sys/stat.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
#ifdef HAVE_ERRNO_H
Packit Service 1d0348
#include <errno.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
#ifdef HAVE_FCNTL_H
Packit Service 1d0348
#include <fcntl.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
#ifdef HAVE_GRP_H
Packit Service 1d0348
#include <grp.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
#ifdef HAVE_IO_H
Packit Service 1d0348
#include <io.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
#ifdef HAVE_LIMITS_H
Packit Service 1d0348
#include <limits.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
#ifdef HAVE_PWD_H
Packit Service 1d0348
#include <pwd.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
#ifdef HAVE_STDINT_H
Packit Service 1d0348
#include <stdint.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
#include <stdio.h>
Packit Service 1d0348
#ifdef HAVE_STDLIB_H
Packit Service 1d0348
#include <stdlib.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
#ifdef HAVE_STRING_H
Packit Service 1d0348
#include <string.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
#ifdef HAVE_TIME_H
Packit Service 1d0348
#include <time.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
#ifdef HAVE_UNISTD_H
Packit Service 1d0348
#include <unistd.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
#include "bsdtar.h"
Packit Service 1d0348
#include "err.h"
Packit Service 1d0348
Packit Service 1d0348
struct progress_data {
Packit Service 1d0348
	struct bsdtar *bsdtar;
Packit Service 1d0348
	struct archive *archive;
Packit Service 1d0348
	struct archive_entry *entry;
Packit Service 1d0348
};
Packit Service 1d0348
Packit Service 1d0348
static void	read_archive(struct bsdtar *bsdtar, char mode, struct archive *);
Packit Service 1d0348
static int unmatched_inclusions_warn(struct archive *matching, const char *);
Packit Service 1d0348
Packit Service 1d0348
Packit Service 1d0348
void
Packit Service 1d0348
tar_mode_t(struct bsdtar *bsdtar)
Packit Service 1d0348
{
Packit Service 1d0348
	read_archive(bsdtar, 't', NULL);
Packit Service 1d0348
	if (unmatched_inclusions_warn(bsdtar->matching,
Packit Service 1d0348
	    "Not found in archive") != 0)
Packit Service 1d0348
		bsdtar->return_value = 1;
Packit Service 1d0348
}
Packit Service 1d0348
Packit Service 1d0348
void
Packit Service 1d0348
tar_mode_x(struct bsdtar *bsdtar)
Packit Service 1d0348
{
Packit Service 1d0348
	struct archive *writer;
Packit Service 1d0348
Packit Service 1d0348
	writer = archive_write_disk_new();
Packit Service 1d0348
	if (writer == NULL)
Packit Service 1d0348
		lafe_errc(1, ENOMEM, "Cannot allocate disk writer object");
Packit Service 1d0348
	if ((bsdtar->flags & OPTFLAG_NUMERIC_OWNER) == 0)
Packit Service 1d0348
		archive_write_disk_set_standard_lookup(writer);
Packit Service 1d0348
	archive_write_disk_set_options(writer, bsdtar->extract_flags);
Packit Service 1d0348
Packit Service 1d0348
	read_archive(bsdtar, 'x', writer);
Packit Service 1d0348
Packit Service 1d0348
	if (unmatched_inclusions_warn(bsdtar->matching,
Packit Service 1d0348
	    "Not found in archive") != 0)
Packit Service 1d0348
		bsdtar->return_value = 1;
Packit Service 1d0348
	archive_write_free(writer);
Packit Service 1d0348
}
Packit Service 1d0348
Packit Service 1d0348
static void
Packit Service 1d0348
progress_func(void *cookie)
Packit Service 1d0348
{
Packit Service 1d0348
	struct progress_data *progress_data = (struct progress_data *)cookie;
Packit Service 1d0348
	struct bsdtar *bsdtar = progress_data->bsdtar;
Packit Service 1d0348
	struct archive *a = progress_data->archive;
Packit Service 1d0348
	struct archive_entry *entry = progress_data->entry;
Packit Service 1d0348
	uint64_t comp, uncomp;
Packit Service 1d0348
	int compression;
Packit Service 1d0348
Packit Service 1d0348
	if (!need_report())
Packit Service 1d0348
		return;
Packit Service 1d0348
Packit Service 1d0348
	if (bsdtar->verbose)
Packit Service 1d0348
		fprintf(stderr, "\n");
Packit Service 1d0348
	if (a != NULL) {
Packit Service 1d0348
		comp = archive_filter_bytes(a, -1);
Packit Service 1d0348
		uncomp = archive_filter_bytes(a, 0);
Packit Service 1d0348
		if (comp > uncomp)
Packit Service 1d0348
			compression = 0;
Packit Service 1d0348
		else
Packit Service 1d0348
			compression = (int)((uncomp - comp) * 100 / uncomp);
Packit Service 1d0348
		fprintf(stderr,
Packit Service 1d0348
		    "In: %s bytes, compression %d%%;",
Packit Service 1d0348
		    tar_i64toa(comp), compression);
Packit Service 1d0348
		fprintf(stderr, "  Out: %d files, %s bytes\n",
Packit Service 1d0348
		    archive_file_count(a), tar_i64toa(uncomp));
Packit Service 1d0348
	}
Packit Service 1d0348
	if (entry != NULL) {
Packit Service 1d0348
		safe_fprintf(stderr, "Current: %s",
Packit Service 1d0348
		    archive_entry_pathname(entry));
Packit Service 1d0348
		fprintf(stderr, " (%s bytes)\n",
Packit Service 1d0348
		    tar_i64toa(archive_entry_size(entry)));
Packit Service 1d0348
	}
Packit Service 1d0348
}
Packit Service 1d0348
Packit Service 1d0348
/*
Packit Service 1d0348
 * Handle 'x' and 't' modes.
Packit Service 1d0348
 */
Packit Service 1d0348
static void
Packit Service 1d0348
read_archive(struct bsdtar *bsdtar, char mode, struct archive *writer)
Packit Service 1d0348
{
Packit Service 1d0348
	struct progress_data	progress_data;
Packit Service 1d0348
	FILE			 *out;
Packit Service 1d0348
	struct archive		 *a;
Packit Service 1d0348
	struct archive_entry	 *entry;
Packit Service 1d0348
	const char		 *reader_options;
Packit Service 1d0348
	int			  r;
Packit Service 1d0348
Packit Service 1d0348
	while (*bsdtar->argv) {
Packit Service 1d0348
		if (archive_match_include_pattern(bsdtar->matching,
Packit Service 1d0348
		    *bsdtar->argv) != ARCHIVE_OK)
Packit Service 1d0348
			lafe_errc(1, 0, "Error inclusion pattern: %s",
Packit Service 1d0348
			    archive_error_string(bsdtar->matching));
Packit Service 1d0348
		bsdtar->argv++;
Packit Service 1d0348
	}
Packit Service 1d0348
Packit Service 1d0348
	if (bsdtar->names_from_file != NULL)
Packit Service 1d0348
		if (archive_match_include_pattern_from_file(
Packit Service 1d0348
		    bsdtar->matching, bsdtar->names_from_file,
Packit Service 1d0348
		    (bsdtar->flags & OPTFLAG_NULL)) != ARCHIVE_OK)
Packit Service 1d0348
			lafe_errc(1, 0, "Error inclusion pattern: %s",
Packit Service 1d0348
			    archive_error_string(bsdtar->matching));
Packit Service 1d0348
Packit Service 1d0348
	a = archive_read_new();
Packit Service 1d0348
	if (cset_read_support_filter_program(bsdtar->cset, a) == 0)
Packit Service 1d0348
		archive_read_support_filter_all(a);
Packit Service 1d0348
	archive_read_support_format_all(a);
Packit Service 1d0348
Packit Service 1d0348
	reader_options = getenv(ENV_READER_OPTIONS);
Packit Service 1d0348
	if (reader_options != NULL) {
Packit Service 1d0348
		size_t module_len = sizeof(IGNORE_WRONG_MODULE_NAME) - 1;
Packit Service 1d0348
		size_t opt_len = strlen(reader_options) + 1;
Packit Service 1d0348
		char *p;
Packit Service 1d0348
		/* Set default read options. */
Packit Service 1d0348
		if ((p = malloc(module_len + opt_len)) == NULL)
Packit Service 1d0348
			lafe_errc(1, errno, "Out of memory");
Packit Service 1d0348
		/* Prepend magic code to ignore options for
Packit Service 1d0348
		 * a format or  modules which are not added to
Packit Service 1d0348
		 *  the archive read object. */
Packit Service 1d0348
		memcpy(p, IGNORE_WRONG_MODULE_NAME, module_len);
Packit Service 1d0348
		memcpy(p + module_len, reader_options, opt_len);
Packit Service 1d0348
		r = archive_read_set_options(a, p);
Packit Service 1d0348
		free(p);
Packit Service 1d0348
		if (r == ARCHIVE_FATAL)
Packit Service 1d0348
			lafe_errc(1, 0, "%s", archive_error_string(a));
Packit Service 1d0348
		else
Packit Service 1d0348
			archive_clear_error(a);
Packit Service 1d0348
	}
Packit Service 1d0348
	if (ARCHIVE_OK != archive_read_set_options(a, bsdtar->option_options))
Packit Service 1d0348
		lafe_errc(1, 0, "%s", archive_error_string(a));
Packit Service 1d0348
	if (bsdtar->flags & OPTFLAG_IGNORE_ZEROS)
Packit Service 1d0348
		if (archive_read_set_options(a,
Packit Service 1d0348
		    "read_concatenated_archives") != ARCHIVE_OK)
Packit Service 1d0348
			lafe_errc(1, 0, "%s", archive_error_string(a));
Packit Service 1d0348
	if (bsdtar->passphrase != NULL)
Packit Service 1d0348
		r = archive_read_add_passphrase(a, bsdtar->passphrase);
Packit Service 1d0348
	else
Packit Service 1d0348
		r = archive_read_set_passphrase_callback(a, bsdtar,
Packit Service 1d0348
			&passphrase_callback);
Packit Service 1d0348
	if (r != ARCHIVE_OK)
Packit Service 1d0348
		lafe_errc(1, 0, "%s", archive_error_string(a));
Packit Service 1d0348
	if (archive_read_open_filename(a, bsdtar->filename,
Packit Service 1d0348
					bsdtar->bytes_per_block))
Packit Service 1d0348
		lafe_errc(1, 0, "Error opening archive: %s",
Packit Service 1d0348
		    archive_error_string(a));
Packit Service 1d0348
Packit Service 1d0348
	do_chdir(bsdtar);
Packit Service 1d0348
Packit Service 1d0348
	if (mode == 'x') {
Packit Service 1d0348
		/* Set an extract callback so that we can handle SIGINFO. */
Packit Service 1d0348
		progress_data.bsdtar = bsdtar;
Packit Service 1d0348
		progress_data.archive = a;
Packit Service 1d0348
		archive_read_extract_set_progress_callback(a, progress_func,
Packit Service 1d0348
		    &progress_data);
Packit Service 1d0348
	}
Packit Service 1d0348
Packit Service 1d0348
	if (mode == 'x' && (bsdtar->flags & OPTFLAG_CHROOT)) {
Packit Service 1d0348
#if HAVE_CHROOT
Packit Service 1d0348
		if (chroot(".") != 0)
Packit Service 1d0348
			lafe_errc(1, errno, "Can't chroot to \".\"");
Packit Service 1d0348
#else
Packit Service 1d0348
		lafe_errc(1, 0,
Packit Service 1d0348
		    "chroot isn't supported on this platform");
Packit Service 1d0348
#endif
Packit Service 1d0348
	}
Packit Service 1d0348
Packit Service 1d0348
#if defined(_WIN32) && !defined(__CYGWIN__)
Packit Service 1d0348
	if (mode == 'x' && (bsdtar->flags & OPTFLAG_STDOUT)) {
Packit Service 1d0348
		_setmode(1, _O_BINARY);
Packit Service 1d0348
	}
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
	for (;;) {
Packit Service 1d0348
		/* Support --fast-read option */
Packit Service 1d0348
		const char *p;
Packit Service 1d0348
		if ((bsdtar->flags & OPTFLAG_FAST_READ) &&
Packit Service 1d0348
		    archive_match_path_unmatched_inclusions(bsdtar->matching) == 0)
Packit Service 1d0348
			break;
Packit Service 1d0348
Packit Service 1d0348
		r = archive_read_next_header(a, &entry);
Packit Service 1d0348
		progress_data.entry = entry;
Packit Service 1d0348
		if (r == ARCHIVE_EOF)
Packit Service 1d0348
			break;
Packit Service 1d0348
		if (r < ARCHIVE_OK)
Packit Service 1d0348
			lafe_warnc(0, "%s", archive_error_string(a));
Packit Service 1d0348
		if (r <= ARCHIVE_WARN)
Packit Service 1d0348
			bsdtar->return_value = 1;
Packit Service 1d0348
		if (r == ARCHIVE_RETRY) {
Packit Service 1d0348
			/* Retryable error: try again */
Packit Service 1d0348
			lafe_warnc(0, "Retrying...");
Packit Service 1d0348
			continue;
Packit Service 1d0348
		}
Packit Service 1d0348
		if (r == ARCHIVE_FATAL)
Packit Service 1d0348
			break;
Packit Service 1d0348
		p = archive_entry_pathname(entry);
Packit Service 1d0348
		if (p == NULL || p[0] == '\0') {
Packit Service 1d0348
			lafe_warnc(0, "Archive entry has empty or unreadable filename ... skipping.");
Packit Service 1d0348
			bsdtar->return_value = 1;
Packit Service 1d0348
			continue;
Packit Service 1d0348
		}
Packit Service 1d0348
Packit Service 1d0348
		if (bsdtar->uid >= 0) {
Packit Service 1d0348
			archive_entry_set_uid(entry, bsdtar->uid);
Packit Service 1d0348
			archive_entry_set_uname(entry, NULL);
Packit Service 1d0348
		}
Packit Service 1d0348
		if (bsdtar->gid >= 0) {
Packit Service 1d0348
			archive_entry_set_gid(entry, bsdtar->gid);
Packit Service 1d0348
			archive_entry_set_gname(entry, NULL);
Packit Service 1d0348
		}
Packit Service 1d0348
		if (bsdtar->uname)
Packit Service 1d0348
			archive_entry_set_uname(entry, bsdtar->uname);
Packit Service 1d0348
		if (bsdtar->gname)
Packit Service 1d0348
			archive_entry_set_gname(entry, bsdtar->gname);
Packit Service 1d0348
Packit Service 1d0348
		/*
Packit Service 1d0348
		 * Note that pattern exclusions are checked before
Packit Service 1d0348
		 * pathname rewrites are handled.  This gives more
Packit Service 1d0348
		 * control over exclusions, since rewrites always lose
Packit Service 1d0348
		 * information.  (For example, consider a rewrite
Packit Service 1d0348
		 * s/foo[0-9]/foo/.  If we check exclusions after the
Packit Service 1d0348
		 * rewrite, there would be no way to exclude foo1/bar
Packit Service 1d0348
		 * while allowing foo2/bar.)
Packit Service 1d0348
		 */
Packit Service 1d0348
		if (archive_match_excluded(bsdtar->matching, entry))
Packit Service 1d0348
			continue; /* Excluded by a pattern test. */
Packit Service 1d0348
Packit Service 1d0348
		if (mode == 't') {
Packit Service 1d0348
			/* Perversely, gtar uses -O to mean "send to stderr"
Packit Service 1d0348
			 * when used with -t. */
Packit Service 1d0348
			out = (bsdtar->flags & OPTFLAG_STDOUT) ?
Packit Service 1d0348
			    stderr : stdout;
Packit Service 1d0348
Packit Service 1d0348
			/*
Packit Service 1d0348
			 * TODO: Provide some reasonable way to
Packit Service 1d0348
			 * preview rewrites.  gtar always displays
Packit Service 1d0348
			 * the unedited path in -t output, which means
Packit Service 1d0348
			 * you cannot easily preview rewrites.
Packit Service 1d0348
			 */
Packit Service 1d0348
			if (bsdtar->verbose < 2)
Packit Service 1d0348
				safe_fprintf(out, "%s",
Packit Service 1d0348
				    archive_entry_pathname(entry));
Packit Service 1d0348
			else
Packit Service 1d0348
				list_item_verbose(bsdtar, out, entry);
Packit Service 1d0348
			fflush(out);
Packit Service 1d0348
			r = archive_read_data_skip(a);
Packit Service 1d0348
			if (r == ARCHIVE_WARN) {
Packit Service 1d0348
				fprintf(out, "\n");
Packit Service 1d0348
				lafe_warnc(0, "%s",
Packit Service 1d0348
				    archive_error_string(a));
Packit Service 1d0348
			}
Packit Service 1d0348
			if (r == ARCHIVE_RETRY) {
Packit Service 1d0348
				fprintf(out, "\n");
Packit Service 1d0348
				lafe_warnc(0, "%s",
Packit Service 1d0348
				    archive_error_string(a));
Packit Service 1d0348
			}
Packit Service 1d0348
			if (r == ARCHIVE_FATAL) {
Packit Service 1d0348
				fprintf(out, "\n");
Packit Service 1d0348
				lafe_warnc(0, "%s",
Packit Service 1d0348
				    archive_error_string(a));
Packit Service 1d0348
				bsdtar->return_value = 1;
Packit Service 1d0348
				break;
Packit Service 1d0348
			}
Packit Service 1d0348
			fprintf(out, "\n");
Packit Service 1d0348
		} else {
Packit Service 1d0348
			/* Note: some rewrite failures prevent extraction. */
Packit Service 1d0348
			if (edit_pathname(bsdtar, entry))
Packit Service 1d0348
				continue; /* Excluded by a rewrite failure. */
Packit Service 1d0348
Packit Service 1d0348
			if ((bsdtar->flags & OPTFLAG_INTERACTIVE) &&
Packit Service 1d0348
			    !yes("extract '%s'", archive_entry_pathname(entry)))
Packit Service 1d0348
				continue;
Packit Service 1d0348
Packit Service 1d0348
			if (bsdtar->verbose > 1) {
Packit Service 1d0348
				/* GNU tar uses -tv format with -xvv */
Packit Service 1d0348
				safe_fprintf(stderr, "x ");
Packit Service 1d0348
				list_item_verbose(bsdtar, stderr, entry);
Packit Service 1d0348
				fflush(stderr);
Packit Service 1d0348
			} else if (bsdtar->verbose > 0) {
Packit Service 1d0348
				/* Format follows SUSv2, including the
Packit Service 1d0348
				 * deferred '\n'. */
Packit Service 1d0348
				safe_fprintf(stderr, "x %s",
Packit Service 1d0348
				    archive_entry_pathname(entry));
Packit Service 1d0348
				fflush(stderr);
Packit Service 1d0348
			}
Packit Service 1d0348
Packit Service 1d0348
			/* TODO siginfo_printinfo(bsdtar, 0); */
Packit Service 1d0348
Packit Service 1d0348
			if (bsdtar->flags & OPTFLAG_STDOUT)
Packit Service 1d0348
				r = archive_read_data_into_fd(a, 1);
Packit Service 1d0348
			else
Packit Service 1d0348
				r = archive_read_extract2(a, entry, writer);
Packit Service 1d0348
			if (r != ARCHIVE_OK) {
Packit Service 1d0348
				if (!bsdtar->verbose)
Packit Service 1d0348
					safe_fprintf(stderr, "%s",
Packit Service 1d0348
					    archive_entry_pathname(entry));
Packit Service 1d0348
				safe_fprintf(stderr, ": %s",
Packit Service 1d0348
				    archive_error_string(a));
Packit Service 1d0348
				if (!bsdtar->verbose)
Packit Service 1d0348
					fprintf(stderr, "\n");
Packit Service 1d0348
				bsdtar->return_value = 1;
Packit Service 1d0348
			}
Packit Service 1d0348
			if (bsdtar->verbose)
Packit Service 1d0348
				fprintf(stderr, "\n");
Packit Service 1d0348
			if (r == ARCHIVE_FATAL)
Packit Service 1d0348
				break;
Packit Service 1d0348
		}
Packit Service 1d0348
	}
Packit Service 1d0348
Packit Service 1d0348
Packit Service 1d0348
	r = archive_read_close(a);
Packit Service 1d0348
	if (r != ARCHIVE_OK)
Packit Service 1d0348
		lafe_warnc(0, "%s", archive_error_string(a));
Packit Service 1d0348
	if (r <= ARCHIVE_WARN)
Packit Service 1d0348
		bsdtar->return_value = 1;
Packit Service 1d0348
Packit Service 1d0348
	if (bsdtar->verbose > 2)
Packit Service 1d0348
		fprintf(stdout, "Archive Format: %s,  Compression: %s\n",
Packit Service 1d0348
		    archive_format_name(a), archive_filter_name(a, 0));
Packit Service 1d0348
Packit Service 1d0348
	archive_read_free(a);
Packit Service 1d0348
}
Packit Service 1d0348
Packit Service 1d0348
Packit Service 1d0348
static int
Packit Service 1d0348
unmatched_inclusions_warn(struct archive *matching, const char *msg)
Packit Service 1d0348
{
Packit Service 1d0348
	const char *p;
Packit Service 1d0348
	int r;
Packit Service 1d0348
Packit Service 1d0348
	if (matching == NULL)
Packit Service 1d0348
		return (0);
Packit Service 1d0348
Packit Service 1d0348
	while ((r = archive_match_path_unmatched_inclusions_next(
Packit Service 1d0348
	    matching, &p)) == ARCHIVE_OK)
Packit Service 1d0348
		lafe_warnc(0, "%s: %s", p, msg);
Packit Service 1d0348
	if (r == ARCHIVE_FATAL)
Packit Service 1d0348
		lafe_errc(1, errno, "Out of memory");
Packit Service 1d0348
Packit Service 1d0348
	return (archive_match_path_unmatched_inclusions(matching));
Packit Service 1d0348
}