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 \
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 \
#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>
static void
mode_pass(struct cpio *cpio, const char *destdir)
{
+ unsigned long blocks;
struct line_reader *lr;
const char *p;
int r;
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");
+ }
+
}
/*
-# $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}/..
${TESTS} \
main.c
-CLEANFILES+= list.h
+CLEANFILES+= list.h bsdcpio_test
NO_MAN=yes
(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.*
* 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)
/* 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("..");
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");
* 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)
{
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));
*/
#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;
/* 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.");
/* 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);
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.");
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);
* 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)
{
/* 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);
* 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.
assertEqualInt(0, chdir(".."));
/* Verify stderr and stdout. */
- assertFileContents("../file\n", 8, "stderr");
+ assertFileContents("../.\n../file\n1 block\n", 21, "stderr");
assertEmptyFile("stdout");
/* Regular file. */
* 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
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 */
-# $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}
*/
#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>
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);
{
char *dest, *src;
char separator = '\0';
- int lastdotdot = 0; /* True if last elt copied was '..' */
dest = src = a->name;
if (*src == '\0') {
"Path contains '..'");
return (ARCHIVE_FAILED);
}
- lastdotdot = 1;
- } else
- lastdotdot = 0;
+ }
/*
* Note: Under no circumstances do we
* remove '..' elements. In
* '/foo/../bar/' should create the
* 'foo' dir as a side-effect.
*/
- } else
- lastdotdot = 0;
- } else
- lastdotdot = 0;
+ }
+ }
/* Copy current element, including leading '/'. */
if (separator)
* 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