diff options
author | kientzle <kientzle@FreeBSD.org> | 2008-08-24 06:21:00 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2008-08-24 06:21:00 +0000 |
commit | 0563028aefc9664cb599ee63480a74b3f19db234 (patch) | |
tree | 6f282445ad62d32a46858241d05c100e0f383b89 /usr.bin | |
parent | 5f09367fcae56d552adcf3cadfee2cf2d37e94ae (diff) | |
download | FreeBSD-src-0563028aefc9664cb599ee63480a74b3f19db234.zip FreeBSD-src-0563028aefc9664cb599ee63480a74b3f19db234.tar.gz |
Update the total archive byte counters when writing entries to disk using
archive_write_disk.
Update cpio to use this to emit block counts in -p mode.
Update cpio tests to verify these block counts.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/cpio/cpio.c | 9 | ||||
-rw-r--r-- | usr.bin/cpio/test/test_basic.c | 5 | ||||
-rw-r--r-- | usr.bin/cpio/test/test_option_L.c | 2 | ||||
-rw-r--r-- | usr.bin/cpio/test/test_option_a.c | 9 | ||||
-rw-r--r-- | usr.bin/cpio/test/test_option_y.c | 2 | ||||
-rw-r--r-- | usr.bin/cpio/test/test_passthrough_dotdot.c | 2 | ||||
-rw-r--r-- | usr.bin/cpio/test/test_passthrough_reverse.c | 3 |
7 files changed, 19 insertions, 13 deletions
diff --git a/usr.bin/cpio/cpio.c b/usr.bin/cpio/cpio.c index 8a23ae9..522d835 100644 --- a/usr.bin/cpio/cpio.c +++ b/usr.bin/cpio/cpio.c @@ -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/usr.bin/cpio/test/test_basic.c b/usr.bin/cpio/test/test_basic.c index 67381ce..c707ad0 100644 --- a/usr.bin/cpio/test/test_basic.c +++ b/usr.bin/cpio/test/test_basic.c @@ -151,10 +151,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(".."); diff --git a/usr.bin/cpio/test/test_option_L.c b/usr.bin/cpio/test/test_option_L.c index 2d69ab6..79e2adb 100644 --- a/usr.bin/cpio/test/test_option_L.c +++ b/usr.bin/cpio/test/test_option_L.c @@ -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/usr.bin/cpio/test/test_option_a.c b/usr.bin/cpio/test/test_option_a.c index fd416bb..7cc75ce 100644 --- a/usr.bin/cpio/test/test_option_a.c +++ b/usr.bin/cpio/test/test_option_a.c @@ -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/usr.bin/cpio/test/test_option_y.c b/usr.bin/cpio/test/test_option_y.c index 56852a8..4181301 100644 --- a/usr.bin/cpio/test/test_option_y.c +++ b/usr.bin/cpio/test/test_option_y.c @@ -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/usr.bin/cpio/test/test_passthrough_dotdot.c b/usr.bin/cpio/test/test_passthrough_dotdot.c index 629d9d6..f8c2c06 100644 --- a/usr.bin/cpio/test/test_passthrough_dotdot.c +++ b/usr.bin/cpio/test/test_passthrough_dotdot.c @@ -71,7 +71,7 @@ DEFINE_TEST(test_passthrough_dotdot) assertEqualInt(0, chdir("..")); /* Verify stderr and stdout. */ - assertFileContents("../.\n../file\n", 13, "stderr"); + assertFileContents("../.\n../file\n1 block\n", 21, "stderr"); assertEmptyFile("stdout"); /* Regular file. */ diff --git a/usr.bin/cpio/test/test_passthrough_reverse.c b/usr.bin/cpio/test/test_passthrough_reverse.c index b049ae5..84b2d72 100644 --- a/usr.bin/cpio/test/test_passthrough_reverse.c +++ b/usr.bin/cpio/test/test_passthrough_reverse.c @@ -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 */ |