summaryrefslogtreecommitdiffstats
path: root/lib/libarchive
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2009-09-08 04:52:12 +0000
committerkientzle <kientzle@FreeBSD.org>2009-09-08 04:52:12 +0000
commitaefa5719c9febd5d7d43ffb17e2f771ff9ccccea (patch)
tree2c77395ece6abe0e45e4d88e3e10f7e74f4bc765 /lib/libarchive
parent1128849cbd3e378ce3d0fefc6184da647f1bc080 (diff)
downloadFreeBSD-src-aefa5719c9febd5d7d43ffb17e2f771ff9ccccea.zip
FreeBSD-src-aefa5719c9febd5d7d43ffb17e2f771ff9ccccea.tar.gz
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.
Diffstat (limited to 'lib/libarchive')
-rw-r--r--lib/libarchive/archive_read_support_format_iso9660.c29
-rw-r--r--lib/libarchive/test/test_read_format_isojoliet_bz2.c27
-rw-r--r--lib/libarchive/test/test_read_format_isorr_bz2.c2
3 files changed, 40 insertions, 18 deletions
diff --git a/lib/libarchive/archive_read_support_format_iso9660.c b/lib/libarchive/archive_read_support_format_iso9660.c
index eaa0f89..efc39b4 100644
--- a/lib/libarchive/archive_read_support_format_iso9660.c
+++ b/lib/libarchive/archive_read_support_format_iso9660.c
@@ -571,9 +571,13 @@ archive_read_format_iso9660_read_header(struct archive_read *a,
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(struct archive_read *a,
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 archive_read *a,
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.
*/
diff --git a/lib/libarchive/test/test_read_format_isojoliet_bz2.c b/lib/libarchive/test/test_read_format_isojoliet_bz2.c
index 7b11bbb..9ee87c9 100644
--- a/lib/libarchive/test/test_read_format_isojoliet_bz2.c
+++ b/lib/libarchive/test/test_read_format_isojoliet_bz2.c
@@ -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));
}
diff --git a/lib/libarchive/test/test_read_format_isorr_bz2.c b/lib/libarchive/test/test_read_format_isorr_bz2.c
index cd53c7c..250019f 100644
--- a/lib/libarchive/test/test_read_format_isorr_bz2.c
+++ b/lib/libarchive/test/test_read_format_isorr_bz2.c
@@ -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);
OpenPOWER on IntegriCloud