Fix tar hard links

This commit is contained in:
Glenn L McGrath 2003-11-27 00:01:43 +00:00
parent fea4b446df
commit e39ee01821
2 changed files with 5 additions and 5 deletions

View File

@ -66,8 +66,9 @@ extern void data_extract_all(archive_handle_t *archive_handle)
} }
} }
/* Handle hard links seperately */ /* Handle hard links seperately
if (!S_ISLNK(file_header->mode) && (file_header->link_name) && (file_header->size == 0)) { * We identified hard links as regular files of size 0 with a symlink */
if (S_ISREG(file_header->mode) && (file_header->link_name) && (file_header->size == 0)) {
/* hard link */ /* hard link */
res = link(file_header->link_name, file_header->name); res = link(file_header->link_name, file_header->name);
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {

View File

@ -151,10 +151,9 @@ extern char get_header_tar(archive_handle_t *archive_handle)
file_header->mode |= S_IFIFO; file_header->mode |= S_IFIFO;
break; break;
# endif # endif
/* hard links are detected as entries with 0 size, a link name, /* hard links are detected as regular files with 0 size and a link name */
* and not being a symlink, hence we have nothing to do here */
case '1': case '1':
file_header->mode |= ~S_IFLNK; file_header->mode &= (S_IFREG | 07777);
break; break;
# ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS # ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
case 'L': { case 'L': {