diff options
author | Ron Yorston <rmy@pobox.com> | 2017-07-18 15:58:52 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2017-07-18 15:58:52 +0100 |
commit | b680f05ad449505e3d914bebd4c8d83bf768c094 (patch) | |
tree | c08ded13d430b0e7e0104f2eb594fad190ce98a3 /archival | |
parent | 258200ff81d5a9da54dab35acf36213eff1e399b (diff) | |
parent | 513a2457b65894b10b9fd6aa8753fca59eced08c (diff) | |
download | busybox-w32-b680f05ad449505e3d914bebd4c8d83bf768c094.tar.gz busybox-w32-b680f05ad449505e3d914bebd4c8d83bf768c094.tar.bz2 busybox-w32-b680f05ad449505e3d914bebd4c8d83bf768c094.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'archival')
-rw-r--r-- | archival/bbunzip.c | 60 | ||||
-rw-r--r-- | archival/bzip2.c | 11 | ||||
-rw-r--r-- | archival/dpkg.c | 4 | ||||
-rw-r--r-- | archival/gzip.c | 19 | ||||
-rw-r--r-- | archival/libarchive/decompress_unxz.c | 16 | ||||
-rw-r--r-- | archival/lzop.c | 53 | ||||
-rw-r--r-- | archival/tar.c | 25 | ||||
-rw-r--r-- | archival/unzip.c | 21 |
8 files changed, 140 insertions, 69 deletions
diff --git a/archival/bbunzip.c b/archival/bbunzip.c index 311c7333e..1e3d6e586 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c | |||
@@ -7,24 +7,30 @@ | |||
7 | #include "libbb.h" | 7 | #include "libbb.h" |
8 | #include "bb_archive.h" | 8 | #include "bb_archive.h" |
9 | 9 | ||
10 | //kbuild:lib-$(CONFIG_ZCAT) += bbunzip.o | ||
11 | //kbuild:lib-$(CONFIG_GUNZIP) += bbunzip.o | ||
12 | //kbuild:lib-$(CONFIG_BZCAT) += bbunzip.o | ||
13 | //kbuild:lib-$(CONFIG_BUNZIP2) += bbunzip.o | ||
14 | |||
10 | /* lzop_main() uses bbunpack(), need this: */ | 15 | /* lzop_main() uses bbunpack(), need this: */ |
11 | //kbuild:lib-$(CONFIG_LZOP) += bbunzip.o | 16 | //kbuild:lib-$(CONFIG_LZOP) += bbunzip.o |
12 | //kbuild:lib-$(CONFIG_LZOPCAT) += bbunzip.o | 17 | //kbuild:lib-$(CONFIG_LZOPCAT) += bbunzip.o |
13 | //kbuild:lib-$(CONFIG_UNLZOP) += bbunzip.o | 18 | //kbuild:lib-$(CONFIG_UNLZOP) += bbunzip.o |
14 | /* bzip2_main() too: */ | 19 | /* bzip2_main() too: */ |
15 | //kbuild:lib-$(CONFIG_FEATURE_BZIP2_DECOMPRESS) += bbunzip.o | 20 | //kbuild:lib-$(CONFIG_BZIP2) += bbunzip.o |
16 | /* gzip_main() too: */ | 21 | /* gzip_main() too: */ |
17 | //kbuild:lib-$(CONFIG_FEATURE_GZIP_DECOMPRESS) += bbunzip.o | 22 | //kbuild:lib-$(CONFIG_GZIP) += bbunzip.o |
18 | 23 | ||
19 | /* Note: must be kept in sync with archival/lzop.c */ | 24 | /* Note: must be kept in sync with archival/lzop.c */ |
20 | enum { | 25 | enum { |
21 | OPT_STDOUT = 1 << 0, | 26 | OPT_STDOUT = 1 << 0, |
22 | OPT_FORCE = 1 << 1, | 27 | OPT_FORCE = 1 << 1, |
23 | /* only some decompressors: */ | 28 | /* only some decompressors: */ |
24 | OPT_VERBOSE = 1 << 2, | 29 | OPT_KEEP = 1 << 2, |
25 | OPT_QUIET = 1 << 3, | 30 | OPT_VERBOSE = 1 << 3, |
26 | OPT_DECOMPRESS = 1 << 4, | 31 | OPT_QUIET = 1 << 4, |
27 | OPT_TEST = 1 << 5, | 32 | OPT_DECOMPRESS = 1 << 5, |
33 | OPT_TEST = 1 << 6, | ||
28 | SEAMLESS_MAGIC = (1 << 31) * ENABLE_ZCAT * SEAMLESS_COMPRESSION, | 34 | SEAMLESS_MAGIC = (1 << 31) * ENABLE_ZCAT * SEAMLESS_COMPRESSION, |
29 | }; | 35 | }; |
30 | 36 | ||
@@ -182,10 +188,13 @@ int FAST_FUNC bbunpack(char **argv, | |||
182 | } | 188 | } |
183 | /* Delete _source_ file */ | 189 | /* Delete _source_ file */ |
184 | del = filename; | 190 | del = filename; |
191 | if (option_mask32 & OPT_KEEP) /* ... unless -k */ | ||
192 | del = NULL; | ||
185 | } | 193 | } |
186 | if (ENABLE_PLATFORM_MINGW32) | 194 | if (ENABLE_PLATFORM_MINGW32) |
187 | xclose(STDIN_FILENO); | 195 | xclose(STDIN_FILENO); |
188 | xunlink(del); | 196 | if (del) |
197 | xunlink(del); | ||
189 | free_name: | 198 | free_name: |
190 | if (new_name != filename) | 199 | if (new_name != filename) |
191 | free(new_name); | 200 | free(new_name); |
@@ -242,7 +251,16 @@ char* FAST_FUNC make_new_name_generic(char *filename, const char *expected_ext) | |||
242 | int uncompress_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 251 | int uncompress_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
243 | int uncompress_main(int argc UNUSED_PARAM, char **argv) | 252 | int uncompress_main(int argc UNUSED_PARAM, char **argv) |
244 | { | 253 | { |
254 | // (N)compress 4.2.4.4: | ||
255 | // -d If given, decompression is done instead | ||
256 | // -c Write output on stdout, don't remove original | ||
257 | // -b Parameter limits the max number of bits/code | ||
258 | // -f Forces output file to be generated | ||
259 | // -v Write compression statistics | ||
260 | // -V Output vesion and compile options | ||
261 | // -r Recursive. If a filename is a directory, descend into it and compress everything | ||
245 | getopt32(argv, "cf"); | 262 | getopt32(argv, "cf"); |
263 | |||
246 | argv += optind; | 264 | argv += optind; |
247 | 265 | ||
248 | return bbunpack(argv, unpack_Z_stream, make_new_name_generic, "Z"); | 266 | return bbunpack(argv, unpack_Z_stream, make_new_name_generic, "Z"); |
@@ -275,11 +293,12 @@ int uncompress_main(int argc UNUSED_PARAM, char **argv) | |||
275 | * Ken Turkowski, Dave Mack and Peter Jannesen. | 293 | * Ken Turkowski, Dave Mack and Peter Jannesen. |
276 | */ | 294 | */ |
277 | //usage:#define gunzip_trivial_usage | 295 | //usage:#define gunzip_trivial_usage |
278 | //usage: "[-cft] [FILE]..." | 296 | //usage: "[-cfkt] [FILE]..." |
279 | //usage:#define gunzip_full_usage "\n\n" | 297 | //usage:#define gunzip_full_usage "\n\n" |
280 | //usage: "Decompress FILEs (or stdin)\n" | 298 | //usage: "Decompress FILEs (or stdin)\n" |
281 | //usage: "\n -c Write to stdout" | 299 | //usage: "\n -c Write to stdout" |
282 | //usage: "\n -f Force" | 300 | //usage: "\n -f Force" |
301 | //usage: "\n -k Keep input files" | ||
283 | //usage: "\n -t Test file integrity" | 302 | //usage: "\n -t Test file integrity" |
284 | //usage: | 303 | //usage: |
285 | //usage:#define gunzip_example_usage | 304 | //usage:#define gunzip_example_usage |
@@ -374,7 +393,7 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv) | |||
374 | #if ENABLE_FEATURE_GUNZIP_LONG_OPTIONS | 393 | #if ENABLE_FEATURE_GUNZIP_LONG_OPTIONS |
375 | applet_long_options = gunzip_longopts; | 394 | applet_long_options = gunzip_longopts; |
376 | #endif | 395 | #endif |
377 | getopt32(argv, "cfvqdtn"); | 396 | getopt32(argv, "cfkvqdtn"); |
378 | argv += optind; | 397 | argv += optind; |
379 | 398 | ||
380 | /* If called as zcat... | 399 | /* If called as zcat... |
@@ -396,11 +415,12 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv) | |||
396 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 415 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
397 | */ | 416 | */ |
398 | //usage:#define bunzip2_trivial_usage | 417 | //usage:#define bunzip2_trivial_usage |
399 | //usage: "[-cf] [FILE]..." | 418 | //usage: "[-cfk] [FILE]..." |
400 | //usage:#define bunzip2_full_usage "\n\n" | 419 | //usage:#define bunzip2_full_usage "\n\n" |
401 | //usage: "Decompress FILEs (or stdin)\n" | 420 | //usage: "Decompress FILEs (or stdin)\n" |
402 | //usage: "\n -c Write to stdout" | 421 | //usage: "\n -c Write to stdout" |
403 | //usage: "\n -f Force" | 422 | //usage: "\n -f Force" |
423 | //usage: "\n -k Keep input files" | ||
404 | //usage:#define bzcat_trivial_usage | 424 | //usage:#define bzcat_trivial_usage |
405 | //usage: "[FILE]..." | 425 | //usage: "[FILE]..." |
406 | //usage:#define bzcat_full_usage "\n\n" | 426 | //usage:#define bzcat_full_usage "\n\n" |
@@ -430,11 +450,11 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv) | |||
430 | //applet:IF_BUNZIP2(APPLET(bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP)) | 450 | //applet:IF_BUNZIP2(APPLET(bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP)) |
431 | // APPLET_ODDNAME:name main location suid_type help | 451 | // APPLET_ODDNAME:name main location suid_type help |
432 | //applet:IF_BZCAT(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat)) | 452 | //applet:IF_BZCAT(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat)) |
433 | #if ENABLE_FEATURE_BZIP2_DECOMPRESS | 453 | #if ENABLE_FEATURE_BZIP2_DECOMPRESS || ENABLE_BUNZIP2 || ENABLE_BZCAT |
434 | int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 454 | int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
435 | int bunzip2_main(int argc UNUSED_PARAM, char **argv) | 455 | int bunzip2_main(int argc UNUSED_PARAM, char **argv) |
436 | { | 456 | { |
437 | getopt32(argv, "cfvqdt"); | 457 | getopt32(argv, "cfkvqdt"); |
438 | argv += optind; | 458 | argv += optind; |
439 | if (ENABLE_BZCAT && applet_name[2] == 'c') /* bzcat */ | 459 | if (ENABLE_BZCAT && applet_name[2] == 'c') /* bzcat */ |
440 | option_mask32 |= OPT_STDOUT; | 460 | option_mask32 |= OPT_STDOUT; |
@@ -453,19 +473,21 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv) | |||
453 | * Licensed under GPLv2, see file LICENSE in this source tree. | 473 | * Licensed under GPLv2, see file LICENSE in this source tree. |
454 | */ | 474 | */ |
455 | //usage:#define unlzma_trivial_usage | 475 | //usage:#define unlzma_trivial_usage |
456 | //usage: "[-cf] [FILE]..." | 476 | //usage: "[-cfk] [FILE]..." |
457 | //usage:#define unlzma_full_usage "\n\n" | 477 | //usage:#define unlzma_full_usage "\n\n" |
458 | //usage: "Decompress FILE (or stdin)\n" | 478 | //usage: "Decompress FILE (or stdin)\n" |
459 | //usage: "\n -c Write to stdout" | 479 | //usage: "\n -c Write to stdout" |
460 | //usage: "\n -f Force" | 480 | //usage: "\n -f Force" |
481 | //usage: "\n -k Keep input files" | ||
461 | //usage: | 482 | //usage: |
462 | //usage:#define lzma_trivial_usage | 483 | //usage:#define lzma_trivial_usage |
463 | //usage: "-d [-cf] [FILE]..." | 484 | //usage: "-d [-cfk] [FILE]..." |
464 | //usage:#define lzma_full_usage "\n\n" | 485 | //usage:#define lzma_full_usage "\n\n" |
465 | //usage: "Decompress FILE (or stdin)\n" | 486 | //usage: "Decompress FILE (or stdin)\n" |
466 | //usage: "\n -d Decompress" | 487 | //usage: "\n -d Decompress" |
467 | //usage: "\n -c Write to stdout" | 488 | //usage: "\n -c Write to stdout" |
468 | //usage: "\n -f Force" | 489 | //usage: "\n -f Force" |
490 | //usage: "\n -k Keep input files" | ||
469 | //usage: | 491 | //usage: |
470 | //usage:#define lzcat_trivial_usage | 492 | //usage:#define lzcat_trivial_usage |
471 | //usage: "[FILE]..." | 493 | //usage: "[FILE]..." |
@@ -522,7 +544,7 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv) | |||
522 | int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 544 | int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
523 | int unlzma_main(int argc UNUSED_PARAM, char **argv) | 545 | int unlzma_main(int argc UNUSED_PARAM, char **argv) |
524 | { | 546 | { |
525 | IF_LZMA(int opts =) getopt32(argv, "cfvqdt"); | 547 | IF_LZMA(int opts =) getopt32(argv, "cfkvqdt"); |
526 | # if ENABLE_LZMA | 548 | # if ENABLE_LZMA |
527 | /* lzma without -d or -t? */ | 549 | /* lzma without -d or -t? */ |
528 | if (applet_name[2] == 'm' && !(opts & (OPT_DECOMPRESS|OPT_TEST))) | 550 | if (applet_name[2] == 'm' && !(opts & (OPT_DECOMPRESS|OPT_TEST))) |
@@ -539,19 +561,21 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv) | |||
539 | 561 | ||
540 | 562 | ||
541 | //usage:#define unxz_trivial_usage | 563 | //usage:#define unxz_trivial_usage |
542 | //usage: "[-cf] [FILE]..." | 564 | //usage: "[-cfk] [FILE]..." |
543 | //usage:#define unxz_full_usage "\n\n" | 565 | //usage:#define unxz_full_usage "\n\n" |
544 | //usage: "Decompress FILE (or stdin)\n" | 566 | //usage: "Decompress FILE (or stdin)\n" |
545 | //usage: "\n -c Write to stdout" | 567 | //usage: "\n -c Write to stdout" |
546 | //usage: "\n -f Force" | 568 | //usage: "\n -f Force" |
569 | //usage: "\n -k Keep input files" | ||
547 | //usage: | 570 | //usage: |
548 | //usage:#define xz_trivial_usage | 571 | //usage:#define xz_trivial_usage |
549 | //usage: "-d [-cf] [FILE]..." | 572 | //usage: "-d [-cfk] [FILE]..." |
550 | //usage:#define xz_full_usage "\n\n" | 573 | //usage:#define xz_full_usage "\n\n" |
551 | //usage: "Decompress FILE (or stdin)\n" | 574 | //usage: "Decompress FILE (or stdin)\n" |
552 | //usage: "\n -d Decompress" | 575 | //usage: "\n -d Decompress" |
553 | //usage: "\n -c Write to stdout" | 576 | //usage: "\n -c Write to stdout" |
554 | //usage: "\n -f Force" | 577 | //usage: "\n -f Force" |
578 | //usage: "\n -k Keep input files" | ||
555 | //usage: | 579 | //usage: |
556 | //usage:#define xzcat_trivial_usage | 580 | //usage:#define xzcat_trivial_usage |
557 | //usage: "[FILE]..." | 581 | //usage: "[FILE]..." |
@@ -588,7 +612,7 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv) | |||
588 | int unxz_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 612 | int unxz_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
589 | int unxz_main(int argc UNUSED_PARAM, char **argv) | 613 | int unxz_main(int argc UNUSED_PARAM, char **argv) |
590 | { | 614 | { |
591 | IF_XZ(int opts =) getopt32(argv, "cfvqdt"); | 615 | IF_XZ(int opts =) getopt32(argv, "cfkvqdt"); |
592 | # if ENABLE_XZ | 616 | # if ENABLE_XZ |
593 | /* xz without -d or -t? */ | 617 | /* xz without -d or -t? */ |
594 | if (applet_name[2] == '\0' && !(opts & (OPT_DECOMPRESS|OPT_TEST))) | 618 | if (applet_name[2] == '\0' && !(opts & (OPT_DECOMPRESS|OPT_TEST))) |
diff --git a/archival/bzip2.c b/archival/bzip2.c index 7e38e78b3..8afa43802 100644 --- a/archival/bzip2.c +++ b/archival/bzip2.c | |||
@@ -43,6 +43,7 @@ | |||
43 | //usage: ) | 43 | //usage: ) |
44 | //usage: "\n -c Write to stdout" | 44 | //usage: "\n -c Write to stdout" |
45 | //usage: "\n -f Force" | 45 | //usage: "\n -f Force" |
46 | //usage: "\n -k Keep input files" | ||
46 | 47 | ||
47 | #include "libbb.h" | 48 | #include "libbb.h" |
48 | #include "bb_archive.h" | 49 | #include "bb_archive.h" |
@@ -196,13 +197,13 @@ int bzip2_main(int argc UNUSED_PARAM, char **argv) | |||
196 | 197 | ||
197 | opt_complementary = "s2"; /* -s means -2 (compatibility) */ | 198 | opt_complementary = "s2"; /* -s means -2 (compatibility) */ |
198 | /* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */ | 199 | /* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */ |
199 | opt = getopt32(argv, "cfv" IF_FEATURE_BZIP2_DECOMPRESS("dt") "123456789qzs"); | 200 | opt = getopt32(argv, "cfkv" IF_FEATURE_BZIP2_DECOMPRESS("dt") "123456789qzs"); |
200 | #if ENABLE_FEATURE_BZIP2_DECOMPRESS /* bunzip2_main may not be visible... */ | 201 | #if ENABLE_FEATURE_BZIP2_DECOMPRESS /* bunzip2_main may not be visible... */ |
201 | if (opt & 0x18) // -d and/or -t | 202 | if (opt & 0x30) // -d and/or -t |
202 | return bunzip2_main(argc, argv); | 203 | return bunzip2_main(argc, argv); |
203 | opt >>= 5; | 204 | opt >>= 6; |
204 | #else | 205 | #else |
205 | opt >>= 3; | 206 | opt >>= 4; |
206 | #endif | 207 | #endif |
207 | opt = (uint8_t)opt; /* isolate bits for -1..-8 */ | 208 | opt = (uint8_t)opt; /* isolate bits for -1..-8 */ |
208 | opt |= 0x100; /* if nothing else, assume -9 */ | 209 | opt |= 0x100; /* if nothing else, assume -9 */ |
@@ -213,6 +214,6 @@ int bzip2_main(int argc UNUSED_PARAM, char **argv) | |||
213 | } | 214 | } |
214 | 215 | ||
215 | argv += optind; | 216 | argv += optind; |
216 | option_mask32 &= 0x7; /* ignore all except -cfv */ | 217 | option_mask32 &= 0xf; /* ignore all except -cfkv */ |
217 | return bbunpack(argv, compressStream, append_ext, "bz2"); | 218 | return bbunpack(argv, compressStream, append_ext, "bz2"); |
218 | } | 219 | } |
diff --git a/archival/dpkg.c b/archival/dpkg.c index 1cd45eda4..da3b0864e 100644 --- a/archival/dpkg.c +++ b/archival/dpkg.c | |||
@@ -1938,10 +1938,6 @@ int dpkg_main(int argc UNUSED_PARAM, char **argv) | |||
1938 | for (i = 0; i < STATUS_HASH_PRIME; i++) { | 1938 | for (i = 0; i < STATUS_HASH_PRIME; i++) { |
1939 | free(status_hashtable[i]); | 1939 | free(status_hashtable[i]); |
1940 | } | 1940 | } |
1941 | |||
1942 | free(status_hashtable); | ||
1943 | free(package_hashtable); | ||
1944 | free(name_hashtable); | ||
1945 | } | 1941 | } |
1946 | 1942 | ||
1947 | return EXIT_SUCCESS; | 1943 | return EXIT_SUCCESS; |
diff --git a/archival/gzip.c b/archival/gzip.c index e698c26cd..c895de426 100644 --- a/archival/gzip.c +++ b/archival/gzip.c | |||
@@ -84,7 +84,7 @@ aa: 85.1% -- replaced with aa.gz | |||
84 | //kbuild:lib-$(CONFIG_GZIP) += gzip.o | 84 | //kbuild:lib-$(CONFIG_GZIP) += gzip.o |
85 | 85 | ||
86 | //usage:#define gzip_trivial_usage | 86 | //usage:#define gzip_trivial_usage |
87 | //usage: "[-cf" IF_FEATURE_GZIP_DECOMPRESS("dt") IF_FEATURE_GZIP_LEVELS("123456789") "] [FILE]..." | 87 | //usage: "[-cfk" IF_FEATURE_GZIP_DECOMPRESS("dt") IF_FEATURE_GZIP_LEVELS("123456789") "] [FILE]..." |
88 | //usage:#define gzip_full_usage "\n\n" | 88 | //usage:#define gzip_full_usage "\n\n" |
89 | //usage: "Compress FILEs (or stdin)\n" | 89 | //usage: "Compress FILEs (or stdin)\n" |
90 | //usage: IF_FEATURE_GZIP_LEVELS( | 90 | //usage: IF_FEATURE_GZIP_LEVELS( |
@@ -96,6 +96,7 @@ aa: 85.1% -- replaced with aa.gz | |||
96 | //usage: ) | 96 | //usage: ) |
97 | //usage: "\n -c Write to stdout" | 97 | //usage: "\n -c Write to stdout" |
98 | //usage: "\n -f Force" | 98 | //usage: "\n -f Force" |
99 | //usage: "\n -k Keep input files" | ||
99 | //usage: | 100 | //usage: |
100 | //usage:#define gzip_example_usage | 101 | //usage:#define gzip_example_usage |
101 | //usage: "$ ls -la /tmp/busybox*\n" | 102 | //usage: "$ ls -la /tmp/busybox*\n" |
@@ -275,7 +276,7 @@ enum { | |||
275 | * input file length plus MIN_LOOKAHEAD. | 276 | * input file length plus MIN_LOOKAHEAD. |
276 | */ | 277 | */ |
277 | 278 | ||
278 | #ifndef ENABLE_FEATURE_GZIP_LEVELS | 279 | #if !ENABLE_FEATURE_GZIP_LEVELS |
279 | 280 | ||
280 | max_chain_length = 4096, | 281 | max_chain_length = 4096, |
281 | /* To speed up deflation, hash chains are never searched beyond this length. | 282 | /* To speed up deflation, hash chains are never searched beyond this length. |
@@ -314,7 +315,7 @@ enum { | |||
314 | 315 | ||
315 | struct globals { | 316 | struct globals { |
316 | 317 | ||
317 | #ifdef ENABLE_FEATURE_GZIP_LEVELS | 318 | #if ENABLE_FEATURE_GZIP_LEVELS |
318 | unsigned max_chain_length; | 319 | unsigned max_chain_length; |
319 | unsigned max_lazy_match; | 320 | unsigned max_lazy_match; |
320 | unsigned good_match; | 321 | unsigned good_match; |
@@ -2196,7 +2197,7 @@ int gzip_main(int argc UNUSED_PARAM, char **argv) | |||
2196 | #endif | 2197 | #endif |
2197 | { | 2198 | { |
2198 | unsigned opt; | 2199 | unsigned opt; |
2199 | #ifdef ENABLE_FEATURE_GZIP_LEVELS | 2200 | #if ENABLE_FEATURE_GZIP_LEVELS |
2200 | static const struct { | 2201 | static const struct { |
2201 | uint8_t good; | 2202 | uint8_t good; |
2202 | uint8_t chain_shift; | 2203 | uint8_t chain_shift; |
@@ -2219,13 +2220,13 @@ int gzip_main(int argc UNUSED_PARAM, char **argv) | |||
2219 | applet_long_options = gzip_longopts; | 2220 | applet_long_options = gzip_longopts; |
2220 | #endif | 2221 | #endif |
2221 | /* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */ | 2222 | /* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */ |
2222 | opt = getopt32(argv, "cfv" IF_FEATURE_GZIP_DECOMPRESS("dt") "qn123456789"); | 2223 | opt = getopt32(argv, "cfkv" IF_FEATURE_GZIP_DECOMPRESS("dt") "qn123456789"); |
2223 | #if ENABLE_FEATURE_GZIP_DECOMPRESS /* gunzip_main may not be visible... */ | 2224 | #if ENABLE_FEATURE_GZIP_DECOMPRESS /* gunzip_main may not be visible... */ |
2224 | if (opt & 0x18) // -d and/or -t | 2225 | if (opt & 0x30) // -d and/or -t |
2225 | return gunzip_main(argc, argv); | 2226 | return gunzip_main(argc, argv); |
2226 | #endif | 2227 | #endif |
2227 | #ifdef ENABLE_FEATURE_GZIP_LEVELS | 2228 | #if ENABLE_FEATURE_GZIP_LEVELS |
2228 | opt >>= ENABLE_FEATURE_GZIP_DECOMPRESS ? 7 : 5; /* drop cfv[dt]qn bits */ | 2229 | opt >>= ENABLE_FEATURE_GZIP_DECOMPRESS ? 8 : 6; /* drop cfkv[dt]qn bits */ |
2229 | if (opt == 0) | 2230 | if (opt == 0) |
2230 | opt = 1 << 6; /* default: 6 */ | 2231 | opt = 1 << 6; /* default: 6 */ |
2231 | opt = ffs(opt >> 4); /* Maps -1..-4 to [0], -5 to [1] ... -9 to [5] */ | 2232 | opt = ffs(opt >> 4); /* Maps -1..-4 to [0], -5 to [1] ... -9 to [5] */ |
@@ -2234,7 +2235,7 @@ int gzip_main(int argc UNUSED_PARAM, char **argv) | |||
2234 | max_lazy_match = gzip_level_config[opt].lazy2 * 2; | 2235 | max_lazy_match = gzip_level_config[opt].lazy2 * 2; |
2235 | nice_match = gzip_level_config[opt].nice2 * 2; | 2236 | nice_match = gzip_level_config[opt].nice2 * 2; |
2236 | #endif | 2237 | #endif |
2237 | option_mask32 &= 0x7; /* retain only -cfv */ | 2238 | option_mask32 &= 0xf; /* retain only -cfkv */ |
2238 | 2239 | ||
2239 | /* Allocate all global buffers (for DYN_ALLOC option) */ | 2240 | /* Allocate all global buffers (for DYN_ALLOC option) */ |
2240 | ALLOC(uch, G1.l_buf, INBUFSIZ); | 2241 | ALLOC(uch, G1.l_buf, INBUFSIZ); |
diff --git a/archival/libarchive/decompress_unxz.c b/archival/libarchive/decompress_unxz.c index cd32cc745..350e5358a 100644 --- a/archival/libarchive/decompress_unxz.c +++ b/archival/libarchive/decompress_unxz.c | |||
@@ -27,11 +27,17 @@ static uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc) | |||
27 | return ~crc32_block_endian0(~crc, buf, size, global_crc32_table); | 27 | return ~crc32_block_endian0(~crc, buf, size, global_crc32_table); |
28 | } | 28 | } |
29 | 29 | ||
30 | /* We use arch-optimized unaligned accessors */ | 30 | /* We use arch-optimized unaligned fixed-endian accessors. |
31 | #define get_unaligned_le32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_LE32(v); }) | 31 | * They have been moved to libbb (proved to be useful elsewhere as well), |
32 | #define get_unaligned_be32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_BE32(v); }) | 32 | * just check that we have them defined: |
33 | #define put_unaligned_le32(val, buf) move_to_unaligned32(buf, SWAP_LE32(val)) | 33 | */ |
34 | #define put_unaligned_be32(val, buf) move_to_unaligned32(buf, SWAP_BE32(val)) | 34 | #if !defined(get_unaligned_le32) \ |
35 | || !defined(get_unaligned_be32) \ | ||
36 | || !defined(put_unaligned_le32) \ | ||
37 | || !defined(put_unaligned_be32) | ||
38 | # error get_unaligned_le32 accessors are not defined | ||
39 | #endif | ||
40 | #define get_le32(p) (*(uint32_t*)(p)) | ||
35 | 41 | ||
36 | #include "unxz/xz_dec_bcj.c" | 42 | #include "unxz/xz_dec_bcj.c" |
37 | #include "unxz/xz_dec_lzma2.c" | 43 | #include "unxz/xz_dec_lzma2.c" |
diff --git a/archival/lzop.c b/archival/lzop.c index ca61add3c..6ef82b749 100644 --- a/archival/lzop.c +++ b/archival/lzop.c | |||
@@ -33,13 +33,13 @@ | |||
33 | //config: | 33 | //config: |
34 | //config:config UNLZOP | 34 | //config:config UNLZOP |
35 | //config: bool "unlzop" | 35 | //config: bool "unlzop" |
36 | //config: default y | 36 | //config: default n # INCOMPAT: upstream lzop does not provide such tool |
37 | //config: help | 37 | //config: help |
38 | //config: Lzop decompresion. | 38 | //config: Lzop decompresion. |
39 | //config: | 39 | //config: |
40 | //config:config LZOPCAT | 40 | //config:config LZOPCAT |
41 | //config: bool "lzopcat" | 41 | //config: bool "lzopcat" |
42 | //config: default y | 42 | //config: default n # INCOMPAT: upstream lzop does not provide such tool |
43 | //config: help | 43 | //config: help |
44 | //config: Alias to "unlzop -c". | 44 | //config: Alias to "unlzop -c". |
45 | //config: | 45 | //config: |
@@ -61,12 +61,14 @@ | |||
61 | //kbuild:lib-$(CONFIG_LZOPCAT) += lzop.o | 61 | //kbuild:lib-$(CONFIG_LZOPCAT) += lzop.o |
62 | 62 | ||
63 | //usage:#define lzop_trivial_usage | 63 | //usage:#define lzop_trivial_usage |
64 | //usage: "[-cfvd123456789CF] [FILE]..." | 64 | //usage: "[-cfUvd123456789CF] [FILE]..." |
65 | //usage:#define lzop_full_usage "\n\n" | 65 | //usage:#define lzop_full_usage "\n\n" |
66 | //usage: " -1..9 Compression level" | 66 | //usage: " -1..9 Compression level" |
67 | //usage: "\n -d Decompress" | 67 | //usage: "\n -d Decompress" |
68 | //usage: "\n -c Write to stdout" | 68 | //usage: "\n -c Write to stdout" |
69 | //usage: "\n -f Force" | 69 | //usage: "\n -f Force" |
70 | //usage: "\n -U Delete input files" | ||
71 | ///////: "\n -k Keep input files" (default, so why bother documenting?) | ||
70 | //usage: "\n -v Verbose" | 72 | //usage: "\n -v Verbose" |
71 | //usage: "\n -F Don't store or verify checksum" | 73 | //usage: "\n -F Don't store or verify checksum" |
72 | //usage: "\n -C Also write checksum of compressed block" | 74 | //usage: "\n -C Also write checksum of compressed block" |
@@ -78,10 +80,12 @@ | |||
78 | //usage: "\n -F Don't verify checksum" | 80 | //usage: "\n -F Don't verify checksum" |
79 | //usage: | 81 | //usage: |
80 | //usage:#define unlzop_trivial_usage | 82 | //usage:#define unlzop_trivial_usage |
81 | //usage: "[-cfvF] [FILE]..." | 83 | //usage: "[-cfkvF] [FILE]..." |
82 | //usage:#define unlzop_full_usage "\n\n" | 84 | //usage:#define unlzop_full_usage "\n\n" |
83 | //usage: " -c Write to stdout" | 85 | //usage: " -c Write to stdout" |
84 | //usage: "\n -f Force" | 86 | //usage: "\n -f Force" |
87 | //usage: "\n -U Delete input files" | ||
88 | ///////: "\n -k Keep input files" (default, so why bother documenting?) | ||
85 | //usage: "\n -v Verbose" | 89 | //usage: "\n -v Verbose" |
86 | //usage: "\n -F Don't verify checksum" | 90 | //usage: "\n -F Don't verify checksum" |
87 | 91 | ||
@@ -472,27 +476,33 @@ struct globals { | |||
472 | //#define LZOP_VERSION_STRING "1.01" | 476 | //#define LZOP_VERSION_STRING "1.01" |
473 | //#define LZOP_VERSION_DATE "Apr 27th 2003" | 477 | //#define LZOP_VERSION_DATE "Apr 27th 2003" |
474 | 478 | ||
475 | #define OPTION_STRING "cfvqdt123456789CF" | 479 | // lzop wants to be weird: |
480 | // unlike all other compressosrs, its -k "keep" option is the default, | ||
481 | // and -U is used to delete the source. We will invert the bit after getopt(). | ||
482 | #define OPTION_STRING "cfUvqdt123456789CFk" | ||
476 | 483 | ||
477 | /* Note: must be kept in sync with archival/bbunzip.c */ | 484 | /* Note: must be kept in sync with archival/bbunzip.c */ |
478 | enum { | 485 | enum { |
479 | OPT_STDOUT = (1 << 0), | 486 | OPT_STDOUT = (1 << 0), |
480 | OPT_FORCE = (1 << 1), | 487 | OPT_FORCE = (1 << 1), |
481 | OPT_VERBOSE = (1 << 2), | 488 | OPT_KEEP = (1 << 2), |
482 | OPT_QUIET = (1 << 3), | 489 | OPT_VERBOSE = (1 << 3), |
483 | OPT_DECOMPRESS = (1 << 4), | 490 | OPT_QUIET = (1 << 4), |
484 | OPT_TEST = (1 << 5), | 491 | OPT_DECOMPRESS = (1 << 5), |
485 | OPT_1 = (1 << 6), | 492 | OPT_TEST = (1 << 6), |
486 | OPT_2 = (1 << 7), | 493 | OPT_1 = (1 << 7), |
487 | OPT_3 = (1 << 8), | 494 | OPT_2 = (1 << 8), |
488 | OPT_4 = (1 << 9), | 495 | OPT_3 = (1 << 9), |
489 | OPT_5 = (1 << 10), | 496 | OPT_4 = (1 << 10), |
490 | OPT_6 = (1 << 11), | 497 | OPT_5 = (1 << 11), |
491 | OPT_789 = (7 << 12), | 498 | OPT_6 = (1 << 12), |
492 | OPT_7 = (1 << 13), | 499 | OPT_7 = (1 << 13), |
493 | OPT_8 = (1 << 14), | 500 | OPT_8 = (1 << 14), |
494 | OPT_C = (1 << 15), | 501 | OPT_9 = (1 << 15), |
495 | OPT_F = (1 << 16), | 502 | OPT_C = (1 << 16), |
503 | OPT_F = (1 << 17), | ||
504 | OPT_k = (1 << 18), | ||
505 | OPT_789 = OPT_7 | OPT_8 | OPT_9 | ||
496 | }; | 506 | }; |
497 | 507 | ||
498 | /**********************************************************************/ | 508 | /**********************************************************************/ |
@@ -1125,6 +1135,13 @@ int lzop_main(int argc UNUSED_PARAM, char **argv) | |||
1125 | { | 1135 | { |
1126 | getopt32(argv, OPTION_STRING); | 1136 | getopt32(argv, OPTION_STRING); |
1127 | argv += optind; | 1137 | argv += optind; |
1138 | /* -U is "anti -k", invert bit for bbunpack(): */ | ||
1139 | option_mask32 ^= OPT_KEEP; | ||
1140 | /* -k disables -U (if any): */ | ||
1141 | /* opt_complementary = "k-U"; - nope, only handles -Uk, not -kU */ | ||
1142 | if (option_mask32 & OPT_k) | ||
1143 | option_mask32 |= OPT_KEEP; | ||
1144 | |||
1128 | /* lzopcat? */ | 1145 | /* lzopcat? */ |
1129 | if (ENABLE_LZOPCAT && applet_name[4] == 'c') | 1146 | if (ENABLE_LZOPCAT && applet_name[4] == 'c') |
1130 | option_mask32 |= (OPT_STDOUT | OPT_DECOMPRESS); | 1147 | option_mask32 |= (OPT_STDOUT | OPT_DECOMPRESS); |
diff --git a/archival/tar.c b/archival/tar.c index be5838d0d..c11b735d5 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -1245,21 +1245,26 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
1245 | USE_FOR_MMU(IF_DESKTOP(long long) int FAST_FUNC (*xformer)(transformer_state_t *xstate);) | 1245 | USE_FOR_MMU(IF_DESKTOP(long long) int FAST_FUNC (*xformer)(transformer_state_t *xstate);) |
1246 | USE_FOR_NOMMU(const char *xformer_prog;) | 1246 | USE_FOR_NOMMU(const char *xformer_prog;) |
1247 | 1247 | ||
1248 | if (opt & OPT_COMPRESS) | 1248 | if (opt & OPT_COMPRESS) { |
1249 | USE_FOR_MMU(xformer = unpack_Z_stream;) | 1249 | USE_FOR_MMU(IF_FEATURE_SEAMLESS_Z(xformer = unpack_Z_stream;)) |
1250 | USE_FOR_NOMMU(xformer_prog = "uncompress";) | 1250 | USE_FOR_NOMMU(xformer_prog = "uncompress";) |
1251 | if (opt & OPT_GZIP) | 1251 | } |
1252 | USE_FOR_MMU(xformer = unpack_gz_stream;) | 1252 | if (opt & OPT_GZIP) { |
1253 | USE_FOR_MMU(IF_FEATURE_SEAMLESS_GZ(xformer = unpack_gz_stream;)) | ||
1253 | USE_FOR_NOMMU(xformer_prog = "gunzip";) | 1254 | USE_FOR_NOMMU(xformer_prog = "gunzip";) |
1254 | if (opt & OPT_BZIP2) | 1255 | } |
1255 | USE_FOR_MMU(xformer = unpack_bz2_stream;) | 1256 | if (opt & OPT_BZIP2) { |
1257 | USE_FOR_MMU(IF_FEATURE_SEAMLESS_BZ2(xformer = unpack_bz2_stream;)) | ||
1256 | USE_FOR_NOMMU(xformer_prog = "bunzip2";) | 1258 | USE_FOR_NOMMU(xformer_prog = "bunzip2";) |
1257 | if (opt & OPT_LZMA) | 1259 | } |
1258 | USE_FOR_MMU(xformer = unpack_lzma_stream;) | 1260 | if (opt & OPT_LZMA) { |
1261 | USE_FOR_MMU(IF_FEATURE_SEAMLESS_LZMA(xformer = unpack_lzma_stream;)) | ||
1259 | USE_FOR_NOMMU(xformer_prog = "unlzma";) | 1262 | USE_FOR_NOMMU(xformer_prog = "unlzma";) |
1260 | if (opt & OPT_XZ) | 1263 | } |
1261 | USE_FOR_MMU(xformer = unpack_xz_stream;) | 1264 | if (opt & OPT_XZ) { |
1265 | USE_FOR_MMU(IF_FEATURE_SEAMLESS_XZ(xformer = unpack_xz_stream;)) | ||
1262 | USE_FOR_NOMMU(xformer_prog = "unxz";) | 1266 | USE_FOR_NOMMU(xformer_prog = "unxz";) |
1267 | } | ||
1263 | 1268 | ||
1264 | fork_transformer_with_sig(tar_handle->src_fd, xformer, xformer_prog); | 1269 | fork_transformer_with_sig(tar_handle->src_fd, xformer, xformer_prog); |
1265 | /* Can't lseek over pipes */ | 1270 | /* Can't lseek over pipes */ |
diff --git a/archival/unzip.c b/archival/unzip.c index 986145d0f..8dfc4e678 100644 --- a/archival/unzip.c +++ b/archival/unzip.c | |||
@@ -349,6 +349,12 @@ static void unzip_extract(zip_header_t *zip, int dst_fd) | |||
349 | return; | 349 | return; |
350 | } | 350 | } |
351 | 351 | ||
352 | // NB: to support symlinks, need to extract symlink target. A-la: | ||
353 | // xstate.mem_output_size_max = zip->fmt.ucmpsize; | ||
354 | // ...unpack... | ||
355 | // if (xstate.mem_output_buf) { success, xstate.mem_output_size is the size } | ||
356 | // Although archives I've seen have fmt.method == 0 for symlinks. | ||
357 | |||
352 | init_transformer_state(&xstate); | 358 | init_transformer_state(&xstate); |
353 | xstate.bytes_in = zip->fmt.cmpsize; | 359 | xstate.bytes_in = zip->fmt.cmpsize; |
354 | xstate.src_fd = zip_fd; | 360 | xstate.src_fd = zip_fd; |
@@ -688,6 +694,20 @@ int unzip_main(int argc, char **argv) | |||
688 | zip.fmt.cmpsize = cdf.fmt.cmpsize; | 694 | zip.fmt.cmpsize = cdf.fmt.cmpsize; |
689 | zip.fmt.ucmpsize = cdf.fmt.ucmpsize; | 695 | zip.fmt.ucmpsize = cdf.fmt.ucmpsize; |
690 | } | 696 | } |
697 | // Seen in some zipfiles: central directory 9 byte extra field contains | ||
698 | // a subfield with ID 0x5455 and 5 data bytes, which is a Unix-style UTC mtime. | ||
699 | // Local header version: | ||
700 | // u16 0x5455 ("UT") | ||
701 | // u16 size (1 + 4 * n) | ||
702 | // u8 flags: bit 0:mtime is present, bit 1:atime is present, bit 2:ctime is present | ||
703 | // u32 mtime | ||
704 | // u32 atime | ||
705 | // u32 ctime | ||
706 | // Central header version: | ||
707 | // u16 0x5455 ("UT") | ||
708 | // u16 size (5 (or 1?)) | ||
709 | // u8 flags: bit 0:mtime is present, bit 1:atime is present, bit 2:ctime is present | ||
710 | // u32 mtime (CDF does not store atime/ctime) | ||
691 | # else | 711 | # else |
692 | /* CDF has the same data as local header, no need to read the latter... | 712 | /* CDF has the same data as local header, no need to read the latter... |
693 | * ...not really. An archive was seen with cdf.extra_len == 6 but | 713 | * ...not really. An archive was seen with cdf.extra_len == 6 but |
@@ -702,6 +722,7 @@ int unzip_main(int argc, char **argv) | |||
702 | if ((cdf.fmt.version_made_by >> 8) == 3) { | 722 | if ((cdf.fmt.version_made_by >> 8) == 3) { |
703 | /* This archive is created on Unix */ | 723 | /* This archive is created on Unix */ |
704 | dir_mode = file_mode = (cdf.fmt.external_attributes >> 16); | 724 | dir_mode = file_mode = (cdf.fmt.external_attributes >> 16); |
725 | //TODO: if (S_ISLNK(file_mode)) this is a symlink | ||
705 | } | 726 | } |
706 | } | 727 | } |
707 | #endif | 728 | #endif |