aboutsummaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
Diffstat (limited to 'archival')
-rw-r--r--archival/Config.in114
-rw-r--r--archival/bbunzip.c12
-rw-r--r--archival/dpkg.c8
-rw-r--r--archival/dpkg_deb.c4
-rw-r--r--archival/libunarchive/Kbuild26
-rw-r--r--archival/libunarchive/decompress_bunzip2.c29
-rw-r--r--archival/libunarchive/decompress_uncompress.c8
-rw-r--r--archival/libunarchive/filter_accept_list_reassign.c15
-rw-r--r--archival/libunarchive/get_header_tar.c4
-rw-r--r--archival/libunarchive/get_header_tar_bz2.c2
-rw-r--r--archival/rpm.c24
-rw-r--r--archival/tar.c92
12 files changed, 145 insertions, 193 deletions
diff --git a/archival/Config.in b/archival/Config.in
index b26be6486..d6332a2b2 100644
--- a/archival/Config.in
+++ b/archival/Config.in
@@ -5,6 +5,30 @@
5 5
6menu "Archival Utilities" 6menu "Archival Utilities"
7 7
8config FEATURE_SEAMLESS_LZMA
9 bool "Make tar, rpm, man, modprobe etc understand .lzma data"
10 default n
11 help
12 Make tar, rpm, man, modprobe etc understand .lzma data.
13
14config FEATURE_SEAMLESS_BZ2
15 bool "Make tar, rpm, man, modprobe etc understand .bz2 data"
16 default n
17 help
18 Make tar, rpm, man, modprobe etc understand .bz2 data.
19
20config FEATURE_SEAMLESS_GZ
21 bool "Make tar, rpm, man, modprobe etc understand .gz data"
22 default n
23 help
24 Make tar, rpm, man, modprobe etc understand .gz data.
25
26config FEATURE_SEAMLESS_Z
27 bool "Make tar and gunzip understand .Z data"
28 default n
29 help
30 Make tar and gunzip understand .Z data.
31
8config AR 32config AR
9 bool "ar" 33 bool "ar"
10 default n 34 default n
@@ -126,15 +150,6 @@ config GUNZIP
126 You can use the `-t' option to test the integrity of 150 You can use the `-t' option to test the integrity of
127 an archive, without decompressing it. 151 an archive, without decompressing it.
128 152
129config FEATURE_GUNZIP_UNCOMPRESS
130 bool "Uncompress support"
131 default n
132 depends on GUNZIP
133 help
134 Enable if you want gunzip to have the ability to decompress
135 archives created by the program compress (not much
136 used anymore).
137
138config GZIP 153config GZIP
139 bool "gzip" 154 bool "gzip"
140 default n 155 default n
@@ -154,13 +169,6 @@ config RPM
154 help 169 help
155 Mini RPM applet - queries and extracts RPM packages. 170 Mini RPM applet - queries and extracts RPM packages.
156 171
157config FEATURE_RPM_BZ2
158 bool "Enable handling of rpms with bzip2-compressed data inside"
159 default n
160 depends on RPM
161 help
162 Enable handling of rpms with bzip2-compressed data inside.
163
164config TAR 172config TAR
165 bool "tar" 173 bool "tar"
166 default n 174 default n
@@ -179,42 +187,10 @@ config FEATURE_TAR_CREATE
179 If you enable this option you'll be able to create 187 If you enable this option you'll be able to create
180 tar archives using the `-c' option. 188 tar archives using the `-c' option.
181 189
182config FEATURE_TAR_GZIP
183 bool "Enable -z option"
184 default y
185 depends on TAR
186 help
187 If you enable this option tar will be able to call gzip,
188 when creating or extracting tar gziped archives.
189
190config FEATURE_TAR_BZIP2
191 bool "Enable -j option to handle .tar.bz2 files"
192 default n
193 depends on TAR
194 help
195 If you enable this option you'll be able to extract
196 archives compressed with bzip2.
197
198config FEATURE_TAR_LZMA
199 bool "Enable -a option to handle .tar.lzma files"
200 default n
201 depends on TAR
202 help
203 If you enable this option you'll be able to extract
204 archives compressed with lzma.
205
206config FEATURE_TAR_COMPRESS
207 bool "Enable -Z option"
208 default n
209 depends on TAR
210 help
211 If you enable this option tar will be able to call uncompress,
212 when extracting .tar.Z archives.
213
214config FEATURE_TAR_AUTODETECT 190config FEATURE_TAR_AUTODETECT
215 bool "Autodetect gz/bz2 compresses tarballs" 191 bool "Autodetect gz/bz2 compressed tarballs"
216 default n 192 default n
217 depends on FEATURE_TAR_GZIP || FEATURE_TAR_BZIP2 193 depends on FEATURE_SEAMLESS_Z || FEATURE_SEAMLESS_GZ || FEATURE_SEAMLESS_BZ2 || FEATURE_SEAMLESS_LZMA
218 help 194 help
219 With this option tar can automatically detect gzip/bzip2 compressed 195 With this option tar can automatically detect gzip/bzip2 compressed
220 tarballs. Currently it works only on files (not pipes etc). 196 tarballs. Currently it works only on files (not pipes etc).
@@ -312,42 +288,4 @@ config UNZIP
312 current directory. Use the `-d' option to extract to a 288 current directory. Use the `-d' option to extract to a
313 directory of your choice. 289 directory of your choice.
314 290
315comment "Common options for cpio and tar"
316 depends on CPIO || TAR
317
318comment "Common options for dpkg and dpkg_deb"
319 depends on DPKG || DPKG_DEB
320
321config FEATURE_DEB_TAR_GZ
322 bool "gzip debian packages (normal)"
323 default y if DPKG || DPKG_DEB
324 depends on DPKG || DPKG_DEB
325 help
326 This is the default compression method inside the debian ar file.
327
328 If you want compatibility with standard .deb's you should say yes
329 here.
330
331config FEATURE_DEB_TAR_BZ2
332 bool "bzip2 debian packages"
333 default n
334 depends on DPKG || DPKG_DEB
335 help
336 This allows dpkg and dpkg-deb to extract deb's that are compressed
337 internally with bzip2 instead of gzip.
338
339 You only want this if you are creating your own custom debian
340 packages that use an internal control.tar.bz2 or data.tar.bz2.
341
342config FEATURE_DEB_TAR_LZMA
343 bool "lzma debian packages"
344 default n
345 depends on DPKG || DPKG_DEB
346 help
347 This allows dpkg and dpkg-deb to extract deb's that are compressed
348 internally with lzma instead of gzip.
349
350 You only want this if you are creating your own custom debian
351 packages that use an internal control.tar.lzma or data.tar.lzma.
352
353endmenu 291endmenu
diff --git a/archival/bbunzip.c b/archival/bbunzip.c
index 65bb8b7f4..c7962058e 100644
--- a/archival/bbunzip.c
+++ b/archival/bbunzip.c
@@ -161,7 +161,7 @@ char* make_new_name_bunzip2(char *filename)
161static 161static
162USE_DESKTOP(long long) int unpack_bunzip2(void) 162USE_DESKTOP(long long) int unpack_bunzip2(void)
163{ 163{
164 return unpack_bz2_stream(STDIN_FILENO, STDOUT_FILENO); 164 return unpack_bz2_stream_prime(STDIN_FILENO, STDOUT_FILENO);
165} 165}
166 166
167int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 167int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
@@ -218,8 +218,8 @@ char* make_new_name_gunzip(char *filename)
218 218
219 extension++; 219 extension++;
220 if (strcmp(extension, "tgz" + 1) == 0 220 if (strcmp(extension, "tgz" + 1) == 0
221#if ENABLE_FEATURE_GUNZIP_UNCOMPRESS 221#if ENABLE_FEATURE_SEAMLESS_Z
222 || strcmp(extension, "Z") == 0 222 || (extension[0] == 'Z' && extension[1] == '\0')
223#endif 223#endif
224 ) { 224 ) {
225 extension[-1] = '\0'; 225 extension[-1] = '\0';
@@ -244,8 +244,8 @@ USE_DESKTOP(long long) int unpack_gunzip(void)
244 unsigned char magic2; 244 unsigned char magic2;
245 245
246 magic2 = xread_char(STDIN_FILENO); 246 magic2 = xread_char(STDIN_FILENO);
247 if (ENABLE_FEATURE_GUNZIP_UNCOMPRESS && magic2 == 0x9d) { 247 if (ENABLE_FEATURE_SEAMLESS_Z && magic2 == 0x9d) {
248 status = uncompress(STDIN_FILENO, STDOUT_FILENO); 248 status = unpack_Z_stream(STDIN_FILENO, STDOUT_FILENO);
249 } else if (magic2 == 0x8b) { 249 } else if (magic2 == 0x8b) {
250 status = unpack_gz_stream(STDIN_FILENO, STDOUT_FILENO); 250 status = unpack_gz_stream(STDIN_FILENO, STDOUT_FILENO);
251 } else { 251 } else {
@@ -351,7 +351,7 @@ USE_DESKTOP(long long) int unpack_uncompress(void)
351 if ((xread_char(STDIN_FILENO) != 0x1f) || (xread_char(STDIN_FILENO) != 0x9d)) { 351 if ((xread_char(STDIN_FILENO) != 0x1f) || (xread_char(STDIN_FILENO) != 0x9d)) {
352 bb_error_msg("invalid magic"); 352 bb_error_msg("invalid magic");
353 } else { 353 } else {
354 status = uncompress(STDIN_FILENO, STDOUT_FILENO); 354 status = unpack_Z_stream(STDIN_FILENO, STDOUT_FILENO);
355 } 355 }
356 return status; 356 return status;
357} 357}
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 54e963233..f31a7f017 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -1438,10 +1438,10 @@ static void init_archive_deb_control(archive_handle_t *ar_handle)
1438 tar_handle->src_fd = ar_handle->src_fd; 1438 tar_handle->src_fd = ar_handle->src_fd;
1439 1439
1440 /* We don't care about data.tar.* or debian-binary, just control.tar.* */ 1440 /* We don't care about data.tar.* or debian-binary, just control.tar.* */
1441#if ENABLE_FEATURE_DEB_TAR_GZ 1441#if ENABLE_FEATURE_SEAMLESS_GZ
1442 llist_add_to(&(ar_handle->accept), (char*)"control.tar.gz"); 1442 llist_add_to(&(ar_handle->accept), (char*)"control.tar.gz");
1443#endif 1443#endif
1444#if ENABLE_FEATURE_DEB_TAR_BZ2 1444#if ENABLE_FEATURE_SEAMLESS_BZ2
1445 llist_add_to(&(ar_handle->accept), (char*)"control.tar.bz2"); 1445 llist_add_to(&(ar_handle->accept), (char*)"control.tar.bz2");
1446#endif 1446#endif
1447 1447
@@ -1458,10 +1458,10 @@ static void init_archive_deb_data(archive_handle_t *ar_handle)
1458 tar_handle->src_fd = ar_handle->src_fd; 1458 tar_handle->src_fd = ar_handle->src_fd;
1459 1459
1460 /* We don't care about control.tar.* or debian-binary, just data.tar.* */ 1460 /* We don't care about control.tar.* or debian-binary, just data.tar.* */
1461#if ENABLE_FEATURE_DEB_TAR_GZ 1461#if ENABLE_FEATURE_SEAMLESS_GZ
1462 llist_add_to(&(ar_handle->accept), (char*)"data.tar.gz"); 1462 llist_add_to(&(ar_handle->accept), (char*)"data.tar.gz");
1463#endif 1463#endif
1464#if ENABLE_FEATURE_DEB_TAR_BZ2 1464#if ENABLE_FEATURE_SEAMLESS_BZ2
1465 llist_add_to(&(ar_handle->accept), (char*)"data.tar.bz2"); 1465 llist_add_to(&(ar_handle->accept), (char*)"data.tar.bz2");
1466#endif 1466#endif
1467 1467
diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c
index 9e6340fd3..f94c90c55 100644
--- a/archival/dpkg_deb.c
+++ b/archival/dpkg_deb.c
@@ -31,12 +31,12 @@ int dpkg_deb_main(int argc, char **argv)
31 ar_archive->sub_archive = tar_archive; 31 ar_archive->sub_archive = tar_archive;
32 ar_archive->filter = filter_accept_list_reassign; 32 ar_archive->filter = filter_accept_list_reassign;
33 33
34#if ENABLE_FEATURE_DEB_TAR_GZ 34#if ENABLE_FEATURE_SEAMLESS_GZ
35 llist_add_to(&(ar_archive->accept), (char*)"data.tar.gz"); 35 llist_add_to(&(ar_archive->accept), (char*)"data.tar.gz");
36 llist_add_to(&control_tar_llist, (char*)"control.tar.gz"); 36 llist_add_to(&control_tar_llist, (char*)"control.tar.gz");
37#endif 37#endif
38 38
39#if ENABLE_FEATURE_DEB_TAR_BZ2 39#if ENABLE_FEATURE_SEAMLESS_BZ2
40 llist_add_to(&(ar_archive->accept), (char*)"data.tar.bz2"); 40 llist_add_to(&(ar_archive->accept), (char*)"data.tar.bz2");
41 llist_add_to(&control_tar_llist, (char*)"control.tar.bz2"); 41 llist_add_to(&control_tar_llist, (char*)"control.tar.bz2");
42#endif 42#endif
diff --git a/archival/libunarchive/Kbuild b/archival/libunarchive/Kbuild
index 468a7e82a..364f9174c 100644
--- a/archival/libunarchive/Kbuild
+++ b/archival/libunarchive/Kbuild
@@ -32,36 +32,20 @@ DPKG_FILES:= \
32 get_header_tar.o \ 32 get_header_tar.o \
33 filter_accept_list_reassign.o 33 filter_accept_list_reassign.o
34 34
35lib-$(CONFIG_RPM) += open_transformer.o
36lib-$(CONFIG_FEATURE_TAR_BZIP2) += open_transformer.o
37lib-$(CONFIG_FEATURE_TAR_LZMA) += open_transformer.o
38lib-$(CONFIG_FEATURE_TAR_GZIP) += open_transformer.o
39lib-$(CONFIG_FEATURE_TAR_COMPRESS) += open_transformer.o
40lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += open_transformer.o
41lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += open_transformer.o
42lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += open_transformer.o
43
44lib-$(CONFIG_FEATURE_MODPROBE_SMALL_ZIPPED) += open_transformer.o decompress_unzip.o decompress_bunzip2.o
45
46lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o 35lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
47lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o 36lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
48lib-$(CONFIG_UNLZMA) += decompress_unlzma.o 37lib-$(CONFIG_UNLZMA) += decompress_unlzma.o
49lib-$(CONFIG_CPIO) += get_header_cpio.o 38lib-$(CONFIG_CPIO) += get_header_cpio.o
50lib-$(CONFIG_DPKG) += $(DPKG_FILES) 39lib-$(CONFIG_DPKG) += $(DPKG_FILES)
51lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES) 40lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
52lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += decompress_unzip.o get_header_tar_gz.o
53lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
54lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
55lib-$(CONFIG_GUNZIP) += decompress_unzip.o 41lib-$(CONFIG_GUNZIP) += decompress_unzip.o
56lib-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
57lib-$(CONFIG_RPM2CPIO) += decompress_unzip.o get_header_cpio.o 42lib-$(CONFIG_RPM2CPIO) += decompress_unzip.o get_header_cpio.o
58lib-$(CONFIG_RPM) += decompress_unzip.o get_header_cpio.o 43lib-$(CONFIG_RPM) += open_transformer.o decompress_unzip.o get_header_cpio.o
59lib-$(CONFIG_FEATURE_RPM_BZ2) += decompress_bunzip2.o
60lib-$(CONFIG_TAR) += get_header_tar.o 44lib-$(CONFIG_TAR) += get_header_tar.o
61lib-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
62lib-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
63lib-$(CONFIG_FEATURE_TAR_GZIP) += decompress_unzip.o get_header_tar_gz.o
64lib-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
65lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o 45lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
66lib-$(CONFIG_UNZIP) += decompress_unzip.o 46lib-$(CONFIG_UNZIP) += decompress_unzip.o
47lib-$(CONFIG_FEATURE_SEAMLESS_Z) += open_transformer.o decompress_uncompress.o
48lib-$(CONFIG_FEATURE_SEAMLESS_GZ) += open_transformer.o decompress_unzip.o get_header_tar_gz.o
49lib-$(CONFIG_FEATURE_SEAMLESS_BZ2) += open_transformer.o decompress_bunzip2.o get_header_tar_bz2.o
50lib-$(CONFIG_FEATURE_SEAMLESS_LZMA) += open_transformer.o decompress_unlzma.o get_header_tar_lzma.o
67lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o 51lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
diff --git a/archival/libunarchive/decompress_bunzip2.c b/archival/libunarchive/decompress_bunzip2.c
index 654dc28a9..b53720f23 100644
--- a/archival/libunarchive/decompress_bunzip2.c
+++ b/archival/libunarchive/decompress_bunzip2.c
@@ -590,7 +590,8 @@ int FAST_FUNC start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *in
590 bunzip_data *bd; 590 bunzip_data *bd;
591 unsigned i; 591 unsigned i;
592 enum { 592 enum {
593 BZh0 = ('B' << 24) + ('Z' << 16) + ('h' << 8) + '0' 593 BZh0 = ('B' << 24) + ('Z' << 16) + ('h' << 8) + '0',
594 h0 = ('h' << 8) + '0',
594 }; 595 };
595 596
596 /* Figure out how much data to allocate */ 597 /* Figure out how much data to allocate */
@@ -617,12 +618,18 @@ int FAST_FUNC start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *in
617 if (i) return i; 618 if (i) return i;
618 619
619 /* Ensure that file starts with "BZh['1'-'9']." */ 620 /* Ensure that file starts with "BZh['1'-'9']." */
620 i = get_bits(bd, 32); 621 /* Update: now caller verifies 1st two bytes, makes .gz/.bz2
621 if ((unsigned)(i - BZh0 - 1) >= 9) return RETVAL_NOT_BZIP_DATA; 622 * integration easier */
623 /* was: */
624 /* i = get_bits(bd, 32); */
625 /* if ((unsigned)(i - BZh0 - 1) >= 9) return RETVAL_NOT_BZIP_DATA; */
626 i = get_bits(bd, 16);
627 if ((unsigned)(i - h0 - 1) >= 9) return RETVAL_NOT_BZIP_DATA;
622 628
623 /* Fourth byte (ascii '1'-'9') indicates block size in units of 100k of 629 /* Fourth byte (ascii '1'-'9') indicates block size in units of 100k of
624 uncompressed data. Allocate intermediate buffer for block. */ 630 uncompressed data. Allocate intermediate buffer for block. */
625 bd->dbufSize = 100000 * (i - BZh0); 631 /* bd->dbufSize = 100000 * (i - BZh0); */
632 bd->dbufSize = 100000 * (i - h0);
626 633
627 /* Cannot use xmalloc - may leak bd in NOFORK case! */ 634 /* Cannot use xmalloc - may leak bd in NOFORK case! */
628 bd->dbuf = malloc_or_warn(bd->dbufSize * sizeof(int)); 635 bd->dbuf = malloc_or_warn(bd->dbufSize * sizeof(int));
@@ -682,6 +689,17 @@ unpack_bz2_stream(int src_fd, int dst_fd)
682 return i ? i : USE_DESKTOP(total_written) + 0; 689 return i ? i : USE_DESKTOP(total_written) + 0;
683} 690}
684 691
692USE_DESKTOP(long long) int FAST_FUNC
693unpack_bz2_stream_prime(int src_fd, int dst_fd)
694{
695 unsigned char magic[2];
696 xread(src_fd, magic, 2);
697 if (magic[0] != 'B' || magic[1] != 'Z') {
698 bb_error_msg_and_die("invalid magic");
699 }
700 return unpack_bz2_stream(src_fd, dst_fd);
701}
702
685#ifdef TESTING 703#ifdef TESTING
686 704
687static char *const bunzip_errors[] = { 705static char *const bunzip_errors[] = {
@@ -693,9 +711,10 @@ static char *const bunzip_errors[] = {
693/* Dumb little test thing, decompress stdin to stdout */ 711/* Dumb little test thing, decompress stdin to stdout */
694int main(int argc, char **argv) 712int main(int argc, char **argv)
695{ 713{
696 int i = unpack_bz2_stream(0, 1); 714 int i;
697 char c; 715 char c;
698 716
717 int i = unpack_bz2_stream_prime(0, 1);
699 if (i < 0) 718 if (i < 0)
700 fprintf(stderr, "%s\n", bunzip_errors[-i]); 719 fprintf(stderr, "%s\n", bunzip_errors[-i]);
701 else if (read(STDIN_FILENO, &c, 1)) 720 else if (read(STDIN_FILENO, &c, 1))
diff --git a/archival/libunarchive/decompress_uncompress.c b/archival/libunarchive/decompress_uncompress.c
index 161570040..fe1491e71 100644
--- a/archival/libunarchive/decompress_uncompress.c
+++ b/archival/libunarchive/decompress_uncompress.c
@@ -1,6 +1,4 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2#include "libbb.h"
3
4/* uncompress for busybox -- (c) 2002 Robert Griebl 2/* uncompress for busybox -- (c) 2002 Robert Griebl
5 * 3 *
6 * based on the original compress42.c source 4 * based on the original compress42.c source
@@ -26,6 +24,10 @@
26 * 24 *
27 */ 25 */
28 26
27#include "libbb.h"
28#include "unarchive.h"
29
30
29/* Default input buffer size */ 31/* Default input buffer size */
30#define IBUFSIZ 2048 32#define IBUFSIZ 2048
31 33
@@ -71,7 +73,7 @@
71 */ 73 */
72 74
73USE_DESKTOP(long long) int FAST_FUNC 75USE_DESKTOP(long long) int FAST_FUNC
74uncompress(int fd_in, int fd_out) 76unpack_Z_stream(int fd_in, int fd_out)
75{ 77{
76 USE_DESKTOP(long long total_written = 0;) 78 USE_DESKTOP(long long total_written = 0;)
77 USE_DESKTOP(long long) int retval = -1; 79 USE_DESKTOP(long long) int retval = -1;
diff --git a/archival/libunarchive/filter_accept_list_reassign.c b/archival/libunarchive/filter_accept_list_reassign.c
index 4dbc2d13e..f1de4e803 100644
--- a/archival/libunarchive/filter_accept_list_reassign.c
+++ b/archival/libunarchive/filter_accept_list_reassign.c
@@ -23,22 +23,25 @@ char FAST_FUNC filter_accept_list_reassign(archive_handle_t *archive_handle)
23 23
24 /* Find extension */ 24 /* Find extension */
25 name_ptr = strrchr(archive_handle->file_header->name, '.'); 25 name_ptr = strrchr(archive_handle->file_header->name, '.');
26 if (!name_ptr)
27 return EXIT_FAILURE;
28 name_ptr++;
26 29
27 /* Modify the subarchive handler based on the extension */ 30 /* Modify the subarchive handler based on the extension */
28 if (ENABLE_FEATURE_DEB_TAR_GZ 31 if (ENABLE_FEATURE_SEAMLESS_GZ
29 && strcmp(name_ptr, ".gz") == 0 32 && strcmp(name_ptr, "gz") == 0
30 ) { 33 ) {
31 archive_handle->action_data_subarchive = get_header_tar_gz; 34 archive_handle->action_data_subarchive = get_header_tar_gz;
32 return EXIT_SUCCESS; 35 return EXIT_SUCCESS;
33 } 36 }
34 if (ENABLE_FEATURE_DEB_TAR_BZ2 37 if (ENABLE_FEATURE_SEAMLESS_BZ2
35 && strcmp(name_ptr, ".bz2") == 0 38 && strcmp(name_ptr, "bz2") == 0
36 ) { 39 ) {
37 archive_handle->action_data_subarchive = get_header_tar_bz2; 40 archive_handle->action_data_subarchive = get_header_tar_bz2;
38 return EXIT_SUCCESS; 41 return EXIT_SUCCESS;
39 } 42 }
40 if (ENABLE_FEATURE_DEB_TAR_LZMA 43 if (ENABLE_FEATURE_SEAMLESS_LZMA
41 && strcmp(name_ptr, ".lzma") == 0 44 && strcmp(name_ptr, "lzma") == 0
42 ) { 45 ) {
43 archive_handle->action_data_subarchive = get_header_tar_lzma; 46 archive_handle->action_data_subarchive = get_header_tar_lzma;
44 return EXIT_SUCCESS; 47 return EXIT_SUCCESS;
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index 5310f3f7c..bf0f92b25 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -148,12 +148,12 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
148 * we can switch to get_header_tar_gz/bz2/lzma(). 148 * we can switch to get_header_tar_gz/bz2/lzma().
149 * Needs seekable fd. I wish recv(MSG_PEEK) works 149 * Needs seekable fd. I wish recv(MSG_PEEK) works
150 * on any fd... */ 150 * on any fd... */
151#if ENABLE_FEATURE_TAR_GZIP 151#if ENABLE_FEATURE_SEAMLESS_GZ
152 if (tar.name[0] == 0x1f && tar.name[1] == (char)0x8b) { /* gzip */ 152 if (tar.name[0] == 0x1f && tar.name[1] == (char)0x8b) { /* gzip */
153 get_header_ptr = get_header_tar_gz; 153 get_header_ptr = get_header_tar_gz;
154 } else 154 } else
155#endif 155#endif
156#if ENABLE_FEATURE_TAR_BZIP2 156#if ENABLE_FEATURE_SEAMLESS_BZ2
157 if (tar.name[0] == 'B' && tar.name[1] == 'Z' 157 if (tar.name[0] == 'B' && tar.name[1] == 'Z'
158 && tar.name[2] == 'h' && isdigit(tar.name[3]) 158 && tar.name[2] == 'h' && isdigit(tar.name[3])
159 ) { /* bzip2 */ 159 ) { /* bzip2 */
diff --git a/archival/libunarchive/get_header_tar_bz2.c b/archival/libunarchive/get_header_tar_bz2.c
index 035c10bfb..615bbba4a 100644
--- a/archival/libunarchive/get_header_tar_bz2.c
+++ b/archival/libunarchive/get_header_tar_bz2.c
@@ -11,7 +11,7 @@ char FAST_FUNC get_header_tar_bz2(archive_handle_t *archive_handle)
11 /* Can't lseek over pipes */ 11 /* Can't lseek over pipes */
12 archive_handle->seek = seek_by_read; 12 archive_handle->seek = seek_by_read;
13 13
14 open_transformer(archive_handle->src_fd, unpack_bz2_stream, "bunzip2"); 14 open_transformer(archive_handle->src_fd, unpack_bz2_stream_prime, "bunzip2");
15 archive_handle->offset = 0; 15 archive_handle->offset = 0;
16 while (get_header_tar(archive_handle) == EXIT_SUCCESS) 16 while (get_header_tar(archive_handle) == EXIT_SUCCESS)
17 continue; 17 continue;
diff --git a/archival/rpm.c b/archival/rpm.c
index e6dd3d853..e1f3c8930 100644
--- a/archival/rpm.c
+++ b/archival/rpm.c
@@ -206,27 +206,27 @@ static void extract_cpio_gz(int fd)
206 archive_handle->src_fd = fd; 206 archive_handle->src_fd = fd;
207 /*archive_handle->offset = 0; - init_handle() did it */ 207 /*archive_handle->offset = 0; - init_handle() did it */
208 208
209// TODO: open_zipped does the same
210
209 xread(archive_handle->src_fd, &magic, 2); 211 xread(archive_handle->src_fd, &magic, 2);
210#if BB_MMU 212#if BB_MMU
211 xformer = unpack_gz_stream; 213 xformer = unpack_gz_stream;
212#else 214#else
213 xformer_prog = "gunzip"; 215 xformer_prog = "gunzip";
214#endif 216#endif
215 if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { 217 if (magic[0] != 0x1f || magic[1] != 0x8b) {
216 if (ENABLE_FEATURE_RPM_BZ2 218 if (!ENABLE_FEATURE_SEAMLESS_BZ2
217 && (magic[0] == 0x42) && (magic[1] == 0x5a)) { 219 || magic[0] != 'B' || magic[1] != 'Z'
220 ) {
221 bb_error_msg_and_die("no gzip"
222 USE_FEATURE_SEAMLESS_BZ2("/bzip2")
223 " magic");
224 }
218#if BB_MMU 225#if BB_MMU
219 xformer = unpack_bz2_stream; 226 xformer = unpack_bz2_stream;
220#else 227#else
221 xformer_prog = "bunzip2"; 228 xformer_prog = "bunzip2";
222#endif 229#endif
223 /* We can do better, need modifying unpack_bz2_stream to not require
224 * first 2 bytes. Not very hard to do... I mean, TODO :) */
225 xlseek(archive_handle->src_fd, -2, SEEK_CUR);
226 } else
227 bb_error_msg_and_die("no gzip"
228 USE_FEATURE_RPM_BZ2("/bzip")
229 " magic");
230 } else { 230 } else {
231#if !BB_MMU 231#if !BB_MMU
232 /* NOMMU version of open_transformer execs an external unzipper that should 232 /* NOMMU version of open_transformer execs an external unzipper that should
diff --git a/archival/tar.c b/archival/tar.c
index b2481b843..45701c985 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -36,7 +36,7 @@
36#define block_buf bb_common_bufsiz1 36#define block_buf bb_common_bufsiz1
37 37
38 38
39#if !ENABLE_FEATURE_TAR_GZIP && !ENABLE_FEATURE_TAR_BZIP2 39#if !ENABLE_FEATURE_SEAMLESS_GZ && !ENABLE_FEATURE_SEAMLESS_BZ2
40/* Do not pass gzip flag to writeTarFile() */ 40/* Do not pass gzip flag to writeTarFile() */
41#define writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude, gzip) \ 41#define writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude, gzip) \
42 writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude) 42 writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude)
@@ -503,19 +503,19 @@ static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statb
503 return TRUE; 503 return TRUE;
504} 504}
505 505
506#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2 506#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
507#if !(ENABLE_FEATURE_TAR_GZIP && ENABLE_FEATURE_TAR_BZIP2) 507#if !(ENABLE_FEATURE_SEAMLESS_GZ && ENABLE_FEATURE_SEAMLESS_BZ2)
508#define vfork_compressor(tar_fd, gzip) vfork_compressor(tar_fd) 508#define vfork_compressor(tar_fd, gzip) vfork_compressor(tar_fd)
509#endif 509#endif
510/* Don't inline: vfork scares gcc and pessimizes code */ 510/* Don't inline: vfork scares gcc and pessimizes code */
511static void NOINLINE vfork_compressor(int tar_fd, int gzip) 511static void NOINLINE vfork_compressor(int tar_fd, int gzip)
512{ 512{
513 pid_t gzipPid; 513 pid_t gzipPid;
514#if ENABLE_FEATURE_TAR_GZIP && ENABLE_FEATURE_TAR_BZIP2 514#if ENABLE_FEATURE_SEAMLESS_GZ && ENABLE_FEATURE_SEAMLESS_BZ2
515 const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2"; 515 const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
516#elif ENABLE_FEATURE_TAR_GZIP 516#elif ENABLE_FEATURE_SEAMLESS_GZ
517 const char *zip_exec = "gzip"; 517 const char *zip_exec = "gzip";
518#else /* only ENABLE_FEATURE_TAR_BZIP2 */ 518#else /* only ENABLE_FEATURE_SEAMLESS_BZ2 */
519 const char *zip_exec = "bzip2"; 519 const char *zip_exec = "bzip2";
520#endif 520#endif
521 // On Linux, vfork never unpauses parent early, although standard 521 // On Linux, vfork never unpauses parent early, although standard
@@ -579,7 +579,7 @@ static void NOINLINE vfork_compressor(int tar_fd, int gzip)
579 bb_perror_msg_and_die("cannot exec %s", zip_exec); 579 bb_perror_msg_and_die("cannot exec %s", zip_exec);
580 } 580 }
581} 581}
582#endif /* ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2 */ 582#endif /* ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2 */
583 583
584 584
585/* gcc 4.2.1 inlines it, making code bigger */ 585/* gcc 4.2.1 inlines it, making code bigger */
@@ -601,7 +601,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
601 if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0) 601 if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0)
602 bb_perror_msg_and_die("cannot stat tar file"); 602 bb_perror_msg_and_die("cannot stat tar file");
603 603
604#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2 604#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
605 if (gzip) 605 if (gzip)
606 vfork_compressor(tbInfo.tarFd, gzip); 606 vfork_compressor(tbInfo.tarFd, gzip);
607#endif 607#endif
@@ -637,7 +637,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
637 if (errorFlag) 637 if (errorFlag)
638 bb_error_msg("error exit delayed from previous errors"); 638 bb_error_msg("error exit delayed from previous errors");
639 639
640#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2 640#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
641 if (gzip) { 641 if (gzip) {
642 int status; 642 int status;
643 if (safe_waitpid(-1, &status, 0) == -1) 643 if (safe_waitpid(-1, &status, 0) == -1)
@@ -679,7 +679,7 @@ static llist_t *append_file_list_to_list(llist_t *list)
679#define append_file_list_to_list(x) 0 679#define append_file_list_to_list(x) 0
680#endif 680#endif
681 681
682#if ENABLE_FEATURE_TAR_COMPRESS 682#if ENABLE_FEATURE_SEAMLESS_Z
683static char FAST_FUNC get_header_tar_Z(archive_handle_t *archive_handle) 683static char FAST_FUNC get_header_tar_Z(archive_handle_t *archive_handle)
684{ 684{
685 /* Can't lseek over pipes */ 685 /* Can't lseek over pipes */
@@ -692,7 +692,7 @@ static char FAST_FUNC get_header_tar_Z(archive_handle_t *archive_handle)
692 bb_error_msg_and_die("invalid magic"); 692 bb_error_msg_and_die("invalid magic");
693 } 693 }
694 694
695 open_transformer(archive_handle->src_fd, uncompress, "uncompress"); 695 open_transformer(archive_handle->src_fd, unpack_Z_stream, "uncompress");
696 archive_handle->offset = 0; 696 archive_handle->offset = 0;
697 while (get_header_tar(archive_handle) == EXIT_SUCCESS) 697 while (get_header_tar(archive_handle) == EXIT_SUCCESS)
698 continue; 698 continue;
@@ -729,14 +729,14 @@ static void handle_SIGCHLD(int status)
729 729
730enum { 730enum {
731 OPTBIT_KEEP_OLD = 7, 731 OPTBIT_KEEP_OLD = 7,
732 USE_FEATURE_TAR_CREATE( OPTBIT_CREATE ,) 732 USE_FEATURE_TAR_CREATE( OPTBIT_CREATE ,)
733 USE_FEATURE_TAR_CREATE( OPTBIT_DEREFERENCE ,) 733 USE_FEATURE_TAR_CREATE( OPTBIT_DEREFERENCE ,)
734 USE_FEATURE_TAR_BZIP2( OPTBIT_BZIP2 ,) 734 USE_FEATURE_SEAMLESS_BZ2( OPTBIT_BZIP2 ,)
735 USE_FEATURE_TAR_LZMA( OPTBIT_LZMA ,) 735 USE_FEATURE_SEAMLESS_LZMA(OPTBIT_LZMA ,)
736 USE_FEATURE_TAR_FROM( OPTBIT_INCLUDE_FROM,) 736 USE_FEATURE_TAR_FROM( OPTBIT_INCLUDE_FROM,)
737 USE_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,) 737 USE_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,)
738 USE_FEATURE_TAR_GZIP( OPTBIT_GZIP ,) 738 USE_FEATURE_SEAMLESS_GZ( OPTBIT_GZIP ,)
739 USE_FEATURE_TAR_COMPRESS(OPTBIT_COMPRESS ,) 739 USE_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,)
740 OPTBIT_NOPRESERVE_OWN, 740 OPTBIT_NOPRESERVE_OWN,
741 OPTBIT_NOPRESERVE_PERM, 741 OPTBIT_NOPRESERVE_PERM,
742 OPT_TEST = 1 << 0, // t 742 OPT_TEST = 1 << 0, // t
@@ -747,14 +747,14 @@ enum {
747 OPT_P = 1 << 5, // p 747 OPT_P = 1 << 5, // p
748 OPT_VERBOSE = 1 << 6, // v 748 OPT_VERBOSE = 1 << 6, // v
749 OPT_KEEP_OLD = 1 << 7, // k 749 OPT_KEEP_OLD = 1 << 7, // k
750 OPT_CREATE = USE_FEATURE_TAR_CREATE( (1<<OPTBIT_CREATE )) + 0, // c 750 OPT_CREATE = USE_FEATURE_TAR_CREATE( (1 << OPTBIT_CREATE )) + 0, // c
751 OPT_DEREFERENCE = USE_FEATURE_TAR_CREATE( (1<<OPTBIT_DEREFERENCE )) + 0, // h 751 OPT_DEREFERENCE = USE_FEATURE_TAR_CREATE( (1 << OPTBIT_DEREFERENCE )) + 0, // h
752 OPT_BZIP2 = USE_FEATURE_TAR_BZIP2( (1<<OPTBIT_BZIP2 )) + 0, // j 752 OPT_BZIP2 = USE_FEATURE_SEAMLESS_BZ2( (1 << OPTBIT_BZIP2 )) + 0, // j
753 OPT_LZMA = USE_FEATURE_TAR_LZMA( (1<<OPTBIT_LZMA )) + 0, // a 753 OPT_LZMA = USE_FEATURE_SEAMLESS_LZMA((1 << OPTBIT_LZMA )) + 0, // a
754 OPT_INCLUDE_FROM = USE_FEATURE_TAR_FROM( (1<<OPTBIT_INCLUDE_FROM)) + 0, // T 754 OPT_INCLUDE_FROM = USE_FEATURE_TAR_FROM( (1 << OPTBIT_INCLUDE_FROM)) + 0, // T
755 OPT_EXCLUDE_FROM = USE_FEATURE_TAR_FROM( (1<<OPTBIT_EXCLUDE_FROM)) + 0, // X 755 OPT_EXCLUDE_FROM = USE_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X
756 OPT_GZIP = USE_FEATURE_TAR_GZIP( (1<<OPTBIT_GZIP )) + 0, // z 756 OPT_GZIP = USE_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z
757 OPT_COMPRESS = USE_FEATURE_TAR_COMPRESS((1<<OPTBIT_COMPRESS )) + 0, // Z 757 OPT_COMPRESS = USE_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z
758 OPT_NOPRESERVE_OWN = 1 << OPTBIT_NOPRESERVE_OWN , // no-same-owner 758 OPT_NOPRESERVE_OWN = 1 << OPTBIT_NOPRESERVE_OWN , // no-same-owner
759 OPT_NOPRESERVE_PERM = 1 << OPTBIT_NOPRESERVE_PERM, // no-same-permissions 759 OPT_NOPRESERVE_PERM = 1 << OPTBIT_NOPRESERVE_PERM, // no-same-permissions
760}; 760};
@@ -772,20 +772,20 @@ static const char tar_longopts[] ALIGN1 =
772 "create\0" No_argument "c" 772 "create\0" No_argument "c"
773 "dereference\0" No_argument "h" 773 "dereference\0" No_argument "h"
774# endif 774# endif
775# if ENABLE_FEATURE_TAR_BZIP2 775# if ENABLE_FEATURE_SEAMLESS_BZ2
776 "bzip2\0" No_argument "j" 776 "bzip2\0" No_argument "j"
777# endif 777# endif
778# if ENABLE_FEATURE_TAR_LZMA 778# if ENABLE_FEATURE_SEAMLESS_LZMA
779 "lzma\0" No_argument "a" 779 "lzma\0" No_argument "a"
780# endif 780# endif
781# if ENABLE_FEATURE_TAR_FROM 781# if ENABLE_FEATURE_TAR_FROM
782 "files-from\0" Required_argument "T" 782 "files-from\0" Required_argument "T"
783 "exclude-from\0" Required_argument "X" 783 "exclude-from\0" Required_argument "X"
784# endif 784# endif
785# if ENABLE_FEATURE_TAR_GZIP 785# if ENABLE_FEATURE_SEAMLESS_GZ
786 "gzip\0" No_argument "z" 786 "gzip\0" No_argument "z"
787# endif 787# endif
788# if ENABLE_FEATURE_TAR_COMPRESS 788# if ENABLE_FEATURE_SEAMLESS_Z
789 "compress\0" No_argument "Z" 789 "compress\0" No_argument "Z"
790# endif 790# endif
791 "no-same-owner\0" No_argument "\xfd" 791 "no-same-owner\0" No_argument "\xfd"
@@ -834,12 +834,12 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
834#endif 834#endif
835 opt = getopt32(argv, 835 opt = getopt32(argv,
836 "txC:f:Opvk" 836 "txC:f:Opvk"
837 USE_FEATURE_TAR_CREATE( "ch" ) 837 USE_FEATURE_TAR_CREATE( "ch" )
838 USE_FEATURE_TAR_BZIP2( "j" ) 838 USE_FEATURE_SEAMLESS_BZ2( "j" )
839 USE_FEATURE_TAR_LZMA( "a" ) 839 USE_FEATURE_SEAMLESS_LZMA("a" )
840 USE_FEATURE_TAR_FROM( "T:X:") 840 USE_FEATURE_TAR_FROM( "T:X:")
841 USE_FEATURE_TAR_GZIP( "z" ) 841 USE_FEATURE_SEAMLESS_GZ( "z" )
842 USE_FEATURE_TAR_COMPRESS("Z" ) 842 USE_FEATURE_SEAMLESS_Z( "Z" )
843 , &base_dir // -C dir 843 , &base_dir // -C dir
844 , &tar_filename // -f filename 844 , &tar_filename // -f filename
845 USE_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T 845 USE_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T
@@ -922,8 +922,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
922 922
923 tar_stream = stdout; 923 tar_stream = stdout;
924 /* Mimicking GNU tar 1.15.1: */ 924 /* Mimicking GNU tar 1.15.1: */
925 flags = O_WRONLY|O_CREAT|O_TRUNC; 925 flags = O_WRONLY | O_CREAT | O_TRUNC;
926 /* was doing unlink; open(O_WRONLY|O_CREAT|O_EXCL); why? */
927 } else { 926 } else {
928 tar_stream = stdin; 927 tar_stream = stdin;
929 flags = O_RDONLY; 928 flags = O_RDONLY;
@@ -933,7 +932,14 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
933 tar_handle->src_fd = fileno(tar_stream); 932 tar_handle->src_fd = fileno(tar_stream);
934 tar_handle->seek = seek_by_read; 933 tar_handle->seek = seek_by_read;
935 } else { 934 } else {
936 tar_handle->src_fd = xopen(tar_filename, flags); 935 if (ENABLE_FEATURE_TAR_AUTODETECT && flags == O_RDONLY) {
936 get_header_ptr = get_header_tar;
937 tar_handle->src_fd = open_zipped(tar_filename);
938 if (tar_handle->src_fd < 0)
939 bb_perror_msg_and_die("can't open '%s'", tar_filename);
940 } else {
941 tar_handle->src_fd = xopen(tar_filename, flags);
942 }
937 } 943 }
938 } 944 }
939 945
@@ -947,11 +953,11 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
947 953
948 /* create an archive */ 954 /* create an archive */
949 if (opt & OPT_CREATE) { 955 if (opt & OPT_CREATE) {
950#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2 956#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
951 int zipMode = 0; 957 int zipMode = 0;
952 if (ENABLE_FEATURE_TAR_GZIP && (opt & OPT_GZIP)) 958 if (ENABLE_FEATURE_SEAMLESS_GZ && (opt & OPT_GZIP))
953 zipMode = 1; 959 zipMode = 1;
954 if (ENABLE_FEATURE_TAR_BZIP2 && (opt & OPT_BZIP2)) 960 if (ENABLE_FEATURE_SEAMLESS_BZ2 && (opt & OPT_BZIP2))
955 zipMode = 2; 961 zipMode = 2;
956#endif 962#endif
957 /* NB: writeTarFile() closes tar_handle->src_fd */ 963 /* NB: writeTarFile() closes tar_handle->src_fd */