diff options
author | mm <mm@FreeBSD.org> | 2011-07-17 21:33:15 +0000 |
---|---|---|
committer | mm <mm@FreeBSD.org> | 2011-07-17 21:33:15 +0000 |
commit | 867c8ddd4db0c581c7d6f04f5317cdc34c07dd5c (patch) | |
tree | 8e28f61596b4577fd91c1332f714c570089da33e /usr.bin/tar/write.c | |
parent | af1b78954b9a91ab8b481f90c8b8c3522f6ea0fa (diff) | |
download | FreeBSD-src-867c8ddd4db0c581c7d6f04f5317cdc34c07dd5c.zip FreeBSD-src-867c8ddd4db0c581c7d6f04f5317cdc34c07dd5c.tar.gz |
Update bsdtar to 2.8.4
Use common code from lib/libarchive/libarchive_fe
Approved by: kientzle
MFC after: 2 weeks
Diffstat (limited to 'usr.bin/tar/write.c')
-rw-r--r-- | usr.bin/tar/write.c | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/usr.bin/tar/write.c b/usr.bin/tar/write.c index 9d9025a..32e43c6 100644 --- a/usr.bin/tar/write.c +++ b/usr.bin/tar/write.c @@ -169,7 +169,7 @@ tar_mode_c(struct bsdtar *bsdtar) int r; if (*bsdtar->argv == NULL && bsdtar->names_from_file == NULL) - bsdtar_errc(1, 0, "no files or directories specified"); + lafe_errc(1, 0, "no files or directories specified"); a = archive_write_new(); @@ -223,21 +223,21 @@ tar_mode_c(struct bsdtar *bsdtar) r = archive_write_set_compression_compress(a); break; default: - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Unrecognized compression option -%c", bsdtar->create_compression); } if (r != ARCHIVE_OK) { - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Unsupported compression option -%c", bsdtar->create_compression); } } if (ARCHIVE_OK != archive_write_set_options(a, bsdtar->option_options)) - bsdtar_errc(1, 0, "%s", archive_error_string(a)); + lafe_errc(1, 0, "%s", archive_error_string(a)); if (ARCHIVE_OK != archive_write_open_file(a, bsdtar->filename)) - bsdtar_errc(1, 0, "%s", archive_error_string(a)); + lafe_errc(1, 0, "%s", archive_error_string(a)); write_archive(a, bsdtar); } @@ -265,7 +265,7 @@ tar_mode_r(struct bsdtar *bsdtar) bsdtar->fd = open(bsdtar->filename, O_RDWR | O_CREAT | O_BINARY, 0666); #endif if (bsdtar->fd < 0) - bsdtar_errc(1, errno, + lafe_errc(1, errno, "Cannot open %s", bsdtar->filename); a = archive_read_new(); @@ -274,14 +274,14 @@ tar_mode_r(struct bsdtar *bsdtar) archive_read_support_format_gnutar(a); r = archive_read_open_fd(a, bsdtar->fd, 10240); if (r != ARCHIVE_OK) - bsdtar_errc(1, archive_errno(a), + lafe_errc(1, archive_errno(a), "Can't read archive %s: %s", bsdtar->filename, archive_error_string(a)); while (0 == archive_read_next_header(a, &entry)) { if (archive_compression(a) != ARCHIVE_COMPRESSION_NONE) { archive_read_finish(a); close(bsdtar->fd); - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Cannot append to compressed archive."); } /* Keep going until we hit end-of-archive */ @@ -310,7 +310,7 @@ tar_mode_r(struct bsdtar *bsdtar) format &= ARCHIVE_FORMAT_BASE_MASK; if (format != (int)(archive_format(a) & ARCHIVE_FORMAT_BASE_MASK) && format != ARCHIVE_FORMAT_EMPTY) { - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Format %s is incompatible with the archive %s.", bsdtar->create_format, bsdtar->filename); } @@ -327,11 +327,11 @@ tar_mode_r(struct bsdtar *bsdtar) archive_write_set_format(a, format); } if (lseek(bsdtar->fd, end_offset, SEEK_SET) < 0) - bsdtar_errc(1, errno, "Could not seek to archive end"); + lafe_errc(1, errno, "Could not seek to archive end"); if (ARCHIVE_OK != archive_write_set_options(a, bsdtar->option_options)) - bsdtar_errc(1, 0, "%s", archive_error_string(a)); + lafe_errc(1, 0, "%s", archive_error_string(a)); if (ARCHIVE_OK != archive_write_open_fd(a, bsdtar->fd)) - bsdtar_errc(1, 0, "%s", archive_error_string(a)); + lafe_errc(1, 0, "%s", archive_error_string(a)); write_archive(a, bsdtar); /* XXX check return val XXX */ @@ -359,7 +359,7 @@ tar_mode_u(struct bsdtar *bsdtar) bsdtar->fd = open(bsdtar->filename, O_RDWR | O_BINARY); if (bsdtar->fd < 0) - bsdtar_errc(1, errno, + lafe_errc(1, errno, "Cannot open %s", bsdtar->filename); a = archive_read_new(); @@ -369,7 +369,7 @@ tar_mode_u(struct bsdtar *bsdtar) if (archive_read_open_fd(a, bsdtar->fd, bsdtar->bytes_per_block != 0 ? bsdtar->bytes_per_block : DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) { - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Can't open %s: %s", bsdtar->filename, archive_error_string(a)); } @@ -379,7 +379,7 @@ tar_mode_u(struct bsdtar *bsdtar) if (archive_compression(a) != ARCHIVE_COMPRESSION_NONE) { archive_read_finish(a); close(bsdtar->fd); - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Cannot append to compressed archive."); } add_dir_list(bsdtar, archive_entry_pathname(entry), @@ -410,11 +410,11 @@ tar_mode_u(struct bsdtar *bsdtar) } else archive_write_set_bytes_per_block(a, DEFAULT_BYTES_PER_BLOCK); if (lseek(bsdtar->fd, end_offset, SEEK_SET) < 0) - bsdtar_errc(1, errno, "Could not seek to archive end"); + lafe_errc(1, errno, "Could not seek to archive end"); if (ARCHIVE_OK != archive_write_set_options(a, bsdtar->option_options)) - bsdtar_errc(1, 0, "%s", archive_error_string(a)); + lafe_errc(1, 0, "%s", archive_error_string(a)); if (ARCHIVE_OK != archive_write_open_fd(a, bsdtar->fd)) - bsdtar_errc(1, 0, "%s", archive_error_string(a)); + lafe_errc(1, 0, "%s", archive_error_string(a)); write_archive(a, bsdtar); @@ -442,14 +442,14 @@ write_archive(struct archive *a, struct bsdtar *bsdtar) /* Allocate a buffer for file data. */ if ((bsdtar->buff = malloc(FILEDATABUFLEN)) == NULL) - bsdtar_errc(1, 0, "cannot allocate memory"); + lafe_errc(1, 0, "cannot allocate memory"); if ((bsdtar->resolver = archive_entry_linkresolver_new()) == NULL) - bsdtar_errc(1, 0, "cannot create link resolver"); + lafe_errc(1, 0, "cannot create link resolver"); archive_entry_linkresolver_set_strategy(bsdtar->resolver, archive_format(a)); if ((bsdtar->diskreader = archive_read_disk_new()) == NULL) - bsdtar_errc(1, 0, "Cannot create read_disk object"); + lafe_errc(1, 0, "Cannot create read_disk object"); archive_read_disk_set_standard_lookup(bsdtar->diskreader); if (bsdtar->names_from_file != NULL) @@ -463,7 +463,7 @@ write_archive(struct archive *a, struct bsdtar *bsdtar) bsdtar->argv++; arg = *bsdtar->argv; if (arg == NULL) { - bsdtar_warnc(0, "%s", + lafe_warnc(0, "%s", "Missing argument for -C"); bsdtar->return_value = 1; goto cleanup; @@ -493,7 +493,7 @@ write_archive(struct archive *a, struct bsdtar *bsdtar) } if (archive_write_close(a)) { - bsdtar_warnc(0, "%s", archive_error_string(a)); + lafe_warnc(0, "%s", archive_error_string(a)); bsdtar->return_value = 1; } @@ -543,7 +543,7 @@ archive_names_from_file(struct bsdtar *bsdtar, struct archive *a) } lafe_line_reader_free(lr); if (bsdtar->next_line_is_dir) - bsdtar_errc(1, errno, + lafe_errc(1, errno, "Unexpected end of filename list; " "directory expected after -C"); } @@ -569,7 +569,7 @@ append_archive_filename(struct bsdtar *bsdtar, struct archive *a, archive_read_support_format_all(ina); archive_read_support_compression_all(ina); if (archive_read_open_file(ina, filename, 10240)) { - bsdtar_warnc(0, "%s", archive_error_string(ina)); + lafe_warnc(0, "%s", archive_error_string(ina)); bsdtar->return_value = 1; return (0); } @@ -577,7 +577,7 @@ append_archive_filename(struct bsdtar *bsdtar, struct archive *a, rc = append_archive(bsdtar, a, ina); if (rc != ARCHIVE_OK) { - bsdtar_warnc(0, "Error reading archive %s: %s", + lafe_warnc(0, "Error reading archive %s: %s", filename, archive_error_string(ina)); bsdtar->return_value = 1; } @@ -610,7 +610,7 @@ append_archive(struct bsdtar *bsdtar, struct archive *a, struct archive *ina) e = archive_write_header(a, in_entry); if (e != ARCHIVE_OK) { if (!bsdtar->verbose) - bsdtar_warnc(0, "%s: %s", + lafe_warnc(0, "%s: %s", archive_entry_pathname(in_entry), archive_error_string(a)); else @@ -651,7 +651,7 @@ copy_file_data(struct bsdtar *bsdtar, struct archive *a, bytes_written = archive_write_data(a, bsdtar->buff, bytes_read); if (bytes_written < bytes_read) { - bsdtar_warnc(0, "%s", archive_error_string(a)); + lafe_warnc(0, "%s", archive_error_string(a)); return (-1); } progress += bytes_written; @@ -678,7 +678,7 @@ write_hierarchy(struct bsdtar *bsdtar, struct archive *a, const char *path) tree = tree_open(path); if (!tree) { - bsdtar_warnc(errno, "%s: Cannot open", path); + lafe_warnc(errno, "%s: Cannot open", path); bsdtar->return_value = 1; return; } @@ -691,11 +691,11 @@ write_hierarchy(struct bsdtar *bsdtar, struct archive *a, const char *path) int descend; if (tree_ret == TREE_ERROR_FATAL) - bsdtar_errc(1, tree_errno(tree), + lafe_errc(1, tree_errno(tree), "%s: Unable to continue traversing directory tree", name); if (tree_ret == TREE_ERROR_DIR) { - bsdtar_warnc(errno, + lafe_warnc(errno, "%s: Couldn't visit directory", name); bsdtar->return_value = 1; } @@ -715,7 +715,7 @@ write_hierarchy(struct bsdtar *bsdtar, struct archive *a, const char *path) lst = tree_current_lstat(tree); if (lst == NULL) { /* Couldn't lstat(); must not exist. */ - bsdtar_warnc(errno, "%s: Cannot stat", name); + lafe_warnc(errno, "%s: Cannot stat", name); /* Return error if files disappear during traverse. */ bsdtar->return_value = 1; continue; @@ -834,7 +834,7 @@ write_hierarchy(struct bsdtar *bsdtar, struct archive *a, const char *path) r = archive_read_disk_entry_from_file(bsdtar->diskreader, entry, -1, st); if (r != ARCHIVE_OK) - bsdtar_warnc(archive_errno(bsdtar->diskreader), + lafe_warnc(archive_errno(bsdtar->diskreader), "%s", archive_error_string(bsdtar->diskreader)); if (r < ARCHIVE_WARN) continue; @@ -929,7 +929,7 @@ write_entry_backend(struct bsdtar *bsdtar, struct archive *a, if (fd == -1) { bsdtar->return_value = 1; if (!bsdtar->verbose) - bsdtar_warnc(errno, + lafe_warnc(errno, "%s: could not open file", pathname); else fprintf(stderr, ": %s", strerror(errno)); @@ -940,7 +940,7 @@ write_entry_backend(struct bsdtar *bsdtar, struct archive *a, e = archive_write_header(a, entry); if (e != ARCHIVE_OK) { if (!bsdtar->verbose) - bsdtar_warnc(0, "%s: %s", + lafe_warnc(0, "%s: %s", archive_entry_pathname(entry), archive_error_string(a)); else @@ -1016,12 +1016,12 @@ write_file_data(struct bsdtar *bsdtar, struct archive *a, bytes_read); if (bytes_written < 0) { /* Write failed; this is bad */ - bsdtar_warnc(0, "%s", archive_error_string(a)); + lafe_warnc(0, "%s", archive_error_string(a)); return (-1); } if (bytes_written < bytes_read) { /* Write was truncated; warn but continue. */ - bsdtar_warnc(0, + lafe_warnc(0, "%s: Truncated write; file may have grown while being archived.", archive_entry_pathname(entry)); return (0); @@ -1030,7 +1030,7 @@ write_file_data(struct bsdtar *bsdtar, struct archive *a, bytes_read = read(fd, bsdtar->buff, FILEDATABUFLEN); } if (bytes_read < 0) { - bsdtar_warnc(errno, + lafe_warnc(errno, "%s: Read error", archive_entry_pathname(entry)); bsdtar->return_value = 1; @@ -1112,11 +1112,11 @@ add_dir_list(struct bsdtar *bsdtar, const char *path, p = malloc(sizeof(*p)); if (p == NULL) - bsdtar_errc(1, ENOMEM, "Can't read archive directory"); + lafe_errc(1, ENOMEM, "Can't read archive directory"); p->name = strdup(path); if (p->name == NULL) - bsdtar_errc(1, ENOMEM, "Can't read archive directory"); + lafe_errc(1, ENOMEM, "Can't read archive directory"); p->mtime_sec = mtime_sec; p->mtime_nsec = mtime_nsec; p->next = NULL; @@ -1134,26 +1134,26 @@ test_for_append(struct bsdtar *bsdtar) struct stat s; if (*bsdtar->argv == NULL && bsdtar->names_from_file == NULL) - bsdtar_errc(1, 0, "no files or directories specified"); + lafe_errc(1, 0, "no files or directories specified"); if (bsdtar->filename == NULL) - bsdtar_errc(1, 0, "Cannot append to stdout."); + lafe_errc(1, 0, "Cannot append to stdout."); if (bsdtar->create_compression != 0) - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Cannot append to %s with compression", bsdtar->filename); if (stat(bsdtar->filename, &s) != 0) return; if (!S_ISREG(s.st_mode) && !S_ISBLK(s.st_mode)) - bsdtar_errc(1, 0, + lafe_errc(1, 0, "Cannot append to %s: not a regular file.", bsdtar->filename); /* Is this an appropriate check here on Windows? */ /* if (GetFileType(handle) != FILE_TYPE_DISK) - bsdtar_errc(1, 0, "Cannot append"); + lafe_errc(1, 0, "Cannot append"); */ } |