From 7ffe1338647d2b890df3ae46e526410b21a90d18 Mon Sep 17 00:00:00 2001 From: Glenn L McGrath Date: Fri, 21 Nov 2003 22:24:57 +0000 Subject: 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. --- archival/tar.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'archival/tar.c') diff --git a/archival/tar.c b/archival/tar.c index b3fa447..cf9bc04 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); -- cgit v1.1