libunarchive: move dpkg-specific things into dpkg.c. 0 byte size differences
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 451c6fa..2e24541 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -1469,6 +1469,14 @@
ar_handle->sub_archive = tar_handle;
}
+static void FAST_FUNC data_extract_to_buffer(archive_handle_t *archive_handle)
+{
+ unsigned size = archive_handle->file_header->size;
+
+ archive_handle->ah_buffer = xzalloc(size + 1);
+ xread(archive_handle->src_fd, archive_handle->ah_buffer, size);
+}
+
static char *deb_extract_control_file_to_buffer(archive_handle_t *ar_handle, llist_t *myaccept)
{
ar_handle->sub_archive->action_data = data_extract_to_buffer;
@@ -1478,7 +1486,7 @@
unpack_ar_archive(ar_handle);
close(ar_handle->src_fd);
- return ar_handle->sub_archive->buffer;
+ return ar_handle->sub_archive->ah_buffer;
}
static void FAST_FUNC data_extract_all_prefix(archive_handle_t *archive_handle)
@@ -1487,7 +1495,7 @@
name_ptr += strspn(name_ptr, "./");
if (name_ptr[0] != '\0') {
- archive_handle->file_header->name = xasprintf("%s%s", archive_handle->buffer, name_ptr);
+ archive_handle->file_header->name = xasprintf("%s%s", archive_handle->ah_buffer, name_ptr);
data_extract_all(archive_handle);
}
}
@@ -1530,7 +1538,7 @@
archive_handle->sub_archive->accept = accept_list;
archive_handle->sub_archive->filter = filter_accept_list;
archive_handle->sub_archive->action_data = data_extract_all_prefix;
- archive_handle->sub_archive->buffer = info_prefix;
+ archive_handle->sub_archive->ah_buffer = info_prefix;
archive_handle->sub_archive->ah_flags |= ARCHIVE_UNLINK_OLD;
unpack_ar_archive(archive_handle);
@@ -1541,7 +1549,7 @@
archive_handle = init_archive_deb_ar(deb_file->filename);
init_archive_deb_data(archive_handle);
archive_handle->sub_archive->action_data = data_extract_all_prefix;
- archive_handle->sub_archive->buffer = (char*)"/"; /* huh? */
+ archive_handle->sub_archive->ah_buffer = (char*)"/"; /* huh? */
archive_handle->sub_archive->ah_flags |= ARCHIVE_UNLINK_OLD;
unpack_ar_archive(archive_handle);
diff --git a/archival/libunarchive/Kbuild b/archival/libunarchive/Kbuild
index 4bb81ce..11d23b2 100644
--- a/archival/libunarchive/Kbuild
+++ b/archival/libunarchive/Kbuild
@@ -11,7 +11,6 @@
data_skip.o \
data_extract_all.o \
data_extract_to_stdout.o \
- data_extract_to_buffer.o \
\
filter_accept_all.o \
filter_accept_list.o \
diff --git a/archival/libunarchive/data_extract_to_buffer.c b/archival/libunarchive/data_extract_to_buffer.c
deleted file mode 100644
index 1d74e03..0000000
--- a/archival/libunarchive/data_extract_to_buffer.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Copyright 2002 Glenn McGrath
- *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
- */
-
-#include "libbb.h"
-#include "unarchive.h"
-
-void FAST_FUNC data_extract_to_buffer(archive_handle_t *archive_handle)
-{
- unsigned int size = archive_handle->file_header->size;
-
- archive_handle->buffer = xzalloc(size + 1);
- xread(archive_handle->src_fd, archive_handle->buffer, size);
-}
diff --git a/archival/tar.c b/archival/tar.c
index d6c44a7..7ec101d 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -729,7 +729,7 @@
/* wait failed?! I'm confused... */
return;
- if (WIFEXITED(status) && WEXITSTATUS(status)==0)
+ if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
/* child exited with 0 */
return;
/* Cannot happen?
@@ -748,15 +748,16 @@
IF_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,)
IF_FEATURE_SEAMLESS_GZ( OPTBIT_GZIP ,)
IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,) // 16th bit
+#if ENABLE_FEATURE_TAR_LONG_OPTIONS
OPTBIT_NUMERIC_OWNER,
- OPTBIT_NOPRESERVE_OWNER,
OPTBIT_NOPRESERVE_PERM,
+#endif
OPT_TEST = 1 << 0, // t
OPT_EXTRACT = 1 << 1, // x
OPT_BASEDIR = 1 << 2, // C
OPT_TARNAME = 1 << 3, // f
OPT_2STDOUT = 1 << 4, // O
- OPT_NOPRESERVE_OWNER = 1 << 5, // no-same-owner
+ OPT_NOPRESERVE_OWNER = 1 << 5, // o == no-same-owner
OPT_P = 1 << 6, // p
OPT_VERBOSE = 1 << 7, // v
OPT_KEEP_OLD = 1 << 8, // k
@@ -768,8 +769,8 @@
OPT_EXCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X
OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z
OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z
- OPT_NUMERIC_OWNER = 1 << OPTBIT_NUMERIC_OWNER,
- OPT_NOPRESERVE_PERM = 1 << OPTBIT_NOPRESERVE_PERM, // no-same-permissions
+ OPT_NUMERIC_OWNER = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER )) + 0, // numeric-owner
+ OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions
};
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
static const char tar_longopts[] ALIGN1 =
@@ -810,8 +811,7 @@
/* do not restore mode */
"no-same-permissions\0" No_argument "\xfe"
/* --exclude takes next bit position in option mask, */
- /* therefore we have to either put it _after_ --no-same-perm */
- /* or add OPT[BIT]_EXCLUDE before OPT[BIT]_NOPRESERVE_OWNER */
+ /* therefore we have to put it _after_ --no-same-permissions */
# if ENABLE_FEATURE_TAR_FROM
"exclude\0" Required_argument "\xff"
# endif
diff --git a/include/unarchive.h b/include/unarchive.h
index 26d79e1..35ce521 100644
--- a/include/unarchive.h
+++ b/include/unarchive.h
@@ -4,15 +4,6 @@
PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
-#define ARCHIVE_RESTORE_DATE (1 << 0)
-#define ARCHIVE_CREATE_LEADING_DIRS (1 << 1)
-#define ARCHIVE_UNLINK_OLD (1 << 2)
-#define ARCHIVE_EXTRACT_QUIET (1 << 3)
-#define ARCHIVE_EXTRACT_NEWER (1 << 4)
-#define ARCHIVE_DONT_RESTORE_OWNER (1 << 5)
-#define ARCHIVE_DONT_RESTORE_PERM (1 << 6)
-#define ARCHIVE_NUMERIC_OWNER (1 << 7)
-
typedef struct file_header_t {
char *name;
char *link_target;
@@ -64,7 +55,7 @@
void FAST_FUNC (*seek)(int fd, off_t amount);
/* Temporary storage */
- char *buffer;
+ char *ah_buffer;
/* Flags and misc. stuff */
unsigned char ah_flags;
@@ -74,6 +65,15 @@
void *ah_priv[8];
} archive_handle_t;
+/* bits in ah_flags */
+#define ARCHIVE_RESTORE_DATE (1 << 0)
+#define ARCHIVE_CREATE_LEADING_DIRS (1 << 1)
+#define ARCHIVE_UNLINK_OLD (1 << 2)
+#define ARCHIVE_EXTRACT_QUIET (1 << 3)
+#define ARCHIVE_EXTRACT_NEWER (1 << 4)
+#define ARCHIVE_DONT_RESTORE_OWNER (1 << 5)
+#define ARCHIVE_DONT_RESTORE_PERM (1 << 6)
+#define ARCHIVE_NUMERIC_OWNER (1 << 7)
/* Info struct unpackers can fill out to inform users of thing like
@@ -94,7 +94,6 @@
extern void data_skip(archive_handle_t *archive_handle) FAST_FUNC;
extern void data_extract_all(archive_handle_t *archive_handle) FAST_FUNC;
extern void data_extract_to_stdout(archive_handle_t *archive_handle) FAST_FUNC;
-extern void data_extract_to_buffer(archive_handle_t *archive_handle) FAST_FUNC;
extern void header_skip(const file_header_t *file_header) FAST_FUNC;
extern void header_list(const file_header_t *file_header) FAST_FUNC;
diff --git a/testsuite/tar.tests b/testsuite/tar.tests
index 0d4fa45..35f96b7 100755
--- a/testsuite/tar.tests
+++ b/testsuite/tar.tests
@@ -8,16 +8,17 @@
# testing "test name" "script" "expected result" "file input" "stdin"
-testing "tar hardlinks and repeated files" \
-">input_hard1
+testing "tar hardlinks and repeated files" "\
+rm -rf input_* test.tar 2>/dev/null
+>input_hard1
ln input_hard1 input_hard2
mkdir input_dir
>input_dir/file
tar cf test.tar input input_dir/ input_hard1 input_hard2 input_hard1 input_dir/ input
tar tvf test.tar | sed 's/.*[0-9] input/input/'
tar xf test.tar 2>&1 && echo Ok
-" \
-"input
+" "\
+input
input_dir/
input_dir/file
input_hard1