diff options
Diffstat (limited to '')
-rw-r--r-- | archival/bbunzip.c | 2 | ||||
-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 | ||||
-rw-r--r-- | archival/rpm.c | 26 | ||||
-rw-r--r-- | archival/tar.c | 2 |
8 files changed, 90 insertions, 44 deletions
diff --git a/archival/bbunzip.c b/archival/bbunzip.c index 56c742a49..a4e525f2e 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c | |||
@@ -298,7 +298,7 @@ USE_DESKTOP(long long) int unpack_unlzma(void) | |||
298 | int unlzma_main(int argc, char **argv); | 298 | int unlzma_main(int argc, char **argv); |
299 | int unlzma_main(int argc, char **argv) | 299 | int unlzma_main(int argc, char **argv) |
300 | { | 300 | { |
301 | getopt32(argv, "c"); | 301 | getopt32(argv, "cf"); |
302 | argv += optind; | 302 | argv += optind; |
303 | /* lzmacat? */ | 303 | /* lzmacat? */ |
304 | if (applet_name[4] == 'c') | 304 | if (applet_name[4] == 'c') |
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 | ||
diff --git a/archival/rpm.c b/archival/rpm.c index 674ee2640..4d723b73f 100644 --- a/archival/rpm.c +++ b/archival/rpm.c | |||
@@ -187,9 +187,15 @@ int rpm_main(int argc, char **argv) | |||
187 | 187 | ||
188 | static void extract_cpio_gz(int fd) | 188 | static void extract_cpio_gz(int fd) |
189 | { | 189 | { |
190 | USE_DESKTOP(long long) int (*xformer)(int src_fd, int dst_fd); | ||
191 | archive_handle_t *archive_handle; | 190 | archive_handle_t *archive_handle; |
192 | unsigned char magic[2]; | 191 | unsigned char magic[2]; |
192 | #if BB_MMU | ||
193 | USE_DESKTOP(long long) int (*xformer)(int src_fd, int dst_fd); | ||
194 | enum { xformer_prog = 0 }; | ||
195 | #else | ||
196 | enum { xformer = 0 }; | ||
197 | const char *xformer_prog; | ||
198 | #endif | ||
193 | 199 | ||
194 | /* Initialize */ | 200 | /* Initialize */ |
195 | archive_handle = init_handle(); | 201 | archive_handle = init_handle(); |
@@ -202,11 +208,19 @@ static void extract_cpio_gz(int fd) | |||
202 | archive_handle->offset = 0; | 208 | archive_handle->offset = 0; |
203 | 209 | ||
204 | xread(archive_handle->src_fd, &magic, 2); | 210 | xread(archive_handle->src_fd, &magic, 2); |
211 | #if BB_MMU | ||
205 | xformer = unpack_gz_stream; | 212 | xformer = unpack_gz_stream; |
213 | #else | ||
214 | xformer_prog = "gunzip"; | ||
215 | #endif | ||
206 | if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { | 216 | if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { |
207 | if (ENABLE_FEATURE_RPM_BZ2 | 217 | if (ENABLE_FEATURE_RPM_BZ2 |
208 | && (magic[0] == 0x42) && (magic[1] == 0x5a)) { | 218 | && (magic[0] == 0x42) && (magic[1] == 0x5a)) { |
219 | #if BB_MMU | ||
209 | xformer = unpack_bz2_stream; | 220 | xformer = unpack_bz2_stream; |
221 | #else | ||
222 | xformer_prog = "bunzip2"; | ||
223 | #endif | ||
210 | /* We can do better, need modifying unpack_bz2_stream to not require | 224 | /* We can do better, need modifying unpack_bz2_stream to not require |
211 | * first 2 bytes. Not very hard to do... I mean, TODO :) */ | 225 | * first 2 bytes. Not very hard to do... I mean, TODO :) */ |
212 | xlseek(archive_handle->src_fd, -2, SEEK_CUR); | 226 | xlseek(archive_handle->src_fd, -2, SEEK_CUR); |
@@ -214,11 +228,17 @@ static void extract_cpio_gz(int fd) | |||
214 | bb_error_msg_and_die("no gzip" | 228 | bb_error_msg_and_die("no gzip" |
215 | USE_FEATURE_RPM_BZ2("/bzip") | 229 | USE_FEATURE_RPM_BZ2("/bzip") |
216 | " magic"); | 230 | " magic"); |
217 | } else | 231 | } else { |
218 | check_header_gzip_or_die(archive_handle->src_fd); | 232 | check_header_gzip_or_die(archive_handle->src_fd); |
233 | #if !BB_MMU | ||
234 | /* NOMMU version of open_transformer execs an external unzipper that should | ||
235 | * have the file position at the start of the file */ | ||
236 | xlseek(archive_handle->src_fd, 0, SEEK_SET); | ||
237 | #endif | ||
238 | } | ||
219 | 239 | ||
220 | xchdir("/"); /* Install RPM's to root */ | 240 | xchdir("/"); /* Install RPM's to root */ |
221 | archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer); | 241 | archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer, xformer_prog, xformer_prog, "-cf", "-", NULL); |
222 | archive_handle->offset = 0; | 242 | archive_handle->offset = 0; |
223 | while (get_header_cpio(archive_handle) == EXIT_SUCCESS) | 243 | while (get_header_cpio(archive_handle) == EXIT_SUCCESS) |
224 | continue; | 244 | continue; |
diff --git a/archival/tar.c b/archival/tar.c index 9bf9058d8..7235616cf 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -648,7 +648,7 @@ static char get_header_tar_Z(archive_handle_t *archive_handle) | |||
648 | bb_error_msg_and_die("invalid magic"); | 648 | bb_error_msg_and_die("invalid magic"); |
649 | } | 649 | } |
650 | 650 | ||
651 | archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress); | 651 | archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress, "uncompress", "uncompress", "-cf", "-", NULL); |
652 | archive_handle->offset = 0; | 652 | archive_handle->offset = 0; |
653 | while (get_header_tar(archive_handle) == EXIT_SUCCESS) | 653 | while (get_header_tar(archive_handle) == EXIT_SUCCESS) |
654 | /* nothing */; | 654 | /* nothing */; |