]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
IFC
authorTim Kientzle <kientzle@gmail.com>
Sun, 24 Aug 2008 23:41:44 +0000 (19:41 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sun, 24 Aug 2008 23:41:44 +0000 (19:41 -0400)
SVN-Revision: 188

Makefile.am
cpio/cpio.c
cpio/test/Makefile
cpio/test/test_basic.c
cpio/test/test_option_L.c
cpio/test/test_option_a.c
cpio/test/test_option_y.c
cpio/test/test_passthrough_dotdot.c
cpio/test/test_passthrough_reverse.c
libarchive/Makefile
libarchive/archive_write_disk.c

index 01c4c5c57ea7626ab5340cbfa92f1a3283336973..9c31fa8298f7851e38ccb2c87ce590ae871ab882 100644 (file)
@@ -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                               \
index 607dfb78ca92b92df9f4c127444d831ec5a07ca3..06bd91b16e372012f441680771c7aa08f570f9ec 100644 (file)
@@ -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 <sys/types.h>
 #include <archive.h>
@@ -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");
+       }
+
 }
 
 /*
index c19e56670437ad694efd95a9a13c5182a928912f..452824e92c3223a096f1fbbfd6184c28926ab210 100644 (file)
@@ -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.*
 
index 954153e280472d158825152a7d5cba93dbe080d9..20d5d1d5b5606304920d79846d54ffc508f2c5c1 100644 (file)
@@ -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");
 
index 2d69ab6ec34dad3db3ee91e678981c03c20871a3..0caa0f0e616af5c7d09d836302ced4cd537b0d30 100644 (file)
@@ -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));
index f735b9116e06d107a0ced4a27165155cac42a20d..86c03c1c89abaeaecca00e69b968b95773cb1fc5 100644 (file)
@@ -24,7 +24,7 @@
  */
 #include "test.h"
 #include <utime.h>
-__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);
index 56852a805f4595ea1dd3b264f5fb33d6385d286b..5aac83ae9902b8754a34959dfd493dd3e36d6df5 100644 (file)
@@ -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);
index e9d5c617ae565d3c738189f1a8ca38fce0c0bf57..5217ada2aa639fcbac1b4aa74d489cb886d3ad1c 100644 (file)
@@ -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. */
index 00ee2bc02c27b90ad43c5eb95894913e063cc061..4a44bbd878c57eda42319eb16c06669a571055c0 100644 (file)
@@ -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 */
index fb81633af7e6a8f2cfae1cd947365a9e55ddacd5..109da0572a06901cacc4a1a524fa3ad3f26ba5e9 100644 (file)
@@ -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}
index d0b3a2cec45814891f2dbc5e69d81f6ea96c7e5c..3e1ab6b726a9801bf1af422a0b8091c4d2fdd10f 100644 (file)
@@ -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 <sys/types.h>
@@ -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