aboutsummaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
Diffstat (limited to 'archival')
-rw-r--r--archival/cpio.c4
-rw-r--r--archival/libarchive/init_handle.c5
-rw-r--r--archival/libarchive/open_transformer.c20
-rw-r--r--archival/rpm2cpio.c2
-rw-r--r--archival/tar.c31
5 files changed, 60 insertions, 2 deletions
diff --git a/archival/cpio.c b/archival/cpio.c
index 454648d68..3cb7fdb35 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -374,6 +374,10 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
374 argv += optind; 374 argv += optind;
375 if (opt & OPT_FILE) { /* -F */ 375 if (opt & OPT_FILE) { /* -F */
376 xmove_fd(xopen(cpio_filename, O_RDONLY), STDIN_FILENO); 376 xmove_fd(xopen(cpio_filename, O_RDONLY), STDIN_FILENO);
377#if ENABLE_PLATFORM_MINGW32
378 /* default is seek_by_read but seek_by_jump is OK for file */
379 archive_handle->seek = seek_by_jump;
380#endif
377 } 381 }
378#else 382#else
379 opt = getopt32(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"), &cpio_filename, &cpio_fmt); 383 opt = getopt32(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"), &cpio_filename, &cpio_fmt);
diff --git a/archival/libarchive/init_handle.c b/archival/libarchive/init_handle.c
index cbae06ac3..b1166d577 100644
--- a/archival/libarchive/init_handle.c
+++ b/archival/libarchive/init_handle.c
@@ -16,7 +16,12 @@ archive_handle_t* FAST_FUNC init_handle(void)
16 archive_handle->action_header = header_skip; 16 archive_handle->action_header = header_skip;
17 archive_handle->action_data = data_skip; 17 archive_handle->action_data = data_skip;
18 archive_handle->filter = filter_accept_all; 18 archive_handle->filter = filter_accept_all;
19#if !ENABLE_PLATFORM_MINGW32
19 archive_handle->seek = seek_by_jump; 20 archive_handle->seek = seek_by_jump;
21#else
22 /* can't reliably detect pipes on WIN32: default to seek_by_read */
23 archive_handle->seek = seek_by_read;
24#endif
20 25
21 return archive_handle; 26 return archive_handle;
22} 27}
diff --git a/archival/libarchive/open_transformer.c b/archival/libarchive/open_transformer.c
index 1c5c185d0..24524f6ee 100644
--- a/archival/libarchive/open_transformer.c
+++ b/archival/libarchive/open_transformer.c
@@ -69,6 +69,7 @@ ssize_t FAST_FUNC xtransformer_write(transformer_state_t *xstate, const void *bu
69} 69}
70 70
71#if SEAMLESS_COMPRESSION 71#if SEAMLESS_COMPRESSION
72#if !ENABLE_PLATFORM_MINGW32
72void check_errors_in_children(int signo) 73void check_errors_in_children(int signo)
73{ 74{
74 int status; 75 int status;
@@ -155,6 +156,25 @@ void FAST_FUNC fork_transformer(int fd, const char *transform_prog)
155 close(fd_pipe.wr); /* don't want to write to the child */ 156 close(fd_pipe.wr); /* don't want to write to the child */
156 xmove_fd(fd_pipe.rd, fd); 157 xmove_fd(fd_pipe.rd, fd);
157} 158}
159#else
160void FAST_FUNC fork_transformer(int fd, const char *transform_prog)
161{
162 char *cmd;
163 int fd1;
164
165 if (find_applet_by_name(transform_prog) >= 0) {
166 cmd = xasprintf("%s %s -cf -", bb_busybox_exec_path, transform_prog);
167 }
168 else {
169 cmd = xasprintf("%s -cf -", transform_prog);
170 }
171 if ( (fd1=mingw_popen_fd(cmd, "r", fd, NULL)) == -1 ) {
172 bb_perror_msg_and_die("can't execute '%s'", transform_prog);
173 }
174 free(cmd);
175 xmove_fd(fd1, fd);
176}
177#endif
158 178
159/* Used by e.g. rpm which gives us a fd without filename, 179/* Used by e.g. rpm which gives us a fd without filename,
160 * thus we can't guess the format from filename's extension. 180 * thus we can't guess the format from filename's extension.
diff --git a/archival/rpm2cpio.c b/archival/rpm2cpio.c
index 7057570f5..7703629cb 100644
--- a/archival/rpm2cpio.c
+++ b/archival/rpm2cpio.c
@@ -88,7 +88,7 @@ int rpm2cpio_main(int argc UNUSED_PARAM, char **argv)
88 close(rpm_fd); 88 close(rpm_fd);
89 } 89 }
90 90
91 if (SEAMLESS_COMPRESSION) { 91 if (SEAMLESS_COMPRESSION && !ENABLE_PLATFORM_MINGW32) {
92 check_errors_in_children(0); 92 check_errors_in_children(0);
93 return bb_got_signal; 93 return bb_got_signal;
94 } 94 }
diff --git a/archival/tar.c b/archival/tar.c
index 85551684b..1f9dd23d2 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -617,6 +617,7 @@ static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statb
617} 617}
618 618
619#if SEAMLESS_COMPRESSION 619#if SEAMLESS_COMPRESSION
620#if !ENABLE_PLATFORM_MINGW32
620/* Don't inline: vfork scares gcc and pessimizes code */ 621/* Don't inline: vfork scares gcc and pessimizes code */
621static void NOINLINE vfork_compressor(int tar_fd, const char *gzip) 622static void NOINLINE vfork_compressor(int tar_fd, const char *gzip)
622{ 623{
@@ -676,6 +677,27 @@ static void NOINLINE vfork_compressor(int tar_fd, const char *gzip)
676 bb_perror_msg_and_die("can't execute '%s'", gzip); 677 bb_perror_msg_and_die("can't execute '%s'", gzip);
677 } 678 }
678} 679}
680#else
681static pid_t vfork_compressor(int tar_fd, const char *gzip)
682{
683 char *cmd;
684 int fd1;
685 pid_t pid;
686
687 if (find_applet_by_name(gzip) >= 0) {
688 cmd = xasprintf("%s %s -cf -", bb_busybox_exec_path, gzip);
689 }
690 else {
691 cmd = xasprintf("%s -cf -", gzip);
692 }
693 if ( (fd1=mingw_popen_fd(cmd, "w", tar_fd, &pid)) == -1 ) {
694 bb_perror_msg_and_die("can't execute '%s'", gzip);
695 }
696 free(cmd);
697 xmove_fd(fd1, tar_fd);
698 return pid;
699}
700#endif /* ENABLE_PLATFORM_MINGW32 */
679#endif /* SEAMLESS_COMPRESSION */ 701#endif /* SEAMLESS_COMPRESSION */
680 702
681 703
@@ -691,6 +713,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
691{ 713{
692 int errorFlag = FALSE; 714 int errorFlag = FALSE;
693 struct TarBallInfo tbInfo; 715 struct TarBallInfo tbInfo;
716 IF_PLATFORM_MINGW32(pid_t pid = 0;)
694 717
695 tbInfo.hlInfoHead = NULL; 718 tbInfo.hlInfoHead = NULL;
696 tbInfo.tarFd = tar_fd; 719 tbInfo.tarFd = tar_fd;
@@ -702,7 +725,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
702 725
703#if SEAMLESS_COMPRESSION 726#if SEAMLESS_COMPRESSION
704 if (gzip) 727 if (gzip)
705 vfork_compressor(tbInfo.tarFd, gzip); 728 IF_PLATFORM_MINGW32(pid = )vfork_compressor(tbInfo.tarFd, gzip);
706#endif 729#endif
707 730
708 tbInfo.excludeList = exclude; 731 tbInfo.excludeList = exclude;
@@ -738,7 +761,11 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
738#if SEAMLESS_COMPRESSION 761#if SEAMLESS_COMPRESSION
739 if (gzip) { 762 if (gzip) {
740 int status; 763 int status;
764#if !ENABLE_PLATFORM_MINGW32
741 if (safe_waitpid(-1, &status, 0) == -1) 765 if (safe_waitpid(-1, &status, 0) == -1)
766#else
767 if (safe_waitpid(pid, &status, 0) == -1)
768#endif
742 bb_perror_msg("waitpid"); 769 bb_perror_msg("waitpid");
743 else if (!WIFEXITED(status) || WEXITSTATUS(status)) 770 else if (!WIFEXITED(status) || WEXITSTATUS(status))
744 /* gzip was killed or has exited with nonzero! */ 771 /* gzip was killed or has exited with nonzero! */
@@ -1208,10 +1235,12 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
1208 if (ENABLE_FEATURE_CLEAN_UP /* && tar_handle->src_fd != STDIN_FILENO */) 1235 if (ENABLE_FEATURE_CLEAN_UP /* && tar_handle->src_fd != STDIN_FILENO */)
1209 close(tar_handle->src_fd); 1236 close(tar_handle->src_fd);
1210 1237
1238#if !ENABLE_PLATFORM_MINGW32
1211 if (SEAMLESS_COMPRESSION || OPT_COMPRESS) { 1239 if (SEAMLESS_COMPRESSION || OPT_COMPRESS) {
1212 /* Set bb_got_signal to 1 if a child died with !0 exitcode */ 1240 /* Set bb_got_signal to 1 if a child died with !0 exitcode */
1213 check_errors_in_children(0); 1241 check_errors_in_children(0);
1214 } 1242 }
1243#endif
1215 1244
1216 return bb_got_signal; 1245 return bb_got_signal;
1217} 1246}