diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2001-03-28 07:27:26 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2001-03-28 07:27:26 +0000 |
commit | 018e9e6799ec34d2793c7b16f52e39cd9206861b (patch) | |
tree | 6d33d3c39b838f96cd47b0247b1696f9337d87b1 | |
parent | ee79ca1ba69b5b43cd0c2e3b6d2eb20a4a5a0f8e (diff) | |
download | busybox-w32-018e9e6799ec34d2793c7b16f52e39cd9206861b.tar.gz busybox-w32-018e9e6799ec34d2793c7b16f52e39cd9206861b.tar.bz2 busybox-w32-018e9e6799ec34d2793c7b16f52e39cd9206861b.zip |
Fix tar -z, calls gz_open now
-rw-r--r-- | archival/gunzip.c | 17 | ||||
-rw-r--r-- | archival/tar.c | 20 | ||||
-rw-r--r-- | gunzip.c | 17 | ||||
-rw-r--r-- | tar.c | 20 |
4 files changed, 52 insertions, 22 deletions
diff --git a/archival/gunzip.c b/archival/gunzip.c index e9f764882..9d81031d7 100644 --- a/archival/gunzip.c +++ b/archival/gunzip.c | |||
@@ -918,7 +918,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file) | |||
918 | in_file = l_in_file; | 918 | in_file = l_in_file; |
919 | out_file = l_out_file; | 919 | out_file = l_out_file; |
920 | 920 | ||
921 | if (signal(SIGINT, SIG_IGN) != SIG_IGN) { | 921 | /* if (signal(SIGINT, SIG_IGN) != SIG_IGN) { |
922 | (void) signal(SIGINT, (sig_type) abort_gzip); | 922 | (void) signal(SIGINT, (sig_type) abort_gzip); |
923 | } | 923 | } |
924 | #ifdef SIGTERM | 924 | #ifdef SIGTERM |
@@ -931,7 +931,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file) | |||
931 | (void) signal(SIGHUP, (sig_type) abort_gzip); | 931 | (void) signal(SIGHUP, (sig_type) abort_gzip); |
932 | } | 932 | } |
933 | #endif | 933 | #endif |
934 | 934 | */ | |
935 | /* Allocate all global buffers (for DYN_ALLOC option) */ | 935 | /* Allocate all global buffers (for DYN_ALLOC option) */ |
936 | window = xmalloc((size_t)(((2L*WSIZE)+1L)*sizeof(unsigned char))); | 936 | window = xmalloc((size_t)(((2L*WSIZE)+1L)*sizeof(unsigned char))); |
937 | outcnt = 0; | 937 | outcnt = 0; |
@@ -1018,33 +1018,32 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file) | |||
1018 | return 0; | 1018 | return 0; |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | extern FILE *gz_open(FILE *compressed_file, int *pid) | 1021 | extern int gz_open(FILE *compressed_file, int *pid) |
1022 | { | 1022 | { |
1023 | int unzip_pipe[2]; | 1023 | int unzip_pipe[2]; |
1024 | 1024 | ||
1025 | signal(SIGCHLD, abort_gzip); | 1025 | // signal(SIGCHLD, abort_gzip); |
1026 | if (pipe(unzip_pipe)!=0) { | 1026 | if (pipe(unzip_pipe)!=0) { |
1027 | error_msg("pipe error"); | 1027 | error_msg("pipe error"); |
1028 | return NULL; | 1028 | return(EXIT_FAILURE); |
1029 | } | 1029 | } |
1030 | if ((*pid = fork()) == -1) { | 1030 | if ((*pid = fork()) == -1) { |
1031 | error_msg("fork failured"); | 1031 | error_msg("fork failured"); |
1032 | return NULL; | 1032 | return(EXIT_FAILURE); |
1033 | } | 1033 | } |
1034 | if (*pid==0) { | 1034 | if (*pid==0) { |
1035 | /* child process */ | 1035 | /* child process */ |
1036 | close(unzip_pipe[0]); | 1036 | close(unzip_pipe[0]); |
1037 | unzip(compressed_file, fdopen(unzip_pipe[1], "w")); | 1037 | unzip(compressed_file, fdopen(unzip_pipe[1], "w")); |
1038 | // printf("finished unzipping\n"); | 1038 | printf("finished unzipping\n"); |
1039 | fflush(NULL); | 1039 | fflush(NULL); |
1040 | // printf("fluched\n"); | ||
1041 | fclose(compressed_file); | 1040 | fclose(compressed_file); |
1042 | close(unzip_pipe[1]); | 1041 | close(unzip_pipe[1]); |
1043 | exit(EXIT_SUCCESS); | 1042 | exit(EXIT_SUCCESS); |
1044 | } | 1043 | } |
1045 | 1044 | ||
1046 | close(unzip_pipe[1]); | 1045 | close(unzip_pipe[1]); |
1047 | return (fdopen(unzip_pipe[0], "r")); | 1046 | return(unzip_pipe[0]); |
1048 | } | 1047 | } |
1049 | 1048 | ||
1050 | extern void gz_close(int gunzip_pid) | 1049 | extern void gz_close(int gunzip_pid) |
diff --git a/archival/tar.c b/archival/tar.c index 16b3fb4b6..46321de60 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -58,6 +58,8 @@ | |||
58 | 58 | ||
59 | #ifdef BB_FEATURE_TAR_GZIP | 59 | #ifdef BB_FEATURE_TAR_GZIP |
60 | extern int unzip(int in, int out); | 60 | extern int unzip(int in, int out); |
61 | extern int gz_open(FILE *compressed_file, int *pid); | ||
62 | extern void gz_close(int gunzip_pid); | ||
61 | #endif | 63 | #endif |
62 | 64 | ||
63 | /* Tar file constants */ | 65 | /* Tar file constants */ |
@@ -202,6 +204,7 @@ extern int tar_main(int argc, char **argv) | |||
202 | char file[256]; | 204 | char file[256]; |
203 | #endif | 205 | #endif |
204 | #if defined BB_FEATURE_TAR_GZIP | 206 | #if defined BB_FEATURE_TAR_GZIP |
207 | FILE *comp_file = NULL; | ||
205 | int unzipFlag = FALSE; | 208 | int unzipFlag = FALSE; |
206 | #endif | 209 | #endif |
207 | int listFlag = FALSE; | 210 | int listFlag = FALSE; |
@@ -211,6 +214,7 @@ extern int tar_main(int argc, char **argv) | |||
211 | int tostdoutFlag = FALSE; | 214 | int tostdoutFlag = FALSE; |
212 | int status = FALSE; | 215 | int status = FALSE; |
213 | int opt; | 216 | int opt; |
217 | pid_t pid; | ||
214 | 218 | ||
215 | if (argc <= 1) | 219 | if (argc <= 1) |
216 | show_usage(); | 220 | show_usage(); |
@@ -315,13 +319,25 @@ extern int tar_main(int argc, char **argv) | |||
315 | 319 | ||
316 | #ifdef BB_FEATURE_TAR_GZIP | 320 | #ifdef BB_FEATURE_TAR_GZIP |
317 | /* unzip tarFd in a seperate process */ | 321 | /* unzip tarFd in a seperate process */ |
318 | if (unzipFlag == TRUE) | 322 | if (unzipFlag == TRUE) { |
319 | tarFd = tar_unzip_init(tarFd); | 323 | comp_file = fdopen(tarFd, "r"); |
324 | printf("1\n"); | ||
325 | if ((tarFd = gz_open(comp_file, &pid)) == EXIT_FAILURE) { | ||
326 | error_msg_and_die("Couldnt unzip file"); | ||
327 | } | ||
328 | printf("2\n"); | ||
329 | } | ||
320 | #endif | 330 | #endif |
321 | status = readTarFile(tarFd, extractFlag, listFlag, tostdoutFlag, | 331 | status = readTarFile(tarFd, extractFlag, listFlag, tostdoutFlag, |
322 | verboseFlag, extractList, excludeList); | 332 | verboseFlag, extractList, excludeList); |
333 | close(tarFd); | ||
323 | } | 334 | } |
324 | 335 | ||
336 | #ifdef BB_FEATURE_TAR_GZIP | ||
337 | gz_close(pid); | ||
338 | fclose(comp_file); | ||
339 | #endif | ||
340 | |||
325 | if (status == TRUE) | 341 | if (status == TRUE) |
326 | return EXIT_SUCCESS; | 342 | return EXIT_SUCCESS; |
327 | else | 343 | else |
@@ -918,7 +918,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file) | |||
918 | in_file = l_in_file; | 918 | in_file = l_in_file; |
919 | out_file = l_out_file; | 919 | out_file = l_out_file; |
920 | 920 | ||
921 | if (signal(SIGINT, SIG_IGN) != SIG_IGN) { | 921 | /* if (signal(SIGINT, SIG_IGN) != SIG_IGN) { |
922 | (void) signal(SIGINT, (sig_type) abort_gzip); | 922 | (void) signal(SIGINT, (sig_type) abort_gzip); |
923 | } | 923 | } |
924 | #ifdef SIGTERM | 924 | #ifdef SIGTERM |
@@ -931,7 +931,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file) | |||
931 | (void) signal(SIGHUP, (sig_type) abort_gzip); | 931 | (void) signal(SIGHUP, (sig_type) abort_gzip); |
932 | } | 932 | } |
933 | #endif | 933 | #endif |
934 | 934 | */ | |
935 | /* Allocate all global buffers (for DYN_ALLOC option) */ | 935 | /* Allocate all global buffers (for DYN_ALLOC option) */ |
936 | window = xmalloc((size_t)(((2L*WSIZE)+1L)*sizeof(unsigned char))); | 936 | window = xmalloc((size_t)(((2L*WSIZE)+1L)*sizeof(unsigned char))); |
937 | outcnt = 0; | 937 | outcnt = 0; |
@@ -1018,33 +1018,32 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file) | |||
1018 | return 0; | 1018 | return 0; |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | extern FILE *gz_open(FILE *compressed_file, int *pid) | 1021 | extern int gz_open(FILE *compressed_file, int *pid) |
1022 | { | 1022 | { |
1023 | int unzip_pipe[2]; | 1023 | int unzip_pipe[2]; |
1024 | 1024 | ||
1025 | signal(SIGCHLD, abort_gzip); | 1025 | // signal(SIGCHLD, abort_gzip); |
1026 | if (pipe(unzip_pipe)!=0) { | 1026 | if (pipe(unzip_pipe)!=0) { |
1027 | error_msg("pipe error"); | 1027 | error_msg("pipe error"); |
1028 | return NULL; | 1028 | return(EXIT_FAILURE); |
1029 | } | 1029 | } |
1030 | if ((*pid = fork()) == -1) { | 1030 | if ((*pid = fork()) == -1) { |
1031 | error_msg("fork failured"); | 1031 | error_msg("fork failured"); |
1032 | return NULL; | 1032 | return(EXIT_FAILURE); |
1033 | } | 1033 | } |
1034 | if (*pid==0) { | 1034 | if (*pid==0) { |
1035 | /* child process */ | 1035 | /* child process */ |
1036 | close(unzip_pipe[0]); | 1036 | close(unzip_pipe[0]); |
1037 | unzip(compressed_file, fdopen(unzip_pipe[1], "w")); | 1037 | unzip(compressed_file, fdopen(unzip_pipe[1], "w")); |
1038 | // printf("finished unzipping\n"); | 1038 | printf("finished unzipping\n"); |
1039 | fflush(NULL); | 1039 | fflush(NULL); |
1040 | // printf("fluched\n"); | ||
1041 | fclose(compressed_file); | 1040 | fclose(compressed_file); |
1042 | close(unzip_pipe[1]); | 1041 | close(unzip_pipe[1]); |
1043 | exit(EXIT_SUCCESS); | 1042 | exit(EXIT_SUCCESS); |
1044 | } | 1043 | } |
1045 | 1044 | ||
1046 | close(unzip_pipe[1]); | 1045 | close(unzip_pipe[1]); |
1047 | return (fdopen(unzip_pipe[0], "r")); | 1046 | return(unzip_pipe[0]); |
1048 | } | 1047 | } |
1049 | 1048 | ||
1050 | extern void gz_close(int gunzip_pid) | 1049 | extern void gz_close(int gunzip_pid) |
@@ -58,6 +58,8 @@ | |||
58 | 58 | ||
59 | #ifdef BB_FEATURE_TAR_GZIP | 59 | #ifdef BB_FEATURE_TAR_GZIP |
60 | extern int unzip(int in, int out); | 60 | extern int unzip(int in, int out); |
61 | extern int gz_open(FILE *compressed_file, int *pid); | ||
62 | extern void gz_close(int gunzip_pid); | ||
61 | #endif | 63 | #endif |
62 | 64 | ||
63 | /* Tar file constants */ | 65 | /* Tar file constants */ |
@@ -202,6 +204,7 @@ extern int tar_main(int argc, char **argv) | |||
202 | char file[256]; | 204 | char file[256]; |
203 | #endif | 205 | #endif |
204 | #if defined BB_FEATURE_TAR_GZIP | 206 | #if defined BB_FEATURE_TAR_GZIP |
207 | FILE *comp_file = NULL; | ||
205 | int unzipFlag = FALSE; | 208 | int unzipFlag = FALSE; |
206 | #endif | 209 | #endif |
207 | int listFlag = FALSE; | 210 | int listFlag = FALSE; |
@@ -211,6 +214,7 @@ extern int tar_main(int argc, char **argv) | |||
211 | int tostdoutFlag = FALSE; | 214 | int tostdoutFlag = FALSE; |
212 | int status = FALSE; | 215 | int status = FALSE; |
213 | int opt; | 216 | int opt; |
217 | pid_t pid; | ||
214 | 218 | ||
215 | if (argc <= 1) | 219 | if (argc <= 1) |
216 | show_usage(); | 220 | show_usage(); |
@@ -315,13 +319,25 @@ extern int tar_main(int argc, char **argv) | |||
315 | 319 | ||
316 | #ifdef BB_FEATURE_TAR_GZIP | 320 | #ifdef BB_FEATURE_TAR_GZIP |
317 | /* unzip tarFd in a seperate process */ | 321 | /* unzip tarFd in a seperate process */ |
318 | if (unzipFlag == TRUE) | 322 | if (unzipFlag == TRUE) { |
319 | tarFd = tar_unzip_init(tarFd); | 323 | comp_file = fdopen(tarFd, "r"); |
324 | printf("1\n"); | ||
325 | if ((tarFd = gz_open(comp_file, &pid)) == EXIT_FAILURE) { | ||
326 | error_msg_and_die("Couldnt unzip file"); | ||
327 | } | ||
328 | printf("2\n"); | ||
329 | } | ||
320 | #endif | 330 | #endif |
321 | status = readTarFile(tarFd, extractFlag, listFlag, tostdoutFlag, | 331 | status = readTarFile(tarFd, extractFlag, listFlag, tostdoutFlag, |
322 | verboseFlag, extractList, excludeList); | 332 | verboseFlag, extractList, excludeList); |
333 | close(tarFd); | ||
323 | } | 334 | } |
324 | 335 | ||
336 | #ifdef BB_FEATURE_TAR_GZIP | ||
337 | gz_close(pid); | ||
338 | fclose(comp_file); | ||
339 | #endif | ||
340 | |||
325 | if (status == TRUE) | 341 | if (status == TRUE) |
326 | return EXIT_SUCCESS; | 342 | return EXIT_SUCCESS; |
327 | else | 343 | else |