summaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2015-05-18 09:36:27 +0100
committerRon Yorston <rmy@pobox.com>2015-05-18 09:36:27 +0100
commit60063627a6d540871061854a362047e6517f821c (patch)
tree0de228630450c64e085f2e3f5141b5ba17eccab3 /archival
parentec39cb770ddd5c0e085d5c4ee10be65bab5e7a44 (diff)
parent9a595bb36ded308e6d4336aef2c1cd3ac738a398 (diff)
downloadbusybox-w32-60063627a6d540871061854a362047e6517f821c.tar.gz
busybox-w32-60063627a6d540871061854a362047e6517f821c.tar.bz2
busybox-w32-60063627a6d540871061854a362047e6517f821c.zip
Merge branch 'busybox' into mergeFRP
Diffstat (limited to 'archival')
-rw-r--r--archival/gzip.c72
-rw-r--r--archival/libarchive/get_header_tar.c28
-rw-r--r--archival/libarchive/open_transformer.c7
3 files changed, 86 insertions, 21 deletions
diff --git a/archival/gzip.c b/archival/gzip.c
index bc1f9c60b..42b2f0b2e 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -62,14 +62,27 @@ aa: 85.1% -- replaced with aa.gz
62//config: 1: larger buffers, larger hash-tables 62//config: 1: larger buffers, larger hash-tables
63//config: 2: larger buffers, largest hash-tables 63//config: 2: larger buffers, largest hash-tables
64//config: Larger models may give slightly better compression 64//config: Larger models may give slightly better compression
65//config:
66//config:config FEATURE_GZIP_LEVELS
67//config: bool "Enable compression levels"
68//config: default n
69//config: depends on GZIP
70//config: help
71//config: Enable support for compression levels 4-9. The default level
72//config: is 6. If levels 1-3 are specified, 4 is used.
73//config: If this option is not selected, -N options are ignored and -9
74//config: is used.
65 75
66//applet:IF_GZIP(APPLET(gzip, BB_DIR_BIN, BB_SUID_DROP)) 76//applet:IF_GZIP(APPLET(gzip, BB_DIR_BIN, BB_SUID_DROP))
67//kbuild:lib-$(CONFIG_GZIP) += gzip.o 77//kbuild:lib-$(CONFIG_GZIP) += gzip.o
68 78
69//usage:#define gzip_trivial_usage 79//usage:#define gzip_trivial_usage
70//usage: "[-cfd] [FILE]..." 80//usage: "[-cfd" IF_FEATURE_GZIP_LEVELS("123456789") "] [FILE]..."
71//usage:#define gzip_full_usage "\n\n" 81//usage:#define gzip_full_usage "\n\n"
72//usage: "Compress FILEs (or stdin)\n" 82//usage: "Compress FILEs (or stdin)\n"
83//usage: IF_FEATURE_GZIP_LEVELS(
84//usage: "\n -1..9 Compression level"
85//usage: )
73//usage: "\n -d Decompress" 86//usage: "\n -d Decompress"
74//usage: "\n -c Write to stdout" 87//usage: "\n -c Write to stdout"
75//usage: "\n -f Force" 88//usage: "\n -f Force"
@@ -252,6 +265,8 @@ enum {
252 * input file length plus MIN_LOOKAHEAD. 265 * input file length plus MIN_LOOKAHEAD.
253 */ 266 */
254 267
268#ifndef ENABLE_FEATURE_GZIP_LEVELS
269
255 max_chain_length = 4096, 270 max_chain_length = 4096,
256/* To speed up deflation, hash chains are never searched beyond this length. 271/* To speed up deflation, hash chains are never searched beyond this length.
257 * A higher limit improves compression ratio but degrades the speed. 272 * A higher limit improves compression ratio but degrades the speed.
@@ -283,11 +298,23 @@ enum {
283 * For deflate_fast() (levels <= 3) good is ignored and lazy has a different 298 * For deflate_fast() (levels <= 3) good is ignored and lazy has a different
284 * meaning. 299 * meaning.
285 */ 300 */
301#endif /* ENABLE_FEATURE_GZIP_LEVELS */
286}; 302};
287 303
288 304
289struct globals { 305struct globals {
290 306
307#ifdef ENABLE_FEATURE_GZIP_LEVELS
308 unsigned max_chain_length;
309 unsigned max_lazy_match;
310 unsigned good_match;
311 unsigned nice_match;
312#define max_chain_length (G1.max_chain_length)
313#define max_lazy_match (G1.max_lazy_match)
314#define good_match (G1.good_match)
315#define nice_match (G1.nice_match)
316#endif
317
291 lng block_start; 318 lng block_start;
292 319
293/* window position at the beginning of the current output block. Gets 320/* window position at the beginning of the current output block. Gets
@@ -2161,24 +2188,48 @@ int gzip_main(int argc UNUSED_PARAM, char **argv)
2161#endif 2188#endif
2162{ 2189{
2163 unsigned opt; 2190 unsigned opt;
2191#ifdef ENABLE_FEATURE_GZIP_LEVELS
2192 static const struct {
2193 uint8_t good;
2194 uint8_t chain_shift;
2195 uint8_t lazy2;
2196 uint8_t nice2;
2197 } gzip_level_config[6] = {
2198 {4, 4, 4/2, 16/2}, /* Level 4 */
2199 {8, 5, 16/2, 32/2}, /* Level 5 */
2200 {8, 7, 16/2, 128/2}, /* Level 6 */
2201 {8, 8, 32/2, 128/2}, /* Level 7 */
2202 {32, 10, 128/2, 258/2}, /* Level 8 */
2203 {32, 12, 258/2, 258/2}, /* Level 9 */
2204 };
2205#endif
2206
2207 SET_PTR_TO_GLOBALS((char *)xzalloc(sizeof(struct globals)+sizeof(struct globals2))
2208 + sizeof(struct globals));
2164 2209
2165#if ENABLE_FEATURE_GZIP_LONG_OPTIONS 2210#if ENABLE_FEATURE_GZIP_LONG_OPTIONS
2166 applet_long_options = gzip_longopts; 2211 applet_long_options = gzip_longopts;
2167#endif 2212#endif
2168 /* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */ 2213 /* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
2169 opt = getopt32(argv, "cfv" IF_GUNZIP("dt") "q123456789n"); 2214 opt = getopt32(argv, "cfv" IF_GUNZIP("dt") "qn123456789");
2170#if ENABLE_GUNZIP /* gunzip_main may not be visible... */ 2215#if ENABLE_GUNZIP /* gunzip_main may not be visible... */
2171 if (opt & 0x18) // -d and/or -t 2216 if (opt & 0x18) // -d and/or -t
2172 return gunzip_main(argc, argv); 2217 return gunzip_main(argc, argv);
2173#endif 2218#endif
2174 option_mask32 &= 0x7; /* ignore -q, -0..9 */ 2219#ifdef ENABLE_FEATURE_GZIP_LEVELS
2175 //if (opt & 0x1) // -c 2220 opt >>= ENABLE_GUNZIP ? 7 : 5; /* drop cfv[dt]qn bits */
2176 //if (opt & 0x2) // -f 2221 if (opt == 0)
2177 //if (opt & 0x4) // -v 2222 opt = 1 << 6; /* default: 6 */
2178 argv += optind; 2223 /* Map 1..3 to 4 */
2179 2224 if (opt & 0x7)
2180 SET_PTR_TO_GLOBALS((char *)xzalloc(sizeof(struct globals)+sizeof(struct globals2)) 2225 opt |= 1 << 4;
2181 + sizeof(struct globals)); 2226 opt = ffs(opt >> 3);
2227 max_chain_length = 1 << gzip_level_config[opt].chain_shift;
2228 good_match = gzip_level_config[opt].good;
2229 max_lazy_match = gzip_level_config[opt].lazy2 * 2;
2230 nice_match = gzip_level_config[opt].nice2 * 2;
2231#endif
2232 option_mask32 &= 0x7; /* retain only -cfv */
2182 2233
2183 /* Allocate all global buffers (for DYN_ALLOC option) */ 2234 /* Allocate all global buffers (for DYN_ALLOC option) */
2184 ALLOC(uch, G1.l_buf, INBUFSIZ); 2235 ALLOC(uch, G1.l_buf, INBUFSIZ);
@@ -2190,5 +2241,6 @@ int gzip_main(int argc UNUSED_PARAM, char **argv)
2190 /* Initialize the CRC32 table */ 2241 /* Initialize the CRC32 table */
2191 global_crc32_table = crc32_filltable(NULL, 0); 2242 global_crc32_table = crc32_filltable(NULL, 0);
2192 2243
2244 argv += optind;
2193 return bbunpack(argv, pack_gzip, append_ext, "gz"); 2245 return bbunpack(argv, pack_gzip, append_ext, "gz");
2194} 2246}
diff --git a/archival/libarchive/get_header_tar.c b/archival/libarchive/get_header_tar.c
index 2dbcdb50c..fb68673b9 100644
--- a/archival/libarchive/get_header_tar.c
+++ b/archival/libarchive/get_header_tar.c
@@ -350,7 +350,14 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
350 case '6': 350 case '6':
351 file_header->mode |= S_IFIFO; 351 file_header->mode |= S_IFIFO;
352 goto size0; 352 goto size0;
353 case 'g': /* pax global header */
354 case 'x': { /* pax extended header */
355 if ((uoff_t)file_header->size > 0xfffff) /* paranoia */
356 goto skip_ext_hdr;
357 process_pax_hdr(archive_handle, file_header->size, (tar.typeflag == 'g'));
358 goto again_after_align;
353#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS 359#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
360/* See http://www.gnu.org/software/tar/manual/html_node/Extensions.html */
354 case 'L': 361 case 'L':
355 /* free: paranoia: tar with several consecutive longnames */ 362 /* free: paranoia: tar with several consecutive longnames */
356 free(p_longname); 363 free(p_longname);
@@ -370,18 +377,17 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
370 archive_handle->offset += file_header->size; 377 archive_handle->offset += file_header->size;
371 /* return get_header_tar(archive_handle); */ 378 /* return get_header_tar(archive_handle); */
372 goto again; 379 goto again;
373 case 'D': /* GNU dump dir */ 380/*
374 case 'M': /* Continuation of multi volume archive */ 381 * case 'S': // Sparse file
375 case 'N': /* Old GNU for names > 100 characters */ 382 * Was seen in the wild. Not supported (yet?).
376 case 'S': /* Sparse file */ 383 * See https://www.gnu.org/software/tar/manual/html_section/tar_92.html
377 case 'V': /* Volume header */ 384 * for the format. (An "Old GNU Format" was seen, not PAX formats).
385 */
386// case 'D': /* GNU dump dir */
387// case 'M': /* Continuation of multi volume archive */
388// case 'N': /* Old GNU for names > 100 characters */
389// case 'V': /* Volume header */
378#endif 390#endif
379 case 'g': /* pax global header */
380 case 'x': { /* pax extended header */
381 if ((uoff_t)file_header->size > 0xfffff) /* paranoia */
382 goto skip_ext_hdr;
383 process_pax_hdr(archive_handle, file_header->size, (tar.typeflag == 'g'));
384 goto again_after_align;
385 } 391 }
386 skip_ext_hdr: 392 skip_ext_hdr:
387 { 393 {
diff --git a/archival/libarchive/open_transformer.c b/archival/libarchive/open_transformer.c
index 0a8c657b7..1c5c185d0 100644
--- a/archival/libarchive/open_transformer.c
+++ b/archival/libarchive/open_transformer.c
@@ -183,6 +183,13 @@ static transformer_state_t *setup_transformer_on_fd(int fd, int fail_if_not_comp
183 USE_FOR_NOMMU(xstate->xformer_prog = "gunzip";) 183 USE_FOR_NOMMU(xstate->xformer_prog = "gunzip";)
184 goto found_magic; 184 goto found_magic;
185 } 185 }
186 if (ENABLE_FEATURE_SEAMLESS_Z
187 && magic.b16[0] == COMPRESS_MAGIC
188 ) {
189 xstate->xformer = unpack_Z_stream;
190 USE_FOR_NOMMU(xstate->xformer_prog = "uncompress";)
191 goto found_magic;
192 }
186 if (ENABLE_FEATURE_SEAMLESS_BZ2 193 if (ENABLE_FEATURE_SEAMLESS_BZ2
187 && magic.b16[0] == BZIP2_MAGIC 194 && magic.b16[0] == BZIP2_MAGIC
188 ) { 195 ) {