summaryrefslogtreecommitdiff
path: root/archival/tar.c
diff options
context:
space:
mode:
authorDenis Vlasenko2006-11-25 23:47:32 +0000
committerDenis Vlasenko2006-11-25 23:47:32 +0000
commit87cd4a87e3f98dd5a1b982cfdfc4dad6800ca010 (patch)
treeba572c8880643df14a9803c30fd710ec8f9feedf /archival/tar.c
parent43bddf31e95080abf7232952da9064207636f47b (diff)
downloadbusybox-87cd4a87e3f98dd5a1b982cfdfc4dad6800ca010.zip
busybox-87cd4a87e3f98dd5a1b982cfdfc4dad6800ca010.tar.gz
tar: small fix and small optimization
Diffstat (limited to 'archival/tar.c')
-rw-r--r--archival/tar.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/archival/tar.c b/archival/tar.c
index d875805..c870d53 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -150,9 +150,8 @@ static HardLinkInfo *findHardLinkInfo(HardLinkInfo * hlInfo, struct stat *statbu
/* Put an octal string into the specified buffer.
* The number is zero padded and possibly null terminated.
- * Stores low-order bits only if whole value does not fit.
- * Returns FALSE if that happens. */
-static int putOctal(char *cp, int len, off_t value)
+ * Stores low-order bits only if whole value does not fit. */
+static void putOctal(char *cp, int len, off_t value)
{
char tempBuffer[sizeof(off_t)*3+1];
char *tempString = tempBuffer;
@@ -169,10 +168,6 @@ static int putOctal(char *cp, int len, off_t value)
/* Copy the string to the field */
memcpy(cp, tempString, len);
-
- /* If after shift we have zero - value did not overflow, */
- /* return 1 (TRUE) then */
- return (value >> (len*3)) == 0;
}
/* Write out a tar header for the specified file/directory/whatever */
@@ -239,14 +234,15 @@ static int writeTarHeader(struct TarBallInfo *tbInfo,
} else if (S_ISFIFO(statbuf->st_mode)) {
header.typeflag = FIFOTYPE;
} else if (S_ISREG(statbuf->st_mode)) {
- header.typeflag = REGTYPE;
- if ((PUT_OCTAL(header.size, statbuf->st_size) == FALSE)
- && sizeof(statbuf->st_size) > 4
+ if (sizeof(statbuf->st_size) > 4
+ && statbuf->st_size > (off_t)0777777777777LL
) {
bb_error_msg_and_die("cannot store file '%s' "
"of size %"OFF_FMT"d, aborting",
fileName, statbuf->st_size);
}
+ header.typeflag = REGTYPE;
+ PUT_OCTAL(header.size, statbuf->st_size);
} else {
bb_error_msg("%s: unknown file type", fileName);
return FALSE;