From owner-p4-projects@FreeBSD.ORG Thu Aug 28 12:36:37 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id AD9481065677; Thu, 28 Aug 2008 12:36:37 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 71090106568D for ; Thu, 28 Aug 2008 12:36:37 +0000 (UTC) (envelope-from strauss@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 627C38FC22 for ; Thu, 28 Aug 2008 12:36:37 +0000 (UTC) (envelope-from strauss@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m7SCabQc083250 for ; Thu, 28 Aug 2008 12:36:37 GMT (envelope-from strauss@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m7SCablN083248 for perforce@freebsd.org; Thu, 28 Aug 2008 12:36:37 GMT (envelope-from strauss@FreeBSD.org) Date: Thu, 28 Aug 2008 12:36:37 GMT Message-Id: <200808281236.m7SCablN083248@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to strauss@FreeBSD.org using -f From: Anselm Strauss To: Perforce Change Reviews Cc: Subject: PERFORCE change 148692 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Aug 2008 12:36:38 -0000 http://perforce.freebsd.org/chv.cgi?CH=148692 Change 148692 by strauss@strauss_marvelman on 2008/08/28 12:36:13 Integration Affected files ... .. //depot/projects/soc2008/strauss_libarchive/Makefile.am#11 integrate .. //depot/projects/soc2008/strauss_libarchive/PROJECTS#4 integrate .. //depot/projects/soc2008/strauss_libarchive/cpio/cmdline.c#7 integrate .. //depot/projects/soc2008/strauss_libarchive/cpio/config_freebsd.h#5 integrate .. //depot/projects/soc2008/strauss_libarchive/cpio/cpio.c#8 integrate .. //depot/projects/soc2008/strauss_libarchive/cpio/cpio.h#4 integrate .. //depot/projects/soc2008/strauss_libarchive/cpio/test/main.c#7 integrate .. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_basic.c#6 integrate .. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_format_newc.c#6 integrate .. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_gcpio_compat.c#6 integrate .. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_option_L.c#6 integrate .. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_option_a.c#6 integrate .. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_option_y.c#6 integrate .. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_passthrough_dotdot.c#1 branch .. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_passthrough_reverse.c#1 branch .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive.h#6 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry.c#7 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry.h#5 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry_link_resolver.c#8 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry_private.h#5 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_private.h#3 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_format_mtree.c#7 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_format_tar.c#7 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_format_zip.c#8 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_disk.3#4 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_disk.c#8 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_compression_compress.c#5 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format.c#5 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_ar.c#6 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_by_name.c#6 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_mtree.c#1 branch .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_pax.c#7 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_shar.c#5 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/config_freebsd.h#5 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/main.c#8 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_compat_gtar_1.tgz.uu#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_compat_tar_hardlink.c#5 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_compat_zip_1.zip.uu#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_pax_filename_encoding.c#7 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_pax_filename_encoding.tar.gz.uu#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_format_gtar_sparse_1_13.tgz.uu#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_format_gtar_sparse_1_17.tgz.uu#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_format_gtar_sparse_1_17_posix00.tgz.uu#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tgz.uu#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tgz.uu#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_format_mtree.c#6 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_format_tar_empty_filename.tar.uu#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_format_zip.c#6 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_format_zip.zip.uu#2 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_tar_large.c#7 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_ustar_filenames.c#5 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_write_disk.c#6 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_write_disk_hardlink.c#6 integrate .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_write_format_tar_ustar.c#5 integrate .. //depot/projects/soc2008/strauss_libarchive/tar/bsdtar.1#4 integrate .. //depot/projects/soc2008/strauss_libarchive/tar/bsdtar.c#8 integrate .. //depot/projects/soc2008/strauss_libarchive/tar/bsdtar.h#4 integrate .. //depot/projects/soc2008/strauss_libarchive/tar/config_freebsd.h#5 integrate .. //depot/projects/soc2008/strauss_libarchive/tar/matching.c#6 integrate .. //depot/projects/soc2008/strauss_libarchive/tar/read.c#7 integrate .. //depot/projects/soc2008/strauss_libarchive/tar/test/main.c#7 integrate .. //depot/projects/soc2008/strauss_libarchive/tar/test/test.h#8 integrate .. //depot/projects/soc2008/strauss_libarchive/tar/test/test_copy.c#6 integrate .. //depot/projects/soc2008/strauss_libarchive/tar/test/test_option_T.c#5 integrate .. //depot/projects/soc2008/strauss_libarchive/tar/test/test_option_q.c#1 branch .. //depot/projects/soc2008/strauss_libarchive/tar/test/test_patterns.c#5 integrate .. //depot/projects/soc2008/strauss_libarchive/tar/test/test_patterns_2.tgz.uu#1 branch .. //depot/projects/soc2008/strauss_libarchive/tar/test/test_patterns_3.tgz.uu#1 branch .. //depot/projects/soc2008/strauss_libarchive/tar/write.c#8 integrate Differences ... ==== //depot/projects/soc2008/strauss_libarchive/Makefile.am#11 (text+ko) ==== @@ -130,6 +130,7 @@ libarchive/archive_write_set_format_by_name.c \ libarchive/archive_write_set_format_cpio.c \ libarchive/archive_write_set_format_cpio_newc.c \ + libarchive/archive_write_set_format_mtree.c \ libarchive/archive_write_set_format_pax.c \ libarchive/archive_write_set_format_shar.c \ libarchive/archive_write_set_format_ustar.c \ @@ -139,8 +140,9 @@ libarchive/filter_fork.c \ libarchive/filter_fork.h -# cygwin barfs without -no-undefined; I don't know what it does or -# whether it helps or hurts other platforms... +libarchive_la_CPPFLAGS=-I $(top_builddir)/libarchive +# -no-undefined marks that libarchive doesn't rely on symbols +# defined in the application. This is mandatory for cygwin. libarchive_la_LDFLAGS= -no-undefined -version-info $(ARCHIVE_LIBTOOL_VERSION) # Manpages to install @@ -317,6 +319,7 @@ 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 \ @@ -335,7 +338,11 @@ bsdtar_TESTS_ENVIRONMENT= endif +bsdtar_test_EXTRA_DIST= \ + tar/test/test_patterns_2.tgz.uu \ + tar/test/test_patterns_3.tgz.uu + # # # bsdcpio source, docs, etc. @@ -392,14 +399,14 @@ cpio/test/test_basic.c \ cpio/test/test_format_newc.c \ cpio/test/test_gcpio_compat.c \ + cpio/test/test_option_B.c \ + cpio/test/test_option_L.c \ cpio/test/test_option_a.c \ - cpio/test/test_option_B.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 \ @@ -407,6 +414,8 @@ cpio/test/test_option_y.c \ cpio/test/test_option_z.c \ cpio/test/test_owner_parse.c \ + cpio/test/test_passthrough_dotdot.c \ + cpio/test/test_passthrough_reverse.c \ cpio/test/test_pathmatch.c bsdcpio_test_CPPFLAGS= -I$(top_builddir)/libarchive -I$(top_srcdir)/libarchive -I$(top_builddir)/cpio/test ==== //depot/projects/soc2008/strauss_libarchive/PROJECTS#4 (text+ko) ==== @@ -4,9 +4,9 @@ on the list. If you think you have time to work on any of these, please let me know. -* mtree format. libarchive can now read mtree files, - though there are still some missing details. The - ability to write mtree format is desirable. +* NetBSD's mtree supports various checksum algorithms. + It would be useful if the reader could verify them and + the writer could compute them. * archive_entry_from_file(). This would be very useful. Ideally, it would accept a pathname (required) and an ==== //depot/projects/soc2008/strauss_libarchive/cpio/cmdline.c#7 (ktext) ==== @@ -26,7 +26,7 @@ #include "cpio_platform.h" -__FBSDID("$FreeBSD: src/usr.bin/cpio/cmdline.c,v 1.3 2008/06/21 02:20:20 kientzle Exp $"); +__FBSDID("$FreeBSD: src/usr.bin/cpio/cmdline.c,v 1.4 2008/07/29 15:23:31 kientzle Exp $"); #ifdef HAVE_ERRNO_H #include @@ -91,6 +91,7 @@ { "link", no_argument, NULL, 'l' }, { "list", no_argument, NULL, 't' }, { "make-directories", no_argument, NULL, 'd' }, + { "no-preserve-owner", no_argument, NULL, OPTION_NO_PRESERVE_OWNER }, { "null", no_argument, NULL, '0' }, { "owner", required_argument, NULL, 'R' }, { "pass-through", no_argument, NULL, 'p' }, ==== //depot/projects/soc2008/strauss_libarchive/cpio/config_freebsd.h#5 (ktext) ==== @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD$ + * $FreeBSD: src/usr.bin/cpio/config_freebsd.h,v 1.2 2008/07/05 05:15:07 kientzle Exp $ */ /* A default configuration for FreeBSD, used if there is no config.h. */ ==== //depot/projects/soc2008/strauss_libarchive/cpio/cpio.c#8 (ktext) ==== @@ -26,7 +26,7 @@ #include "cpio_platform.h" -__FBSDID("$FreeBSD: src/usr.bin/cpio/cpio.c,v 1.4 2008/06/24 15:18:40 kientzle Exp $"); +__FBSDID("$FreeBSD: src/usr.bin/cpio/cpio.c,v 1.12 2008/08/24 06:21:00 kientzle Exp $"); #include #include @@ -111,6 +111,9 @@ cpio->extract_flags |= ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER; cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_SYMLINKS; cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_NODOTDOT; + cpio->extract_flags |= ARCHIVE_EXTRACT_PERM; + cpio->extract_flags |= ARCHIVE_EXTRACT_FFLAGS; + cpio->extract_flags |= ARCHIVE_EXTRACT_ACL; if (geteuid() == 0) cpio->extract_flags |= ARCHIVE_EXTRACT_OWNER; cpio->bytes_per_block = 512; @@ -175,6 +178,9 @@ case 'm': /* POSIX 1997 */ cpio->extract_flags |= ARCHIVE_EXTRACT_TIME; break; + case OPTION_NO_PRESERVE_OWNER: /* GNU cpio */ + cpio->extract_flags &= ~ARCHIVE_EXTRACT_OWNER; + break; case 'O': /* GNU cpio */ cpio->filename = optarg; break; @@ -829,6 +835,7 @@ static void mode_pass(struct cpio *cpio, const char *destdir) { + unsigned long blocks; struct line_reader *lr; const char *p; int r; @@ -857,6 +864,14 @@ 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"); + } + } /* ==== //depot/projects/soc2008/strauss_libarchive/cpio/cpio.h#4 (text+ko) ==== @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/usr.bin/cpio/cpio.h,v 1.2 2008/06/21 02:20:20 kientzle Exp $ + * $FreeBSD: src/usr.bin/cpio/cpio.h,v 1.4 2008/08/04 01:25:48 cperciva Exp $ */ #ifndef CPIO_H_INCLUDED @@ -85,7 +85,7 @@ /* Name of this program; used in error reporting, initialized in main(). */ const char *cpio_progname; -void cpio_errc(int _eval, int _code, const char *fmt, ...); +void cpio_errc(int _eval, int _code, const char *fmt, ...) __dead2; void cpio_warnc(int _code, const char *fmt, ...); int owner_parse(const char *, int *, int *); @@ -94,6 +94,7 @@ /* Fake short equivalents for long options that otherwise lack them. */ enum { OPTION_INSECURE = 1, + OPTION_NO_PRESERVE_OWNER, OPTION_QUIET, OPTION_VERSION }; ==== //depot/projects/soc2008/strauss_libarchive/cpio/test/main.c#7 (ktext) ==== @@ -44,7 +44,7 @@ #undef EXTRA_DUMP /* How to dump extra data */ /* How to generate extra version info. */ #define EXTRA_VERSION (systemf("%s --version", testprog) ? "" : "") -__FBSDID("$FreeBSD: src/usr.bin/cpio/test/main.c,v 1.2 2008/06/21 02:17:18 kientzle Exp $"); +__FBSDID("$FreeBSD: src/usr.bin/cpio/test/main.c,v 1.3 2008/08/24 04:58:22 kientzle Exp $"); /* * "list.h" is simply created by "grep DEFINE_TEST"; it has @@ -598,8 +598,8 @@ va_end(ap); fd = open(f, O_RDONLY); - contents = malloc(s * 2); - n = read(fd, contents, s * 2); + contents = malloc(s * 2 + 128); + n = read(fd, contents, s * 2 + 128); if (n == s && memcmp(buff, contents, s) == 0) { free(contents); return (1); ==== //depot/projects/soc2008/strauss_libarchive/cpio/test/test_basic.c#6 (ktext) ==== @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$"); +__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_basic.c,v 1.4 2008/08/25 06:39:29 kientzle Exp $"); static void verify_files(const char *target) @@ -81,11 +81,25 @@ } } + /* Another file with 1 link and different permissions. */ + r = lstat("file2", &st); + failure("Failed to stat file %s/file2, errno=%d", target, errno); + assertEqualInt(r, 0); + if (r == 0) { + assert(S_ISREG(st.st_mode)); + failure("%s/file2: st.st_mode = %o", target, st.st_mode); + assertEqualInt(0777, st.st_mode & 0777); + assertEqualInt(10, st.st_size); + failure("file %s/file2 should have 1 link", target); + assertEqualInt(1, st.st_nlink); + } + /* dir */ r = lstat("dir", &st); if (r == 0) { assertEqualInt(r, 0); assert(S_ISDIR(st.st_mode)); + failure("%s/dir: st.st_mode = %o", target, st.st_mode); assertEqualInt(0775, st.st_mode & 0777); } } @@ -141,7 +155,7 @@ /* * Use cpio passthrough mode to copy files to another directory. */ - r = systemf("%s -p -W quiet %s %s/stdout 2>%s/stderr", + r = systemf("%s -p %s %s/stdout 2>%s/stderr", testprog, target, target, target); failure("Error invoking %s -p", testprog); assertEqualInt(r, 0); @@ -151,7 +165,7 @@ /* Verify stderr. */ failure("Error invoking %s -p in dir %s", testprog, target); - assertEmptyFile("stderr"); + assertFileContents("1 block\n", 8, "stderr"); verify_files(target); chdir(".."); @@ -185,18 +199,27 @@ assertEqualInt(0, symlink("file", "symlink")); write(filelist, "symlink\n", 8); + /* Another file with different permissions. */ + fd = open("file2", O_CREAT | O_WRONLY, 0777); + assert(fd >= 0); + assertEqualInt(10, write(fd, "123456789", 10)); + close(fd); + write(filelist, "file2\n", 6); + /* Directory. */ assertEqualInt(0, mkdir("dir", 0775)); write(filelist, "dir\n", 4); /* All done. */ close(filelist); + umask(022); + /* Archive/dearchive with a variety of options. */ - basic_cpio("copy", "", "", "1 block\n"); - basic_cpio("copy_odc", "--format=odc", "", "1 block\n"); + 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"); - 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"); ==== //depot/projects/soc2008/strauss_libarchive/cpio/test/test_format_newc.c#6 (ktext) ==== @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$"); +__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_format_newc.c,v 1.2 2008/08/22 02:09:10 kientzle Exp $"); static int is_hex(const char *p, size_t l) @@ -68,7 +68,7 @@ int devmajor, devminor, ino, gid; time_t t, t2, now; char *p, *e; - size_t s; + size_t s, fs, ns; mode_t oldmask; oldmask = umask(0); @@ -141,16 +141,21 @@ " first appearance should be empty, so this file size\n" " field should be zero"); assertEqualInt(0, from_hex(e + 54, 8)); /* File size */ + fs = from_hex(e + 54, 8); + fs += 3 & -fs; devmajor = from_hex(e + 62, 8); /* devmajor */ devminor = from_hex(e + 70, 8); /* devminor */ assert(is_hex(e + 78, 8)); /* rdevmajor */ assert(is_hex(e + 86, 8)); /* rdevminor */ assertEqualMem(e + 94, "00000006", 8); /* Name size */ + ns = from_hex(e + 94, 8); + ns += 3 & (-ns - 2); assertEqualInt(0, from_hex(e + 102, 8)); /* check field */ assertEqualMem(e + 110, "file1\0", 6); /* Name contents */ /* Since there's another link, no file contents here. */ /* But add in file size so that an error here doesn't cascade. */ - e += 116 + from_hex(e + 54, 8) + (3 & -from_hex(e + 54, 8)); + e += 110 + fs + ns; + /* "symlink" pointing to "file1" */ assert(is_hex(e, 110)); assertEqualMem(e + 0, "070701", 6); /* Magic */ @@ -163,15 +168,19 @@ failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2); assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */ assertEqualMem(e + 54, "00000005", 8); /* File size */ + fs = from_hex(e + 54, 8); + fs += 3 & -fs; assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */ assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */ assert(is_hex(e + 78, 8)); /* rdevmajor */ assert(is_hex(e + 86, 8)); /* rdevminor */ assertEqualMem(e + 94, "00000008", 8); /* Name size */ + ns = from_hex(e + 94, 8); + ns += 3 & (-ns - 2); assertEqualInt(0, from_hex(e + 102, 8)); /* check field */ assertEqualMem(e + 110, "symlink\0\0\0", 10); /* Name contents */ - assertEqualMem(e + 120, "file1\0\0\0", 8); /* symlink target */ - e += 120 + from_hex(e + 54, 8) + (3 & -from_hex(e + 54, 8)); + assertEqualMem(e + 110 + ns, "file1\0\0\0", 8); /* symlink target */ + e += 110 + fs + ns; /* "dir" */ assert(is_hex(e, 110)); @@ -185,16 +194,18 @@ failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2); assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */ assertEqualMem(e + 54, "00000000", 8); /* File size */ + fs = from_hex(e + 54, 8); + fs += 3 & -fs; assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */ assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */ assert(is_hex(e + 78, 8)); /* rdevmajor */ assert(is_hex(e + 86, 8)); /* rdevminor */ assertEqualMem(e + 94, "00000004", 8); /* Name size */ + ns = from_hex(e + 94, 8); + ns += 3 & (-ns - 2); assertEqualInt(0, from_hex(e + 102, 8)); /* check field */ assertEqualMem(e + 110, "dir\0\0\0", 6); /* Name contents */ - e += 116; - - /* TODO: Verify other types of entries. */ + e += 110 + fs + ns; /* Hardlink identical to "file1" */ /* Since we only wrote two of the three links to this @@ -211,15 +222,19 @@ failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2); assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */ assertEqualInt(10, from_hex(e + 54, 8)); /* File size */ + fs = from_hex(e + 54, 8); + fs += 3 & -fs; assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */ assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */ assert(is_hex(e + 78, 8)); /* rdevmajor */ assert(is_hex(e + 86, 8)); /* rdevminor */ assertEqualMem(e + 94, "00000009", 8); /* Name size */ + ns = from_hex(e + 94, 8); + ns += 3 & (-ns - 2); assertEqualInt(0, from_hex(e + 102, 8)); /* check field */ assertEqualMem(e + 110, "hardlink\0\0", 10); /* Name contents */ - assertEqualMem(e + 120, "123456789\0\0\0", 12); /* File contents */ - e += 120 + from_hex(e + 54, 8) + (3 & -from_hex(e + 54, 8)); + assertEqualMem(e + 110 + ns, "123456789\0\0\0", 12); /* File contents */ + e += 110 + ns + fs; /* Last entry is end-of-archive marker. */ assert(is_hex(e, 110)); ==== //depot/projects/soc2008/strauss_libarchive/cpio/test/test_gcpio_compat.c#6 (ktext) ==== @@ -23,8 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$"); - +__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_gcpio_compat.c,v 1.2 2008/08/22 02:27:06 kientzle Exp $"); static void unpack_test(const char *from, const char *options, const char *se) @@ -48,6 +47,7 @@ assertEqualInt(r, 0); /* Verify that nothing went to stderr. */ + failure("Error invoking %s -i %s < %s", testprog, options, from); assertFileContents(se, strlen(se), "unpack.err"); /* @@ -121,6 +121,7 @@ unpack_test("test_gcpio_compat_ref.bin", "", "1 block\n"); unpack_test("test_gcpio_compat_ref.crc", "", "2 blocks\n"); unpack_test("test_gcpio_compat_ref.newc", "", "2 blocks\n"); + /* gcpio-2.9 only reads 6 blocks here */ unpack_test("test_gcpio_compat_ref.ustar", "", "7 blocks\n"); umask(oldumask); ==== //depot/projects/soc2008/strauss_libarchive/cpio/test/test_option_L.c#6 (ktext) ==== @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$"); +__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 @@ 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)); ==== //depot/projects/soc2008/strauss_libarchive/cpio/test/test_option_a.c#6 (ktext) ==== @@ -24,7 +24,7 @@ */ #include "test.h" #include -__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$"); +__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,7 +118,7 @@ /* 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); - 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."); @@ -127,7 +127,7 @@ /* 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); @@ -142,7 +142,7 @@ 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."); @@ -152,7 +152,7 @@ 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); ==== //depot/projects/soc2008/strauss_libarchive/cpio/test/test_option_y.c#6 (ktext) ==== @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$"); +__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 @@ /* 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); ==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive.h#6 (ktext) ==== @@ -247,8 +247,6 @@ #define ARCHIVE_FORMAT_AR_GNU (ARCHIVE_FORMAT_AR | 1) #define ARCHIVE_FORMAT_AR_BSD (ARCHIVE_FORMAT_AR | 2) #define ARCHIVE_FORMAT_MTREE 0x80000 -#define ARCHIVE_FORMAT_MTREE_V1 (ARCHIVE_FORMAT_MTREE | 1) -#define ARCHIVE_FORMAT_MTREE_V2 (ARCHIVE_FORMAT_MTREE | 2) /*- * Basic outline for reading an archive: @@ -465,13 +463,13 @@ __LA_DECL int archive_write_set_format_ar_svr4(struct archive *); __LA_DECL int archive_write_set_format_cpio(struct archive *); __LA_DECL int archive_write_set_format_cpio_newc(struct archive *); +__LA_DECL int archive_write_set_format_mtree(struct archive *); /* TODO: int archive_write_set_format_old_tar(struct archive *); */ __LA_DECL int archive_write_set_format_pax(struct archive *); __LA_DECL int archive_write_set_format_pax_restricted(struct archive *); __LA_DECL int archive_write_set_format_shar(struct archive *); __LA_DECL int archive_write_set_format_shar_dump(struct archive *); __LA_DECL int archive_write_set_format_ustar(struct archive *); -__LA_DECL int archive_write_set_format_zip(struct archive *); __LA_DECL int archive_write_open(struct archive *, void *, archive_open_callback *, archive_write_callback *, archive_close_callback *); ==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry.c#7 (ktext) ==== @@ -24,7 +24,7 @@ */ #include "archive_platform.h" -__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry.c,v 1.52 2008/05/26 17:00:22 kientzle Exp $"); #ifdef HAVE_SYS_STAT_H #include @@ -395,8 +395,7 @@ aes_copy(&entry2->ae_hardlink, &entry->ae_hardlink); aes_copy(&entry2->ae_pathname, &entry->ae_pathname); aes_copy(&entry2->ae_symlink, &entry->ae_symlink); - entry2->ae_hardlinkset = entry->ae_hardlinkset; - entry2->ae_symlinkset = entry->ae_symlinkset; + entry2->ae_set = entry->ae_set; aes_copy(&entry2->ae_uname, &entry->ae_uname); /* Copy ACL data over. */ @@ -455,6 +454,12 @@ return (entry->ae_stat.aest_atime_nsec); } +int +archive_entry_atime_is_set(struct archive_entry *entry) +{ + return (entry->ae_set & AE_SET_ATIME); +} + time_t archive_entry_ctime(struct archive_entry *entry) { @@ -562,17 +567,17 @@ const char * archive_entry_hardlink(struct archive_entry *entry) { - if (!entry->ae_hardlinkset) - return (NULL); - return (aes_get_mbs(&entry->ae_hardlink)); + if (entry->ae_set & AE_SET_HARDLINK) + return (aes_get_mbs(&entry->ae_hardlink)); + return (NULL); } const wchar_t * archive_entry_hardlink_w(struct archive_entry *entry) { - if (!entry->ae_hardlinkset) - return (NULL); - return (aes_get_wcs(&entry->ae_hardlink)); + if (entry->ae_set & AE_SET_HARDLINK) + return (aes_get_wcs(&entry->ae_hardlink)); + return (NULL); } ino_t @@ -651,6 +656,12 @@ return (entry->ae_stat.aest_size); } +int +archive_entry_size_is_set(struct archive_entry *entry) +{ + return (entry->ae_set & AE_SET_SIZE); +} + const char * archive_entry_sourcepath(struct archive_entry *entry) { @@ -660,17 +671,17 @@ const char * archive_entry_symlink(struct archive_entry *entry) { - if (!entry->ae_symlinkset) - return (NULL); - return (aes_get_mbs(&entry->ae_symlink)); + if (entry->ae_set & AE_SET_SYMLINK) + return (aes_get_mbs(&entry->ae_symlink)); + return (NULL); } const wchar_t * archive_entry_symlink_w(struct archive_entry *entry) { - if (!entry->ae_symlinkset) - return (NULL); - return (aes_get_wcs(&entry->ae_symlink)); + if (entry->ae_set & AE_SET_SYMLINK) + return (aes_get_wcs(&entry->ae_symlink)); + return (NULL); } uid_t @@ -773,7 +784,9 @@ { aes_set_mbs(&entry->ae_hardlink, target); if (target != NULL) - entry->ae_hardlinkset = 1; + entry->ae_set |= AE_SET_HARDLINK; + else + entry->ae_set &= ~AE_SET_HARDLINK; } void @@ -781,7 +794,9 @@ { aes_copy_mbs(&entry->ae_hardlink, target); if (target != NULL) - entry->ae_hardlinkset = 1; + entry->ae_set |= AE_SET_HARDLINK; + else + entry->ae_set &= ~AE_SET_HARDLINK; } void @@ -789,13 +804,16 @@ { aes_copy_wcs(&entry->ae_hardlink, target); if (target != NULL) - entry->ae_hardlinkset = 1; + entry->ae_set |= AE_SET_HARDLINK; + else + entry->ae_set &= ~AE_SET_HARDLINK; } void archive_entry_set_atime(struct archive_entry *entry, time_t t, long ns) { entry->stat_valid = 0; + entry->ae_set |= AE_SET_ATIME; entry->ae_stat.aest_atime = t; entry->ae_stat.aest_atime_nsec = ns; } @@ -836,7 +854,7 @@ void archive_entry_set_link(struct archive_entry *entry, const char *target) { - if (entry->ae_symlinkset) + if (entry->ae_set & AE_SET_SYMLINK) aes_set_mbs(&entry->ae_symlink, target); else aes_set_mbs(&entry->ae_hardlink, target); @@ -846,7 +864,7 @@ void archive_entry_copy_link(struct archive_entry *entry, const char *target) { - if (entry->ae_symlinkset) + if (entry->ae_set & AE_SET_SYMLINK) aes_copy_mbs(&entry->ae_symlink, target); else aes_copy_mbs(&entry->ae_hardlink, target); @@ -856,7 +874,7 @@ void archive_entry_copy_link_w(struct archive_entry *entry, const wchar_t *target) { - if (entry->ae_symlinkset) + if (entry->ae_set & AE_SET_SYMLINK) aes_copy_wcs(&entry->ae_symlink, target); else aes_copy_wcs(&entry->ae_hardlink, target); @@ -865,7 +883,7 @@ int archive_entry_update_link_utf8(struct archive_entry *entry, const char *target) { - if (entry->ae_symlinkset) + if (entry->ae_set & AE_SET_SYMLINK) return (aes_update_utf8(&entry->ae_symlink, target)); else return (aes_update_utf8(&entry->ae_hardlink, target)); @@ -954,6 +972,14 @@ { entry->stat_valid = 0; entry->ae_stat.aest_size = s; + entry->ae_set |= AE_SET_SIZE; +} + +void +archive_entry_unset_size(struct archive_entry *entry) +{ + archive_entry_set_size(entry, 0); + entry->ae_set &= ~AE_SET_SIZE; } void @@ -967,7 +993,9 @@ { aes_set_mbs(&entry->ae_symlink, linkname); if (linkname != NULL) - entry->ae_symlinkset = 1; + entry->ae_set |= AE_SET_SYMLINK; + else + entry->ae_set &= ~AE_SET_SYMLINK; } void @@ -975,7 +1003,9 @@ { aes_copy_mbs(&entry->ae_symlink, linkname); if (linkname != NULL) - entry->ae_symlinkset = 1; + entry->ae_set |= AE_SET_SYMLINK; + else + entry->ae_set &= ~AE_SET_SYMLINK; } void @@ -983,7 +1013,9 @@ { aes_copy_wcs(&entry->ae_symlink, linkname); if (linkname != NULL) - entry->ae_symlinkset = 1; + entry->ae_set |= AE_SET_SYMLINK; + else + entry->ae_set &= ~AE_SET_SYMLINK; } void ==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry.h#5 (ktext) ==== @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2003-2008 Tim Kientzle * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id$ $Change: 143014 $ $DateTime$ $Author$ + * $FreeBSD: src/lib/libarchive/archive_entry.h,v 1.27 2008/05/26 17:00:22 kientzle Exp $ */ #ifndef ARCHIVE_ENTRY_H_INCLUDED @@ -152,10 +152,26 @@ /* * Retrieve fields from an archive_entry. + * + * There are a number of implicit conversions among these fields. For + * example, if a regular string field is set and you read the _w wide + * character field, the entry will implicitly convert narrow-to-wide + * using the current locale. Similarly, dev values are automatically + * updated when you write devmajor or devminor and vice versa. + * + * In addition, fields can be "set" or "unset." Unset string fields + * return NULL, non-string fields have _is_set() functions to test + * whether they've been set. You can "unset" a string field by + * assigning NULL; there is currently no way to unset a non-string + * field. + * + * Note: There is one ambiguity in the above; string fields will + * also return NULL when implicit character set conversions fail. + * This is usually what you want. */ - __LA_DECL time_t archive_entry_atime(struct archive_entry *); __LA_DECL long archive_entry_atime_nsec(struct archive_entry *); +__LA_DECL int archive_entry_atime_is_set(struct archive_entry *); __LA_DECL time_t archive_entry_ctime(struct archive_entry *); __LA_DECL long archive_entry_ctime_nsec(struct archive_entry *); __LA_DECL dev_t archive_entry_dev(struct archive_entry *); @@ -183,6 +199,7 @@ __LA_DECL dev_t archive_entry_rdevminor(struct archive_entry *); __LA_DECL const char *archive_entry_sourcepath(struct archive_entry *); __LA_DECL int64_t archive_entry_size(struct archive_entry *); +__LA_DECL int archive_entry_size_is_set(struct archive_entry *); __LA_DECL const char *archive_entry_strmode(struct archive_entry *); __LA_DECL const char *archive_entry_symlink(struct archive_entry *); __LA_DECL const wchar_t *archive_entry_symlink_w(struct archive_entry *); @@ -195,6 +212,10 @@ * * Note that string 'set' functions do not copy the string, only the pointer. * In contrast, 'copy' functions do copy the object pointed to. + * + * Note: As of libarchive 2.4, 'set' functions do copy the string and + * are therefore exact synonyms for the 'copy' versions. The 'copy' + * names will be retired in libarchive 3.0. */ __LA_DECL void archive_entry_set_atime(struct archive_entry *, time_t, long); @@ -236,6 +257,7 @@ __LA_DECL void archive_entry_set_rdevmajor(struct archive_entry *, dev_t); __LA_DECL void archive_entry_set_rdevminor(struct archive_entry *, dev_t); __LA_DECL void archive_entry_set_size(struct archive_entry *, int64_t); +__LA_DECL void archive_entry_unset_size(struct archive_entry *); __LA_DECL void archive_entry_copy_sourcepath(struct archive_entry *, const char *); __LA_DECL void archive_entry_set_symlink(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_symlink(struct archive_entry *, const char *); ==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry_link_resolver.c#8 (ktext) ==== @@ -189,7 +189,7 @@ case ARCHIVE_ENTRY_LINKIFY_LIKE_TAR: le = find_entry(res, *e); if (le != NULL) { - archive_entry_set_size(*e, 0); + archive_entry_unset_size(*e); archive_entry_copy_hardlink(*e, archive_entry_pathname(le->canonical)); } else @@ -217,7 +217,7 @@ *e = le->entry; le->entry = t; /* Make the old entry into a hardlink. */ - archive_entry_set_size(*e, 0); + archive_entry_unset_size(*e); archive_entry_copy_hardlink(*e, archive_entry_pathname(le->canonical)); /* If we ran out of links, return the ==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry_private.h#5 (ktext) ==== @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id$ $Change: 143014 $ $DateTime$ $Author$ + * $FreeBSD: src/lib/libarchive/archive_entry_private.h,v 1.4 2008/05/26 17:00:22 kientzle Exp $ */ #ifndef ARCHIVE_ENTRY_PRIVATE_H_INCLUDED @@ -136,6 +136,12 @@ dev_t aest_rdevminor; } ae_stat; + int ae_set; /* bitmap of fields that are currently set */ +#define AE_SET_HARDLINK 1 +#define AE_SET_SYMLINK 2 +#define AE_SET_ATIME 4 +#define AE_SET_SIZE 32 + /* * Use aes here so that we get transparent mbs<->wcs conversions. */ @@ -147,8 +153,6 @@ struct aes ae_pathname; /* Name of entry */ struct aes ae_symlink; /* symlink contents */ struct aes ae_uname; /* Name of owner */ - unsigned char ae_hardlinkset; - unsigned char ae_symlinkset; /* Not used within libarchive; useful for some clients. */ struct aes ae_sourcepath; /* Path this entry is sourced from. */ >>> TRUNCATED FOR MAIL (1000 lines) <<<