diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2003-11-21 22:24:57 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2003-11-21 22:24:57 +0000 |
commit | 7ffe1338647d2b890df3ae46e526410b21a90d18 (patch) | |
tree | e949e5879a7083bac9e2da249363f9c613d0a409 /archival/tar.c | |
parent | 1a2d75fd7273e8de936e5fd91462bdff381f9b62 (diff) |
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.c | 17 |
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, if ((tbInfo->hlInfo == NULL) && (S_ISREG(statbuf->st_mode))) { int inputFileFd; - char buffer[BUFSIZ]; - ssize_t size = 0, readSize = 0; + ssize_t readSize = 0; /* open the file we want to archive, and make sure all is well */ if ((inputFileFd = open(fileName, O_RDONLY)) < 0) { @@ -424,18 +423,8 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, } /* write the file to the archive */ - while ((size = bb_full_read(inputFileFd, buffer, sizeof(buffer))) > 0) { - if (bb_full_write(tbInfo->tarFd, buffer, size) != size) { - /* Output file seems to have a problem */ - bb_error_msg(bb_msg_io_error, fileName); - return (FALSE); - } - readSize += size; - } - if (size == -1) { - bb_error_msg(bb_msg_io_error, fileName); - return (FALSE); - } + readSize = bb_copyfd_eof(inputFileFd, tbInfo->tarFd); + /* Pad the file up to the tar block size */ for (; (readSize % TAR_BLOCK_SIZE) != 0; readSize++) { write(tbInfo->tarFd, "\0", 1); |