mkdir /tmp/iso
mkdir /tmp/iso/dir
echo "hello" >/tmp/iso/file
-dd if=/dev/zero bs=1 count=12345678 >>/tmp/iso/file
+dd if=/dev/zero count=1 bs=12345678 >>/tmp/iso/file
ln /tmp/iso/file /tmp/iso/hardlink
(cd /tmp/iso; ln -s file symlink)
+(cd /tmp/iso; ln -s /tmp/ symlink2)
+(cd /tmp/iso; ln -s /tmp/../ symlink3)
+(cd /tmp/iso; ln -s .././../tmp/ symlink4)
TZ=utc touch -afhm -t 197001020000.01 /tmp/iso /tmp/iso/file /tmp/iso/dir
TZ=utc touch -afhm -t 197001030000.02 /tmp/iso/symlink
mkhybrid -R -uid 1 -gid 2 /tmp/iso | bzip2 > test_read_format_isorr_bz2.iso.bz2
const void *p;
size_t size;
off_t offset;
+ int i;
int r;
extract_reference_file(refname);
assertEqualInt(ARCHIVE_OK,
archive_read_open_filename(a, refname, 10240));
- /* First entry is '.' root directory. */
- assertEqualInt(0, archive_read_next_header(a, &ae));
- assertEqualString(".", archive_entry_pathname(ae));
- assert(S_ISDIR(archive_entry_stat(ae)->st_mode));
- assertEqualInt(2048, archive_entry_size(ae));
- assertEqualInt(86401, archive_entry_mtime(ae));
- assertEqualInt(0, archive_entry_mtime_nsec(ae));
- assertEqualInt(86401, archive_entry_ctime(ae));
- assertEqualInt(0, archive_entry_stat(ae)->st_nlink);
- assertEqualInt(0, archive_entry_uid(ae));
- assertEqualIntA(a, ARCHIVE_EOF,
- archive_read_data_block(a, &p, &size, &offset));
- assertEqualInt((int)size, 0);
+ /* Retrieve each of the 8 files on the ISO image and
+ * verify that each one is what we expect. */
+ for (i = 0; i < 8; ++i) {
+ assertEqualInt(0, archive_read_next_header(a, &ae));
- /* A directory. */
- assertEqualInt(0, archive_read_next_header(a, &ae));
- assertEqualString("dir", archive_entry_pathname(ae));
- assert(S_ISDIR(archive_entry_stat(ae)->st_mode));
- assertEqualInt(2048, archive_entry_size(ae));
- assertEqualInt(86401, archive_entry_mtime(ae));
- assertEqualInt(86401, archive_entry_atime(ae));
- assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
- assertEqualInt(1, archive_entry_uid(ae));
- assertEqualInt(2, archive_entry_gid(ae));
-
- /* A regular file. */
- assertEqualInt(0, archive_read_next_header(a, &ae));
- assertEqualString("file", archive_entry_pathname(ae));
- assert(S_ISREG(archive_entry_stat(ae)->st_mode));
- assertEqualInt(12345684, archive_entry_size(ae));
- assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset));
- assertEqualInt(0, offset);
- assertEqualMem(p, "hello\n", 6);
- assertEqualInt(86401, archive_entry_mtime(ae));
- assertEqualInt(86401, archive_entry_atime(ae));
- assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
- assertEqualInt(1, archive_entry_uid(ae));
- assertEqualInt(2, archive_entry_gid(ae));
-
- /* A hardlink to the regular file. */
- assertEqualInt(0, archive_read_next_header(a, &ae));
- 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));
- assertEqualInt(86401, archive_entry_mtime(ae));
- assertEqualInt(86401, archive_entry_atime(ae));
- assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
- assertEqualInt(1, archive_entry_uid(ae));
- assertEqualInt(2, archive_entry_gid(ae));
-
- /* A symlink to the regular file. */
- assertEqualInt(0, archive_read_next_header(a, &ae));
- assertEqualString("symlink", archive_entry_pathname(ae));
- assert(S_ISLNK(archive_entry_stat(ae)->st_mode));
- assertEqualString("file", archive_entry_symlink(ae));
- assertEqualInt(0, archive_entry_size(ae));
- assertEqualInt(172802, archive_entry_mtime(ae));
- assertEqualInt(172802, archive_entry_atime(ae));
- assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
- assertEqualInt(1, archive_entry_uid(ae));
- assertEqualInt(2, archive_entry_gid(ae));
+ if (strcmp(".", archive_entry_pathname(ae)) == 0) {
+ /* '.' root directory. */
+ assert(S_ISDIR(archive_entry_stat(ae)->st_mode));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(0, archive_entry_mtime_nsec(ae));
+ assertEqualInt(86401, archive_entry_ctime(ae));
+ assertEqualInt(0, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(0, archive_entry_uid(ae));
+ assertEqualIntA(a, ARCHIVE_EOF,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt((int)size, 0);
+ } else if (strcmp("dir", archive_entry_pathname(ae)) == 0) {
+ /* A directory. */
+ assertEqualString("dir", archive_entry_pathname(ae));
+ assert(S_ISDIR(archive_entry_stat(ae)->st_mode));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("file", archive_entry_pathname(ae)) == 0) {
+ /* A regular file. */
+ assertEqualString("file", archive_entry_pathname(ae));
+ assert(S_ISREG(archive_entry_stat(ae)->st_mode));
+ assertEqualInt(12345684, archive_entry_size(ae));
+ assertEqualInt(0,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt(0, offset);
+ assertEqualMem(p, "hello\n", 6);
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("hardlink", archive_entry_pathname(ae)) == 0) {
+ /* A hardlink to the regular file. */
+ /* Note: If "hardlink" gets returned before "file",
+ * then "hardlink" will get returned as a regular file
+ * and "file" will get returned as the hardlink.
+ * This test should tolerate that, since it's a
+ * perfectly permissible thing for libarchive to do. */
+ assertEqualString("hardlink", archive_entry_pathname(ae));
+ assert(S_ISREG(archive_entry_stat(ae)->st_mode));
+ assertEqualString("file", archive_entry_hardlink(ae));
+ assertEqualInt(0, archive_entry_size_is_set(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to the regular file. */
+ assert(S_ISLNK(archive_entry_stat(ae)->st_mode));
+ assertEqualString("file", archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(172802, archive_entry_mtime(ae));
+ assertEqualInt(172802, archive_entry_atime(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink2", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to /tmp (an absolute path) */
+ assert(S_ISLNK(archive_entry_stat(ae)->st_mode));
+ assertEqualString("/tmp", archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink3", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to /tmp/.. (with a ".." component) */
+ assert(S_ISLNK(archive_entry_stat(ae)->st_mode));
+ assertEqualString("/tmp/..", archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink4", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to a path with ".." and "." components */
+ assert(S_ISLNK(archive_entry_stat(ae)->st_mode));
+ assertEqualString(".././../tmp",
+ archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else {
+ failure("Saw a file that shouldn't have been there");
+ assertEqualString(archive_entry_pathname(ae), "");
+ }
+ }
/* End of archive. */
assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
/* Close the archive. */
assertEqualInt(0, archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
- archive_read_finish(a);
-#else
assertEqualInt(0, archive_read_finish(a));
-#endif
}
begin 644 test_read_format_isorr_bz2.iso.bz2
-M0EIH.3%!629363S[0-4``,?_W?__R_158__Z/__?8*?OWB8AZB2```4@`,0"
-M@0C0`SX`6UH$P:F@32FCU-D1Z@#U'J!HT>H#0`!H`T9`#U-#33(-`-3TFA#1
-MJ933TFR%#(&@`#0-````'J`T``,.-#1HT&C0-``````R````-`9``8<:&C1H
-M-&@:`````!D````:`R``P1*(1$]3U,C(--``T!H:9``````:``&F)?&F1;DY
-M&:FB?6\AB@WG9X@8AM,HTK/Q9EXPZD#E2A$D)(@;F(G^B.92GLB`=H@`+I1!
-M1$`';Y%%P_YU^!0+8BJ(@#DC&D@D4"1D4?Z1!$1`&Z`V[]0H($(!6L90;<NF
-M9^?26V%/AEU/G]J7$.#!IBC,>:>A0V<))<GYB`(B`.INK=BX9"_=9R*"<::E
-MFLK=4PYO'Q\%X>XH7BH%"KAF8!:H8<BRI_..!GF=:H4'$TR7@-X.M"X!J02@
-M$"QE&OW!J]D&9@$]-M!R8/GDX=A>\].K:4`Y`,4,!RN:#SL[!;-"!6%0F?`H
-M2_2AM@*%/%<\*!XL/C2%A1AI$8/AF(#SZ;]:>$5^/NKNO<+EH@_CS4XUI(Q*
-M123&G=9T]QQR?"=WMV(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