]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Warn if target of hard-link is not present
authorGraham Percival <gperciva@tarsnap.com>
Sun, 30 Aug 2015 17:53:12 +0000 (10:53 -0700)
committerGraham Percival <gperciva@tarsnap.com>
Thu, 3 Sep 2015 05:05:38 +0000 (22:05 -0700)
To reproduce,

        touch a
        ln a b
        ./bsdtar -c -f warn-hard-links.tar a b
        rm a b
        ./bsdtar -x -f warn-hard-links.tar b

should produce a warning message about failing to create 'b' because the
hard-link target 'a' does not exist.  Previously, it did not give any hints
about why 'b' could not be created.

libarchive/archive_write_disk_posix.c

index 102bab9568ab3dc2044679c9abfa4fdaf4bf2525..0fc61930c2ed8449d12fe56223082c67be9e2e04 100644 (file)
@@ -1876,6 +1876,13 @@ restore_entry(struct archive_write_disk *a)
                en = create_filesystem_object(a);
        }
 
+       if ((en == ENOENT) && (archive_entry_hardlink(a->entry) != NULL)) {
+               archive_set_error(&a->archive, en,
+                   "Hard-link target '%s' does not exist.",
+                   archive_entry_hardlink(a->entry));
+               return (ARCHIVE_FAILED);
+       }
+
        if ((en == EISDIR || en == EEXIST)
            && (a->flags & ARCHIVE_EXTRACT_NO_OVERWRITE)) {
                /* If we're not overwriting, we're done. */