Fix tar -z, calls gz_open now
This commit is contained in:
parent
ee79ca1ba6
commit
018e9e6799
@ -918,7 +918,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
|
|||||||
in_file = l_in_file;
|
in_file = l_in_file;
|
||||||
out_file = l_out_file;
|
out_file = l_out_file;
|
||||||
|
|
||||||
if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
|
/* if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
|
||||||
(void) signal(SIGINT, (sig_type) abort_gzip);
|
(void) signal(SIGINT, (sig_type) abort_gzip);
|
||||||
}
|
}
|
||||||
#ifdef SIGTERM
|
#ifdef SIGTERM
|
||||||
@ -931,7 +931,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
|
|||||||
(void) signal(SIGHUP, (sig_type) abort_gzip);
|
(void) signal(SIGHUP, (sig_type) abort_gzip);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
/* Allocate all global buffers (for DYN_ALLOC option) */
|
/* Allocate all global buffers (for DYN_ALLOC option) */
|
||||||
window = xmalloc((size_t)(((2L*WSIZE)+1L)*sizeof(unsigned char)));
|
window = xmalloc((size_t)(((2L*WSIZE)+1L)*sizeof(unsigned char)));
|
||||||
outcnt = 0;
|
outcnt = 0;
|
||||||
@ -1018,33 +1018,32 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern FILE *gz_open(FILE *compressed_file, int *pid)
|
extern int gz_open(FILE *compressed_file, int *pid)
|
||||||
{
|
{
|
||||||
int unzip_pipe[2];
|
int unzip_pipe[2];
|
||||||
|
|
||||||
signal(SIGCHLD, abort_gzip);
|
// signal(SIGCHLD, abort_gzip);
|
||||||
if (pipe(unzip_pipe)!=0) {
|
if (pipe(unzip_pipe)!=0) {
|
||||||
error_msg("pipe error");
|
error_msg("pipe error");
|
||||||
return NULL;
|
return(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if ((*pid = fork()) == -1) {
|
if ((*pid = fork()) == -1) {
|
||||||
error_msg("fork failured");
|
error_msg("fork failured");
|
||||||
return NULL;
|
return(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (*pid==0) {
|
if (*pid==0) {
|
||||||
/* child process */
|
/* child process */
|
||||||
close(unzip_pipe[0]);
|
close(unzip_pipe[0]);
|
||||||
unzip(compressed_file, fdopen(unzip_pipe[1], "w"));
|
unzip(compressed_file, fdopen(unzip_pipe[1], "w"));
|
||||||
// printf("finished unzipping\n");
|
printf("finished unzipping\n");
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
// printf("fluched\n");
|
|
||||||
fclose(compressed_file);
|
fclose(compressed_file);
|
||||||
close(unzip_pipe[1]);
|
close(unzip_pipe[1]);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
close(unzip_pipe[1]);
|
close(unzip_pipe[1]);
|
||||||
return (fdopen(unzip_pipe[0], "r"));
|
return(unzip_pipe[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void gz_close(int gunzip_pid)
|
extern void gz_close(int gunzip_pid)
|
||||||
|
@ -58,6 +58,8 @@
|
|||||||
|
|
||||||
#ifdef BB_FEATURE_TAR_GZIP
|
#ifdef BB_FEATURE_TAR_GZIP
|
||||||
extern int unzip(int in, int out);
|
extern int unzip(int in, int out);
|
||||||
|
extern int gz_open(FILE *compressed_file, int *pid);
|
||||||
|
extern void gz_close(int gunzip_pid);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Tar file constants */
|
/* Tar file constants */
|
||||||
@ -202,6 +204,7 @@ extern int tar_main(int argc, char **argv)
|
|||||||
char file[256];
|
char file[256];
|
||||||
#endif
|
#endif
|
||||||
#if defined BB_FEATURE_TAR_GZIP
|
#if defined BB_FEATURE_TAR_GZIP
|
||||||
|
FILE *comp_file = NULL;
|
||||||
int unzipFlag = FALSE;
|
int unzipFlag = FALSE;
|
||||||
#endif
|
#endif
|
||||||
int listFlag = FALSE;
|
int listFlag = FALSE;
|
||||||
@ -211,6 +214,7 @@ extern int tar_main(int argc, char **argv)
|
|||||||
int tostdoutFlag = FALSE;
|
int tostdoutFlag = FALSE;
|
||||||
int status = FALSE;
|
int status = FALSE;
|
||||||
int opt;
|
int opt;
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
if (argc <= 1)
|
if (argc <= 1)
|
||||||
show_usage();
|
show_usage();
|
||||||
@ -315,13 +319,25 @@ extern int tar_main(int argc, char **argv)
|
|||||||
|
|
||||||
#ifdef BB_FEATURE_TAR_GZIP
|
#ifdef BB_FEATURE_TAR_GZIP
|
||||||
/* unzip tarFd in a seperate process */
|
/* unzip tarFd in a seperate process */
|
||||||
if (unzipFlag == TRUE)
|
if (unzipFlag == TRUE) {
|
||||||
tarFd = tar_unzip_init(tarFd);
|
comp_file = fdopen(tarFd, "r");
|
||||||
|
printf("1\n");
|
||||||
|
if ((tarFd = gz_open(comp_file, &pid)) == EXIT_FAILURE) {
|
||||||
|
error_msg_and_die("Couldnt unzip file");
|
||||||
|
}
|
||||||
|
printf("2\n");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
status = readTarFile(tarFd, extractFlag, listFlag, tostdoutFlag,
|
status = readTarFile(tarFd, extractFlag, listFlag, tostdoutFlag,
|
||||||
verboseFlag, extractList, excludeList);
|
verboseFlag, extractList, excludeList);
|
||||||
|
close(tarFd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BB_FEATURE_TAR_GZIP
|
||||||
|
gz_close(pid);
|
||||||
|
fclose(comp_file);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (status == TRUE)
|
if (status == TRUE)
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
else
|
else
|
||||||
|
17
gunzip.c
17
gunzip.c
@ -918,7 +918,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
|
|||||||
in_file = l_in_file;
|
in_file = l_in_file;
|
||||||
out_file = l_out_file;
|
out_file = l_out_file;
|
||||||
|
|
||||||
if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
|
/* if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
|
||||||
(void) signal(SIGINT, (sig_type) abort_gzip);
|
(void) signal(SIGINT, (sig_type) abort_gzip);
|
||||||
}
|
}
|
||||||
#ifdef SIGTERM
|
#ifdef SIGTERM
|
||||||
@ -931,7 +931,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
|
|||||||
(void) signal(SIGHUP, (sig_type) abort_gzip);
|
(void) signal(SIGHUP, (sig_type) abort_gzip);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
/* Allocate all global buffers (for DYN_ALLOC option) */
|
/* Allocate all global buffers (for DYN_ALLOC option) */
|
||||||
window = xmalloc((size_t)(((2L*WSIZE)+1L)*sizeof(unsigned char)));
|
window = xmalloc((size_t)(((2L*WSIZE)+1L)*sizeof(unsigned char)));
|
||||||
outcnt = 0;
|
outcnt = 0;
|
||||||
@ -1018,33 +1018,32 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern FILE *gz_open(FILE *compressed_file, int *pid)
|
extern int gz_open(FILE *compressed_file, int *pid)
|
||||||
{
|
{
|
||||||
int unzip_pipe[2];
|
int unzip_pipe[2];
|
||||||
|
|
||||||
signal(SIGCHLD, abort_gzip);
|
// signal(SIGCHLD, abort_gzip);
|
||||||
if (pipe(unzip_pipe)!=0) {
|
if (pipe(unzip_pipe)!=0) {
|
||||||
error_msg("pipe error");
|
error_msg("pipe error");
|
||||||
return NULL;
|
return(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if ((*pid = fork()) == -1) {
|
if ((*pid = fork()) == -1) {
|
||||||
error_msg("fork failured");
|
error_msg("fork failured");
|
||||||
return NULL;
|
return(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (*pid==0) {
|
if (*pid==0) {
|
||||||
/* child process */
|
/* child process */
|
||||||
close(unzip_pipe[0]);
|
close(unzip_pipe[0]);
|
||||||
unzip(compressed_file, fdopen(unzip_pipe[1], "w"));
|
unzip(compressed_file, fdopen(unzip_pipe[1], "w"));
|
||||||
// printf("finished unzipping\n");
|
printf("finished unzipping\n");
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
// printf("fluched\n");
|
|
||||||
fclose(compressed_file);
|
fclose(compressed_file);
|
||||||
close(unzip_pipe[1]);
|
close(unzip_pipe[1]);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
close(unzip_pipe[1]);
|
close(unzip_pipe[1]);
|
||||||
return (fdopen(unzip_pipe[0], "r"));
|
return(unzip_pipe[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void gz_close(int gunzip_pid)
|
extern void gz_close(int gunzip_pid)
|
||||||
|
20
tar.c
20
tar.c
@ -58,6 +58,8 @@
|
|||||||
|
|
||||||
#ifdef BB_FEATURE_TAR_GZIP
|
#ifdef BB_FEATURE_TAR_GZIP
|
||||||
extern int unzip(int in, int out);
|
extern int unzip(int in, int out);
|
||||||
|
extern int gz_open(FILE *compressed_file, int *pid);
|
||||||
|
extern void gz_close(int gunzip_pid);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Tar file constants */
|
/* Tar file constants */
|
||||||
@ -202,6 +204,7 @@ extern int tar_main(int argc, char **argv)
|
|||||||
char file[256];
|
char file[256];
|
||||||
#endif
|
#endif
|
||||||
#if defined BB_FEATURE_TAR_GZIP
|
#if defined BB_FEATURE_TAR_GZIP
|
||||||
|
FILE *comp_file = NULL;
|
||||||
int unzipFlag = FALSE;
|
int unzipFlag = FALSE;
|
||||||
#endif
|
#endif
|
||||||
int listFlag = FALSE;
|
int listFlag = FALSE;
|
||||||
@ -211,6 +214,7 @@ extern int tar_main(int argc, char **argv)
|
|||||||
int tostdoutFlag = FALSE;
|
int tostdoutFlag = FALSE;
|
||||||
int status = FALSE;
|
int status = FALSE;
|
||||||
int opt;
|
int opt;
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
if (argc <= 1)
|
if (argc <= 1)
|
||||||
show_usage();
|
show_usage();
|
||||||
@ -315,13 +319,25 @@ extern int tar_main(int argc, char **argv)
|
|||||||
|
|
||||||
#ifdef BB_FEATURE_TAR_GZIP
|
#ifdef BB_FEATURE_TAR_GZIP
|
||||||
/* unzip tarFd in a seperate process */
|
/* unzip tarFd in a seperate process */
|
||||||
if (unzipFlag == TRUE)
|
if (unzipFlag == TRUE) {
|
||||||
tarFd = tar_unzip_init(tarFd);
|
comp_file = fdopen(tarFd, "r");
|
||||||
|
printf("1\n");
|
||||||
|
if ((tarFd = gz_open(comp_file, &pid)) == EXIT_FAILURE) {
|
||||||
|
error_msg_and_die("Couldnt unzip file");
|
||||||
|
}
|
||||||
|
printf("2\n");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
status = readTarFile(tarFd, extractFlag, listFlag, tostdoutFlag,
|
status = readTarFile(tarFd, extractFlag, listFlag, tostdoutFlag,
|
||||||
verboseFlag, extractList, excludeList);
|
verboseFlag, extractList, excludeList);
|
||||||
|
close(tarFd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BB_FEATURE_TAR_GZIP
|
||||||
|
gz_close(pid);
|
||||||
|
fclose(comp_file);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (status == TRUE)
|
if (status == TRUE)
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user