diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-04-13 08:43:01 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-04-13 08:43:01 +0000 |
commit | 114de5566849b3ab533f2892d5edfdf16c542db5 (patch) | |
tree | b5e67628ab1b4724225bea5b599b8169032a202b /archival/libunarchive | |
parent | 1d1d2f9b1879775a8e04bcd189b66a058405c9c1 (diff) | |
download | busybox-w32-114de5566849b3ab533f2892d5edfdf16c542db5.tar.gz busybox-w32-114de5566849b3ab533f2892d5edfdf16c542db5.tar.bz2 busybox-w32-114de5566849b3ab533f2892d5edfdf16c542db5.zip |
Patch from Laurence Anderson <L.D.Anderson@warwick.ac.uk> for
better tape drive support in tar/cpio by using an intervening
pipe...
Diffstat (limited to 'archival/libunarchive')
-rw-r--r-- | archival/libunarchive/unarchive.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/archival/libunarchive/unarchive.c b/archival/libunarchive/unarchive.c index 41be963ef..49908affb 100644 --- a/archival/libunarchive/unarchive.c +++ b/archival/libunarchive/unarchive.c | |||
@@ -21,8 +21,10 @@ | |||
21 | #include <string.h> | 21 | #include <string.h> |
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | #include <utime.h> | 23 | #include <utime.h> |
24 | #include <sys/wait.h> | ||
25 | #include <signal.h> | ||
24 | #include "unarchive.h" | 26 | #include "unarchive.h" |
25 | #include "libbb.h" | 27 | #include "busybox.h" |
26 | 28 | ||
27 | /* Extract the data postioned at src_stream to either filesystem, stdout or | 29 | /* Extract the data postioned at src_stream to either filesystem, stdout or |
28 | * buffer depending on the value of 'function' which is defined in libbb.h | 30 | * buffer depending on the value of 'function' which is defined in libbb.h |
@@ -202,7 +204,22 @@ char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers | |||
202 | int extract_flag = TRUE; | 204 | int extract_flag = TRUE; |
203 | int i; | 205 | int i; |
204 | char *buffer = NULL; | 206 | char *buffer = NULL; |
207 | #ifdef CONFIG_FEATURE_UNARCHIVE_TAPE | ||
208 | int pid, tape_pipe[2]; | ||
205 | 209 | ||
210 | if (pipe(tape_pipe) != 0) error_msg_and_die("Can't create pipe\n"); | ||
211 | if ((pid = fork()) == -1) error_msg_and_die("Fork failed\n"); | ||
212 | if (pid==0) { /* child process */ | ||
213 | close(tape_pipe[0]); /* We don't wan't to read from the pipe */ | ||
214 | copyfd(fileno(src_stream), tape_pipe[1]); | ||
215 | close(tape_pipe[1]); /* Send EOF */ | ||
216 | exit(0); | ||
217 | /* notreached */ | ||
218 | } | ||
219 | close(tape_pipe[1]); /* Don't want to write down the pipe */ | ||
220 | fclose(src_stream); | ||
221 | src_stream = fdopen(tape_pipe[0], "r"); | ||
222 | #endif | ||
206 | archive_offset = 0; | 223 | archive_offset = 0; |
207 | while ((file_entry = get_headers(src_stream)) != NULL) { | 224 | while ((file_entry = get_headers(src_stream)) != NULL) { |
208 | 225 | ||
@@ -238,5 +255,9 @@ char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers | |||
238 | free(file_entry->link_name); | 255 | free(file_entry->link_name); |
239 | free(file_entry); | 256 | free(file_entry); |
240 | } | 257 | } |
258 | #ifdef CONFIG_FEATURE_UNARCHIVE_TAPE | ||
259 | kill(pid, SIGTERM); | ||
260 | waitpid(pid, NULL, 0); | ||
261 | #endif | ||
241 | return(buffer); | 262 | return(buffer); |
242 | } | 263 | } |