From owner-svn-src-all@FreeBSD.ORG Tue Sep 8 04:52:13 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 22149106566C; Tue, 8 Sep 2009 04:52:13 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 060F88FC15; Tue, 8 Sep 2009 04:52:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n884qCNr036197; Tue, 8 Sep 2009 04:52:12 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n884qC2n036193; Tue, 8 Sep 2009 04:52:12 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <200909080452.n884qC2n036193@svn.freebsd.org> From: Tim Kientzle Date: Tue, 8 Sep 2009 04:52:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196961 - in head/lib/libarchive: . test X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2009 04:52:13 -0000 Author: kientzle Date: Tue Sep 8 04:52:12 2009 New Revision: 196961 URL: http://svn.freebsd.org/changeset/base/196961 Log: Update tests to match r195873, which corrected how hardlinked files on iso9660 images were returned. While I'm poking around, update some comments around this area to try to clarify what's going on and what still remains to be improved. Modified: head/lib/libarchive/archive_read_support_format_iso9660.c head/lib/libarchive/test/test_read_format_isojoliet_bz2.c head/lib/libarchive/test/test_read_format_isorr_bz2.c Modified: head/lib/libarchive/archive_read_support_format_iso9660.c ============================================================================== --- head/lib/libarchive/archive_read_support_format_iso9660.c Tue Sep 8 04:08:14 2009 (r196960) +++ head/lib/libarchive/archive_read_support_format_iso9660.c Tue Sep 8 04:52:12 2009 (r196961) @@ -571,9 +571,13 @@ archive_read_format_iso9660_read_header( if (file->symlink.s != NULL) archive_entry_copy_symlink(entry, file->symlink.s); - /* If this entry points to the same data as the previous - * entry, convert this into a hardlink to that entry. - * But don't bother for zero-length files. */ + /* Note: If the input isn't seekable, we can't rewind to + * return the same body again, so if the next entry refers to + * the same data, we have to return it as a hardlink to the + * original entry. */ + /* TODO: We have enough information here to compute an + * accurate value for nlinks. We should do so and ignore + * nlinks from the RR extensions. */ if (file->offset == iso9660->previous_offset && file->size == iso9660->previous_size && file->size > 0) { @@ -586,8 +590,21 @@ archive_read_format_iso9660_read_header( return (ARCHIVE_OK); } - /* If the offset is before our current position, we can't - * seek backwards to extract it, so issue a warning. */ + /* Except for the hardlink case above, if the offset of the + * next entry is before our current position, we can't seek + * backwards to extract it, so issue a warning. Note that + * this can only happen if this entry was added to the heap + * after we passed this offset, that is, only if the directory + * mentioning this entry is later than the body of the entry. + * Such layouts are very unusual; most ISO9660 writers lay out + * and record all directory information first, then store + * all file bodies. */ + /* TODO: Someday, libarchive's I/O core will support optional + * seeking. When that day comes, this code should attempt to + * seek and only return the error if the seek fails. That + * will give us support for whacky ISO images that require + * seeking while retaining the ability to read almost all ISO + * images in a streaming fashion. */ if (file->offset < iso9660->current_position) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Ignoring out-of-order file @%x (%s) %jd < %jd", @@ -628,7 +645,7 @@ archive_read_format_iso9660_read_header( struct file_info *child; /* N.B.: these special directory identifiers - * are 8 bit "values" even on a + * are 8 bit "values" even on a * Joliet CD with UCS-2 (16bit) encoding. */ Modified: head/lib/libarchive/test/test_read_format_isojoliet_bz2.c ============================================================================== --- head/lib/libarchive/test/test_read_format_isojoliet_bz2.c Tue Sep 8 04:08:14 2009 (r196960) +++ head/lib/libarchive/test/test_read_format_isojoliet_bz2.c Tue Sep 8 04:52:12 2009 (r196961) @@ -107,14 +107,12 @@ joliettest(int withrr) assertEqualInt(2, archive_entry_gid(ae)); } - /* A hardlink to the regular file. */ + /* A regular file with two names ("hardlink" gets returned + * first, so it's not marked as a hardlink). */ assertEqualInt(0, archive_read_next_header(a, &ae)); assertEqualString("hardlink", archive_entry_pathname(ae)); assert(S_ISREG(archive_entry_stat(ae)->st_mode)); - if (withrr) { - assertEqualString("long-joliet-file-name.textfile", - archive_entry_hardlink(ae)); - } + assert(archive_entry_hardlink(ae) == NULL); assertEqualInt(6, archive_entry_size(ae)); assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset)); assertEqualInt(6, (int)size); @@ -123,20 +121,27 @@ joliettest(int withrr) if (withrr) { assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(86401, archive_entry_atime(ae)); - assertEqualInt(2, archive_entry_stat(ae)->st_nlink); + /* TODO: Actually, libarchive should be able to + * compute nlinks correctly even without RR + * extensions. See comments in libarchive source. */ + assertEqualInt(2, archive_entry_nlink(ae)); assertEqualInt(1, archive_entry_uid(ae)); assertEqualInt(2, archive_entry_gid(ae)); } - /* A regular file. */ + /* Second name for the same regular file (this happens to be + * returned second, so does get marked as a hardlink). */ assertEqualInt(0, archive_read_next_header(a, &ae)); - assertEqualString("long-joliet-file-name.textfile", archive_entry_pathname(ae)); + assertEqualString("long-joliet-file-name.textfile", + archive_entry_pathname(ae)); assert(S_ISREG(archive_entry_stat(ae)->st_mode)); - assertEqualInt(6, archive_entry_size(ae)); + assertEqualString("hardlink", archive_entry_hardlink(ae)); + assert(!archive_entry_size_is_set(ae)); if (withrr) { assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(86401, archive_entry_atime(ae)); - assertEqualInt(2, archive_entry_stat(ae)->st_nlink); + /* TODO: See above. */ + assertEqualInt(2, archive_entry_nlink(ae)); assertEqualInt(1, archive_entry_uid(ae)); assertEqualInt(2, archive_entry_gid(ae)); } @@ -153,7 +158,7 @@ joliettest(int withrr) assertEqualInt(172802, archive_entry_mtime(ae)); assertEqualInt(172802, archive_entry_atime(ae)); if (withrr) { - assertEqualInt(1, archive_entry_stat(ae)->st_nlink); + assertEqualInt(1, archive_entry_nlink(ae)); assertEqualInt(1, archive_entry_uid(ae)); assertEqualInt(2, archive_entry_gid(ae)); } Modified: head/lib/libarchive/test/test_read_format_isorr_bz2.c ============================================================================== --- head/lib/libarchive/test/test_read_format_isorr_bz2.c Tue Sep 8 04:08:14 2009 (r196960) +++ head/lib/libarchive/test/test_read_format_isorr_bz2.c Tue Sep 8 04:52:12 2009 (r196961) @@ -111,7 +111,7 @@ DEFINE_TEST(test_read_format_isorr_bz2) assertEqualString("hardlink", archive_entry_pathname(ae)); assert(S_ISREG(archive_entry_stat(ae)->st_mode)); assertEqualString("file", archive_entry_hardlink(ae)); - assertEqualInt(12345684, archive_entry_size(ae)); + assert(!archive_entry_size_is_set(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(86401, archive_entry_atime(ae)); assertEqualInt(2, archive_entry_stat(ae)->st_nlink);