diff options
Diffstat (limited to 'archival')
-rw-r--r-- | archival/ar.c | 2 | ||||
-rw-r--r-- | archival/libunarchive/Makefile.in | 3 | ||||
-rw-r--r-- | archival/libunarchive/archive_copy_file.c | 44 | ||||
-rw-r--r-- | archival/libunarchive/archive_xread.c | 33 | ||||
-rw-r--r-- | archival/libunarchive/archive_xread_all.c | 2 | ||||
-rw-r--r-- | archival/libunarchive/archive_xread_all_eof.c | 2 | ||||
-rw-r--r-- | archival/libunarchive/data_extract_all.c | 2 | ||||
-rw-r--r-- | archival/libunarchive/data_extract_to_stdout.c | 2 | ||||
-rw-r--r-- | archival/libunarchive/get_header_tar.c | 2 | ||||
-rw-r--r-- | archival/libunarchive/seek_by_char.c | 16 | ||||
-rw-r--r-- | archival/tar.c | 17 |
11 files changed, 11 insertions, 114 deletions
diff --git a/archival/ar.c b/archival/ar.c index 57ec92719..32ecd5736 100644 --- a/archival/ar.c +++ b/archival/ar.c | |||
@@ -59,7 +59,7 @@ static void data_extract_regular_file(archive_handle_t *archive_handle) | |||
59 | 59 | ||
60 | file_header = archive_handle->file_header; | 60 | file_header = archive_handle->file_header; |
61 | dst_fd = bb_xopen(file_header->name, O_WRONLY | O_CREAT); | 61 | dst_fd = bb_xopen(file_header->name, O_WRONLY | O_CREAT); |
62 | archive_copy_file(archive_handle, dst_fd); | 62 | bb_copyfd_eof(archive_handle->src_fd, dst_fd, file_header->size); |
63 | close(dst_fd); | 63 | close(dst_fd); |
64 | 64 | ||
65 | chmod(file_header->name, file_header->mode); | 65 | chmod(file_header->name, file_header->mode); |
diff --git a/archival/libunarchive/Makefile.in b/archival/libunarchive/Makefile.in index c9dec09ad..09b0571ed 100644 --- a/archival/libunarchive/Makefile.in +++ b/archival/libunarchive/Makefile.in | |||
@@ -37,15 +37,12 @@ LIBUNARCHIVE-y:= \ | |||
37 | header_list.o \ | 37 | header_list.o \ |
38 | header_verbose_list.o \ | 38 | header_verbose_list.o \ |
39 | \ | 39 | \ |
40 | archive_xread.o \ | ||
41 | archive_xread_all.o \ | 40 | archive_xread_all.o \ |
42 | archive_xread_all_eof.o \ | 41 | archive_xread_all_eof.o \ |
43 | \ | 42 | \ |
44 | seek_by_char.o \ | 43 | seek_by_char.o \ |
45 | seek_by_jump.o \ | 44 | seek_by_jump.o \ |
46 | \ | 45 | \ |
47 | archive_copy_file.o \ | ||
48 | \ | ||
49 | data_align.o \ | 46 | data_align.o \ |
50 | find_list_entry.o \ | 47 | find_list_entry.o \ |
51 | open_transformer.o \ | 48 | open_transformer.o \ |
diff --git a/archival/libunarchive/archive_copy_file.c b/archival/libunarchive/archive_copy_file.c deleted file mode 100644 index 675bc6ffe..000000000 --- a/archival/libunarchive/archive_copy_file.c +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | /* | ||
2 | * This program is free software; you can redistribute it and/or modify | ||
3 | * it under the terms of the GNU General Public License as published by | ||
4 | * the Free Software Foundation; either version 2 of the License, or | ||
5 | * (at your option) any later version. | ||
6 | * | ||
7 | * This program is distributed in the hope that it will be useful, | ||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
10 | * GNU General Public License for more details. | ||
11 | * | ||
12 | * You should have received a copy of the GNU General Public License | ||
13 | * along with this program; if not, write to the Free Software | ||
14 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
15 | */ | ||
16 | |||
17 | #include <unistd.h> | ||
18 | |||
19 | #include "libbb.h" | ||
20 | #include "unarchive.h" | ||
21 | |||
22 | extern void archive_copy_file(const archive_handle_t *archive_handle, const int dst_fd) | ||
23 | { | ||
24 | char buffer[512]; | ||
25 | off_t chunksize = archive_handle->file_header->size; | ||
26 | |||
27 | while (chunksize != 0) { | ||
28 | size_t size; | ||
29 | if (chunksize > 512) { | ||
30 | size = 512; | ||
31 | } else { | ||
32 | size = chunksize; | ||
33 | } | ||
34 | // archive_xread_all(archive_handle, buffer, size); | ||
35 | size = archive_xread(archive_handle, buffer, size); | ||
36 | |||
37 | if (write(dst_fd, buffer, size) != size) { | ||
38 | bb_error_msg_and_die ("Short write"); | ||
39 | } | ||
40 | chunksize -= size; | ||
41 | } | ||
42 | |||
43 | return; | ||
44 | } | ||
diff --git a/archival/libunarchive/archive_xread.c b/archival/libunarchive/archive_xread.c deleted file mode 100644 index 59b4d77a8..000000000 --- a/archival/libunarchive/archive_xread.c +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | /* | ||
2 | * This program is free software; you can redistribute it and/or modify | ||
3 | * it under the terms of the GNU General Public License as published by | ||
4 | * the Free Software Foundation; either version 2 of the License, or | ||
5 | * (at your option) any later version. | ||
6 | * | ||
7 | * This program is distributed in the hope that it will be useful, | ||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
10 | * GNU Library General Public License for more details. | ||
11 | * | ||
12 | * You should have received a copy of the GNU General Public License | ||
13 | * along with this program; if not, write to the Free Software | ||
14 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
15 | */ | ||
16 | |||
17 | #include <stdio.h> | ||
18 | #include <stdlib.h> | ||
19 | #include <string.h> | ||
20 | #include "unarchive.h" | ||
21 | #include "libbb.h" | ||
22 | |||
23 | extern ssize_t archive_xread(const archive_handle_t *archive_handle, unsigned char *buf, const size_t count) | ||
24 | { | ||
25 | ssize_t size; | ||
26 | |||
27 | size = bb_full_read(archive_handle->src_fd, buf, count); | ||
28 | if (size < 0) { | ||
29 | bb_perror_msg_and_die("Read error"); | ||
30 | } | ||
31 | |||
32 | return(size); | ||
33 | } | ||
diff --git a/archival/libunarchive/archive_xread_all.c b/archival/libunarchive/archive_xread_all.c index cfe046b27..ba9ade2d5 100644 --- a/archival/libunarchive/archive_xread_all.c +++ b/archival/libunarchive/archive_xread_all.c | |||
@@ -24,7 +24,7 @@ extern void archive_xread_all(const archive_handle_t *archive_handle, void *buf, | |||
24 | { | 24 | { |
25 | ssize_t size; | 25 | ssize_t size; |
26 | 26 | ||
27 | size = archive_xread(archive_handle, buf, count); | 27 | size = bb_full_read(archive_handle->src_fd, buf, count); |
28 | if (size != count) { | 28 | if (size != count) { |
29 | bb_error_msg_and_die("Short read"); | 29 | bb_error_msg_and_die("Short read"); |
30 | } | 30 | } |
diff --git a/archival/libunarchive/archive_xread_all_eof.c b/archival/libunarchive/archive_xread_all_eof.c index 23719cd7b..8084e3524 100644 --- a/archival/libunarchive/archive_xread_all_eof.c +++ b/archival/libunarchive/archive_xread_all_eof.c | |||
@@ -24,7 +24,7 @@ extern ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, unsigned | |||
24 | { | 24 | { |
25 | ssize_t size; | 25 | ssize_t size; |
26 | 26 | ||
27 | size = archive_xread(archive_handle, buf, count); | 27 | size = bb_full_read(archive_handle->src_fd, buf, count); |
28 | if ((size != 0) && (size != count)) { | 28 | if ((size != 0) && (size != count)) { |
29 | bb_perror_msg_and_die("Short read, read %d of %d", size, count); | 29 | bb_perror_msg_and_die("Short read, read %d of %d", size, count); |
30 | } | 30 | } |
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c index 4dccb815d..bf3be5b35 100644 --- a/archival/libunarchive/data_extract_all.c +++ b/archival/libunarchive/data_extract_all.c | |||
@@ -79,7 +79,7 @@ extern void data_extract_all(archive_handle_t *archive_handle) | |||
79 | case S_IFREG: { | 79 | case S_IFREG: { |
80 | /* Regular file */ | 80 | /* Regular file */ |
81 | dst_fd = bb_xopen(file_header->name, O_WRONLY | O_CREAT | O_EXCL); | 81 | dst_fd = bb_xopen(file_header->name, O_WRONLY | O_CREAT | O_EXCL); |
82 | archive_copy_file(archive_handle, dst_fd); | 82 | bb_copyfd_size(archive_handle->src_fd, dst_fd, file_header->size); |
83 | close(dst_fd); | 83 | close(dst_fd); |
84 | break; | 84 | break; |
85 | } | 85 | } |
diff --git a/archival/libunarchive/data_extract_to_stdout.c b/archival/libunarchive/data_extract_to_stdout.c index 8be2fa2e9..ce5d4b8d0 100644 --- a/archival/libunarchive/data_extract_to_stdout.c +++ b/archival/libunarchive/data_extract_to_stdout.c | |||
@@ -18,5 +18,5 @@ | |||
18 | 18 | ||
19 | extern void data_extract_to_stdout(archive_handle_t *archive_handle) | 19 | extern void data_extract_to_stdout(archive_handle_t *archive_handle) |
20 | { | 20 | { |
21 | archive_copy_file(archive_handle, fileno(stdout)); | 21 | bb_copyfd_eof(archive_handle->src_fd, fileno(stdout)); |
22 | } | 22 | } |
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c index d55189f42..603535a4c 100644 --- a/archival/libunarchive/get_header_tar.c +++ b/archival/libunarchive/get_header_tar.c | |||
@@ -57,7 +57,7 @@ extern char get_header_tar(archive_handle_t *archive_handle) | |||
57 | /* Align header */ | 57 | /* Align header */ |
58 | data_align(archive_handle, 512); | 58 | data_align(archive_handle, 512); |
59 | 59 | ||
60 | if (archive_xread(archive_handle, tar.raw, 512) != 512) { | 60 | if (bb_full_read(archive_handle->src_fd, tar.raw, 512) != 512) { |
61 | /* Assume end of file */ | 61 | /* Assume end of file */ |
62 | return(EXIT_FAILURE); | 62 | return(EXIT_FAILURE); |
63 | } | 63 | } |
diff --git a/archival/libunarchive/seek_by_char.c b/archival/libunarchive/seek_by_char.c index 77da4ef2e..c0315616e 100644 --- a/archival/libunarchive/seek_by_char.c +++ b/archival/libunarchive/seek_by_char.c | |||
@@ -26,19 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | extern void seek_by_char(const archive_handle_t *archive_handle, const unsigned int jump_size) | 27 | extern void seek_by_char(const archive_handle_t *archive_handle, const unsigned int jump_size) |
28 | { | 28 | { |
29 | unsigned int remaining = jump_size; | 29 | if (jump_size) { |
30 | unsigned int read_amount; | 30 | bb_full_fd_action(archive_handle->src_fd, -1, jump_size, NULL); |
31 | RESERVE_CONFIG_BUFFER(buf, BUFSIZ); | ||
32 | |||
33 | while (remaining > 0) { | ||
34 | if (remaining > BUFSIZ) { | ||
35 | read_amount = BUFSIZ; | ||
36 | } else { | ||
37 | read_amount = remaining; | ||
38 | } | ||
39 | read_amount = archive_xread(archive_handle, buf, read_amount); | ||
40 | remaining -= read_amount; | ||
41 | } | 31 | } |
42 | |||
43 | RELEASE_CONFIG_BUFFER(buf); | ||
44 | } | 32 | } |
diff --git a/archival/tar.c b/archival/tar.c index b3fa447f2..cf9bc04d3 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -414,8 +414,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, | |||
414 | if ((tbInfo->hlInfo == NULL) | 414 | if ((tbInfo->hlInfo == NULL) |
415 | && (S_ISREG(statbuf->st_mode))) { | 415 | && (S_ISREG(statbuf->st_mode))) { |
416 | int inputFileFd; | 416 | int inputFileFd; |
417 | char buffer[BUFSIZ]; | 417 | ssize_t readSize = 0; |
418 | ssize_t size = 0, readSize = 0; | ||
419 | 418 | ||
420 | /* open the file we want to archive, and make sure all is well */ | 419 | /* open the file we want to archive, and make sure all is well */ |
421 | if ((inputFileFd = open(fileName, O_RDONLY)) < 0) { | 420 | if ((inputFileFd = open(fileName, O_RDONLY)) < 0) { |
@@ -424,18 +423,8 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, | |||
424 | } | 423 | } |
425 | 424 | ||
426 | /* write the file to the archive */ | 425 | /* write the file to the archive */ |
427 | while ((size = bb_full_read(inputFileFd, buffer, sizeof(buffer))) > 0) { | 426 | readSize = bb_copyfd_eof(inputFileFd, tbInfo->tarFd); |
428 | if (bb_full_write(tbInfo->tarFd, buffer, size) != size) { | 427 | |
429 | /* Output file seems to have a problem */ | ||
430 | bb_error_msg(bb_msg_io_error, fileName); | ||
431 | return (FALSE); | ||
432 | } | ||
433 | readSize += size; | ||
434 | } | ||
435 | if (size == -1) { | ||
436 | bb_error_msg(bb_msg_io_error, fileName); | ||
437 | return (FALSE); | ||
438 | } | ||
439 | /* Pad the file up to the tar block size */ | 428 | /* Pad the file up to the tar block size */ |
440 | for (; (readSize % TAR_BLOCK_SIZE) != 0; readSize++) { | 429 | for (; (readSize % TAR_BLOCK_SIZE) != 0; readSize++) { |
441 | write(tbInfo->tarFd, "\0", 1); | 430 | write(tbInfo->tarFd, "\0", 1); |