diff options
Diffstat (limited to 'archival/tar.c')
-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 280ded4e1..d90a5dc4f 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -542,6 +542,7 @@ static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statb | |||
542 | } | 542 | } |
543 | } | 543 | } |
544 | 544 | ||
545 | #if !ENABLE_PLATFORM_MINGW32 | ||
545 | /* It is a bad idea to store the archive we are in the process of creating, | 546 | /* It is a bad idea to store the archive we are in the process of creating, |
546 | * so check the device and inode to be sure that this particular file isn't | 547 | * so check the device and inode to be sure that this particular file isn't |
547 | * the new tarball */ | 548 | * the new tarball */ |
@@ -551,6 +552,7 @@ static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statb | |||
551 | bb_error_msg("%s: file is the archive; skipping", fileName); | 552 | bb_error_msg("%s: file is the archive; skipping", fileName); |
552 | return TRUE; | 553 | return TRUE; |
553 | } | 554 | } |
555 | #endif | ||
554 | 556 | ||
555 | if (exclude_file(tbInfo->excludeList, header_name)) | 557 | if (exclude_file(tbInfo->excludeList, header_name)) |
556 | return SKIP; | 558 | return SKIP; |
@@ -608,6 +610,7 @@ static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statb | |||
608 | } | 610 | } |
609 | 611 | ||
610 | #if SEAMLESS_COMPRESSION | 612 | #if SEAMLESS_COMPRESSION |
613 | #if !ENABLE_PLATFORM_MINGW32 | ||
611 | /* Don't inline: vfork scares gcc and pessimizes code */ | 614 | /* Don't inline: vfork scares gcc and pessimizes code */ |
612 | static void NOINLINE vfork_compressor(int tar_fd, const char *gzip) | 615 | static void NOINLINE vfork_compressor(int tar_fd, const char *gzip) |
613 | { | 616 | { |
@@ -667,6 +670,27 @@ static void NOINLINE vfork_compressor(int tar_fd, const char *gzip) | |||
667 | bb_perror_msg_and_die("can't execute '%s'", gzip); | 670 | bb_perror_msg_and_die("can't execute '%s'", gzip); |
668 | } | 671 | } |
669 | } | 672 | } |
673 | #else | ||
674 | static pid_t vfork_compressor(int tar_fd, const char *gzip) | ||
675 | { | ||
676 | char *cmd; | ||
677 | int fd1; | ||
678 | pid_t pid; | ||
679 | |||
680 | if (find_applet_by_name(gzip) >= 0) { | ||
681 | cmd = xasprintf("%s --busybox %s -cf -", bb_busybox_exec_path, gzip); | ||
682 | } | ||
683 | else { | ||
684 | cmd = xasprintf("%s -cf -", gzip); | ||
685 | } | ||
686 | if ( (fd1=mingw_popen_fd(cmd, "w", tar_fd, &pid)) == -1 ) { | ||
687 | bb_perror_msg_and_die("can't execute '%s'", gzip); | ||
688 | } | ||
689 | free(cmd); | ||
690 | xmove_fd(fd1, tar_fd); | ||
691 | return pid; | ||
692 | } | ||
693 | #endif /* ENABLE_PLATFORM_MINGW32 */ | ||
670 | #endif /* SEAMLESS_COMPRESSION */ | 694 | #endif /* SEAMLESS_COMPRESSION */ |
671 | 695 | ||
672 | 696 | ||
@@ -682,6 +706,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag, | |||
682 | { | 706 | { |
683 | int errorFlag = FALSE; | 707 | int errorFlag = FALSE; |
684 | struct TarBallInfo tbInfo; | 708 | struct TarBallInfo tbInfo; |
709 | IF_PLATFORM_MINGW32(pid_t pid = 0;) | ||
685 | 710 | ||
686 | tbInfo.hlInfoHead = NULL; | 711 | tbInfo.hlInfoHead = NULL; |
687 | tbInfo.tarFd = tar_fd; | 712 | tbInfo.tarFd = tar_fd; |
@@ -693,7 +718,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag, | |||
693 | 718 | ||
694 | #if SEAMLESS_COMPRESSION | 719 | #if SEAMLESS_COMPRESSION |
695 | if (gzip) | 720 | if (gzip) |
696 | vfork_compressor(tbInfo.tarFd, gzip); | 721 | IF_PLATFORM_MINGW32(pid = )vfork_compressor(tbInfo.tarFd, gzip); |
697 | #endif | 722 | #endif |
698 | 723 | ||
699 | tbInfo.excludeList = exclude; | 724 | tbInfo.excludeList = exclude; |
@@ -729,7 +754,11 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag, | |||
729 | #if SEAMLESS_COMPRESSION | 754 | #if SEAMLESS_COMPRESSION |
730 | if (gzip) { | 755 | if (gzip) { |
731 | int status; | 756 | int status; |
757 | #if !ENABLE_PLATFORM_MINGW32 | ||
732 | if (safe_waitpid(-1, &status, 0) == -1) | 758 | if (safe_waitpid(-1, &status, 0) == -1) |
759 | #else | ||
760 | if (safe_waitpid(pid, &status, 0) == -1) | ||
761 | #endif | ||
733 | bb_perror_msg("waitpid"); | 762 | bb_perror_msg("waitpid"); |
734 | else if (!WIFEXITED(status) || WEXITSTATUS(status)) | 763 | else if (!WIFEXITED(status) || WEXITSTATUS(status)) |
735 | /* gzip was killed or has exited with nonzero! */ | 764 | /* gzip was killed or has exited with nonzero! */ |