From: Graham Percival Date: Sun, 30 Aug 2015 17:53:12 +0000 (-0700) Subject: Warn if target of hard-link is not present X-Git-Tag: v3.1.900a~69^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99d593a43dc33267a79537b3c6de7bee5949054e;p=thirdparty%2Flibarchive.git Warn if target of hard-link is not present 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. --- diff --git a/libarchive/archive_write_disk_posix.c b/libarchive/archive_write_disk_posix.c index 102bab956..0fc61930c 100644 --- a/libarchive/archive_write_disk_posix.c +++ b/libarchive/archive_write_disk_posix.c @@ -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. */