diff options
Diffstat (limited to '')
-rw-r--r-- | archival/ar.c | 16 | ||||
-rw-r--r-- | archival/bbunzip.c | 2 | ||||
-rw-r--r-- | archival/libarchive/decompress_gunzip.c | 6 | ||||
-rw-r--r-- | archival/libarchive/open_transformer.c | 26 | ||||
-rw-r--r-- | archival/tar.c | 31 | ||||
-rw-r--r-- | archival/unzip.c | 3 |
6 files changed, 82 insertions, 2 deletions
diff --git a/archival/ar.c b/archival/ar.c index e49d5cb2b..a850868f6 100644 --- a/archival/ar.c +++ b/archival/ar.c | |||
@@ -165,6 +165,7 @@ static int write_ar_archive(archive_handle_t *handle) | |||
165 | { | 165 | { |
166 | struct stat st; | 166 | struct stat st; |
167 | archive_handle_t *out_handle; | 167 | archive_handle_t *out_handle; |
168 | char *temp_fn = NULL; | ||
168 | 169 | ||
169 | xfstat(handle->src_fd, &st, handle->ar__name); | 170 | xfstat(handle->src_fd, &st, handle->ar__name); |
170 | 171 | ||
@@ -173,8 +174,14 @@ static int write_ar_archive(archive_handle_t *handle) | |||
173 | */ | 174 | */ |
174 | if (st.st_size != 0) { | 175 | if (st.st_size != 0) { |
175 | out_handle = init_handle(); | 176 | out_handle = init_handle(); |
177 | #if !ENABLE_PLATFORM_MINGW32 | ||
176 | xunlink(handle->ar__name); | 178 | xunlink(handle->ar__name); |
177 | out_handle->src_fd = xopen(handle->ar__name, O_WRONLY | O_CREAT | O_TRUNC); | 179 | out_handle->src_fd = xopen(handle->ar__name, O_WRONLY | O_CREAT | O_TRUNC); |
180 | #else | ||
181 | /* can't unlink open file, create temporary output file */ | ||
182 | temp_fn = xasprintf("%sXXXXXX", handle->ar__name); | ||
183 | out_handle->src_fd = xmkstemp(temp_fn); | ||
184 | #endif | ||
178 | out_handle->accept = handle->accept; | 185 | out_handle->accept = handle->accept; |
179 | } else { | 186 | } else { |
180 | out_handle = handle; | 187 | out_handle = handle; |
@@ -196,12 +203,19 @@ static int write_ar_archive(archive_handle_t *handle) | |||
196 | continue; | 203 | continue; |
197 | 204 | ||
198 | /* optional, since we exit right after we return */ | 205 | /* optional, since we exit right after we return */ |
199 | if (ENABLE_FEATURE_CLEAN_UP) { | 206 | if (ENABLE_FEATURE_CLEAN_UP || ENABLE_PLATFORM_MINGW32) { |
200 | close(handle->src_fd); | 207 | close(handle->src_fd); |
201 | if (out_handle->src_fd != handle->src_fd) | 208 | if (out_handle->src_fd != handle->src_fd) |
202 | close(out_handle->src_fd); | 209 | close(out_handle->src_fd); |
203 | } | 210 | } |
204 | 211 | ||
212 | #if ENABLE_PLATFORM_MINGW32 | ||
213 | if ( temp_fn != NULL ) { | ||
214 | xrename(temp_fn, handle->ar__name); | ||
215 | free(temp_fn); | ||
216 | } | ||
217 | #endif | ||
218 | |||
205 | return EXIT_SUCCESS; | 219 | return EXIT_SUCCESS; |
206 | } | 220 | } |
207 | #endif /* FEATURE_AR_CREATE */ | 221 | #endif /* FEATURE_AR_CREATE */ |
diff --git a/archival/bbunzip.c b/archival/bbunzip.c index 60a837e22..343aec9bd 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c | |||
@@ -183,6 +183,8 @@ int FAST_FUNC bbunpack(char **argv, | |||
183 | /* Delete _source_ file */ | 183 | /* Delete _source_ file */ |
184 | del = filename; | 184 | del = filename; |
185 | } | 185 | } |
186 | if (ENABLE_PLATFORM_MINGW32) | ||
187 | xclose(STDIN_FILENO); | ||
186 | xunlink(del); | 188 | xunlink(del); |
187 | free_name: | 189 | free_name: |
188 | if (new_name != filename) | 190 | if (new_name != filename) |
diff --git a/archival/libarchive/decompress_gunzip.c b/archival/libarchive/decompress_gunzip.c index c7fa5b526..74d364379 100644 --- a/archival/libarchive/decompress_gunzip.c +++ b/archival/libarchive/decompress_gunzip.c | |||
@@ -1118,6 +1118,9 @@ static uint32_t buffer_read_le_u32(STATE_PARAM_ONLY) | |||
1118 | return res; | 1118 | return res; |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | #if ENABLE_PLATFORM_MINGW32 && __GNUC__ | ||
1122 | #pragma pack(2) | ||
1123 | #endif | ||
1121 | static int check_header_gzip(STATE_PARAM transformer_state_t *xstate) | 1124 | static int check_header_gzip(STATE_PARAM transformer_state_t *xstate) |
1122 | { | 1125 | { |
1123 | union { | 1126 | union { |
@@ -1189,6 +1192,9 @@ static int check_header_gzip(STATE_PARAM transformer_state_t *xstate) | |||
1189 | } | 1192 | } |
1190 | return 1; | 1193 | return 1; |
1191 | } | 1194 | } |
1195 | #if ENABLE_PLATFORM_MINGW32 && __GNUC__ | ||
1196 | #pragma pack() | ||
1197 | #endif | ||
1192 | 1198 | ||
1193 | IF_DESKTOP(long long) int FAST_FUNC | 1199 | IF_DESKTOP(long long) int FAST_FUNC |
1194 | unpack_gz_stream(transformer_state_t *xstate) | 1200 | unpack_gz_stream(transformer_state_t *xstate) |
diff --git a/archival/libarchive/open_transformer.c b/archival/libarchive/open_transformer.c index ac7e5db95..641256787 100644 --- a/archival/libarchive/open_transformer.c +++ b/archival/libarchive/open_transformer.c | |||
@@ -65,6 +65,7 @@ ssize_t FAST_FUNC xtransformer_write(transformer_state_t *xstate, const void *bu | |||
65 | return nwrote; | 65 | return nwrote; |
66 | } | 66 | } |
67 | 67 | ||
68 | #if !ENABLE_PLATFORM_MINGW32 | ||
68 | void check_errors_in_children(int signo) | 69 | void check_errors_in_children(int signo) |
69 | { | 70 | { |
70 | int status; | 71 | int status; |
@@ -151,6 +152,31 @@ void FAST_FUNC fork_transformer(int fd, const char *transform_prog) | |||
151 | close(fd_pipe.wr); /* don't want to write to the child */ | 152 | close(fd_pipe.wr); /* don't want to write to the child */ |
152 | xmove_fd(fd_pipe.rd, fd); | 153 | xmove_fd(fd_pipe.rd, fd); |
153 | } | 154 | } |
155 | #else /* ENABLE_PLATFORM_MINGW */ | ||
156 | void check_errors_in_children(int signo UNUSED_PARAM) | ||
157 | { | ||
158 | bb_got_signal = 0; | ||
159 | } | ||
160 | |||
161 | void FAST_FUNC fork_transformer(int fd, const char *transform_prog) | ||
162 | { | ||
163 | char *cmd; | ||
164 | int fd1; | ||
165 | |||
166 | if (find_applet_by_name(transform_prog) >= 0) { | ||
167 | cmd = xasprintf("%s --busybox %s -cf -", bb_busybox_exec_path, | ||
168 | transform_prog); | ||
169 | } | ||
170 | else { | ||
171 | cmd = xasprintf("%s -cf -", transform_prog); | ||
172 | } | ||
173 | if ( (fd1=mingw_popen_fd(cmd, "r", fd, NULL)) == -1 ) { | ||
174 | bb_perror_msg_and_die("can't execute '%s'", transform_prog); | ||
175 | } | ||
176 | free(cmd); | ||
177 | xmove_fd(fd1, fd); | ||
178 | } | ||
179 | #endif | ||
154 | 180 | ||
155 | 181 | ||
156 | #if SEAMLESS_COMPRESSION | 182 | #if SEAMLESS_COMPRESSION |
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! */ |
diff --git a/archival/unzip.c b/archival/unzip.c index c540485ac..27adb3420 100644 --- a/archival/unzip.c +++ b/archival/unzip.c | |||
@@ -44,6 +44,9 @@ | |||
44 | 44 | ||
45 | #include "libbb.h" | 45 | #include "libbb.h" |
46 | #include "bb_archive.h" | 46 | #include "bb_archive.h" |
47 | #if ENABLE_PLATFORM_MINGW32 && __GNUC__ | ||
48 | #pragma pack(2) | ||
49 | #endif | ||
47 | 50 | ||
48 | #if 0 | 51 | #if 0 |
49 | # define dbg(...) bb_error_msg(__VA_ARGS__) | 52 | # define dbg(...) bb_error_msg(__VA_ARGS__) |