From: Tim Kientzle Date: Sun, 24 Aug 2008 23:41:44 +0000 (-0400) Subject: IFC X-Git-Tag: v2.6.0~104 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=691997fdef06d762a451acf79652ab99dfbd3f2c;p=thirdparty%2Flibarchive.git IFC SVN-Revision: 188 --- diff --git a/Makefile.am b/Makefile.am index 01c4c5c57..9c31fa829 100644 --- a/Makefile.am +++ b/Makefile.am @@ -316,6 +316,7 @@ bsdtar_test_SOURCES= \ tar/test/test_copy.c \ tar/test/test_getdate.c \ tar/test/test_help.c \ + tar/test/test_option_q.c \ tar/test/test_option_T.c \ tar/test/test_patterns.c \ tar/test/test_stdio.c \ @@ -395,14 +396,14 @@ bsdcpio_test_SOURCES= \ cpio/test/test_basic.c \ cpio/test/test_format_newc.c \ cpio/test/test_gcpio_compat.c \ - cpio/test/test_option_a.c \ cpio/test/test_option_B.c \ + cpio/test/test_option_L.c \ + cpio/test/test_option_a.c \ cpio/test/test_option_c.c \ cpio/test/test_option_d.c \ + cpio/test/test_option_ell.c \ cpio/test/test_option_f.c \ cpio/test/test_option_help.c \ - cpio/test/test_option_L.c \ - cpio/test/test_option_ell.c \ cpio/test/test_option_m.c \ cpio/test/test_option_t.c \ cpio/test/test_option_u.c \ diff --git a/cpio/cpio.c b/cpio/cpio.c index 607dfb78c..06bd91b16 100644 --- a/cpio/cpio.c +++ b/cpio/cpio.c @@ -26,7 +26,7 @@ #include "cpio_platform.h" -__FBSDID("$FreeBSD: src/usr.bin/cpio/cpio.c,v 1.11 2008/08/20 16:39:18 kientzle Exp $"); +__FBSDID("$FreeBSD: src/usr.bin/cpio/cpio.c,v 1.12 2008/08/24 06:21:00 kientzle Exp $"); #include #include @@ -835,6 +835,7 @@ mode_list(struct cpio *cpio) static void mode_pass(struct cpio *cpio, const char *destdir) { + unsigned long blocks; struct line_reader *lr; const char *p; int r; @@ -863,6 +864,14 @@ mode_pass(struct cpio *cpio, const char *destdir) if (r != ARCHIVE_OK) cpio_errc(1, 0, archive_error_string(cpio->archive)); archive_write_finish(cpio->archive); + + if (!cpio->quiet) { + blocks = (archive_position_uncompressed(cpio->archive) + 511) + / 512; + fprintf(stderr, "%lu %s\n", blocks, + blocks == 1 ? "block" : "blocks"); + } + } /* diff --git a/cpio/test/Makefile b/cpio/test/Makefile index c19e56670..452824e92 100644 --- a/cpio/test/Makefile +++ b/cpio/test/Makefile @@ -1,4 +1,4 @@ -# $FreeBSD: src/usr.bin/cpio/test/Makefile,v 1.3 2008/08/24 05:14:03 kientzle Exp $ +# $FreeBSD: src/usr.bin/cpio/test/Makefile,v 1.4 2008/08/24 05:49:36 kientzle Exp $ # Where to find the cpio sources (for the internal unit tests) CPIO_SRCDIR=${.CURDIR}/.. @@ -37,7 +37,7 @@ SRCS= list.h \ ${TESTS} \ main.c -CLEANFILES+= list.h +CLEANFILES+= list.h bsdcpio_test NO_MAN=yes @@ -62,12 +62,8 @@ ${.OBJDIR}/list.h list.h: ${TESTS} Makefile (cd ${.CURDIR}; cat ${TESTS}) | grep DEFINE_TEST > list.h clean: - rm -f *.out - rm -f *.o - rm -f *.core + rm -f ${CLEANFILES} rm -f *~ - rm -f list.h - rm -f archive.h ../archive.h -chmod -R +w /tmp/bsdcpio_test.* rm -rf /tmp/bsdcpio_test.* diff --git a/cpio/test/test_basic.c b/cpio/test/test_basic.c index 954153e28..20d5d1d5b 100644 --- a/cpio/test/test_basic.c +++ b/cpio/test/test_basic.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_basic.c,v 1.2 2008/08/22 02:27:06 kientzle Exp $"); +__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_basic.c,v 1.3 2008/08/24 06:21:00 kientzle Exp $"); static void verify_files(const char *target) @@ -165,10 +165,7 @@ passthrough(const char *target) /* Verify stderr. */ failure("Error invoking %s -p in dir %s", testprog, target); - /* gcpio 2.9 writes "1 block" to stderr */ - /* assertFileContents("1 block\n", 8, "stderr"); */ - /* bsdcpio writes nothing to stderr for passthrough mode */ - assertFileContents("", 0, "stderr"); + assertFileContents("1 block\n", 8, "stderr"); verify_files(target); chdir(".."); @@ -221,10 +218,8 @@ DEFINE_TEST(test_basic) basic_cpio("copy", "", "", "2 blocks\n"); basic_cpio("copy_odc", "--format=odc", "", "2 blocks\n"); basic_cpio("copy_newc", "-H newc", "", "2 blocks\n"); - basic_cpio("copy_cpio", "-H odc", "", "1 block\n"); - /* For some reason, gcpio 2.9 writes 7 blocks but only reads 6? */ - /* bsdcpio writes 7 blocks and reads 7 blocks. */ - basic_cpio("copy_ustar", "-H ustar", "", "7 blocks\n"); + basic_cpio("copy_cpio", "-H odc", "", "2 blocks\n"); + basic_cpio("copy_ustar", "-H ustar", "", "9 blocks\n"); /* Copy in one step using -p */ passthrough("passthrough"); diff --git a/cpio/test/test_option_L.c b/cpio/test/test_option_L.c index 2d69ab6ec..0caa0f0e6 100644 --- a/cpio/test/test_option_L.c +++ b/cpio/test/test_option_L.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_option_L.c,v 1.2 2008/08/24 06:21:00 kientzle Exp $"); DEFINE_TEST(test_option_L) { @@ -55,7 +55,7 @@ DEFINE_TEST(test_option_L) r = systemf("cat filelist | %s -pd -L copy-L >copy-L.out 2>copy-L.err", testprog); assertEqualInt(r, 0); assertEmptyFile("copy-L.out"); - assertEmptyFile("copy-L.err"); + assertFileContents("1 block\n", 8, "copy-L.err"); assertEqualInt(0, lstat("copy-L/symlink", &st)); failure("-pdL should dereference symlinks and turn them into files."); assert(!S_ISLNK(st.st_mode)); diff --git a/cpio/test/test_option_a.c b/cpio/test/test_option_a.c index f735b9116..86c03c1c8 100644 --- a/cpio/test/test_option_a.c +++ b/cpio/test/test_option_a.c @@ -24,7 +24,7 @@ */ #include "test.h" #include -__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_option_a.c,v 1.2 2008/08/22 02:27:06 kientzle Exp $"); +__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_option_a.c,v 1.3 2008/08/24 06:21:00 kientzle Exp $"); static struct { const char *name; @@ -118,8 +118,7 @@ DEFINE_TEST(test_option_a) /* Copy the file without -a; should change the atime. */ r = systemf("echo %s | %s -pd copy-no-a > copy-no-a.out 2>copy-no-a.err", files[1].name, testprog); assertEqualInt(r, 0); - /* bsdcpio writes nothing to stderr in -p mode */ - assertEmptyFile("copy-no-a.err"); + assertFileContents("1 block\n", 8, "copy-no-a.err"); assertEmptyFile("copy-no-a.out"); assertEqualInt(0, stat(files[1].name, &st)); failure("Copying file without -a should have changed atime."); @@ -128,7 +127,7 @@ DEFINE_TEST(test_option_a) /* Archive the file without -a; should change the atime. */ r = systemf("echo %s | %s -o > archive-no-a.out 2>archive-no-a.err", files[2].name, testprog); assertEqualInt(r, 0); - assertEmptyFile("copy-no-a.err"); + assertFileContents("1 block\n", 8, "copy-no-a.err"); assertEqualInt(0, stat(files[2].name, &st)); failure("Archiving file without -a should have changed atime."); assert(st.st_atime != files[2].atime_sec); @@ -143,7 +142,7 @@ DEFINE_TEST(test_option_a) r = systemf("echo %s | %s -pad copy-a > copy-a.out 2>copy-a.err", files[3].name, testprog); assertEqualInt(r, 0); - assertEmptyFile("copy-a.err"); + assertFileContents("1 block\n", 8, "copy-a.err"); assertEmptyFile("copy-a.out"); assertEqualInt(0, stat(files[3].name, &st)); failure("Copying file with -a should not have changed atime."); @@ -153,7 +152,7 @@ DEFINE_TEST(test_option_a) r = systemf("echo %s | %s -oa > archive-a.out 2>archive-a.err", files[4].name, testprog); assertEqualInt(r, 0); - assertEmptyFile("copy-a.err"); + assertFileContents("1 block\n", 8, "copy-a.err"); assertEqualInt(0, stat(files[4].name, &st)); failure("Archiving file with -a should not have changed atime."); assertEqualInt(st.st_atime, files[4].atime_sec); diff --git a/cpio/test/test_option_y.c b/cpio/test/test_option_y.c index 56852a805..5aac83ae9 100644 --- a/cpio/test/test_option_y.c +++ b/cpio/test/test_option_y.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_option_y.c,v 1.2 2008/08/24 06:21:00 kientzle Exp $"); DEFINE_TEST(test_option_y) { @@ -41,9 +41,9 @@ DEFINE_TEST(test_option_y) /* Archive it with bzip2 compression. */ r = systemf("echo f | %s -oy >archive.out 2>archive.err", testprog); - assertFileContents("1 block\n", 8, "archive.err"); failure("-y (bzip) option seems to be broken"); if (assertEqualInt(r, 0)) { + assertFileContents("1 block\n", 8, "archive.err"); /* Check that the archive file has a bzip2 signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); diff --git a/cpio/test/test_passthrough_dotdot.c b/cpio/test/test_passthrough_dotdot.c index e9d5c617a..5217ada2a 100644 --- a/cpio/test/test_passthrough_dotdot.c +++ b/cpio/test/test_passthrough_dotdot.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_passthrough_dotdot.c,v 1.2 2008/08/24 05:24:52 kientzle Exp $"); +__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_passthrough_dotdot.c,v 1.4 2008/08/24 06:21:00 kientzle Exp $"); /* * Verify that "cpio -p .." works. @@ -71,7 +71,7 @@ DEFINE_TEST(test_passthrough_dotdot) assertEqualInt(0, chdir("..")); /* Verify stderr and stdout. */ - assertFileContents("../file\n", 8, "stderr"); + assertFileContents("../.\n../file\n1 block\n", 21, "stderr"); assertEmptyFile("stdout"); /* Regular file. */ diff --git a/cpio/test/test_passthrough_reverse.c b/cpio/test/test_passthrough_reverse.c index 00ee2bc02..4a44bbd87 100644 --- a/cpio/test/test_passthrough_reverse.c +++ b/cpio/test/test_passthrough_reverse.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_passthrough_reverse.c,v 1.1 2008/08/24 04:58:22 kientzle Exp $"); +__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_passthrough_reverse.c,v 1.2 2008/08/24 06:21:00 kientzle Exp $"); /* * As reported by Bernd Walter: Some people are in the habit of @@ -75,7 +75,8 @@ DEFINE_TEST(test_passthrough_reverse) assertEqualInt(0, chdir("out")); /* Verify stderr and stdout. */ - assertFileContents("out/dir/file\nout/dir\n", 21, "../stderr"); + assertFileContents("out/dir/file\nout/dir\n1 block\n", 29, + "../stderr"); assertEmptyFile("../stdout"); /* dir */ diff --git a/libarchive/Makefile b/libarchive/Makefile index fb81633af..109da0572 100644 --- a/libarchive/Makefile +++ b/libarchive/Makefile @@ -1,4 +1,4 @@ -# $FreeBSD: src/lib/libarchive/Makefile,v 1.85 2008/06/15 05:05:53 kientzle Exp $ +# $FreeBSD: src/lib/libarchive/Makefile,v 1.87 2008/08/24 05:54:28 kientzle Exp $ LIB= archive DPADD= ${LIBBZ2} ${LIBZ} diff --git a/libarchive/archive_write_disk.c b/libarchive/archive_write_disk.c index d0b3a2cec..3e1ab6b72 100644 --- a/libarchive/archive_write_disk.c +++ b/libarchive/archive_write_disk.c @@ -25,7 +25,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.29 2008/08/24 05:01:01 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.31 2008/08/24 06:21:00 kientzle Exp $"); #ifdef HAVE_SYS_TYPES_H #include @@ -562,6 +562,8 @@ write_data_block(struct archive_write_disk *a, buff += bytes_written; size -= bytes_written; offset += bytes_written; + a->archive.file_position += bytes_written; + a->archive.raw_position += bytes_written; a->last_offset = a->offset = offset; } return (bytes_written); @@ -1395,7 +1397,6 @@ cleanup_pathname(struct archive_write_disk *a) { char *dest, *src; char separator = '\0'; - int lastdotdot = 0; /* True if last elt copied was '..' */ dest = src = a->name; if (*src == '\0') { @@ -1434,9 +1435,7 @@ cleanup_pathname(struct archive_write_disk *a) "Path contains '..'"); return (ARCHIVE_FAILED); } - lastdotdot = 1; - } else - lastdotdot = 0; + } /* * Note: Under no circumstances do we * remove '..' elements. In @@ -1444,10 +1443,8 @@ cleanup_pathname(struct archive_write_disk *a) * '/foo/../bar/' should create the * 'foo' dir as a side-effect. */ - } else - lastdotdot = 0; - } else - lastdotdot = 0; + } + } /* Copy current element, including leading '/'. */ if (separator) @@ -1466,13 +1463,6 @@ cleanup_pathname(struct archive_write_disk *a) * We've just copied zero or more path elements, not including the * final '/'. */ - if (lastdotdot) { - /* Trailing '..' is always wrong. */ - archive_set_error(&a->archive, - ARCHIVE_ERRNO_MISC, - "Path contains trailing '..'"); - return (ARCHIVE_FAILED); - } if (dest == a->name) { /* * Nothing got copied. The path must have been something