diff options
Diffstat (limited to '')
-rw-r--r-- | archival/tar.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/archival/tar.c b/archival/tar.c index 8e315c610..c87d23597 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -554,6 +554,7 @@ static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statb | |||
554 | } | 554 | } |
555 | } | 555 | } |
556 | 556 | ||
557 | #if !ENABLE_PLATFORM_MINGW32 | ||
557 | /* It is a bad idea to store the archive we are in the process of creating, | 558 | /* It is a bad idea to store the archive we are in the process of creating, |
558 | * so check the device and inode to be sure that this particular file isn't | 559 | * so check the device and inode to be sure that this particular file isn't |
559 | * the new tarball */ | 560 | * the new tarball */ |
@@ -563,6 +564,7 @@ static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statb | |||
563 | bb_error_msg("%s: file is the archive; skipping", fileName); | 564 | bb_error_msg("%s: file is the archive; skipping", fileName); |
564 | return TRUE; | 565 | return TRUE; |
565 | } | 566 | } |
567 | #endif | ||
566 | 568 | ||
567 | if (exclude_file(tbInfo->excludeList, header_name)) | 569 | if (exclude_file(tbInfo->excludeList, header_name)) |
568 | return SKIP; | 570 | return SKIP; |
@@ -620,6 +622,7 @@ static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statb | |||
620 | } | 622 | } |
621 | 623 | ||
622 | #if SEAMLESS_COMPRESSION | 624 | #if SEAMLESS_COMPRESSION |
625 | #if !ENABLE_PLATFORM_MINGW32 | ||
623 | /* Don't inline: vfork scares gcc and pessimizes code */ | 626 | /* Don't inline: vfork scares gcc and pessimizes code */ |
624 | static void NOINLINE vfork_compressor(int tar_fd, const char *gzip) | 627 | static void NOINLINE vfork_compressor(int tar_fd, const char *gzip) |
625 | { | 628 | { |
@@ -679,6 +682,27 @@ static void NOINLINE vfork_compressor(int tar_fd, const char *gzip) | |||
679 | bb_perror_msg_and_die("can't execute '%s'", gzip); | 682 | bb_perror_msg_and_die("can't execute '%s'", gzip); |
680 | } | 683 | } |
681 | } | 684 | } |
685 | #else | ||
686 | static pid_t vfork_compressor(int tar_fd, const char *gzip) | ||
687 | { | ||
688 | char *cmd; | ||
689 | int fd1; | ||
690 | pid_t pid; | ||
691 | |||
692 | if (find_applet_by_name(gzip) >= 0) { | ||
693 | cmd = xasprintf("%s --busybox %s -cf -", bb_busybox_exec_path, gzip); | ||
694 | } | ||
695 | else { | ||
696 | cmd = xasprintf("%s -cf -", gzip); | ||
697 | } | ||
698 | if ( (fd1=mingw_popen_fd(cmd, "w", tar_fd, &pid)) == -1 ) { | ||
699 | bb_perror_msg_and_die("can't execute '%s'", gzip); | ||
700 | } | ||
701 | free(cmd); | ||
702 | xmove_fd(fd1, tar_fd); | ||
703 | return pid; | ||
704 | } | ||
705 | #endif /* ENABLE_PLATFORM_MINGW32 */ | ||
682 | #endif /* SEAMLESS_COMPRESSION */ | 706 | #endif /* SEAMLESS_COMPRESSION */ |
683 | 707 | ||
684 | 708 | ||
@@ -694,6 +718,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag, | |||
694 | { | 718 | { |
695 | int errorFlag = FALSE; | 719 | int errorFlag = FALSE; |
696 | struct TarBallInfo tbInfo; | 720 | struct TarBallInfo tbInfo; |
721 | IF_PLATFORM_MINGW32(pid_t pid = 0;) | ||
697 | 722 | ||
698 | tbInfo.hlInfoHead = NULL; | 723 | tbInfo.hlInfoHead = NULL; |
699 | tbInfo.tarFd = tar_fd; | 724 | tbInfo.tarFd = tar_fd; |
@@ -705,7 +730,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag, | |||
705 | 730 | ||
706 | #if SEAMLESS_COMPRESSION | 731 | #if SEAMLESS_COMPRESSION |
707 | if (gzip) | 732 | if (gzip) |
708 | vfork_compressor(tbInfo.tarFd, gzip); | 733 | IF_PLATFORM_MINGW32(pid = )vfork_compressor(tbInfo.tarFd, gzip); |
709 | #endif | 734 | #endif |
710 | 735 | ||
711 | tbInfo.excludeList = exclude; | 736 | tbInfo.excludeList = exclude; |
@@ -741,7 +766,11 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag, | |||
741 | #if SEAMLESS_COMPRESSION | 766 | #if SEAMLESS_COMPRESSION |
742 | if (gzip) { | 767 | if (gzip) { |
743 | int status; | 768 | int status; |
769 | #if !ENABLE_PLATFORM_MINGW32 | ||
744 | if (safe_waitpid(-1, &status, 0) == -1) | 770 | if (safe_waitpid(-1, &status, 0) == -1) |
771 | #else | ||
772 | if (safe_waitpid(pid, &status, 0) == -1) | ||
773 | #endif | ||
745 | bb_perror_msg("waitpid"); | 774 | bb_perror_msg("waitpid"); |
746 | else if (!WIFEXITED(status) || WEXITSTATUS(status)) | 775 | else if (!WIFEXITED(status) || WEXITSTATUS(status)) |
747 | /* gzip was killed or has exited with nonzero! */ | 776 | /* gzip was killed or has exited with nonzero! */ |