aboutsummaryrefslogtreecommitdiff
path: root/archival/tar.c
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2003-11-21 22:24:57 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2003-11-21 22:24:57 +0000
commit7ffe1338647d2b890df3ae46e526410b21a90d18 (patch)
treee949e5879a7083bac9e2da249363f9c613d0a409 /archival/tar.c
parent1a2d75fd7273e8de936e5fd91462bdff381f9b62 (diff)
downloadbusybox-w32-7ffe1338647d2b890df3ae46e526410b21a90d18.tar.gz
busybox-w32-7ffe1338647d2b890df3ae46e526410b21a90d18.tar.bz2
busybox-w32-7ffe1338647d2b890df3ae46e526410b21a90d18.zip
As we no longer use function pointers for read in common archiving code
archive_xread can be replaced with bb_full_read, and archive_copy_file with bb_copyfd* bb_copyfd is split into two functions bb_copyfd_size and bb_copyfd_eof, they share a common backend.
Diffstat (limited to 'archival/tar.c')
-rw-r--r--archival/tar.c17
1 files changed, 3 insertions, 14 deletions
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);