diff options
Diffstat (limited to 'archival/libunarchive')
-rw-r--r-- | archival/libunarchive/Kbuild | 60 | ||||
-rw-r--r-- | archival/libunarchive/get_header_tar_bz2.c | 2 | ||||
-rw-r--r-- | archival/libunarchive/get_header_tar_gz.c | 9 | ||||
-rw-r--r-- | archival/libunarchive/get_header_tar_lzma.c | 2 | ||||
-rw-r--r-- | archival/libunarchive/open_transformer.c | 31 |
5 files changed, 65 insertions, 39 deletions
diff --git a/archival/libunarchive/Kbuild b/archival/libunarchive/Kbuild index 3c29d541a..d104524e4 100644 --- a/archival/libunarchive/Kbuild +++ b/archival/libunarchive/Kbuild | |||
@@ -35,36 +35,34 @@ DPKG_FILES:= \ | |||
35 | get_header_tar.o \ | 35 | get_header_tar.o \ |
36 | filter_accept_list_reassign.o | 36 | filter_accept_list_reassign.o |
37 | 37 | ||
38 | # open_transformer uses fork(). Compile it only if absolutely necessary | ||
39 | lib-$(CONFIG_RPM) += open_transformer.o | 38 | lib-$(CONFIG_RPM) += open_transformer.o |
40 | lib-$(CONFIG_FEATURE_TAR_BZIP2) += open_transformer.o | 39 | lib-$(CONFIG_FEATURE_TAR_BZIP2) += open_transformer.o |
41 | lib-$(CONFIG_FEATURE_TAR_LZMA) += open_transformer.o | 40 | lib-$(CONFIG_FEATURE_TAR_LZMA) += open_transformer.o |
42 | lib-$(CONFIG_FEATURE_TAR_GZIP) += open_transformer.o | 41 | lib-$(CONFIG_FEATURE_TAR_GZIP) += open_transformer.o |
43 | lib-$(CONFIG_FEATURE_TAR_COMPRESS) += open_transformer.o | 42 | lib-$(CONFIG_FEATURE_TAR_COMPRESS) += open_transformer.o |
44 | lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += open_transformer.o | 43 | lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += open_transformer.o |
45 | lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += open_transformer.o | 44 | lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += open_transformer.o |
46 | lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += open_transformer.o | 45 | lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += open_transformer.o |
47 | |||
48 | lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o | ||
49 | lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o | ||
50 | lib-$(CONFIG_UNLZMA) += decompress_unlzma.o | ||
51 | lib-$(CONFIG_CPIO) += get_header_cpio.o | ||
52 | lib-$(CONFIG_DPKG) += $(DPKG_FILES) | ||
53 | lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES) | ||
54 | lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o | ||
55 | lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o | ||
56 | lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o | ||
57 | lib-$(CONFIG_GUNZIP) += $(GUNZIP_FILES) | ||
58 | lib-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o | ||
59 | lib-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o | ||
60 | lib-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o | ||
61 | lib-$(CONFIG_FEATURE_RPM_BZ2) += decompress_bunzip2.o | ||
62 | lib-$(CONFIG_TAR) += get_header_tar.o | ||
63 | lib-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o | ||
64 | lib-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o | ||
65 | lib-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o | ||
66 | lib-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o | ||
67 | lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o | ||
68 | lib-$(CONFIG_UNZIP) += $(GUNZIP_FILES) | ||
69 | lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o | ||
70 | 46 | ||
47 | lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o | ||
48 | lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o | ||
49 | lib-$(CONFIG_UNLZMA) += decompress_unlzma.o | ||
50 | lib-$(CONFIG_CPIO) += get_header_cpio.o | ||
51 | lib-$(CONFIG_DPKG) += $(DPKG_FILES) | ||
52 | lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES) | ||
53 | lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o | ||
54 | lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o | ||
55 | lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o | ||
56 | lib-$(CONFIG_GUNZIP) += $(GUNZIP_FILES) | ||
57 | lib-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o | ||
58 | lib-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o | ||
59 | lib-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o | ||
60 | lib-$(CONFIG_FEATURE_RPM_BZ2) += decompress_bunzip2.o | ||
61 | lib-$(CONFIG_TAR) += get_header_tar.o | ||
62 | lib-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o | ||
63 | lib-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o | ||
64 | lib-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o | ||
65 | lib-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o | ||
66 | lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o | ||
67 | lib-$(CONFIG_UNZIP) += $(GUNZIP_FILES) | ||
68 | lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o | ||
diff --git a/archival/libunarchive/get_header_tar_bz2.c b/archival/libunarchive/get_header_tar_bz2.c index e11f44cad..8f7f83fc2 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); | 14 | archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_bz2_stream, "bunzip2", "bunzip2", "-cf", "-", NULL); |
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 | 17 | ||
diff --git a/archival/libunarchive/get_header_tar_gz.c b/archival/libunarchive/get_header_tar_gz.c index 85070d978..a99061411 100644 --- a/archival/libunarchive/get_header_tar_gz.c +++ b/archival/libunarchive/get_header_tar_gz.c | |||
@@ -8,19 +8,26 @@ | |||
8 | 8 | ||
9 | char get_header_tar_gz(archive_handle_t *archive_handle) | 9 | char get_header_tar_gz(archive_handle_t *archive_handle) |
10 | { | 10 | { |
11 | #if BB_MMU | ||
11 | unsigned char magic[2]; | 12 | unsigned char magic[2]; |
13 | #endif | ||
12 | 14 | ||
13 | /* Can't lseek over pipes */ | 15 | /* Can't lseek over pipes */ |
14 | archive_handle->seek = seek_by_read; | 16 | archive_handle->seek = seek_by_read; |
15 | 17 | ||
18 | /* Check gzip magic only if open_transformer will invoke unpack_gz_stream (MMU case). | ||
19 | * Otherwise, it will invoke an external helper "gunzip -cf" (NOMMU case) which will | ||
20 | * need the header. */ | ||
21 | #if BB_MMU | ||
16 | xread(archive_handle->src_fd, &magic, 2); | 22 | xread(archive_handle->src_fd, &magic, 2); |
17 | if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { | 23 | if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { |
18 | bb_error_msg_and_die("invalid gzip magic"); | 24 | bb_error_msg_and_die("invalid gzip magic"); |
19 | } | 25 | } |
20 | 26 | ||
21 | check_header_gzip_or_die(archive_handle->src_fd); | 27 | check_header_gzip_or_die(archive_handle->src_fd); |
28 | #endif | ||
22 | 29 | ||
23 | archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_gz_stream); | 30 | archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_gz_stream, "gunzip", "gunzip", "-cf", "-", NULL); |
24 | archive_handle->offset = 0; | 31 | archive_handle->offset = 0; |
25 | while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/; | 32 | while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/; |
26 | 33 | ||
diff --git a/archival/libunarchive/get_header_tar_lzma.c b/archival/libunarchive/get_header_tar_lzma.c index 771f664f2..f0e45f2c5 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); | 17 | archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_lzma_stream, "unlzma", "unlzma", "-cf", "-", NULL); |
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 | 20 | ||
diff --git a/archival/libunarchive/open_transformer.c b/archival/libunarchive/open_transformer.c index 0ee080621..f8f587e8d 100644 --- a/archival/libunarchive/open_transformer.c +++ b/archival/libunarchive/open_transformer.c | |||
@@ -7,27 +7,48 @@ | |||
7 | #include "unarchive.h" | 7 | #include "unarchive.h" |
8 | 8 | ||
9 | /* transformer(), more than meets the eye */ | 9 | /* transformer(), more than meets the eye */ |
10 | /* | ||
11 | * On MMU machine, the transform_prog and ... are stripped | ||
12 | * by a macro in include/unarchive.h. On NOMMU, transformer is stripped. | ||
13 | */ | ||
10 | int open_transformer(int src_fd, | 14 | int open_transformer(int src_fd, |
11 | 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, ...) | ||
12 | { | 17 | { |
13 | int fd_pipe[2]; | 18 | int fd_pipe[2]; |
14 | int pid; | 19 | int pid; |
15 | 20 | ||
16 | xpipe(fd_pipe); | 21 | xpipe(fd_pipe); |
17 | 22 | ||
23 | #if BB_MMU | ||
18 | pid = fork(); | 24 | pid = fork(); |
19 | if (pid == -1) { | 25 | #else |
26 | pid = vfork(); | ||
27 | #endif | ||
28 | if (pid == -1) | ||
20 | bb_perror_msg_and_die("fork failed"); | 29 | bb_perror_msg_and_die("fork failed"); |
21 | } | ||
22 | 30 | ||
23 | if (pid == 0) { | 31 | if (pid == 0) { |
32 | #if !BB_MMU | ||
33 | va_list ap; | ||
34 | #endif | ||
24 | /* child process */ | 35 | /* child process */ |
25 | close(fd_pipe[0]); /* We don't wan't to read from the parent */ | 36 | close(fd_pipe[0]); /* We don't wan't to read from the parent */ |
26 | // FIXME: error check? | 37 | // FIXME: error check? |
38 | #if BB_MMU | ||
27 | transformer(src_fd, fd_pipe[1]); | 39 | transformer(src_fd, fd_pipe[1]); |
28 | close(fd_pipe[1]); /* Send EOF */ | 40 | if (ENABLE_FEATURE_CLEAN_UP) { |
29 | close(src_fd); | 41 | close(fd_pipe[1]); /* Send EOF */ |
42 | close(src_fd); | ||
43 | } | ||
30 | exit(0); | 44 | exit(0); |
45 | #else | ||
46 | xmove_fd(src_fd, 0); | ||
47 | xmove_fd(fd_pipe[1], 1); | ||
48 | va_start(ap, transform_prog); | ||
49 | BB_EXECVP(transform_prog, ap); | ||
50 | bb_perror_and_die("exec failed"); | ||
51 | #endif | ||
31 | /* notreached */ | 52 | /* notreached */ |
32 | } | 53 | } |
33 | 54 | ||