aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-11-12 02:13:12 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-11-12 02:13:12 +0000
commit059c91711f664927534246bd5c1d5e202fcf8e1d (patch)
treebf40a8f1895af5bae790c65435c8d4ae621c55cf
parent4bfb84db4e941e227f07346a3b3a56afd7d1e3fe (diff)
downloadbusybox-w32-059c91711f664927534246bd5c1d5e202fcf8e1d.tar.gz
busybox-w32-059c91711f664927534246bd5c1d5e202fcf8e1d.tar.bz2
busybox-w32-059c91711f664927534246bd5c1d5e202fcf8e1d.zip
open_transformer: do not duplicate "<program> -cf -"
text data bss dec hex filename 677858 738 7236 685832 a7708 busybox_old 677804 738 7236 685778 a76d2 busybox_unstripped
-rw-r--r--archival/libunarchive/get_header_tar_bz2.c2
-rw-r--r--archival/libunarchive/get_header_tar_gz.c2
-rw-r--r--archival/libunarchive/get_header_tar_lzma.c2
-rw-r--r--archival/libunarchive/open_transformer.c26
-rw-r--r--archival/rpm.c2
-rw-r--r--archival/tar.c2
-rw-r--r--include/unarchive.h6
7 files changed, 22 insertions, 20 deletions
diff --git a/archival/libunarchive/get_header_tar_bz2.c b/archival/libunarchive/get_header_tar_bz2.c
index 6d4f5851e..c2cbaff5f 100644
--- a/archival/libunarchive/get_header_tar_bz2.c
+++ b/archival/libunarchive/get_header_tar_bz2.c
@@ -11,7 +11,7 @@ char get_header_tar_bz2(archive_handle_t *archive_handle)
11 /* Can't lseek over pipes */ 11 /* Can't lseek over pipes */
12 archive_handle->seek = seek_by_read; 12 archive_handle->seek = seek_by_read;
13 13
14 archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_bz2_stream, "bunzip2", "bunzip2", "-cf", "-", NULL); 14 archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_bz2_stream, "bunzip2");
15 archive_handle->offset = 0; 15 archive_handle->offset = 0;
16 while (get_header_tar(archive_handle) == EXIT_SUCCESS) 16 while (get_header_tar(archive_handle) == EXIT_SUCCESS)
17 continue; 17 continue;
diff --git a/archival/libunarchive/get_header_tar_gz.c b/archival/libunarchive/get_header_tar_gz.c
index dd655f557..9772e33fb 100644
--- a/archival/libunarchive/get_header_tar_gz.c
+++ b/archival/libunarchive/get_header_tar_gz.c
@@ -25,7 +25,7 @@ char get_header_tar_gz(archive_handle_t *archive_handle)
25 } 25 }
26#endif 26#endif
27 27
28 archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_gz_stream, "gunzip", "gunzip", "-cf", "-", NULL); 28 archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_gz_stream, "gunzip");
29 archive_handle->offset = 0; 29 archive_handle->offset = 0;
30 while (get_header_tar(archive_handle) == EXIT_SUCCESS) 30 while (get_header_tar(archive_handle) == EXIT_SUCCESS)
31 continue; 31 continue;
diff --git a/archival/libunarchive/get_header_tar_lzma.c b/archival/libunarchive/get_header_tar_lzma.c
index cf73824e3..c859dcc58 100644
--- a/archival/libunarchive/get_header_tar_lzma.c
+++ b/archival/libunarchive/get_header_tar_lzma.c
@@ -14,7 +14,7 @@ char get_header_tar_lzma(archive_handle_t * archive_handle)
14 /* Can't lseek over pipes */ 14 /* Can't lseek over pipes */
15 archive_handle->seek = seek_by_read; 15 archive_handle->seek = seek_by_read;
16 16
17 archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_lzma_stream, "unlzma", "unlzma", "-cf", "-", NULL); 17 archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_lzma_stream, "unlzma");
18 archive_handle->offset = 0; 18 archive_handle->offset = 0;
19 while (get_header_tar(archive_handle) == EXIT_SUCCESS) 19 while (get_header_tar(archive_handle) == EXIT_SUCCESS)
20 continue; 20 continue;
diff --git a/archival/libunarchive/open_transformer.c b/archival/libunarchive/open_transformer.c
index 355613a67..757a2a389 100644
--- a/archival/libunarchive/open_transformer.c
+++ b/archival/libunarchive/open_transformer.c
@@ -8,12 +8,12 @@
8 8
9/* transformer(), more than meets the eye */ 9/* transformer(), more than meets the eye */
10/* 10/*
11 * On MMU machine, the transform_prog and ... are stripped 11 * On MMU machine, the transform_prog is removed by macro magic
12 * by a macro in include/unarchive.h. On NOMMU, transformer is stripped. 12 * in include/unarchive.h. On NOMMU, transformer is removed.
13 */ 13 */
14int open_transformer(int src_fd, 14int open_transformer(int src_fd,
15 USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd), 15 USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd),
16 const char *transform_prog, ...) 16 const char *transform_prog)
17{ 17{
18 int fd_pipe[2]; 18 int fd_pipe[2];
19 int pid; 19 int pid;
@@ -29,9 +29,6 @@ int open_transformer(int src_fd,
29 bb_perror_msg_and_die("fork failed"); 29 bb_perror_msg_and_die("fork failed");
30 30
31 if (pid == 0) { 31 if (pid == 0) {
32#if !BB_MMU
33 va_list ap;
34#endif
35 /* child process */ 32 /* child process */
36 close(fd_pipe[0]); /* We don't wan't to read from the parent */ 33 close(fd_pipe[0]); /* We don't wan't to read from the parent */
37 // FIXME: error check? 34 // FIXME: error check?
@@ -43,12 +40,17 @@ int open_transformer(int src_fd,
43 } 40 }
44 exit(0); 41 exit(0);
45#else 42#else
46 xmove_fd(src_fd, 0); 43 {
47 xmove_fd(fd_pipe[1], 1); 44 char *argv[4];
48 va_start(ap, transform_prog); 45 xmove_fd(src_fd, 0);
49 /* hoping that va_list -> char** on our CPU is working... */ 46 xmove_fd(fd_pipe[1], 1);
50 BB_EXECVP(transform_prog, (void*)ap); 47 argv[0] = (char*)transform_prog;
51 bb_perror_msg_and_die("exec failed"); 48 argv[1] = (char*)"-cf";
49 argv[2] = (char*)"-";
50 argv[3] = NULL;
51 BB_EXECVP(transform_prog, argv);
52 bb_perror_msg_and_die("exec failed");
53 }
52#endif 54#endif
53 /* notreached */ 55 /* notreached */
54 } 56 }
diff --git a/archival/rpm.c b/archival/rpm.c
index f078aea10..41b8c81b2 100644
--- a/archival/rpm.c
+++ b/archival/rpm.c
@@ -237,7 +237,7 @@ static void extract_cpio_gz(int fd)
237 } 237 }
238 238
239 xchdir("/"); /* Install RPM's to root */ 239 xchdir("/"); /* Install RPM's to root */
240 archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer, xformer_prog, xformer_prog, "-cf", "-", NULL); 240 archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer, xformer_prog);
241 archive_handle->offset = 0; 241 archive_handle->offset = 0;
242 while (get_header_cpio(archive_handle) == EXIT_SUCCESS) 242 while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
243 continue; 243 continue;
diff --git a/archival/tar.c b/archival/tar.c
index 3fe188656..1def615b5 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -662,7 +662,7 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
662 bb_error_msg_and_die("invalid magic"); 662 bb_error_msg_and_die("invalid magic");
663 } 663 }
664 664
665 archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress, "uncompress", "uncompress", "-cf", "-", NULL); 665 archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress, "uncompress");
666 archive_handle->offset = 0; 666 archive_handle->offset = 0;
667 while (get_header_tar(archive_handle) == EXIT_SUCCESS) 667 while (get_header_tar(archive_handle) == EXIT_SUCCESS)
668 continue; 668 continue;
diff --git a/include/unarchive.h b/include/unarchive.h
index 3d3965528..00a00d672 100644
--- a/include/unarchive.h
+++ b/include/unarchive.h
@@ -116,10 +116,10 @@ extern USE_DESKTOP(long long) int unpack_lzma_stream(int src_fd, int dst_fd);
116#if BB_MMU 116#if BB_MMU
117extern int open_transformer(int src_fd, 117extern int open_transformer(int src_fd,
118 USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd)); 118 USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd));
119#define open_transformer(src_fd, transformer, transform_prog, ...) open_transformer(src_fd, transformer) 119#define open_transformer(src_fd, transformer, transform_prog) open_transformer(src_fd, transformer)
120#else 120#else
121extern int open_transformer(int src_fd, const char *transform_prog, ...); 121extern int open_transformer(int src_fd, const char *transform_prog);
122#define open_transformer(src_fd, transformer, transform_prog, ...) open_transformer(src_fd, transform_prog, __VA_ARGS__) 122#define open_transformer(src_fd, transformer, transform_prog) open_transformer(src_fd, transform_prog)
123#endif 123#endif
124 124
125#endif 125#endif