aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2012-03-06 16:32:06 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2012-03-06 16:32:06 +0100
commit02c3c3842004d88207b46450dbd19f80e6596c7e (patch)
tree68890b6d081c3851b898f41bede25badc6b453fa
parent8a6a2f9c9c214b94bd945acd97ac8b28c25e194e (diff)
downloadbusybox-w32-02c3c3842004d88207b46450dbd19f80e6596c7e.tar.gz
busybox-w32-02c3c3842004d88207b46450dbd19f80e6596c7e.tar.bz2
busybox-w32-02c3c3842004d88207b46450dbd19f80e6596c7e.zip
Move seamless .Z support into unpack_gz_stream
unpack_gz_stream 566 643 +77 unpack_gunzip 123 12 -111 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--archival/Config.src4
-rw-r--r--archival/bbunzip.c24
-rw-r--r--archival/libarchive/decompress_gunzip.c18
3 files changed, 21 insertions, 25 deletions
diff --git a/archival/Config.src b/archival/Config.src
index 885cb5bcc..ae1afc594 100644
--- a/archival/Config.src
+++ b/archival/Config.src
@@ -32,10 +32,10 @@ config FEATURE_SEAMLESS_GZ
32 Make tar, rpm, modprobe etc understand .gz data. 32 Make tar, rpm, modprobe etc understand .gz data.
33 33
34config FEATURE_SEAMLESS_Z 34config FEATURE_SEAMLESS_Z
35 bool "Make tar and gunzip understand .Z data" 35 bool "tar, rpm, modprobe etc understand .Z data"
36 default n 36 default n
37 help 37 help
38 Make tar and gunzip understand .Z data. 38 Make tar, rpm, modprobe etc understand .Z data.
39 39
40config AR 40config AR
41 bool "ar" 41 bool "ar"
diff --git a/archival/bbunzip.c b/archival/bbunzip.c
index 1bc04ed33..94d8a81c9 100644
--- a/archival/bbunzip.c
+++ b/archival/bbunzip.c
@@ -274,29 +274,7 @@ char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UN
274static 274static
275IF_DESKTOP(long long) int FAST_FUNC unpack_gunzip(transformer_aux_data_t *aux) 275IF_DESKTOP(long long) int FAST_FUNC unpack_gunzip(transformer_aux_data_t *aux)
276{ 276{
277 IF_DESKTOP(long long) int status = -1; 277 return unpack_gz_stream(aux, STDIN_FILENO, STDOUT_FILENO);
278 uint16_t magic2;
279
280//TODO: fold below into unpack_gz_stream? Then the whole level of indirection
281// unpack_FOO() -> unpack_FOO_stream can be collapsed in this module!
282
283 aux->check_signature = 0; /* we will check it here, not in unpack_*_stream */
284
285 if (full_read(STDIN_FILENO, &magic2, 2) != 2)
286 goto bad_magic;
287 if (ENABLE_FEATURE_SEAMLESS_Z && magic2 == COMPRESS_MAGIC) {
288 status = unpack_Z_stream(aux, STDIN_FILENO, STDOUT_FILENO);
289 } else if (magic2 == GZIP_MAGIC) {
290 status = unpack_gz_stream(aux, STDIN_FILENO, STDOUT_FILENO);
291 } else {
292 bad_magic:
293 bb_error_msg("invalid magic");
294 /* status is still == -1 */
295 }
296 if (status < 0) {
297 bb_error_msg("error inflating");
298 }
299 return status;
300} 278}
301/* 279/*
302 * Linux kernel build uses gzip -d -n. We accept and ignore it. 280 * Linux kernel build uses gzip -d -n. We accept and ignore it.
diff --git a/archival/libarchive/decompress_gunzip.c b/archival/libarchive/decompress_gunzip.c
index f1c9a79e5..66152a853 100644
--- a/archival/libarchive/decompress_gunzip.c
+++ b/archival/libarchive/decompress_gunzip.c
@@ -1188,8 +1188,26 @@ unpack_gz_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
1188 IF_DESKTOP(long long) int total, n; 1188 IF_DESKTOP(long long) int total, n;
1189 DECLARE_STATE; 1189 DECLARE_STATE;
1190 1190
1191#if !ENABLE_FEATURE_SEAMLESS_Z
1191 if (check_signature16(aux, src_fd, GZIP_MAGIC)) 1192 if (check_signature16(aux, src_fd, GZIP_MAGIC))
1192 return -1; 1193 return -1;
1194#else
1195 if (aux && aux->check_signature) {
1196 uint16_t magic2;
1197
1198 if (full_read(STDIN_FILENO, &magic2, 2) != 2) {
1199 bad_magic:
1200 bb_error_msg("invalid magic");
1201 return -1;
1202 }
1203 if (magic2 == COMPRESS_MAGIC) {
1204 aux->check_signature = 0;
1205 return unpack_Z_stream(aux, src_fd, dst_fd);
1206 }
1207 if (magic2 != GZIP_MAGIC)
1208 goto bad_magic;
1209 }
1210#endif
1193 1211
1194 total = 0; 1212 total = 0;
1195 1213