From 7b7b89339476401943198c223845ec4d840b5dc6 Mon Sep 17 00:00:00 2001 From: "Bruce A. Mah" Date: Tue, 18 Sep 2007 20:20:37 +0000 Subject: [PATCH] Revert the last commit to libarchive. It introduced some regresssions, most noticably the incorrect extraction of files by bsdtar. This commit reverts: src/lib/libarchive/archive_write_disk.c 1.15 src/lib/libarchive/test/test_write_disk.c 1.4 Approved by: re (implicitly) --- lib/libarchive/archive_write_disk.c | 11 ++++------- lib/libarchive/test/test_write_disk.c | 27 +-------------------------- 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/lib/libarchive/archive_write_disk.c b/lib/libarchive/archive_write_disk.c index 0c15b77f9a75..f5fb3aa8937b 100644 --- a/lib/libarchive/archive_write_disk.c +++ b/lib/libarchive/archive_write_disk.c @@ -444,14 +444,12 @@ _archive_write_data_block(struct archive *_a, const void *buff, size_t size, off_t offset) { struct archive_write_disk *a = (struct archive_write_disk *)_a; - ssize_t bytes_written = 0, total_written = 0; + ssize_t bytes_written = 0; __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, ARCHIVE_STATE_DATA, "archive_write_disk_block"); - if (a->fd < 0) { - archive_set_error(&a->archive, 0, "File not open"); - return (ARCHIVE_WARN); - } + if (a->fd < 0) + return (ARCHIVE_OK); archive_clear_error(&a->archive); /* Seek if necessary to the specified offset. */ @@ -472,9 +470,8 @@ _archive_write_data_block(struct archive *_a, } size -= bytes_written; a->offset += bytes_written; - total_written += bytes_written; } - return (total_written); + return (ARCHIVE_OK); } static ssize_t diff --git a/lib/libarchive/test/test_write_disk.c b/lib/libarchive/test/test_write_disk.c index d8ab7b970360..6b28830ee6f9 100644 --- a/lib/libarchive/test/test_write_disk.c +++ b/lib/libarchive/test/test_write_disk.c @@ -50,31 +50,6 @@ static void create(struct archive_entry *ae, const char *msg) st.st_mode, archive_entry_mode(ae)); assert(st.st_mode == (archive_entry_mode(ae) & ~UMASK)); } - -static void create_reg_file(struct archive_entry *ae, const char *msg) -{ - static const char data[]="abcdefghijklmnopqrstuvwxyz"; - struct archive *ad; - struct stat st; - - /* Write the entry to disk. */ - assert((ad = archive_write_disk_new()) != NULL); - failure("%s", msg); - assertEqualIntA(ad, 0, archive_write_header(ad, ae)); - assertEqualIntA(ad, sizeof(data), archive_write_data(ad, data, sizeof(data))); - assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); -#if ARCHIVE_API_VERSION > 1 - assertEqualInt(0, archive_write_finish(ad)); -#else - archive_write_finish(ad); -#endif - /* Test the entries on disk. */ - assert(0 == stat(archive_entry_pathname(ae), &st)); - failure("st.st_mode=%o archive_entry_mode(ae)=%o", - st.st_mode, archive_entry_mode(ae)); - assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK)); - assertEqualInt(st.st_size, sizeof(data)); -} #endif DEFINE_TEST(test_write_disk) @@ -91,7 +66,7 @@ DEFINE_TEST(test_write_disk) assert((ae = archive_entry_new()) != NULL); archive_entry_copy_pathname(ae, "file"); archive_entry_set_mode(ae, S_IFREG | 0755); - create_reg_file(ae, "Test creating a regular file"); + create(ae, "Test creating a regular file"); archive_entry_free(ae); /* A regular file over an existing file */