summaryrefslogtreecommitdiff
path: root/tar/write.c
diff options
context:
space:
mode:
Diffstat (limited to 'tar/write.c')
-rw-r--r--tar/write.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/tar/write.c b/tar/write.c
index 40d2fb0a9f52..53b63834c419 100644
--- a/tar/write.c
+++ b/tar/write.c
@@ -236,6 +236,13 @@ tar_mode_c(struct bsdtar *bsdtar)
}
set_writer_options(bsdtar, a);
+ if (bsdtar->passphrase != NULL)
+ r = archive_write_set_passphrase(a, bsdtar->passphrase);
+ else
+ r = archive_write_set_passphrase_callback(a, bsdtar,
+ &passphrase_callback);
+ if (r != ARCHIVE_OK)
+ lafe_errc(1, 0, "%s", archive_error_string(a));
if (ARCHIVE_OK != archive_write_open_filename(a, bsdtar->filename))
lafe_errc(1, 0, "%s", archive_error_string(a));
write_archive(a, bsdtar);
@@ -647,7 +654,15 @@ append_archive_filename(struct bsdtar *bsdtar, struct archive *a,
ina = archive_read_new();
archive_read_support_format_all(ina);
archive_read_support_filter_all(ina);
- set_reader_options(bsdtar, a);
+ set_reader_options(bsdtar, ina);
+ archive_read_set_options(ina, "mtree:checkfs");
+ if (bsdtar->passphrase != NULL)
+ rc = archive_read_add_passphrase(a, bsdtar->passphrase);
+ else
+ rc = archive_read_set_passphrase_callback(ina, bsdtar,
+ &passphrase_callback);
+ if (rc != ARCHIVE_OK)
+ lafe_errc(1, 0, "%s", archive_error_string(a));
if (archive_read_open_filename(ina, filename,
bsdtar->bytes_per_block)) {
lafe_warnc(0, "%s", archive_error_string(ina));
@@ -679,7 +694,10 @@ append_archive(struct bsdtar *bsdtar, struct archive *a, struct archive *ina)
if (bsdtar->option_interactive &&
!yes("copy '%s'", archive_entry_pathname(in_entry)))
continue;
- if (bsdtar->verbose)
+ if (bsdtar->verbose > 1) {
+ safe_fprintf(stderr, "a ");
+ list_item_verbose(bsdtar, stderr, in_entry);
+ } else if (bsdtar->verbose > 0)
safe_fprintf(stderr, "a %s",
archive_entry_pathname(in_entry));
if (need_report())
@@ -899,11 +917,15 @@ write_hierarchy(struct bsdtar *bsdtar, struct archive *a, const char *path)
if (edit_pathname(bsdtar, entry))
continue;
- /* Display entry as we process it.
- * This format is required by SUSv2. */
- if (bsdtar->verbose)
+ /* Display entry as we process it. */
+ if (bsdtar->verbose > 1) {
+ safe_fprintf(stderr, "a ");
+ list_item_verbose(bsdtar, stderr, entry);
+ } else if (bsdtar->verbose > 0) {
+ /* This format is required by SUSv2. */
safe_fprintf(stderr, "a %s",
archive_entry_pathname(entry));
+ }
/* Non-regular files get archived with zero size. */
if (archive_entry_filetype(entry) != AE_IFREG)
@@ -947,11 +969,15 @@ write_entry(struct bsdtar *bsdtar, struct archive *a,
e = archive_write_header(a, entry);
if (e != ARCHIVE_OK) {
- if (!bsdtar->verbose)
+ if (bsdtar->verbose > 1) {
+ safe_fprintf(stderr, "a ");
+ list_item_verbose(bsdtar, stderr, entry);
+ lafe_warnc(0, ": %s", archive_error_string(a));
+ } else if (bsdtar->verbose > 0) {
lafe_warnc(0, "%s: %s",
archive_entry_pathname(entry),
archive_error_string(a));
- else
+ } else
fprintf(stderr, ": %s", archive_error_string(a));
}