aboutsummaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
Diffstat (limited to 'archival')
-rw-r--r--archival/bbunzip.c9
-rw-r--r--archival/tar.c5
2 files changed, 4 insertions, 10 deletions
diff --git a/archival/bbunzip.c b/archival/bbunzip.c
index 3c3cc2886..4dba498b8 100644
--- a/archival/bbunzip.c
+++ b/archival/bbunzip.c
@@ -20,16 +20,11 @@ enum {
static
int open_to_or_warn(int to_fd, const char *filename, int flags, int mode)
{
- int fd = open(filename, flags, mode);
+ int fd = open3_or_warn(filename, flags, mode);
if (fd < 0) {
- bb_perror_msg("%s", filename);
return 1;
}
- if (fd != to_fd) {
- if (dup2(fd, to_fd) < 0)
- bb_perror_msg_and_die("cannot dup");
- close(fd);
- }
+ xmove_fd(fd, to_fd);
return 0;
}
diff --git a/archival/tar.c b/archival/tar.c
index f2f1ccd06..11a74dfe9 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -440,9 +440,8 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
/* Is this a regular file? */
if (tbInfo->hlInfo == NULL && S_ISREG(statbuf->st_mode)) {
/* open the file we want to archive, and make sure all is well */
- inputFileFd = open(fileName, O_RDONLY);
+ inputFileFd = open_or_warn(fileName, O_RDONLY);
if (inputFileFd < 0) {
- bb_perror_msg("%s: cannot open", fileName);
return FALSE;
}
}
@@ -455,7 +454,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
/* If it was a regular file, write out the body */
if (inputFileFd >= 0) {
size_t readSize;
- /* Wwrite the file to the archive. */
+ /* Write the file to the archive. */
/* We record size into header first, */
/* and then write out file. If file shrinks in between, */
/* tar will be corrupted. So we don't allow for that. */