summaryrefslogtreecommitdiff
path: root/archival/libunarchive/data_extract_all.c
diff options
context:
space:
mode:
authorGlenn L McGrath2003-08-14 02:55:15 +0000
committerGlenn L McGrath2003-08-14 02:55:15 +0000
commit3d5828fb6da7376eb220817376f22fac4da2815a (patch)
tree95b3ba1423159a87678f3caad26a99f8797faf45 /archival/libunarchive/data_extract_all.c
parent062913f66288b93aaefe052cb15b4115f4b1a839 (diff)
downloadbusybox-3d5828fb6da7376eb220817376f22fac4da2815a.zip
busybox-3d5828fb6da7376eb220817376f22fac4da2815a.tar.gz
Change hardlink handling for tar to work the same way as cpio
Diffstat (limited to 'archival/libunarchive/data_extract_all.c')
-rw-r--r--archival/libunarchive/data_extract_all.c82
1 files changed, 40 insertions, 42 deletions
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c
index bd264dd..c6ace2c 100644
--- a/archival/libunarchive/data_extract_all.c
+++ b/archival/libunarchive/data_extract_all.c
@@ -39,54 +39,52 @@ extern void data_extract_all(archive_handle_t *archive_handle)
free(name);
}
- /* Create the filesystem entry */
- switch(file_header->mode & S_IFMT) {
- case S_IFREG: {
-#ifdef CONFIG_CPIO
- if (file_header->link_name && file_header->size == 0) {
- /* hard link */
- res = link(file_header->link_name, file_header->name);
- if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
- bb_perror_msg("Couldnt create hard link");
- }
- } else
-#endif
- {
+ /* Handle hard links seperately */
+ if (!S_ISLNK(file_header->mode) && (file_header->link_name) && (file_header->size == 0)) {
+ /* hard link */
+ res = link(file_header->link_name, file_header->name);
+ if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
+ bb_perror_msg("Couldnt create hard link");
+ }
+ } else {
+ /* Create the filesystem entry */
+ switch(file_header->mode & S_IFMT) {
+ case S_IFREG: {
/* Regular file */
unlink(file_header->name);
dst_fd = bb_xopen(file_header->name, O_WRONLY | O_CREAT | O_EXCL);
archive_copy_file(archive_handle, dst_fd);
close(dst_fd);
- }
- break;
+ break;
+ }
+ case S_IFDIR:
+ unlink(file_header->name);
+ res = mkdir(file_header->name, file_header->mode);
+ if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
+ bb_perror_msg("extract_archive: %s", file_header->name);
+ }
+ break;
+ case S_IFLNK:
+ /* Symlink */
+ unlink(file_header->name);
+ res = symlink(file_header->link_name, file_header->name);
+ if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
+ bb_perror_msg("Cannot create symlink from %s to '%s'", file_header->name, file_header->link_name);
+ }
+ break;
+ case S_IFSOCK:
+ case S_IFBLK:
+ case S_IFCHR:
+ case S_IFIFO:
+ unlink(file_header->name);
+ res = mknod(file_header->name, file_header->mode, file_header->device);
+ if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
+ bb_perror_msg("Cannot create node %s", file_header->name);
+ }
+ break;
+ default:
+ bb_error_msg_and_die("Unrecognised file type");
}
- case S_IFDIR:
- unlink(file_header->name);
- res = mkdir(file_header->name, file_header->mode);
- if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
- bb_perror_msg("extract_archive: %s", file_header->name);
- }
- break;
- case S_IFLNK:
- /* Symlink */
- unlink(file_header->name);
- res = symlink(file_header->link_name, file_header->name);
- if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
- bb_perror_msg("Cannot create symlink from %s to '%s'", file_header->name, file_header->link_name);
- }
- break;
- case S_IFSOCK:
- case S_IFBLK:
- case S_IFCHR:
- case S_IFIFO:
- unlink(file_header->name);
- res = mknod(file_header->name, file_header->mode, file_header->device);
- if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
- bb_perror_msg("Cannot create node %s", file_header->name);
- }
- break;
- default:
- bb_error_msg_and_die("Unrecognised file type");
}
chmod(file_header->name, file_header->mode);