open_transformer: do not duplicate "<program> -cf -"
authorDenis Vlasenko <vda.linux@googlemail.com>
Mon, 12 Nov 2007 02:13:12 +0000 (02:13 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Mon, 12 Nov 2007 02:13:12 +0000 (02:13 -0000)
   text    data     bss     dec     hex filename
 677858     738    7236  685832   a7708 busybox_old
 677804     738    7236  685778   a76d2 busybox_unstripped

archival/libunarchive/get_header_tar_bz2.c
archival/libunarchive/get_header_tar_gz.c
archival/libunarchive/get_header_tar_lzma.c
archival/libunarchive/open_transformer.c
archival/rpm.c
archival/tar.c
include/unarchive.h

index 6d4f5851ed6e0899f64f5fac5a7e120805c798f9..c2cbaff5fcfc0e635b988f591196c7322b634963 100644 (file)
@@ -11,7 +11,7 @@ char get_header_tar_bz2(archive_handle_t *archive_handle)
        /* Can't lseek over pipes */
        archive_handle->seek = seek_by_read;
 
-       archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_bz2_stream, "bunzip2", "bunzip2", "-cf", "-", NULL);
+       archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_bz2_stream, "bunzip2");
        archive_handle->offset = 0;
        while (get_header_tar(archive_handle) == EXIT_SUCCESS)
                continue;
index dd655f557c1c1a1515a2bcc8d8edb82792604dbb..9772e33fbc5a76bc6d7c0c5a949c5016a9f569c8 100644 (file)
@@ -25,7 +25,7 @@ char get_header_tar_gz(archive_handle_t *archive_handle)
        }
 #endif
 
-       archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_gz_stream, "gunzip", "gunzip", "-cf", "-", NULL);
+       archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_gz_stream, "gunzip");
        archive_handle->offset = 0;
        while (get_header_tar(archive_handle) == EXIT_SUCCESS)
                continue;
index cf73824e36c7a7d557ddd708054a845b021cff64..c859dcc583c40dd784e295b114a80bdbd5e1d52a 100644 (file)
@@ -14,7 +14,7 @@ char get_header_tar_lzma(archive_handle_t * archive_handle)
        /* Can't lseek over pipes */
        archive_handle->seek = seek_by_read;
 
-       archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_lzma_stream, "unlzma", "unlzma", "-cf", "-", NULL);
+       archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_lzma_stream, "unlzma");
        archive_handle->offset = 0;
        while (get_header_tar(archive_handle) == EXIT_SUCCESS)
                continue;
index 355613a67849d1baca08622de32d2da63864c71c..757a2a38905e2618309a28854cc26c6789c6f107 100644 (file)
@@ -8,12 +8,12 @@
 
 /* transformer(), more than meets the eye */
 /*
- * On MMU machine, the transform_prog and ... are stripped
- * by a macro in include/unarchive.h. On NOMMU, transformer is stripped.
+ * On MMU machine, the transform_prog is removed by macro magic
+ * in include/unarchive.h. On NOMMU, transformer is removed.
  */
 int open_transformer(int src_fd,
        USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd),
-       const char *transform_prog, ...)
+       const char *transform_prog)
 {
        int fd_pipe[2];
        int pid;
@@ -29,9 +29,6 @@ int open_transformer(int src_fd,
                bb_perror_msg_and_die("fork failed");
 
        if (pid == 0) {
-#if !BB_MMU
-               va_list ap;
-#endif
                /* child process */
                close(fd_pipe[0]); /* We don't wan't to read from the parent */
                // FIXME: error check?
@@ -43,12 +40,17 @@ int open_transformer(int src_fd,
                }
                exit(0);
 #else
-               xmove_fd(src_fd, 0);
-               xmove_fd(fd_pipe[1], 1);
-               va_start(ap, transform_prog);
-               /* hoping that va_list -> char** on our CPU is working... */
-               BB_EXECVP(transform_prog, (void*)ap);
-               bb_perror_msg_and_die("exec failed");
+               {
+                       char *argv[4];
+                       xmove_fd(src_fd, 0);
+                       xmove_fd(fd_pipe[1], 1);
+                       argv[0] = (char*)transform_prog;
+                       argv[1] = (char*)"-cf";
+                       argv[2] = (char*)"-";
+                       argv[3] = NULL;
+                       BB_EXECVP(transform_prog, argv);
+                       bb_perror_msg_and_die("exec failed");
+               }
 #endif
                /* notreached */
        }
index f078aea1045f9b94e5fc3162c4791deee70437dc..41b8c81b22b7c059540e2e527998019c79e54162 100644 (file)
@@ -237,7 +237,7 @@ static void extract_cpio_gz(int fd)
        }
 
        xchdir("/"); /* Install RPM's to root */
-       archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer, xformer_prog, xformer_prog, "-cf", "-", NULL);
+       archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer, xformer_prog);
        archive_handle->offset = 0;
        while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
                continue;
index 3fe188656e04807195f53e719df7f6c63f13da8a..1def615b5a30cafae4183461d02f84b29f7a09d8 100644 (file)
@@ -662,7 +662,7 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
                bb_error_msg_and_die("invalid magic");
        }
 
-       archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress, "uncompress", "uncompress", "-cf", "-", NULL);
+       archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress, "uncompress");
        archive_handle->offset = 0;
        while (get_header_tar(archive_handle) == EXIT_SUCCESS)
                continue;
index 3d3965528d5ba86648327f11c84a3ba5378763ca..00a00d6721a3cdf14b310a1049a169441037da9c 100644 (file)
@@ -116,10 +116,10 @@ extern USE_DESKTOP(long long) int unpack_lzma_stream(int src_fd, int dst_fd);
 #if BB_MMU
 extern int open_transformer(int src_fd,
        USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd));
-#define open_transformer(src_fd, transformer, transform_prog, ...) open_transformer(src_fd, transformer)
+#define open_transformer(src_fd, transformer, transform_prog) open_transformer(src_fd, transformer)
 #else
-extern int open_transformer(int src_fd, const char *transform_prog, ...);
-#define open_transformer(src_fd, transformer, transform_prog, ...) open_transformer(src_fd, transform_prog, __VA_ARGS__)
+extern int open_transformer(int src_fd, const char *transform_prog);
+#define open_transformer(src_fd, transformer, transform_prog) open_transformer(src_fd, transform_prog)
 #endif
 
 #endif