diff options
Diffstat (limited to 'archival')
-rw-r--r-- | archival/Config.src | 351 | ||||
-rw-r--r-- | archival/Kbuild.src | 19 | ||||
-rw-r--r-- | archival/ar.c | 43 | ||||
-rw-r--r-- | archival/bbunzip.c | 96 | ||||
-rw-r--r-- | archival/bzip2.c | 16 | ||||
-rw-r--r-- | archival/cpio.c | 33 | ||||
-rw-r--r-- | archival/dpkg.c | 16 | ||||
-rw-r--r-- | archival/dpkg_deb.c | 27 | ||||
-rw-r--r-- | archival/gzip.c | 31 | ||||
-rw-r--r-- | archival/libarchive/bz/compress.c | 16 | ||||
-rw-r--r-- | archival/libarchive/decompress_bunzip2.c | 27 | ||||
-rw-r--r-- | archival/libarchive/decompress_gunzip.c | 2 | ||||
-rw-r--r-- | archival/libarchive/get_header_ar.c | 35 | ||||
-rw-r--r-- | archival/libarchive/get_header_tar.c | 14 | ||||
-rw-r--r-- | archival/libarchive/lzo1x_9x.c | 3 | ||||
-rw-r--r-- | archival/libarchive/open_transformer.c | 5 | ||||
-rw-r--r-- | archival/lzop.c | 20 | ||||
-rw-r--r-- | archival/rpm.c | 9 | ||||
-rw-r--r-- | archival/rpm2cpio.c | 9 | ||||
-rw-r--r-- | archival/tar.c | 117 | ||||
-rw-r--r-- | archival/unzip.c | 19 |
21 files changed, 477 insertions, 431 deletions
diff --git a/archival/Config.src b/archival/Config.src index 13c33c795..76635ba78 100644 --- a/archival/Config.src +++ b/archival/Config.src | |||
@@ -5,8 +5,6 @@ | |||
5 | 5 | ||
6 | menu "Archival Utilities" | 6 | menu "Archival Utilities" |
7 | 7 | ||
8 | INSERT | ||
9 | |||
10 | config FEATURE_SEAMLESS_XZ | 8 | config FEATURE_SEAMLESS_XZ |
11 | bool "Make tar, rpm, modprobe etc understand .xz data" | 9 | bool "Make tar, rpm, modprobe etc understand .xz data" |
12 | default y | 10 | default y |
@@ -37,353 +35,6 @@ config FEATURE_SEAMLESS_Z | |||
37 | help | 35 | help |
38 | Make tar, rpm, modprobe etc understand .Z data. | 36 | Make tar, rpm, modprobe etc understand .Z data. |
39 | 37 | ||
40 | config AR | 38 | INSERT |
41 | bool "ar" | ||
42 | default n # needs to be improved to be able to replace binutils ar | ||
43 | help | ||
44 | ar is an archival utility program used to create, modify, and | ||
45 | extract contents from archives. An archive is a single file holding | ||
46 | a collection of other files in a structure that makes it possible to | ||
47 | retrieve the original individual files (called archive members). | ||
48 | The original files' contents, mode (permissions), timestamp, owner, | ||
49 | and group are preserved in the archive, and can be restored on | ||
50 | extraction. | ||
51 | |||
52 | The stored filename is limited to 15 characters. (for more information | ||
53 | see long filename support). | ||
54 | ar has 60 bytes of overheads for every stored file. | ||
55 | |||
56 | This implementation of ar can extract archives, it cannot create or | ||
57 | modify them. | ||
58 | On an x86 system, the ar applet adds about 1K. | ||
59 | |||
60 | Unless you have a specific application which requires ar, you should | ||
61 | probably say N here. | ||
62 | |||
63 | config FEATURE_AR_LONG_FILENAMES | ||
64 | bool "Support for long filenames (not needed for debs)" | ||
65 | default y | ||
66 | depends on AR | ||
67 | help | ||
68 | By default the ar format can only store the first 15 characters | ||
69 | of the filename, this option removes that limitation. | ||
70 | It supports the GNU ar long filename method which moves multiple long | ||
71 | filenames into a the data section of a new ar entry. | ||
72 | |||
73 | config FEATURE_AR_CREATE | ||
74 | bool "Support archive creation" | ||
75 | default y | ||
76 | depends on AR | ||
77 | help | ||
78 | This enables archive creation (-c and -r) with busybox ar. | ||
79 | |||
80 | config BUNZIP2 | ||
81 | bool "bunzip2" | ||
82 | default y | ||
83 | help | ||
84 | bunzip2 is a compression utility using the Burrows-Wheeler block | ||
85 | sorting text compression algorithm, and Huffman coding. Compression | ||
86 | is generally considerably better than that achieved by more | ||
87 | conventional LZ77/LZ78-based compressors, and approaches the | ||
88 | performance of the PPM family of statistical compressors. | ||
89 | |||
90 | Unless you have a specific application which requires bunzip2, you | ||
91 | should probably say N here. | ||
92 | |||
93 | config BZIP2 | ||
94 | bool "bzip2" | ||
95 | default y | ||
96 | help | ||
97 | bzip2 is a compression utility using the Burrows-Wheeler block | ||
98 | sorting text compression algorithm, and Huffman coding. Compression | ||
99 | is generally considerably better than that achieved by more | ||
100 | conventional LZ77/LZ78-based compressors, and approaches the | ||
101 | performance of the PPM family of statistical compressors. | ||
102 | |||
103 | Unless you have a specific application which requires bzip2, you | ||
104 | should probably say N here. | ||
105 | |||
106 | config CPIO | ||
107 | bool "cpio" | ||
108 | default y | ||
109 | help | ||
110 | cpio is an archival utility program used to create, modify, and | ||
111 | extract contents from archives. | ||
112 | cpio has 110 bytes of overheads for every stored file. | ||
113 | |||
114 | This implementation of cpio can extract cpio archives created in the | ||
115 | "newc" or "crc" format, it cannot create or modify them. | ||
116 | |||
117 | Unless you have a specific application which requires cpio, you | ||
118 | should probably say N here. | ||
119 | |||
120 | config FEATURE_CPIO_O | ||
121 | bool "Support for archive creation" | ||
122 | default y | ||
123 | depends on CPIO | ||
124 | help | ||
125 | This implementation of cpio can create cpio archives in the "newc" | ||
126 | format only. | ||
127 | |||
128 | config FEATURE_CPIO_P | ||
129 | bool "Support for passthrough mode" | ||
130 | default y | ||
131 | depends on FEATURE_CPIO_O | ||
132 | help | ||
133 | Passthrough mode. Rarely used. | ||
134 | |||
135 | config DPKG | ||
136 | bool "dpkg" | ||
137 | default n | ||
138 | select FEATURE_SEAMLESS_GZ | ||
139 | help | ||
140 | dpkg is a medium-level tool to install, build, remove and manage | ||
141 | Debian packages. | ||
142 | |||
143 | This implementation of dpkg has a number of limitations, | ||
144 | you should use the official dpkg if possible. | ||
145 | |||
146 | config DPKG_DEB | ||
147 | bool "dpkg_deb" | ||
148 | default n | ||
149 | select FEATURE_SEAMLESS_GZ | ||
150 | help | ||
151 | dpkg-deb unpacks and provides information about Debian archives. | ||
152 | |||
153 | This implementation of dpkg-deb cannot pack archives. | ||
154 | |||
155 | Unless you have a specific application which requires dpkg-deb, | ||
156 | say N here. | ||
157 | |||
158 | config FEATURE_DPKG_DEB_EXTRACT_ONLY | ||
159 | bool "Extract only (-x)" | ||
160 | default n | ||
161 | depends on DPKG_DEB | ||
162 | help | ||
163 | This reduces dpkg-deb to the equivalent of | ||
164 | "ar -p <deb> data.tar.gz | tar -zx". However it saves space as none | ||
165 | of the extra dpkg-deb, ar or tar options are needed, they are linked | ||
166 | to internally. | ||
167 | |||
168 | config GUNZIP | ||
169 | bool "gunzip" | ||
170 | default y | ||
171 | help | ||
172 | gunzip is used to decompress archives created by gzip. | ||
173 | You can use the `-t' option to test the integrity of | ||
174 | an archive, without decompressing it. | ||
175 | |||
176 | config GZIP | ||
177 | bool "gzip" | ||
178 | default y | ||
179 | help | ||
180 | gzip is used to compress files. | ||
181 | It's probably the most widely used UNIX compression program. | ||
182 | |||
183 | config FEATURE_GZIP_LONG_OPTIONS | ||
184 | bool "Enable long options" | ||
185 | default y | ||
186 | depends on GZIP && LONG_OPTS | ||
187 | help | ||
188 | Enable use of long options, increases size by about 106 Bytes | ||
189 | |||
190 | config GZIP_FAST | ||
191 | int "Trade memory for gzip speed (0:small,slow - 2:fast,big)" | ||
192 | default 0 | ||
193 | range 0 2 | ||
194 | depends on GZIP | ||
195 | help | ||
196 | Enable big memory options for gzip. | ||
197 | 0: small buffers, small hash-tables | ||
198 | 1: larger buffers, larger hash-tables | ||
199 | 2: larger buffers, largest hash-tables | ||
200 | Larger models may give slightly better compression | ||
201 | |||
202 | config LZOP | ||
203 | bool "lzop" | ||
204 | default y | ||
205 | depends on PLATFORM_POSIX || WIN32_NET | ||
206 | help | ||
207 | Lzop compression/decompresion. | ||
208 | |||
209 | config LZOP_COMPR_HIGH | ||
210 | bool "lzop compression levels 7,8,9 (not very useful)" | ||
211 | default n | ||
212 | depends on LZOP | ||
213 | help | ||
214 | High levels (7,8,9) of lzop compression. These levels | ||
215 | are actually slower than gzip at equivalent compression ratios | ||
216 | and take up 3.2K of code. | ||
217 | |||
218 | config RPM2CPIO | ||
219 | bool "rpm2cpio" | ||
220 | default y | ||
221 | help | ||
222 | Converts a RPM file into a CPIO archive. | ||
223 | |||
224 | config RPM | ||
225 | bool "rpm" | ||
226 | default y | ||
227 | help | ||
228 | Mini RPM applet - queries and extracts RPM packages. | ||
229 | |||
230 | config TAR | ||
231 | bool "tar" | ||
232 | default y | ||
233 | help | ||
234 | tar is an archiving program. It's commonly used with gzip to | ||
235 | create compressed archives. It's probably the most widely used | ||
236 | UNIX archive program. | ||
237 | |||
238 | config FEATURE_TAR_CREATE | ||
239 | bool "Enable archive creation" | ||
240 | default y | ||
241 | depends on TAR | ||
242 | help | ||
243 | If you enable this option you'll be able to create | ||
244 | tar archives using the `-c' option. | ||
245 | |||
246 | config FEATURE_TAR_AUTODETECT | ||
247 | bool "Autodetect compressed tarballs" | ||
248 | default y | ||
249 | depends on TAR && (FEATURE_SEAMLESS_Z || FEATURE_SEAMLESS_GZ || FEATURE_SEAMLESS_BZ2 || FEATURE_SEAMLESS_LZMA || FEATURE_SEAMLESS_XZ) | ||
250 | help | ||
251 | With this option tar can automatically detect compressed | ||
252 | tarballs. Currently it works only on files (not pipes etc). | ||
253 | |||
254 | config FEATURE_TAR_FROM | ||
255 | bool "Enable -X (exclude from) and -T (include from) options)" | ||
256 | default y | ||
257 | depends on TAR | ||
258 | help | ||
259 | If you enable this option you'll be able to specify | ||
260 | a list of files to include or exclude from an archive. | ||
261 | |||
262 | config FEATURE_TAR_OLDGNU_COMPATIBILITY | ||
263 | bool "Support for old tar header format" | ||
264 | default y | ||
265 | depends on TAR || DPKG | ||
266 | help | ||
267 | This option is required to unpack archives created in | ||
268 | the old GNU format; help to kill this old format by | ||
269 | repacking your ancient archives with the new format. | ||
270 | |||
271 | config FEATURE_TAR_OLDSUN_COMPATIBILITY | ||
272 | bool "Enable untarring of tarballs with checksums produced by buggy Sun tar" | ||
273 | default y | ||
274 | depends on TAR || DPKG | ||
275 | help | ||
276 | This option is required to unpack archives created by some old | ||
277 | version of Sun's tar (it was calculating checksum using signed | ||
278 | arithmetic). It is said to be fixed in newer Sun tar, but "old" | ||
279 | tarballs still exist. | ||
280 | |||
281 | config FEATURE_TAR_GNU_EXTENSIONS | ||
282 | bool "Support for GNU tar extensions (long filenames)" | ||
283 | default y | ||
284 | depends on TAR || DPKG | ||
285 | help | ||
286 | With this option busybox supports GNU long filenames and | ||
287 | linknames. | ||
288 | |||
289 | config FEATURE_TAR_LONG_OPTIONS | ||
290 | bool "Enable long options" | ||
291 | default y | ||
292 | depends on TAR && LONG_OPTS | ||
293 | help | ||
294 | Enable use of long options, increases size by about 400 Bytes | ||
295 | |||
296 | config FEATURE_TAR_TO_COMMAND | ||
297 | bool "Support for writing to an external program" | ||
298 | default y | ||
299 | depends on TAR && FEATURE_TAR_LONG_OPTIONS | ||
300 | help | ||
301 | If you enable this option you'll be able to instruct tar to send | ||
302 | the contents of each extracted file to the standard input of an | ||
303 | external program. | ||
304 | |||
305 | config FEATURE_TAR_UNAME_GNAME | ||
306 | bool "Enable use of user and group names" | ||
307 | default y | ||
308 | depends on TAR | ||
309 | help | ||
310 | Enables use of user and group names in tar. This affects contents | ||
311 | listings (-t) and preserving permissions when unpacking (-p). | ||
312 | +200 bytes. | ||
313 | |||
314 | config FEATURE_TAR_NOPRESERVE_TIME | ||
315 | bool "Enable -m (do not preserve time) option" | ||
316 | default y | ||
317 | depends on TAR | ||
318 | help | ||
319 | With this option busybox supports GNU tar -m | ||
320 | (do not preserve time) option. | ||
321 | |||
322 | config FEATURE_TAR_SELINUX | ||
323 | bool "Support for extracting SELinux labels" | ||
324 | default n | ||
325 | depends on TAR && SELINUX | ||
326 | help | ||
327 | With this option busybox supports restoring SELinux labels | ||
328 | when extracting files from tar archives. | ||
329 | |||
330 | config UNCOMPRESS | ||
331 | bool "uncompress" | ||
332 | default n | ||
333 | help | ||
334 | uncompress is used to decompress archives created by compress. | ||
335 | Not much used anymore, replaced by gzip/gunzip. | ||
336 | |||
337 | config UNLZMA | ||
338 | bool "unlzma" | ||
339 | default y | ||
340 | help | ||
341 | unlzma is a compression utility using the Lempel-Ziv-Markov chain | ||
342 | compression algorithm, and range coding. Compression | ||
343 | is generally considerably better than that achieved by the bzip2 | ||
344 | compressors. | ||
345 | |||
346 | The BusyBox unlzma applet is limited to decompression only. | ||
347 | On an x86 system, this applet adds about 4K. | ||
348 | |||
349 | config FEATURE_LZMA_FAST | ||
350 | bool "Optimize unlzma for speed" | ||
351 | default n | ||
352 | depends on UNLZMA | ||
353 | help | ||
354 | This option reduces decompression time by about 25% at the cost of | ||
355 | a 1K bigger binary. | ||
356 | |||
357 | config LZMA | ||
358 | bool "Provide lzma alias which supports only unpacking" | ||
359 | default y | ||
360 | depends on UNLZMA | ||
361 | help | ||
362 | Enable this option if you want commands like "lzma -d" to work. | ||
363 | IOW: you'll get lzma applet, but it will always require -d option. | ||
364 | |||
365 | config UNXZ | ||
366 | bool "unxz" | ||
367 | default y | ||
368 | help | ||
369 | unxz is a unlzma successor. | ||
370 | |||
371 | config XZ | ||
372 | bool "Provide xz alias which supports only unpacking" | ||
373 | default y | ||
374 | depends on UNXZ | ||
375 | help | ||
376 | Enable this option if you want commands like "xz -d" to work. | ||
377 | IOW: you'll get xz applet, but it will always require -d option. | ||
378 | |||
379 | config UNZIP | ||
380 | bool "unzip" | ||
381 | default y | ||
382 | help | ||
383 | unzip will list or extract files from a ZIP archive, | ||
384 | commonly found on DOS/WIN systems. The default behavior | ||
385 | (with no options) is to extract the archive into the | ||
386 | current directory. Use the `-d' option to extract to a | ||
387 | directory of your choice. | ||
388 | 39 | ||
389 | endmenu | 40 | endmenu |
diff --git a/archival/Kbuild.src b/archival/Kbuild.src index 3466452f7..a6fd2eac0 100644 --- a/archival/Kbuild.src +++ b/archival/Kbuild.src | |||
@@ -9,22 +9,3 @@ libs-y += libarchive/ | |||
9 | lib-y:= | 9 | lib-y:= |
10 | 10 | ||
11 | INSERT | 11 | INSERT |
12 | |||
13 | lib-$(CONFIG_AR) += ar.o | ||
14 | lib-$(CONFIG_CPIO) += cpio.o | ||
15 | lib-$(CONFIG_DPKG) += dpkg.o | ||
16 | lib-$(CONFIG_DPKG_DEB) += dpkg_deb.o | ||
17 | lib-$(CONFIG_RPM2CPIO) += rpm2cpio.o | ||
18 | lib-$(CONFIG_RPM) += rpm.o | ||
19 | lib-$(CONFIG_TAR) += tar.o | ||
20 | lib-$(CONFIG_UNZIP) += unzip.o | ||
21 | |||
22 | lib-$(CONFIG_LZOP) += lzop.o bbunzip.o | ||
23 | lib-$(CONFIG_GZIP) += gzip.o bbunzip.o | ||
24 | lib-$(CONFIG_BZIP2) += bzip2.o bbunzip.o | ||
25 | |||
26 | lib-$(CONFIG_UNXZ) += bbunzip.o | ||
27 | lib-$(CONFIG_UNLZMA) += bbunzip.o | ||
28 | lib-$(CONFIG_BUNZIP2) += bbunzip.o | ||
29 | lib-$(CONFIG_GUNZIP) += bbunzip.o | ||
30 | lib-$(CONFIG_UNCOMPRESS) += bbunzip.o | ||
diff --git a/archival/ar.c b/archival/ar.c index 88236e878..f86c52d9b 100644 --- a/archival/ar.c +++ b/archival/ar.c | |||
@@ -17,6 +17,49 @@ | |||
17 | * http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html | 17 | * http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html |
18 | */ | 18 | */ |
19 | 19 | ||
20 | //config:config AR | ||
21 | //config: bool "ar" | ||
22 | //config: default n # needs to be improved to be able to replace binutils ar | ||
23 | //config: help | ||
24 | //config: ar is an archival utility program used to create, modify, and | ||
25 | //config: extract contents from archives. An archive is a single file holding | ||
26 | //config: a collection of other files in a structure that makes it possible to | ||
27 | //config: retrieve the original individual files (called archive members). | ||
28 | //config: The original files' contents, mode (permissions), timestamp, owner, | ||
29 | //config: and group are preserved in the archive, and can be restored on | ||
30 | //config: extraction. | ||
31 | //config: | ||
32 | //config: The stored filename is limited to 15 characters. (for more information | ||
33 | //config: see long filename support). | ||
34 | //config: ar has 60 bytes of overheads for every stored file. | ||
35 | //config: | ||
36 | //config: This implementation of ar can extract archives, it cannot create or | ||
37 | //config: modify them. | ||
38 | //config: On an x86 system, the ar applet adds about 1K. | ||
39 | //config: | ||
40 | //config: Unless you have a specific application which requires ar, you should | ||
41 | //config: probably say N here. | ||
42 | //config: | ||
43 | //config:config FEATURE_AR_LONG_FILENAMES | ||
44 | //config: bool "Support for long filenames (not needed for debs)" | ||
45 | //config: default y | ||
46 | //config: depends on AR | ||
47 | //config: help | ||
48 | //config: By default the ar format can only store the first 15 characters | ||
49 | //config: of the filename, this option removes that limitation. | ||
50 | //config: It supports the GNU ar long filename method which moves multiple long | ||
51 | //config: filenames into a the data section of a new ar entry. | ||
52 | //config: | ||
53 | //config:config FEATURE_AR_CREATE | ||
54 | //config: bool "Support archive creation" | ||
55 | //config: default y | ||
56 | //config: depends on AR | ||
57 | //config: help | ||
58 | //config: This enables archive creation (-c and -r) with busybox ar. | ||
59 | |||
60 | //applet:IF_AR(APPLET(ar, BB_DIR_USR_BIN, BB_SUID_DROP)) | ||
61 | //kbuild:lib-$(CONFIG_AR) += ar.o | ||
62 | |||
20 | //usage:#define ar_trivial_usage | 63 | //usage:#define ar_trivial_usage |
21 | //usage: "[-o] [-v] [-p] [-t] [-x] ARCHIVE FILES" | 64 | //usage: "[-o] [-v] [-p] [-t] [-x] ARCHIVE FILES" |
22 | //usage:#define ar_full_usage "\n\n" | 65 | //usage:#define ar_full_usage "\n\n" |
diff --git a/archival/bbunzip.c b/archival/bbunzip.c index 9d1cd9485..3de8e1d48 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c | |||
@@ -7,6 +7,9 @@ | |||
7 | #include "libbb.h" | 7 | #include "libbb.h" |
8 | #include "bb_archive.h" | 8 | #include "bb_archive.h" |
9 | 9 | ||
10 | /* lzop_main() uses bbunpack(), need this: */ | ||
11 | //kbuild:lib-$(CONFIG_LZOP) += bbunzip.o | ||
12 | |||
10 | /* Note: must be kept in sync with archival/lzop.c */ | 13 | /* Note: must be kept in sync with archival/lzop.c */ |
11 | enum { | 14 | enum { |
12 | OPT_STDOUT = 1 << 0, | 15 | OPT_STDOUT = 1 << 0, |
@@ -207,7 +210,6 @@ char* FAST_FUNC make_new_name_generic(char *filename, const char *expected_ext) | |||
207 | * | 210 | * |
208 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 211 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
209 | */ | 212 | */ |
210 | |||
211 | //usage:#define uncompress_trivial_usage | 213 | //usage:#define uncompress_trivial_usage |
212 | //usage: "[-cf] [FILE]..." | 214 | //usage: "[-cf] [FILE]..." |
213 | //usage:#define uncompress_full_usage "\n\n" | 215 | //usage:#define uncompress_full_usage "\n\n" |
@@ -215,6 +217,15 @@ char* FAST_FUNC make_new_name_generic(char *filename, const char *expected_ext) | |||
215 | //usage: "\n -c Write to stdout" | 217 | //usage: "\n -c Write to stdout" |
216 | //usage: "\n -f Overwrite" | 218 | //usage: "\n -f Overwrite" |
217 | 219 | ||
220 | //config:config UNCOMPRESS | ||
221 | //config: bool "uncompress" | ||
222 | //config: default n | ||
223 | //config: help | ||
224 | //config: uncompress is used to decompress archives created by compress. | ||
225 | //config: Not much used anymore, replaced by gzip/gunzip. | ||
226 | |||
227 | //applet:IF_UNCOMPRESS(APPLET(uncompress, BB_DIR_BIN, BB_SUID_DROP)) | ||
228 | //kbuild:lib-$(CONFIG_UNCOMPRESS) += bbunzip.o | ||
218 | #if ENABLE_UNCOMPRESS | 229 | #if ENABLE_UNCOMPRESS |
219 | static | 230 | static |
220 | IF_DESKTOP(long long) int FAST_FUNC unpack_uncompress(transformer_aux_data_t *aux) | 231 | IF_DESKTOP(long long) int FAST_FUNC unpack_uncompress(transformer_aux_data_t *aux) |
@@ -255,11 +266,7 @@ int uncompress_main(int argc UNUSED_PARAM, char **argv) | |||
255 | * Portions of the lzw code are derived from the public domain 'compress' | 266 | * Portions of the lzw code are derived from the public domain 'compress' |
256 | * written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies, | 267 | * written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies, |
257 | * Ken Turkowski, Dave Mack and Peter Jannesen. | 268 | * Ken Turkowski, Dave Mack and Peter Jannesen. |
258 | * | ||
259 | * See the license_msg below and the file COPYING for the software license. | ||
260 | * See the file algorithm.doc for the compression algorithms and file formats. | ||
261 | */ | 269 | */ |
262 | |||
263 | //usage:#define gunzip_trivial_usage | 270 | //usage:#define gunzip_trivial_usage |
264 | //usage: "[-cft] [FILE]..." | 271 | //usage: "[-cft] [FILE]..." |
265 | //usage:#define gunzip_full_usage "\n\n" | 272 | //usage:#define gunzip_full_usage "\n\n" |
@@ -280,6 +287,18 @@ int uncompress_main(int argc UNUSED_PARAM, char **argv) | |||
280 | //usage:#define zcat_full_usage "\n\n" | 287 | //usage:#define zcat_full_usage "\n\n" |
281 | //usage: "Decompress to stdout" | 288 | //usage: "Decompress to stdout" |
282 | 289 | ||
290 | //config:config GUNZIP | ||
291 | //config: bool "gunzip" | ||
292 | //config: default y | ||
293 | //config: help | ||
294 | //config: gunzip is used to decompress archives created by gzip. | ||
295 | //config: You can use the `-t' option to test the integrity of | ||
296 | //config: an archive, without decompressing it. | ||
297 | |||
298 | //applet:IF_GUNZIP(APPLET(gunzip, BB_DIR_BIN, BB_SUID_DROP)) | ||
299 | //applet:IF_GUNZIP(APPLET_ODDNAME(zcat, gunzip, BB_DIR_BIN, BB_SUID_DROP, zcat)) | ||
300 | //kbuild:lib-$(CONFIG_GZIP) += bbunzip.o | ||
301 | //kbuild:lib-$(CONFIG_GUNZIP) += bbunzip.o | ||
283 | #if ENABLE_GUNZIP | 302 | #if ENABLE_GUNZIP |
284 | static | 303 | static |
285 | char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UNUSED_PARAM) | 304 | char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UNUSED_PARAM) |
@@ -358,8 +377,24 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv) | |||
358 | //usage: "[FILE]..." | 377 | //usage: "[FILE]..." |
359 | //usage:#define bzcat_full_usage "\n\n" | 378 | //usage:#define bzcat_full_usage "\n\n" |
360 | //usage: "Decompress to stdout" | 379 | //usage: "Decompress to stdout" |
380 | |||
381 | //config:config BUNZIP2 | ||
382 | //config: bool "bunzip2" | ||
383 | //config: default y | ||
384 | //config: help | ||
385 | //config: bunzip2 is a compression utility using the Burrows-Wheeler block | ||
386 | //config: sorting text compression algorithm, and Huffman coding. Compression | ||
387 | //config: is generally considerably better than that achieved by more | ||
388 | //config: conventional LZ77/LZ78-based compressors, and approaches the | ||
389 | //config: performance of the PPM family of statistical compressors. | ||
390 | //config: | ||
391 | //config: Unless you have a specific application which requires bunzip2, you | ||
392 | //config: should probably say N here. | ||
393 | |||
361 | //applet:IF_BUNZIP2(APPLET(bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP)) | 394 | //applet:IF_BUNZIP2(APPLET(bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP)) |
362 | //applet:IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat)) | 395 | //applet:IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat)) |
396 | //kbuild:lib-$(CONFIG_BZIP2) += bbunzip.o | ||
397 | //kbuild:lib-$(CONFIG_BUNZIP2) += bbunzip.o | ||
363 | #if ENABLE_BUNZIP2 | 398 | #if ENABLE_BUNZIP2 |
364 | static | 399 | static |
365 | IF_DESKTOP(long long) int FAST_FUNC unpack_bunzip2(transformer_aux_data_t *aux) | 400 | IF_DESKTOP(long long) int FAST_FUNC unpack_bunzip2(transformer_aux_data_t *aux) |
@@ -387,7 +422,6 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv) | |||
387 | * | 422 | * |
388 | * Licensed under GPLv2, see file LICENSE in this source tree. | 423 | * Licensed under GPLv2, see file LICENSE in this source tree. |
389 | */ | 424 | */ |
390 | |||
391 | //usage:#define unlzma_trivial_usage | 425 | //usage:#define unlzma_trivial_usage |
392 | //usage: "[-cf] [FILE]..." | 426 | //usage: "[-cf] [FILE]..." |
393 | //usage:#define unlzma_full_usage "\n\n" | 427 | //usage:#define unlzma_full_usage "\n\n" |
@@ -428,6 +462,38 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv) | |||
428 | //usage:#define xzcat_full_usage "\n\n" | 462 | //usage:#define xzcat_full_usage "\n\n" |
429 | //usage: "Decompress to stdout" | 463 | //usage: "Decompress to stdout" |
430 | 464 | ||
465 | //config:config UNLZMA | ||
466 | //config: bool "unlzma" | ||
467 | //config: default y | ||
468 | //config: help | ||
469 | //config: unlzma is a compression utility using the Lempel-Ziv-Markov chain | ||
470 | //config: compression algorithm, and range coding. Compression | ||
471 | //config: is generally considerably better than that achieved by the bzip2 | ||
472 | //config: compressors. | ||
473 | //config: | ||
474 | //config: The BusyBox unlzma applet is limited to decompression only. | ||
475 | //config: On an x86 system, this applet adds about 4K. | ||
476 | //config: | ||
477 | //config:config FEATURE_LZMA_FAST | ||
478 | //config: bool "Optimize unlzma for speed" | ||
479 | //config: default n | ||
480 | //config: depends on UNLZMA | ||
481 | //config: help | ||
482 | //config: This option reduces decompression time by about 25% at the cost of | ||
483 | //config: a 1K bigger binary. | ||
484 | //config: | ||
485 | //config:config LZMA | ||
486 | //config: bool "Provide lzma alias which supports only unpacking" | ||
487 | //config: default y | ||
488 | //config: depends on UNLZMA | ||
489 | //config: help | ||
490 | //config: Enable this option if you want commands like "lzma -d" to work. | ||
491 | //config: IOW: you'll get lzma applet, but it will always require -d option. | ||
492 | |||
493 | //applet:IF_UNLZMA(APPLET(unlzma, BB_DIR_USR_BIN, BB_SUID_DROP)) | ||
494 | //applet:IF_UNLZMA(APPLET_ODDNAME(lzcat, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzcat)) | ||
495 | //applet:IF_LZMA(APPLET_ODDNAME(lzma, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzma)) | ||
496 | //kbuild:lib-$(CONFIG_UNLZMA) += bbunzip.o | ||
431 | #if ENABLE_UNLZMA | 497 | #if ENABLE_UNLZMA |
432 | static | 498 | static |
433 | IF_DESKTOP(long long) int FAST_FUNC unpack_unlzma(transformer_aux_data_t *aux) | 499 | IF_DESKTOP(long long) int FAST_FUNC unpack_unlzma(transformer_aux_data_t *aux) |
@@ -453,6 +519,24 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv) | |||
453 | #endif | 519 | #endif |
454 | 520 | ||
455 | 521 | ||
522 | //config:config UNXZ | ||
523 | //config: bool "unxz" | ||
524 | //config: default y | ||
525 | //config: help | ||
526 | //config: unxz is a unlzma successor. | ||
527 | //config: | ||
528 | //config:config XZ | ||
529 | //config: bool "Provide xz alias which supports only unpacking" | ||
530 | //config: default y | ||
531 | //config: depends on UNXZ | ||
532 | //config: help | ||
533 | //config: Enable this option if you want commands like "xz -d" to work. | ||
534 | //config: IOW: you'll get xz applet, but it will always require -d option. | ||
535 | |||
536 | //applet:IF_UNXZ(APPLET(unxz, BB_DIR_USR_BIN, BB_SUID_DROP)) | ||
537 | //applet:IF_UNXZ(APPLET_ODDNAME(xzcat, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xzcat)) | ||
538 | //applet:IF_XZ(APPLET_ODDNAME(xz, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xz)) | ||
539 | //kbuild:lib-$(CONFIG_UNXZ) += bbunzip.o | ||
456 | #if ENABLE_UNXZ | 540 | #if ENABLE_UNXZ |
457 | static | 541 | static |
458 | IF_DESKTOP(long long) int FAST_FUNC unpack_unxz(transformer_aux_data_t *aux) | 542 | IF_DESKTOP(long long) int FAST_FUNC unpack_unxz(transformer_aux_data_t *aux) |
diff --git a/archival/bzip2.c b/archival/bzip2.c index dd77c8efc..f7718b411 100644 --- a/archival/bzip2.c +++ b/archival/bzip2.c | |||
@@ -7,6 +7,22 @@ | |||
7 | * about bzip2 library code. | 7 | * about bzip2 library code. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | //config:config BZIP2 | ||
11 | //config: bool "bzip2" | ||
12 | //config: default y | ||
13 | //config: help | ||
14 | //config: bzip2 is a compression utility using the Burrows-Wheeler block | ||
15 | //config: sorting text compression algorithm, and Huffman coding. Compression | ||
16 | //config: is generally considerably better than that achieved by more | ||
17 | //config: conventional LZ77/LZ78-based compressors, and approaches the | ||
18 | //config: performance of the PPM family of statistical compressors. | ||
19 | //config: | ||
20 | //config: Unless you have a specific application which requires bzip2, you | ||
21 | //config: should probably say N here. | ||
22 | |||
23 | //applet:IF_BZIP2(APPLET(bzip2, BB_DIR_USR_BIN, BB_SUID_DROP)) | ||
24 | //kbuild:lib-$(CONFIG_BZIP2) += bzip2.o | ||
25 | |||
10 | //usage:#define bzip2_trivial_usage | 26 | //usage:#define bzip2_trivial_usage |
11 | //usage: "[OPTIONS] [FILE]..." | 27 | //usage: "[OPTIONS] [FILE]..." |
12 | //usage:#define bzip2_full_usage "\n\n" | 28 | //usage:#define bzip2_full_usage "\n\n" |
diff --git a/archival/cpio.c b/archival/cpio.c index 699c6dbb7..1cce7c8b4 100644 --- a/archival/cpio.c +++ b/archival/cpio.c | |||
@@ -9,11 +9,42 @@ | |||
9 | * Limitations: | 9 | * Limitations: |
10 | * Doesn't check CRC's | 10 | * Doesn't check CRC's |
11 | * Only supports new ASCII and CRC formats | 11 | * Only supports new ASCII and CRC formats |
12 | * | ||
13 | */ | 12 | */ |
14 | #include "libbb.h" | 13 | #include "libbb.h" |
15 | #include "bb_archive.h" | 14 | #include "bb_archive.h" |
16 | 15 | ||
16 | //config:config CPIO | ||
17 | //config: bool "cpio" | ||
18 | //config: default y | ||
19 | //config: help | ||
20 | //config: cpio is an archival utility program used to create, modify, and | ||
21 | //config: extract contents from archives. | ||
22 | //config: cpio has 110 bytes of overheads for every stored file. | ||
23 | //config: | ||
24 | //config: This implementation of cpio can extract cpio archives created in the | ||
25 | //config: "newc" or "crc" format, it cannot create or modify them. | ||
26 | //config: | ||
27 | //config: Unless you have a specific application which requires cpio, you | ||
28 | //config: should probably say N here. | ||
29 | //config: | ||
30 | //config:config FEATURE_CPIO_O | ||
31 | //config: bool "Support for archive creation" | ||
32 | //config: default y | ||
33 | //config: depends on CPIO | ||
34 | //config: help | ||
35 | //config: This implementation of cpio can create cpio archives in the "newc" | ||
36 | //config: format only. | ||
37 | //config: | ||
38 | //config:config FEATURE_CPIO_P | ||
39 | //config: bool "Support for passthrough mode" | ||
40 | //config: default y | ||
41 | //config: depends on FEATURE_CPIO_O | ||
42 | //config: help | ||
43 | //config: Passthrough mode. Rarely used. | ||
44 | |||
45 | //applet:IF_CPIO(APPLET(cpio, BB_DIR_BIN, BB_SUID_DROP)) | ||
46 | //kbuild:lib-$(CONFIG_CPIO) += cpio.o | ||
47 | |||
17 | //usage:#define cpio_trivial_usage | 48 | //usage:#define cpio_trivial_usage |
18 | //usage: "[-dmvu] [-F FILE]" IF_FEATURE_CPIO_O(" [-H newc]") | 49 | //usage: "[-dmvu] [-F FILE]" IF_FEATURE_CPIO_O(" [-H newc]") |
19 | //usage: " [-ti"IF_FEATURE_CPIO_O("o")"]" IF_FEATURE_CPIO_P(" [-p DIR]") | 50 | //usage: " [-ti"IF_FEATURE_CPIO_O("o")"]" IF_FEATURE_CPIO_P(" [-p DIR]") |
diff --git a/archival/dpkg.c b/archival/dpkg.c index ed86f3355..2893cfc2d 100644 --- a/archival/dpkg.c +++ b/archival/dpkg.c | |||
@@ -14,7 +14,6 @@ | |||
14 | * | 14 | * |
15 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 15 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
16 | */ | 16 | */ |
17 | |||
18 | /* | 17 | /* |
19 | * known difference between busybox dpkg and the official dpkg that i don't | 18 | * known difference between busybox dpkg and the official dpkg that i don't |
20 | * consider important, its worth keeping a note of differences anyway, just to | 19 | * consider important, its worth keeping a note of differences anyway, just to |
@@ -25,9 +24,22 @@ | |||
25 | * | 24 | * |
26 | * bugs that need to be fixed | 25 | * bugs that need to be fixed |
27 | * - (unknown, please let me know when you find any) | 26 | * - (unknown, please let me know when you find any) |
28 | * | ||
29 | */ | 27 | */ |
30 | 28 | ||
29 | //config:config DPKG | ||
30 | //config: bool "dpkg" | ||
31 | //config: default n | ||
32 | //config: select FEATURE_SEAMLESS_GZ | ||
33 | //config: help | ||
34 | //config: dpkg is a medium-level tool to install, build, remove and manage | ||
35 | //config: Debian packages. | ||
36 | //config: | ||
37 | //config: This implementation of dpkg has a number of limitations, | ||
38 | //config: you should use the official dpkg if possible. | ||
39 | |||
40 | //applet:IF_DPKG(APPLET(dpkg, BB_DIR_USR_BIN, BB_SUID_DROP)) | ||
41 | //kbuild:lib-$(CONFIG_DPKG) += dpkg.o | ||
42 | |||
31 | //usage:#define dpkg_trivial_usage | 43 | //usage:#define dpkg_trivial_usage |
32 | //usage: "[-ilCPru] [-F OPT] PACKAGE" | 44 | //usage: "[-ilCPru] [-F OPT] PACKAGE" |
33 | //usage:#define dpkg_full_usage "\n\n" | 45 | //usage:#define dpkg_full_usage "\n\n" |
diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c index a04ec9407..13f9db991 100644 --- a/archival/dpkg_deb.c +++ b/archival/dpkg_deb.c | |||
@@ -5,8 +5,33 @@ | |||
5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | //config:config DPKG_DEB | ||
9 | //config: bool "dpkg_deb" | ||
10 | //config: default n | ||
11 | //config: select FEATURE_SEAMLESS_GZ | ||
12 | //config: help | ||
13 | //config: dpkg-deb unpacks and provides information about Debian archives. | ||
14 | //config: | ||
15 | //config: This implementation of dpkg-deb cannot pack archives. | ||
16 | //config: | ||
17 | //config: Unless you have a specific application which requires dpkg-deb, | ||
18 | //config: say N here. | ||
19 | //config: | ||
20 | //config:config FEATURE_DPKG_DEB_EXTRACT_ONLY | ||
21 | //config: bool "Extract only (-x)" | ||
22 | //config: default n | ||
23 | //config: depends on DPKG_DEB | ||
24 | //config: help | ||
25 | //config: This reduces dpkg-deb to the equivalent of | ||
26 | //config: "ar -p <deb> data.tar.gz | tar -zx". However it saves space as none | ||
27 | //config: of the extra dpkg-deb, ar or tar options are needed, they are linked | ||
28 | //config: to internally. | ||
29 | |||
30 | //applet:IF_DPKG_DEB(APPLET_ODDNAME(dpkg-deb, dpkg_deb, BB_DIR_USR_BIN, BB_SUID_DROP, dpkg_deb)) | ||
31 | //kbuild:lib-$(CONFIG_DPKG_DEB) += dpkg_deb.o | ||
32 | |||
8 | //usage:#define dpkg_deb_trivial_usage | 33 | //usage:#define dpkg_deb_trivial_usage |
9 | //usage: "[-cefxX] FILE [argument" | 34 | //usage: "[-cefxX] FILE [argument]" |
10 | //usage:#define dpkg_deb_full_usage "\n\n" | 35 | //usage:#define dpkg_deb_full_usage "\n\n" |
11 | //usage: "Perform actions on Debian packages (.debs)\n" | 36 | //usage: "Perform actions on Debian packages (.debs)\n" |
12 | //usage: "\n -c List contents of filesystem tree" | 37 | //usage: "\n -c List contents of filesystem tree" |
diff --git a/archival/gzip.c b/archival/gzip.c index 31ccab3cd..1e779c9c3 100644 --- a/archival/gzip.c +++ b/archival/gzip.c | |||
@@ -15,7 +15,6 @@ | |||
15 | * | 15 | * |
16 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 16 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
17 | */ | 17 | */ |
18 | |||
19 | /* big objects in bss: | 18 | /* big objects in bss: |
20 | * 00000020 b bl_count | 19 | * 00000020 b bl_count |
21 | * 00000074 b base_length | 20 | * 00000074 b base_length |
@@ -31,7 +30,6 @@ | |||
31 | * 00000480 b static_ltree | 30 | * 00000480 b static_ltree |
32 | * 000008f4 b dyn_ltree | 31 | * 000008f4 b dyn_ltree |
33 | */ | 32 | */ |
34 | |||
35 | /* TODO: full support for -v for DESKTOP | 33 | /* TODO: full support for -v for DESKTOP |
36 | * "/usr/bin/gzip -v a bogus aa" should say: | 34 | * "/usr/bin/gzip -v a bogus aa" should say: |
37 | a: 85.1% -- replaced with a.gz | 35 | a: 85.1% -- replaced with a.gz |
@@ -39,6 +37,35 @@ gzip: bogus: No such file or directory | |||
39 | aa: 85.1% -- replaced with aa.gz | 37 | aa: 85.1% -- replaced with aa.gz |
40 | */ | 38 | */ |
41 | 39 | ||
40 | //config:config GZIP | ||
41 | //config: bool "gzip" | ||
42 | //config: default y | ||
43 | //config: help | ||
44 | //config: gzip is used to compress files. | ||
45 | //config: It's probably the most widely used UNIX compression program. | ||
46 | //config: | ||
47 | //config:config FEATURE_GZIP_LONG_OPTIONS | ||
48 | //config: bool "Enable long options" | ||
49 | //config: default y | ||
50 | //config: depends on GZIP && LONG_OPTS | ||
51 | //config: help | ||
52 | //config: Enable use of long options, increases size by about 106 Bytes | ||
53 | //config: | ||
54 | //config:config GZIP_FAST | ||
55 | //config: int "Trade memory for gzip speed (0:small,slow - 2:fast,big)" | ||
56 | //config: default 0 | ||
57 | //config: range 0 2 | ||
58 | //config: depends on GZIP | ||
59 | //config: help | ||
60 | //config: Enable big memory options for gzip. | ||
61 | //config: 0: small buffers, small hash-tables | ||
62 | //config: 1: larger buffers, larger hash-tables | ||
63 | //config: 2: larger buffers, largest hash-tables | ||
64 | //config: Larger models may give slightly better compression | ||
65 | |||
66 | //applet:IF_GZIP(APPLET(gzip, BB_DIR_BIN, BB_SUID_DROP)) | ||
67 | //kbuild:lib-$(CONFIG_GZIP) += gzip.o | ||
68 | |||
42 | //usage:#define gzip_trivial_usage | 69 | //usage:#define gzip_trivial_usage |
43 | //usage: "[-cfd] [FILE]..." | 70 | //usage: "[-cfd] [FILE]..." |
44 | //usage:#define gzip_full_usage "\n\n" | 71 | //usage:#define gzip_full_usage "\n\n" |
diff --git a/archival/libarchive/bz/compress.c b/archival/libarchive/bz/compress.c index e9f1afdaf..23de9d3f5 100644 --- a/archival/libarchive/bz/compress.c +++ b/archival/libarchive/bz/compress.c | |||
@@ -249,7 +249,7 @@ void generateMTFValues(EState* s) | |||
249 | static NOINLINE | 249 | static NOINLINE |
250 | void sendMTFValues(EState* s) | 250 | void sendMTFValues(EState* s) |
251 | { | 251 | { |
252 | int32_t v, t, i, j, gs, ge, totc, bt, bc, iter; | 252 | int32_t v, t, i, j, gs, ge, bt, bc, iter; |
253 | int32_t nSelectors, alphaSize, minLen, maxLen, selCtr; | 253 | int32_t nSelectors, alphaSize, minLen, maxLen, selCtr; |
254 | int32_t nGroups; | 254 | int32_t nGroups; |
255 | 255 | ||
@@ -345,7 +345,6 @@ void sendMTFValues(EState* s) | |||
345 | } | 345 | } |
346 | #endif | 346 | #endif |
347 | nSelectors = 0; | 347 | nSelectors = 0; |
348 | totc = 0; | ||
349 | gs = 0; | 348 | gs = 0; |
350 | while (1) { | 349 | while (1) { |
351 | /*--- Set group start & end marks. --*/ | 350 | /*--- Set group start & end marks. --*/ |
@@ -411,7 +410,6 @@ void sendMTFValues(EState* s) | |||
411 | bt = t; | 410 | bt = t; |
412 | } | 411 | } |
413 | } | 412 | } |
414 | totc += bc; | ||
415 | fave[bt]++; | 413 | fave[bt]++; |
416 | s->selector[nSelectors] = bt; | 414 | s->selector[nSelectors] = bt; |
417 | nSelectors++; | 415 | nSelectors++; |
@@ -501,14 +499,14 @@ void sendMTFValues(EState* s) | |||
501 | for (i = 0; i < 16; i++) { | 499 | for (i = 0; i < 16; i++) { |
502 | if (sizeof(long) <= 4) { | 500 | if (sizeof(long) <= 4) { |
503 | inUse16 = inUse16*2 + | 501 | inUse16 = inUse16*2 + |
504 | ((*(uint32_t*)&(s->inUse[i * 16 + 0]) | 502 | ((*(bb__aliased_uint32_t*)&(s->inUse[i * 16 + 0]) |
505 | | *(uint32_t*)&(s->inUse[i * 16 + 4]) | 503 | | *(bb__aliased_uint32_t*)&(s->inUse[i * 16 + 4]) |
506 | | *(uint32_t*)&(s->inUse[i * 16 + 8]) | 504 | | *(bb__aliased_uint32_t*)&(s->inUse[i * 16 + 8]) |
507 | | *(uint32_t*)&(s->inUse[i * 16 + 12])) != 0); | 505 | | *(bb__aliased_uint32_t*)&(s->inUse[i * 16 + 12])) != 0); |
508 | } else { /* Our CPU can do better */ | 506 | } else { /* Our CPU can do better */ |
509 | inUse16 = inUse16*2 + | 507 | inUse16 = inUse16*2 + |
510 | ((*(uint64_t*)&(s->inUse[i * 16 + 0]) | 508 | ((*(bb__aliased_uint64_t*)&(s->inUse[i * 16 + 0]) |
511 | | *(uint64_t*)&(s->inUse[i * 16 + 8])) != 0); | 509 | | *(bb__aliased_uint64_t*)&(s->inUse[i * 16 + 8])) != 0); |
512 | } | 510 | } |
513 | } | 511 | } |
514 | 512 | ||
diff --git a/archival/libarchive/decompress_bunzip2.c b/archival/libarchive/decompress_bunzip2.c index dc252bb82..6396fe40d 100644 --- a/archival/libarchive/decompress_bunzip2.c +++ b/archival/libarchive/decompress_bunzip2.c | |||
@@ -42,6 +42,12 @@ | |||
42 | #include "libbb.h" | 42 | #include "libbb.h" |
43 | #include "bb_archive.h" | 43 | #include "bb_archive.h" |
44 | 44 | ||
45 | #if 0 | ||
46 | # define dbg(...) bb_error_msg(__VA_ARGS__) | ||
47 | #else | ||
48 | # define dbg(...) ((void)0) | ||
49 | #endif | ||
50 | |||
45 | /* Constants for Huffman coding */ | 51 | /* Constants for Huffman coding */ |
46 | #define MAX_GROUPS 6 | 52 | #define MAX_GROUPS 6 |
47 | #define GROUP_SIZE 50 /* 64 would have been more efficient */ | 53 | #define GROUP_SIZE 50 /* 64 would have been more efficient */ |
@@ -52,13 +58,13 @@ | |||
52 | 58 | ||
53 | /* Status return values */ | 59 | /* Status return values */ |
54 | #define RETVAL_OK 0 | 60 | #define RETVAL_OK 0 |
55 | #define RETVAL_LAST_BLOCK (-1) | 61 | #define RETVAL_LAST_BLOCK (dbg("%d", __LINE__), -1) |
56 | #define RETVAL_NOT_BZIP_DATA (-2) | 62 | #define RETVAL_NOT_BZIP_DATA (dbg("%d", __LINE__), -2) |
57 | #define RETVAL_UNEXPECTED_INPUT_EOF (-3) | 63 | #define RETVAL_UNEXPECTED_INPUT_EOF (dbg("%d", __LINE__), -3) |
58 | #define RETVAL_SHORT_WRITE (-4) | 64 | #define RETVAL_SHORT_WRITE (dbg("%d", __LINE__), -4) |
59 | #define RETVAL_DATA_ERROR (-5) | 65 | #define RETVAL_DATA_ERROR (dbg("%d", __LINE__), -5) |
60 | #define RETVAL_OUT_OF_MEMORY (-6) | 66 | #define RETVAL_OUT_OF_MEMORY (dbg("%d", __LINE__), -6) |
61 | #define RETVAL_OBSOLETE_INPUT (-7) | 67 | #define RETVAL_OBSOLETE_INPUT (dbg("%d", __LINE__), -7) |
62 | 68 | ||
63 | /* Other housekeeping constants */ | 69 | /* Other housekeeping constants */ |
64 | #define IOBUF_SIZE 4096 | 70 | #define IOBUF_SIZE 4096 |
@@ -440,7 +446,11 @@ static int get_next_block(bunzip_data *bd) | |||
440 | literal used is the one at the head of the mtfSymbol array.) */ | 446 | literal used is the one at the head of the mtfSymbol array.) */ |
441 | if (runPos != 0) { | 447 | if (runPos != 0) { |
442 | uint8_t tmp_byte; | 448 | uint8_t tmp_byte; |
443 | if (dbufCount + runCnt >= dbufSize) return RETVAL_DATA_ERROR; | 449 | if (dbufCount + runCnt > dbufSize) { |
450 | dbg("dbufCount:%d+runCnt:%d %d > dbufSize:%d RETVAL_DATA_ERROR", | ||
451 | dbufCount, runCnt, dbufCount + runCnt, dbufSize); | ||
452 | return RETVAL_DATA_ERROR; | ||
453 | } | ||
444 | tmp_byte = symToByte[mtfSymbol[0]]; | 454 | tmp_byte = symToByte[mtfSymbol[0]]; |
445 | byteCount[tmp_byte] += runCnt; | 455 | byteCount[tmp_byte] += runCnt; |
446 | while (--runCnt >= 0) dbuf[dbufCount++] = (uint32_t)tmp_byte; | 456 | while (--runCnt >= 0) dbuf[dbufCount++] = (uint32_t)tmp_byte; |
@@ -808,7 +818,6 @@ static char *const bunzip_errors[] = { | |||
808 | /* Dumb little test thing, decompress stdin to stdout */ | 818 | /* Dumb little test thing, decompress stdin to stdout */ |
809 | int main(int argc, char **argv) | 819 | int main(int argc, char **argv) |
810 | { | 820 | { |
811 | int i; | ||
812 | char c; | 821 | char c; |
813 | 822 | ||
814 | int i = unpack_bz2_stream(0, 1); | 823 | int i = unpack_bz2_stream(0, 1); |
diff --git a/archival/libarchive/decompress_gunzip.c b/archival/libarchive/decompress_gunzip.c index 4e6b138c3..7c6f38ec3 100644 --- a/archival/libarchive/decompress_gunzip.c +++ b/archival/libarchive/decompress_gunzip.c | |||
@@ -336,7 +336,7 @@ static int huft_build(const unsigned *b, const unsigned n, | |||
336 | } | 336 | } |
337 | 337 | ||
338 | /* Find minimum and maximum length, bound *m by those */ | 338 | /* Find minimum and maximum length, bound *m by those */ |
339 | for (j = 1; (c[j] == 0) && (j <= BMAX); j++) | 339 | for (j = 1; (j <= BMAX) && (c[j] == 0); j++) |
340 | continue; | 340 | continue; |
341 | k = j; /* minimum code length */ | 341 | k = j; /* minimum code length */ |
342 | for (i = BMAX; (c[i] == 0) && i; i--) | 342 | for (i = BMAX; (c[i] == 0) && i; i--) |
diff --git a/archival/libarchive/get_header_ar.c b/archival/libarchive/get_header_ar.c index 23c412496..c66bb3ee7 100644 --- a/archival/libarchive/get_header_ar.c +++ b/archival/libarchive/get_header_ar.c | |||
@@ -8,11 +8,19 @@ | |||
8 | #include "bb_archive.h" | 8 | #include "bb_archive.h" |
9 | #include "ar.h" | 9 | #include "ar.h" |
10 | 10 | ||
11 | static unsigned read_num(const char *str, int base) | 11 | /* WARNING: Clobbers str[len], so fields must be read in reverse order! */ |
12 | static unsigned read_num(char *str, int base, int len) | ||
12 | { | 13 | { |
14 | int err; | ||
15 | |||
16 | /* ar fields are fixed length text strings (padded with spaces). | ||
17 | * Ensure bb_strtou doesn't read past the field in case the full | ||
18 | * width is used. */ | ||
19 | str[len] = 0; | ||
20 | |||
13 | /* This code works because | 21 | /* This code works because |
14 | * on misformatted numbers bb_strtou returns all-ones */ | 22 | * on misformatted numbers bb_strtou returns all-ones */ |
15 | int err = bb_strtou(str, NULL, base); | 23 | err = bb_strtou(str, NULL, base); |
16 | if (err == -1) | 24 | if (err == -1) |
17 | bb_error_msg_and_die("invalid ar header"); | 25 | bb_error_msg_and_die("invalid ar header"); |
18 | return err; | 26 | return err; |
@@ -51,11 +59,13 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle) | |||
51 | if (ar.formatted.magic[0] != '`' || ar.formatted.magic[1] != '\n') | 59 | if (ar.formatted.magic[0] != '`' || ar.formatted.magic[1] != '\n') |
52 | bb_error_msg_and_die("invalid ar header"); | 60 | bb_error_msg_and_die("invalid ar header"); |
53 | 61 | ||
54 | /* FIXME: more thorough routine would be in order here | 62 | /* |
55 | * (we have something like that in tar) | 63 | * Note that the fields MUST be read in reverse order as |
56 | * but for now we are lax. */ | 64 | * read_num() clobbers the next byte after the field! |
57 | ar.formatted.magic[0] = '\0'; /* else 4G-2 file will have size="4294967294`\n..." */ | 65 | * Order is: name, date, uid, gid, mode, size, magic. |
58 | typed->size = size = read_num(ar.formatted.size, 10); | 66 | */ |
67 | typed->size = size = read_num(ar.formatted.size, 10, | ||
68 | sizeof(ar.formatted.size)); | ||
59 | 69 | ||
60 | /* special filenames have '/' as the first character */ | 70 | /* special filenames have '/' as the first character */ |
61 | if (ar.formatted.name[0] == '/') { | 71 | if (ar.formatted.name[0] == '/') { |
@@ -87,10 +97,10 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle) | |||
87 | * long filename pseudo file. Thus we decode the rest | 97 | * long filename pseudo file. Thus we decode the rest |
88 | * after dealing with long filename pseudo file. | 98 | * after dealing with long filename pseudo file. |
89 | */ | 99 | */ |
90 | typed->mode = read_num(ar.formatted.mode, 8); | 100 | typed->mode = read_num(ar.formatted.mode, 8, sizeof(ar.formatted.mode)); |
91 | typed->mtime = read_num(ar.formatted.date, 10); | 101 | typed->gid = read_num(ar.formatted.gid, 10, sizeof(ar.formatted.gid)); |
92 | typed->uid = read_num(ar.formatted.uid, 10); | 102 | typed->uid = read_num(ar.formatted.uid, 10, sizeof(ar.formatted.uid)); |
93 | typed->gid = read_num(ar.formatted.gid, 10); | 103 | typed->mtime = read_num(ar.formatted.date, 10, sizeof(ar.formatted.date)); |
94 | 104 | ||
95 | #if ENABLE_FEATURE_AR_LONG_FILENAMES | 105 | #if ENABLE_FEATURE_AR_LONG_FILENAMES |
96 | if (ar.formatted.name[0] == '/') { | 106 | if (ar.formatted.name[0] == '/') { |
@@ -98,7 +108,8 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle) | |||
98 | 108 | ||
99 | /* The number after the '/' indicates the offset in the ar data section | 109 | /* The number after the '/' indicates the offset in the ar data section |
100 | * (saved in ar_long_names) that conatains the real filename */ | 110 | * (saved in ar_long_names) that conatains the real filename */ |
101 | long_offset = read_num(&ar.formatted.name[1], 10); | 111 | long_offset = read_num(&ar.formatted.name[1], 10, |
112 | sizeof(ar.formatted.name) - 1); | ||
102 | if (long_offset >= ar_long_name_size) { | 113 | if (long_offset >= ar_long_name_size) { |
103 | bb_error_msg_and_die("can't resolve long filename"); | 114 | bb_error_msg_and_die("can't resolve long filename"); |
104 | } | 115 | } |
diff --git a/archival/libarchive/get_header_tar.c b/archival/libarchive/get_header_tar.c index bc09756ba..32f842095 100644 --- a/archival/libarchive/get_header_tar.c +++ b/archival/libarchive/get_header_tar.c | |||
@@ -198,13 +198,13 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle) | |||
198 | * the message and we don't check whether we indeed | 198 | * the message and we don't check whether we indeed |
199 | * saw zero block directly before this. */ | 199 | * saw zero block directly before this. */ |
200 | if (i == 0) { | 200 | if (i == 0) { |
201 | xfunc_error_retval = 0; | 201 | bb_error_msg("short read"); |
202 | short_read: | 202 | /* this merely signals end of archive, not exit(1): */ |
203 | bb_error_msg_and_die("short read"); | 203 | return EXIT_FAILURE; |
204 | } | 204 | } |
205 | if (i != 512) { | 205 | if (i != 512) { |
206 | IF_FEATURE_TAR_AUTODETECT(goto autodetect;) | 206 | IF_FEATURE_TAR_AUTODETECT(goto autodetect;) |
207 | goto short_read; | 207 | bb_error_msg_and_die("short read"); |
208 | } | 208 | } |
209 | 209 | ||
210 | #else | 210 | #else |
@@ -221,10 +221,10 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle) | |||
221 | */ | 221 | */ |
222 | while (full_read(archive_handle->src_fd, &tar, 512) == 512) | 222 | while (full_read(archive_handle->src_fd, &tar, 512) == 512) |
223 | continue; | 223 | continue; |
224 | return EXIT_FAILURE; | 224 | return EXIT_FAILURE; /* "end of archive" */ |
225 | } | 225 | } |
226 | archive_handle->tar__end = 1; | 226 | archive_handle->tar__end = 1; |
227 | return EXIT_SUCCESS; | 227 | return EXIT_SUCCESS; /* "decoded one header" */ |
228 | } | 228 | } |
229 | archive_handle->tar__end = 0; | 229 | archive_handle->tar__end = 0; |
230 | 230 | ||
@@ -471,5 +471,5 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle) | |||
471 | free(file_header->tar__uname); | 471 | free(file_header->tar__uname); |
472 | free(file_header->tar__gname); | 472 | free(file_header->tar__gname); |
473 | #endif | 473 | #endif |
474 | return EXIT_SUCCESS; | 474 | return EXIT_SUCCESS; /* "decoded one header" */ |
475 | } | 475 | } |
diff --git a/archival/libarchive/lzo1x_9x.c b/archival/libarchive/lzo1x_9x.c index 897132987..2b490ae83 100644 --- a/archival/libarchive/lzo1x_9x.c +++ b/archival/libarchive/lzo1x_9x.c | |||
@@ -94,7 +94,7 @@ typedef struct { | |||
94 | ( ((0x9f5f * ((((b[p]<<5)^b[p+1])<<5) ^ b[p+2])) >> 5) & (SWD_HSIZE-1) ) | 94 | ( ((0x9f5f * ((((b[p]<<5)^b[p+1])<<5) ^ b[p+2])) >> 5) & (SWD_HSIZE-1) ) |
95 | 95 | ||
96 | #if defined(LZO_UNALIGNED_OK_2) | 96 | #if defined(LZO_UNALIGNED_OK_2) |
97 | # define HEAD2(b,p) (* (uint16_t *) &(b[p])) | 97 | # define HEAD2(b,p) (* (bb__aliased_uint16_t *) &(b[p])) |
98 | #else | 98 | #else |
99 | # define HEAD2(b,p) (b[p] ^ ((unsigned)b[p+1]<<8)) | 99 | # define HEAD2(b,p) (b[p] ^ ((unsigned)b[p+1]<<8)) |
100 | #endif | 100 | #endif |
@@ -466,7 +466,6 @@ static int find_match(lzo1x_999_t *c, lzo_swd_p s, | |||
466 | } | 466 | } |
467 | 467 | ||
468 | s->m_len = 1; | 468 | s->m_len = 1; |
469 | s->m_len = 1; | ||
470 | #ifdef SWD_BEST_OFF | 469 | #ifdef SWD_BEST_OFF |
471 | if (s->use_best_off) | 470 | if (s->use_best_off) |
472 | memset(s->best_pos, 0, sizeof(s->best_pos)); | 471 | memset(s->best_pos, 0, sizeof(s->best_pos)); |
diff --git a/archival/libarchive/open_transformer.c b/archival/libarchive/open_transformer.c index 841e9dce9..c4e02f0f7 100644 --- a/archival/libarchive/open_transformer.c +++ b/archival/libarchive/open_transformer.c | |||
@@ -81,16 +81,17 @@ void FAST_FUNC open_transformer(int fd, const char *transform_prog) | |||
81 | // FIXME: error check? | 81 | // FIXME: error check? |
82 | #if BB_MMU | 82 | #if BB_MMU |
83 | { | 83 | { |
84 | IF_DESKTOP(long long) int r; | ||
84 | transformer_aux_data_t aux; | 85 | transformer_aux_data_t aux; |
85 | init_transformer_aux_data(&aux); | 86 | init_transformer_aux_data(&aux); |
86 | aux.check_signature = check_signature; | 87 | aux.check_signature = check_signature; |
87 | transformer(&aux, fd, fd_pipe.wr); | 88 | r = transformer(&aux, fd, fd_pipe.wr); |
88 | if (ENABLE_FEATURE_CLEAN_UP) { | 89 | if (ENABLE_FEATURE_CLEAN_UP) { |
89 | close(fd_pipe.wr); /* send EOF */ | 90 | close(fd_pipe.wr); /* send EOF */ |
90 | close(fd); | 91 | close(fd); |
91 | } | 92 | } |
92 | /* must be _exit! bug was actually seen here */ | 93 | /* must be _exit! bug was actually seen here */ |
93 | _exit(EXIT_SUCCESS); | 94 | _exit(/*error if:*/ r < 0); |
94 | } | 95 | } |
95 | #else | 96 | #else |
96 | { | 97 | { |
diff --git a/archival/lzop.c b/archival/lzop.c index 9b42e5fd3..5062d9300 100644 --- a/archival/lzop.c +++ b/archival/lzop.c | |||
@@ -25,6 +25,26 @@ | |||
25 | "Minimalized" for busybox by Alain Knaff | 25 | "Minimalized" for busybox by Alain Knaff |
26 | */ | 26 | */ |
27 | 27 | ||
28 | //config:config LZOP | ||
29 | //config: bool "lzop" | ||
30 | //config: default y | ||
31 | //config: help | ||
32 | //config: Lzop compression/decompresion. | ||
33 | //config: | ||
34 | //config:config LZOP_COMPR_HIGH | ||
35 | //config: bool "lzop compression levels 7,8,9 (not very useful)" | ||
36 | //config: default n | ||
37 | //config: depends on LZOP | ||
38 | //config: help | ||
39 | //config: High levels (7,8,9) of lzop compression. These levels | ||
40 | //config: are actually slower than gzip at equivalent compression ratios | ||
41 | //config: and take up 3.2K of code. | ||
42 | |||
43 | //applet:IF_LZOP(APPLET(lzop, BB_DIR_BIN, BB_SUID_DROP)) | ||
44 | //applet:IF_LZOP(APPLET_ODDNAME(lzopcat, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, lzopcat)) | ||
45 | //applet:IF_LZOP(APPLET_ODDNAME(unlzop, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, unlzop)) | ||
46 | //kbuild:lib-$(CONFIG_LZOP) += lzop.o | ||
47 | |||
28 | //usage:#define lzop_trivial_usage | 48 | //usage:#define lzop_trivial_usage |
29 | //usage: "[-cfvd123456789CF] [FILE]..." | 49 | //usage: "[-cfvd123456789CF] [FILE]..." |
30 | //usage:#define lzop_full_usage "\n\n" | 50 | //usage:#define lzop_full_usage "\n\n" |
diff --git a/archival/rpm.c b/archival/rpm.c index 86ba4dca4..885eddd64 100644 --- a/archival/rpm.c +++ b/archival/rpm.c | |||
@@ -7,6 +7,15 @@ | |||
7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | //config:config RPM | ||
11 | //config: bool "rpm" | ||
12 | //config: default y | ||
13 | //config: help | ||
14 | //config: Mini RPM applet - queries and extracts RPM packages. | ||
15 | |||
16 | //applet:IF_RPM(APPLET(rpm, BB_DIR_BIN, BB_SUID_DROP)) | ||
17 | //kbuild:lib-$(CONFIG_RPM) += rpm.o | ||
18 | |||
10 | //usage:#define rpm_trivial_usage | 19 | //usage:#define rpm_trivial_usage |
11 | //usage: "-i PACKAGE.rpm; rpm -qp[ildc] PACKAGE.rpm" | 20 | //usage: "-i PACKAGE.rpm; rpm -qp[ildc] PACKAGE.rpm" |
12 | //usage:#define rpm_full_usage "\n\n" | 21 | //usage:#define rpm_full_usage "\n\n" |
diff --git a/archival/rpm2cpio.c b/archival/rpm2cpio.c index f3dfa5159..61adde795 100644 --- a/archival/rpm2cpio.c +++ b/archival/rpm2cpio.c | |||
@@ -7,6 +7,15 @@ | |||
7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | //config:config RPM2CPIO | ||
11 | //config: bool "rpm2cpio" | ||
12 | //config: default y | ||
13 | //config: help | ||
14 | //config: Converts a RPM file into a CPIO archive. | ||
15 | |||
16 | //applet:IF_RPM2CPIO(APPLET(rpm2cpio, BB_DIR_USR_BIN, BB_SUID_DROP)) | ||
17 | //kbuild:lib-$(CONFIG_RPM2CPIO) += rpm2cpio.o | ||
18 | |||
10 | //usage:#define rpm2cpio_trivial_usage | 19 | //usage:#define rpm2cpio_trivial_usage |
11 | //usage: "package.rpm" | 20 | //usage: "package.rpm" |
12 | //usage:#define rpm2cpio_full_usage "\n\n" | 21 | //usage:#define rpm2cpio_full_usage "\n\n" |
diff --git a/archival/tar.c b/archival/tar.c index 3129781d2..2909eca1b 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -22,7 +22,6 @@ | |||
22 | * | 22 | * |
23 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 23 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
24 | */ | 24 | */ |
25 | |||
26 | /* TODO: security with -C DESTDIR option can be enhanced. | 25 | /* TODO: security with -C DESTDIR option can be enhanced. |
27 | * Consider tar file created via: | 26 | * Consider tar file created via: |
28 | * $ tar cvf bug.tar anything.txt | 27 | * $ tar cvf bug.tar anything.txt |
@@ -42,6 +41,109 @@ | |||
42 | * This doesn't feel right, and IIRC GNU tar doesn't do that. | 41 | * This doesn't feel right, and IIRC GNU tar doesn't do that. |
43 | */ | 42 | */ |
44 | 43 | ||
44 | //config:config TAR | ||
45 | //config: bool "tar" | ||
46 | //config: default y | ||
47 | //config: help | ||
48 | //config: tar is an archiving program. It's commonly used with gzip to | ||
49 | //config: create compressed archives. It's probably the most widely used | ||
50 | //config: UNIX archive program. | ||
51 | //config: | ||
52 | //config:config FEATURE_TAR_CREATE | ||
53 | //config: bool "Enable archive creation" | ||
54 | //config: default y | ||
55 | //config: depends on TAR | ||
56 | //config: help | ||
57 | //config: If you enable this option you'll be able to create | ||
58 | //config: tar archives using the `-c' option. | ||
59 | //config: | ||
60 | //config:config FEATURE_TAR_AUTODETECT | ||
61 | //config: bool "Autodetect compressed tarballs" | ||
62 | //config: default y | ||
63 | //config: depends on TAR && (FEATURE_SEAMLESS_Z || FEATURE_SEAMLESS_GZ || FEATURE_SEAMLESS_BZ2 || FEATURE_SEAMLESS_LZMA || FEATURE_SEAMLESS_XZ) | ||
64 | //config: help | ||
65 | //config: With this option tar can automatically detect compressed | ||
66 | //config: tarballs. Currently it works only on files (not pipes etc). | ||
67 | //config: | ||
68 | //config:config FEATURE_TAR_FROM | ||
69 | //config: bool "Enable -X (exclude from) and -T (include from) options)" | ||
70 | //config: default y | ||
71 | //config: depends on TAR | ||
72 | //config: help | ||
73 | //config: If you enable this option you'll be able to specify | ||
74 | //config: a list of files to include or exclude from an archive. | ||
75 | //config: | ||
76 | //config:config FEATURE_TAR_OLDGNU_COMPATIBILITY | ||
77 | //config: bool "Support for old tar header format" | ||
78 | //config: default y | ||
79 | //config: depends on TAR || DPKG | ||
80 | //config: help | ||
81 | //config: This option is required to unpack archives created in | ||
82 | //config: the old GNU format; help to kill this old format by | ||
83 | //config: repacking your ancient archives with the new format. | ||
84 | //config: | ||
85 | //config:config FEATURE_TAR_OLDSUN_COMPATIBILITY | ||
86 | //config: bool "Enable untarring of tarballs with checksums produced by buggy Sun tar" | ||
87 | //config: default y | ||
88 | //config: depends on TAR || DPKG | ||
89 | //config: help | ||
90 | //config: This option is required to unpack archives created by some old | ||
91 | //config: version of Sun's tar (it was calculating checksum using signed | ||
92 | //config: arithmetic). It is said to be fixed in newer Sun tar, but "old" | ||
93 | //config: tarballs still exist. | ||
94 | //config: | ||
95 | //config:config FEATURE_TAR_GNU_EXTENSIONS | ||
96 | //config: bool "Support for GNU tar extensions (long filenames)" | ||
97 | //config: default y | ||
98 | //config: depends on TAR || DPKG | ||
99 | //config: help | ||
100 | //config: With this option busybox supports GNU long filenames and | ||
101 | //config: linknames. | ||
102 | //config: | ||
103 | //config:config FEATURE_TAR_LONG_OPTIONS | ||
104 | //config: bool "Enable long options" | ||
105 | //config: default y | ||
106 | //config: depends on TAR && LONG_OPTS | ||
107 | //config: help | ||
108 | //config: Enable use of long options, increases size by about 400 Bytes | ||
109 | //config: | ||
110 | //config:config FEATURE_TAR_TO_COMMAND | ||
111 | //config: bool "Support for writing to an external program" | ||
112 | //config: default y | ||
113 | //config: depends on TAR && FEATURE_TAR_LONG_OPTIONS | ||
114 | //config: help | ||
115 | //config: If you enable this option you'll be able to instruct tar to send | ||
116 | //config: the contents of each extracted file to the standard input of an | ||
117 | //config: external program. | ||
118 | //config: | ||
119 | //config:config FEATURE_TAR_UNAME_GNAME | ||
120 | //config: bool "Enable use of user and group names" | ||
121 | //config: default y | ||
122 | //config: depends on TAR | ||
123 | //config: help | ||
124 | //config: Enables use of user and group names in tar. This affects contents | ||
125 | //config: listings (-t) and preserving permissions when unpacking (-p). | ||
126 | //config: +200 bytes. | ||
127 | //config: | ||
128 | //config:config FEATURE_TAR_NOPRESERVE_TIME | ||
129 | //config: bool "Enable -m (do not preserve time) option" | ||
130 | //config: default y | ||
131 | //config: depends on TAR | ||
132 | //config: help | ||
133 | //config: With this option busybox supports GNU tar -m | ||
134 | //config: (do not preserve time) option. | ||
135 | //config: | ||
136 | //config:config FEATURE_TAR_SELINUX | ||
137 | //config: bool "Support for extracting SELinux labels" | ||
138 | //config: default n | ||
139 | //config: depends on TAR && SELINUX | ||
140 | //config: help | ||
141 | //config: With this option busybox supports restoring SELinux labels | ||
142 | //config: when extracting files from tar archives. | ||
143 | |||
144 | //applet:IF_TAR(APPLET(tar, BB_DIR_BIN, BB_SUID_DROP)) | ||
145 | //kbuild:lib-$(CONFIG_TAR) += tar.o | ||
146 | |||
45 | #include <fnmatch.h> | 147 | #include <fnmatch.h> |
46 | #include "libbb.h" | 148 | #include "libbb.h" |
47 | #include "bb_archive.h" | 149 | #include "bb_archive.h" |
@@ -1096,8 +1198,14 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
1096 | /*tar_handle->offset = 0; - already is */ | 1198 | /*tar_handle->offset = 0; - already is */ |
1097 | } | 1199 | } |
1098 | 1200 | ||
1201 | /* Zero processed headers (== empty file) is not a valid tarball. | ||
1202 | * We (ab)use bb_got_signal as exitcode here, | ||
1203 | * because check_errors_in_children() uses _it_ as error indicator. | ||
1204 | */ | ||
1205 | bb_got_signal = EXIT_FAILURE; | ||
1206 | |||
1099 | while (get_header_tar(tar_handle) == EXIT_SUCCESS) | 1207 | while (get_header_tar(tar_handle) == EXIT_SUCCESS) |
1100 | continue; | 1208 | bb_got_signal = EXIT_SUCCESS; /* saw at least one header, good */ |
1101 | 1209 | ||
1102 | /* Check that every file that should have been extracted was */ | 1210 | /* Check that every file that should have been extracted was */ |
1103 | while (tar_handle->accept) { | 1211 | while (tar_handle->accept) { |
@@ -1113,8 +1221,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
1113 | close(tar_handle->src_fd); | 1221 | close(tar_handle->src_fd); |
1114 | 1222 | ||
1115 | if (SEAMLESS_COMPRESSION || OPT_COMPRESS) { | 1223 | if (SEAMLESS_COMPRESSION || OPT_COMPRESS) { |
1224 | /* Set bb_got_signal to 1 if a child died with !0 exitcode */ | ||
1116 | check_errors_in_children(0); | 1225 | check_errors_in_children(0); |
1117 | return bb_got_signal; | ||
1118 | } | 1226 | } |
1119 | return EXIT_SUCCESS; | 1227 | |
1228 | return bb_got_signal; | ||
1120 | } | 1229 | } |
diff --git a/archival/unzip.c b/archival/unzip.c index 673e5fe08..fcfc9a448 100644 --- a/archival/unzip.c +++ b/archival/unzip.c | |||
@@ -9,16 +9,27 @@ | |||
9 | * | 9 | * |
10 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 10 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
11 | */ | 11 | */ |
12 | |||
13 | /* For reference see | 12 | /* For reference see |
14 | * http://www.pkware.com/company/standards/appnote/ | 13 | * http://www.pkware.com/company/standards/appnote/ |
15 | * http://www.info-zip.org/pub/infozip/doc/appnote-iz-latest.zip | 14 | * http://www.info-zip.org/pub/infozip/doc/appnote-iz-latest.zip |
16 | */ | 15 | * |
17 | 16 | * TODO | |
18 | /* TODO | ||
19 | * Zip64 + other methods | 17 | * Zip64 + other methods |
20 | */ | 18 | */ |
21 | 19 | ||
20 | //config:config UNZIP | ||
21 | //config: bool "unzip" | ||
22 | //config: default y | ||
23 | //config: help | ||
24 | //config: unzip will list or extract files from a ZIP archive, | ||
25 | //config: commonly found on DOS/WIN systems. The default behavior | ||
26 | //config: (with no options) is to extract the archive into the | ||
27 | //config: current directory. Use the `-d' option to extract to a | ||
28 | //config: directory of your choice. | ||
29 | |||
30 | //applet:IF_UNZIP(APPLET(unzip, BB_DIR_USR_BIN, BB_SUID_DROP)) | ||
31 | //kbuild:lib-$(CONFIG_UNZIP) += unzip.o | ||
32 | |||
22 | //usage:#define unzip_trivial_usage | 33 | //usage:#define unzip_trivial_usage |
23 | //usage: "[-lnopq] FILE[.zip] [FILE]... [-x FILE...] [-d DIR]" | 34 | //usage: "[-lnopq] FILE[.zip] [FILE]... [-x FILE...] [-d DIR]" |
24 | //usage:#define unzip_full_usage "\n\n" | 35 | //usage:#define unzip_full_usage "\n\n" |