summaryrefslogtreecommitdiff
path: root/archivers/libarchive/files/libarchive
diff options
context:
space:
mode:
Diffstat (limited to 'archivers/libarchive/files/libarchive')
-rw-r--r--archivers/libarchive/files/libarchive/archive.h.in82
-rw-r--r--archivers/libarchive/files/libarchive/archive_entry.356
-rw-r--r--archivers/libarchive/files/libarchive/archive_entry.c9
-rw-r--r--archivers/libarchive/files/libarchive/archive_entry.h34
-rw-r--r--archivers/libarchive/files/libarchive/archive_entry_link_resolver.c150
-rw-r--r--archivers/libarchive/files/libarchive/archive_read.384
-rw-r--r--archivers/libarchive/files/libarchive/archive_read.c17
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_private.h50
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_format_ar.c77
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_format_mtree.c282
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_format_tar.c28
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_format_zip.c21
-rw-r--r--archivers/libarchive/files/libarchive/archive_string.h5
-rw-r--r--archivers/libarchive/files/libarchive/archive_string_sprintf.c12
-rw-r--r--archivers/libarchive/files/libarchive/archive_util.39
-rw-r--r--archivers/libarchive/files/libarchive/archive_util.c26
-rw-r--r--archivers/libarchive/files/libarchive/archive_write.344
-rw-r--r--archivers/libarchive/files/libarchive/archive_write.c9
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_disk.321
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_disk.c6
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_private.h9
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_compression_compress.c494
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_format_ar.c14
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_format_cpio.c6
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_format_cpio_newc.c6
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_format_pax.c48
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_format_shar.c10
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_format_ustar.c6
-rw-r--r--archivers/libarchive/files/libarchive/config_freebsd.h4
-rw-r--r--archivers/libarchive/files/libarchive/config_windows.h16
-rw-r--r--archivers/libarchive/files/libarchive/mtree.552
-rw-r--r--archivers/libarchive/files/libarchive/test/list.h1
-rw-r--r--archivers/libarchive/files/libarchive/test/main.c253
-rw-r--r--archivers/libarchive/files/libarchive/test/test.h24
-rw-r--r--archivers/libarchive/files/libarchive/test/test_archive_api_feature.c27
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_gtar.c6
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_tar_hardlink.c6
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_zip.c6
-rw-r--r--archivers/libarchive/files/libarchive/test/test_empty_write.c5
-rw-r--r--archivers/libarchive/files/libarchive/test/test_entry.c55
-rw-r--r--archivers/libarchive/files/libarchive/test/test_link_resolver.c41
-rw-r--r--archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.c31
-rw-r--r--archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.tar.gz.uu10
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_ar.c6
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c9
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_compress.c102
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_format_ar.c6
47 files changed, 1684 insertions, 591 deletions
diff --git a/archivers/libarchive/files/libarchive/archive.h.in b/archivers/libarchive/files/libarchive/archive.h.in
index d76c85e51bd..c6d0c1c0e0e 100644
--- a/archivers/libarchive/files/libarchive/archive.h.in
+++ b/archivers/libarchive/files/libarchive/archive.h.in
@@ -22,18 +22,12 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/archive.h.in,v 1.47 2007/12/30 04:58:21 kientzle Exp $
+ * $FreeBSD: src/lib/libarchive/archive.h.in,v 1.49 2008/03/14 22:19:50 kientzle Exp $
*/
#ifndef ARCHIVE_H_INCLUDED
#define ARCHIVE_H_INCLUDED
-/*
- * This header file corresponds to:
- * Library version @ARCHIVE_VERSION@
- * Shared library version @SHLIB_MAJOR@
- */
-
#include <sys/types.h> /* Linux requires this for off_t */
@ARCHIVE_H_INCLUDE_INTTYPES_H@
#include <stdio.h> /* For FILE * */
@@ -51,58 +45,60 @@ extern "C" {
#endif
/*
- * Each of the version identifiers comes as a macro and a function.
+ * The version number is provided as both a macro and a function.
* The macro identifies the installed header; the function identifies
* the library version (which may not be the same if you're using a
* dynamically-linked version of the library).
*/
/*
- * Textual name/version of the library, useful for version displays.
- */
-#define ARCHIVE_LIBRARY_VERSION "libarchive @LIBARCHIVE_VERSION_STRING@"
-const char * archive_version(void);
-
-/*
- * The "version stamp" is a single integer that makes it easy to check
- * the exact version: for version a.b.c, the version stamp is
- * printf("%d%03d%03d",a,b,c). For example, version 2.12.108 has
- * version stamp 2012108.
+ * The version number is expressed as a single integer that makes it
+ * easy to compare versions at build time: for version a.b.c, the
+ * version number is printf("%d%03d%03d",a,b,c). For example, if you
+ * know your application requires version 2.12.108 or later, you can
+ * assert that ARCHIVE_VERSION >= 2012108.
*
- * This was introduced with libarchive 1.9.0 in the libarchive 1.x family
- * and libarchive 2.2.4 in the libarchive 2.x family. The following
- * may be useful if you really want to do feature detection for earlier
- * libarchive versions (which defined API_VERSION and API_FEATURE):
+ * This single-number format was introduced with libarchive 1.9.0 in
+ * the libarchive 1.x family and libarchive 2.2.4 in the libarchive
+ * 2.x family. The following may be useful if you really want to do
+ * feature detection for earlier libarchive versions (which defined
+ * ARCHIVE_API_VERSION and ARCHIVE_API_FEATURE instead):
*
- * #ifndef ARCHIVE_VERSION_STAMP
- * #define ARCHIVE_VERSION_STAMP \
+ * #ifndef ARCHIVE_VERSION_NUMBER
+ * #define ARCHIVE_VERSION_NUMBER \
* (ARCHIVE_API_VERSION * 1000000 + ARCHIVE_API_FEATURE * 1000)
* #endif
*/
-#define ARCHIVE_VERSION_STAMP @LIBARCHIVE_VERSION@
-int archive_version_stamp(void);
+#define ARCHIVE_VERSION_NUMBER @LIBARCHIVE_VERSION_NUMBER@
+int archive_version_number(void);
/*
- * Major version number: If ARCHIVE_API_VERSION !=
- * archive_api_version(), then the library you were linked with is
- * using an incompatible API to the one you were compiled with. This
- * is almost certainly a fatal problem.
- * This is deprecated and will be removed; use ARCHIVE_VERSION_STAMP
- * instead.
+ * Textual name/version of the library, useful for version displays.
*/
-#define ARCHIVE_API_VERSION (ARCHIVE_VERSION_STAMP / 1000000)
-int archive_api_version(void);
+#define ARCHIVE_VERSION_STRING "libarchive @LIBARCHIVE_VERSION_STRING@"
+const char * archive_version_string(void);
+#if ARCHIVE_VERSION_NUMBER < 3000000
/*
- * Minor version number. This is deprecated and will be removed.
- * Use ARCHIVE_VERSION_STAMP to adapt to libarchive API variations.
+ * Deprecated; these are older names that will be removed in favor of
+ * the simpler definitions above.
*/
-#define ARCHIVE_API_FEATURE ((ARCHIVE_VERSION_STAMP / 1000) % 1000)
+#define ARCHIVE_VERSION_STAMP ARCHIVE_VERSION_NUMBER
+int archive_version_stamp(void);
+#define ARCHIVE_LIBRARY_VERSION ARCHIVE_VERSION_STRING
+const char * archive_version(void);
+#define ARCHIVE_API_VERSION (ARCHIVE_VERSION_NUMBER / 1000000)
+int archive_api_version(void);
+#define ARCHIVE_API_FEATURE ((ARCHIVE_VERSION_NUMBER / 1000) % 1000)
int archive_api_feature(void);
+#endif
-
+#if ARCHIVE_VERSION_NUMBER < 3000000
+/* This should never have been here in the first place. */
+/* Legacy of old tar assumptions, will be removed in libarchive 3.0. */
#define ARCHIVE_BYTES_PER_RECORD 512
#define ARCHIVE_DEFAULT_BYTES_PER_BLOCK 10240
+#endif
/* Declare our basic types. */
struct archive;
@@ -119,6 +115,7 @@ struct archive_entry;
#define ARCHIVE_WARN (-20) /* Partial success. */
/* For example, if write_header "fails", then you can't push data. */
#define ARCHIVE_FAILED (-25) /* Current operation cannot complete. */
+/* But if write_header is "fatal," then this archive is dead and useless. */
#define ARCHIVE_FATAL (-30) /* No more operations are possible. */
/*
@@ -146,7 +143,7 @@ struct archive_entry;
typedef ssize_t archive_read_callback(struct archive *, void *_client_data,
const void **_buffer);
/* Skips at most request bytes from archive and returns the skipped amount */
-#if ARCHIVE_API_VERSION < 2
+#if ARCHIVE_VERSION_NUMBER < 2000000
typedef ssize_t archive_skip_callback(struct archive *, void *_client_data,
size_t request);
#else
@@ -370,7 +367,7 @@ void archive_read_extract_set_skip_file(struct archive *,
int archive_read_close(struct archive *);
/* Release all resources and destroy the object. */
/* Note that archive_read_finish will call archive_read_close for you. */
-#if ARCHIVE_API_VERSION > 1
+#if ARCHIVE_VERSION_NUMBER >= 2000000
int archive_read_finish(struct archive *);
#else
/* Temporarily allow library to compile with either 1.x or 2.0 API. */
@@ -407,6 +404,7 @@ int archive_write_get_bytes_in_last_block(struct archive *);
int archive_write_set_skip_file(struct archive *, dev_t, ino_t);
int archive_write_set_compression_bzip2(struct archive *);
+int archive_write_set_compression_compress(struct archive *);
int archive_write_set_compression_gzip(struct archive *);
int archive_write_set_compression_none(struct archive *);
int archive_write_set_compression_program(struct archive *,
@@ -445,7 +443,7 @@ int archive_write_open_memory(struct archive *,
*/
int archive_write_header(struct archive *,
struct archive_entry *);
-#if ARCHIVE_API_VERSION > 1
+#if ARCHIVE_VERSION_NUMBER >= 2000000
ssize_t archive_write_data(struct archive *, const void *, size_t);
#else
/* Temporarily allow library to compile with either 1.x or 2.0 API. */
@@ -455,7 +453,7 @@ int archive_write_data(struct archive *, const void *, size_t);
ssize_t archive_write_data_block(struct archive *, const void *, size_t, off_t);
int archive_write_finish_entry(struct archive *);
int archive_write_close(struct archive *);
-#if ARCHIVE_API_VERSION > 1
+#if ARCHIVE_VERSION_NUMBER >= 2000000
int archive_write_finish(struct archive *);
#else
/* Temporarily allow library to compile with either 1.x or 2.0 API. */
diff --git a/archivers/libarchive/files/libarchive/archive_entry.3 b/archivers/libarchive/files/libarchive/archive_entry.3
index 6b1b270f1a5..8d96de1fbf4 100644
--- a/archivers/libarchive/files/libarchive/archive_entry.3
+++ b/archivers/libarchive/files/libarchive/archive_entry.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/lib/libarchive/archive_entry.3,v 1.15 2007/07/15 19:10:34 kientzle Exp $
+.\" $FreeBSD: src/lib/libarchive/archive_entry.3,v 1.17 2008/03/14 23:00:53 kientzle Exp $
.\"
.Dd December 15, 2003
.Dt archive_entry 3
@@ -45,6 +45,8 @@
.Nm archive_entry_copy_gname_w ,
.Nm archive_entry_copy_hardlink ,
.Nm archive_entry_copy_hardlink_w ,
+.Nm archive_entry_copy_link ,
+.Nm archive_entry_copy_link_w ,
.Nm archive_entry_copy_pathname_w ,
.Nm archive_entry_copy_stat ,
.Nm archive_entry_copy_symlink ,
@@ -101,17 +103,47 @@
.Sh SYNOPSIS
.In archive_entry.h
.Ft void
-.Fn archive_entry_acl_add_entry "struct archive_entry *" "int type" "int permset" "int tag" "int qual" "const char *name"
-.Ft void
-.Fn archive_entry_acl_add_entry_w "struct archive_entry *" "int type" "int permset" "int tag" "int qual" "const wchar_t *name"
+.Fo archive_entry_acl_add_entry
+.Fa "struct archive_entry *"
+.Fa "int type"
+.Fa "int permset"
+.Fa "int tag"
+.Fa "int qual"
+.Fa "const char *name"
+.Fc
+.Ft void
+.Fo archive_entry_acl_add_entry_w
+.Fa "struct archive_entry *"
+.Fa "int type"
+.Fa "int permset"
+.Fa "int tag"
+.Fa "int qual"
+.Fa "const wchar_t *name"
+.Fc
.Ft void
.Fn archive_entry_acl_clear "struct archive_entry *"
.Ft int
.Fn archive_entry_acl_count "struct archive_entry *" "int type"
.Ft int
-.Fn archive_entry_acl_next "struct archive_entry *" "int want_type" "int *type" "int *permset" "int *tag" "int *qual" "const char **name"
+.Fo archive_entry_acl_next
+.Fa "struct archive_entry *"
+.Fa "int want_type"
+.Fa "int *type"
+.Fa "int *permset"
+.Fa "int *tag"
+.Fa "int *qual"
+.Fa "const char **name"
+.Fc
.Ft int
-.Fn archive_entry_acl_next_w "struct archive_entry *" "int want_type" "int *type" "int *permset" "int *tag" "int *qual" "const wchar_t **name"
+.Fo archive_entry_acl_next_w
+.Fa "struct archive_entry *"
+.Fa "int want_type"
+.Fa "int *type"
+.Fa "int *permset"
+.Fa "int *tag"
+.Fa "int *qual"
+.Fa "const wchar_t **name"
+.Fc
.Ft int
.Fn archive_entry_acl_reset "struct archive_entry *" "int want_type"
.Ft const wchar_t *
@@ -155,7 +187,11 @@
.Ft mode_t
.Fn archive_entry_filetype "struct archive_entry *"
.Ft void
-.Fn archive_entry_fflags "struct archive_entry *" "unsigned long *set" "unsigned long *clear"
+.Fo archive_entry_fflags
+.Fa "struct archive_entry *"
+.Fa "unsigned long *set"
+.Fa "unsigned long *clear"
+.Fc
.Ft const char *
.Fn archive_entry_fflags_text "struct archive_entry *"
.Ft void
@@ -195,7 +231,11 @@
.Ft void
.Fn archive_entry_set_filetype "struct archive_entry *" "unsigned int"
.Ft void
-.Fn archive_entry_set_fflags "struct archive_entry *" "unsigned long set" "unsigned long clear"
+.Fo archive_entry_set_fflags
+.Fa "struct archive_entry *"
+.Fa "unsigned long set"
+.Fa "unsigned long clear"
+.Fc
.Ft void
.Fn archive_entry_set_gid "struct archive_entry *" "gid_t"
.Ft void
diff --git a/archivers/libarchive/files/libarchive/archive_entry.c b/archivers/libarchive/files/libarchive/archive_entry.c
index a6c9b4496c1..5f9e39a6674 100644
--- a/archivers/libarchive/files/libarchive/archive_entry.c
+++ b/archivers/libarchive/files/libarchive/archive_entry.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry.c,v 1.45 2007/12/30 04:58:21 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry.c,v 1.51 2008/03/14 23:19:46 kientzle Exp $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -1155,6 +1155,11 @@ archive_entry_acl_next(struct archive_entry *entry, int want_type, int *type,
entry->acl_p = entry->acl_p->next;
if (entry->acl_p == NULL) {
entry->acl_state = 0;
+ *type = 0;
+ *permset = 0;
+ *tag = 0;
+ *id = -1;
+ *name = NULL;
return (ARCHIVE_EOF); /* End of ACL entries. */
}
*type = entry->acl_p->type;
@@ -1536,7 +1541,7 @@ archive_entry_xattr_next(struct archive_entry * entry,
return (ARCHIVE_OK);
} else {
*name = NULL;
- *name = NULL;
+ *value = NULL;
*size = (size_t)0;
return (ARCHIVE_WARN);
}
diff --git a/archivers/libarchive/files/libarchive/archive_entry.h b/archivers/libarchive/files/libarchive/archive_entry.h
index cebd55ba8ae..69d7702a533 100644
--- a/archivers/libarchive/files/libarchive/archive_entry.h
+++ b/archivers/libarchive/files/libarchive/archive_entry.h
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/archive_entry.h,v 1.24 2007/12/30 04:58:21 kientzle Exp $
+ * $FreeBSD: src/lib/libarchive/archive_entry.h,v 1.26 2008/03/14 23:00:53 kientzle Exp $
*/
#ifndef ARCHIVE_ENTRY_H_INCLUDED
@@ -31,7 +31,15 @@
#include <sys/types.h>
#include <stddef.h> /* for wchar_t */
#include <time.h>
+#ifndef _WIN32
#include <unistd.h>
+#else
+typedef unsigned int uid_t;
+typedef unsigned int gid_t;
+typedef unsigned int ino_t;
+typedef unsigned int dev_t;
+typedef unsigned short mode_t;
+#endif
#ifdef __cplusplus
extern "C" {
@@ -317,12 +325,12 @@ int archive_entry_xattr_next(struct archive_entry *,
const char ** /* name */, const void ** /* value */, size_t *);
/*
- * Utility to detect hardlinks.
+ * Utility to match up hardlinks.
*
* The 'struct archive_entry_linkresolver' is a cache of archive entries
* for files with multiple links. Here's how to use it:
* 1. Create a lookup object with archive_entry_linkresolver_new()
- * 2. Set the appropriate strategy.
+ * 2. Tell it the archive format you're using.
* 3. Hand each archive_entry to archive_entry_linkify().
* That function will return 0, 1, or 2 entries that should
* be written.
@@ -347,8 +355,8 @@ int archive_entry_xattr_next(struct archive_entry *,
struct archive_entry_linkresolver;
/*
- * This machine supports three different strategies for marking
- * hardlinks. The names come from the best-known
+ * There are three different strategies for marking hardlinks.
+ * The descriptions below name them after the best-known
* formats that rely on each strategy:
*
* "Old cpio" is the simplest, it always returns any entry unmodified.
@@ -357,7 +365,7 @@ struct archive_entry_linkresolver;
* to detect and properly link the files as they are restored.
* "tar" is also pretty simple; it caches a copy the first time it sees
* any link. Subsequent appearances are modified to be hardlink
- * references without any body to the first one. Used by all tar
+ * references to the first one without any body. Used by all tar
* formats, although the newest tar formats permit the "old cpio" strategy
* as well. This strategy is very simple for the dearchiver,
* and reasonably straightforward for the archiver.
@@ -385,26 +393,14 @@ struct archive_entry_linkresolver;
* strategy requires you to rescan the archive from the beginning to
* correctly extract an arbitrary link.
*/
-#define ARCHIVE_ENTRY_LINKIFY_LIKE_TAR 0
-#define ARCHIVE_ENTRY_LINKIFY_LIKE_OLD_CPIO 1
-#define ARCHIVE_ENTRY_LINKIFY_LIKE_NEW_CPIO 2
struct archive_entry_linkresolver *archive_entry_linkresolver_new(void);
void archive_entry_linkresolver_set_strategy(
- struct archive_entry_linkresolver *, int /* strategy */);
+ struct archive_entry_linkresolver *, int /* format_code */);
void archive_entry_linkresolver_free(struct archive_entry_linkresolver *);
void archive_entry_linkify(struct archive_entry_linkresolver *,
struct archive_entry **, struct archive_entry **);
-/*
- * DEPRECATED: This will be removed in libarchive 3.0. It was an
- * early attempt at providing library-level hardlink recognition
- * support, but it only handles the tar strategy and cannot easily
- * be extended, so it's being replaced with the "linkify" function.
- */
-const char *archive_entry_linkresolve(struct archive_entry_linkresolver *,
- struct archive_entry *);
-
#ifdef __cplusplus
}
#endif
diff --git a/archivers/libarchive/files/libarchive/archive_entry_link_resolver.c b/archivers/libarchive/files/libarchive/archive_entry_link_resolver.c
index 37131ff325d..0df9ff92e68 100644
--- a/archivers/libarchive/files/libarchive/archive_entry_link_resolver.c
+++ b/archivers/libarchive/files/libarchive/archive_entry_link_resolver.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_entry_link_resolver.c,v 1.1 2007/
#include <string.h>
#endif
+#include "archive.h"
#include "archive_entry.h"
/*
@@ -57,6 +58,11 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_entry_link_resolver.c,v 1.1 2007/
* below.
*/
+/* Users pass us a format code, we translate that into a strategy here. */
+#define ARCHIVE_ENTRY_LINKIFY_LIKE_TAR 0
+#define ARCHIVE_ENTRY_LINKIFY_LIKE_OLD_CPIO 1
+#define ARCHIVE_ENTRY_LINKIFY_LIKE_NEW_CPIO 2
+
/* Initial size of link cache. */
#define links_cache_initial_size 1024
@@ -65,6 +71,7 @@ struct links_entry {
struct links_entry *previous;
int links; /* # links not yet seen */
int hash;
+ struct archive_entry *canonical;
struct archive_entry *entry;
};
@@ -79,8 +86,9 @@ struct archive_entry_linkresolver {
static struct links_entry *find_entry(struct archive_entry_linkresolver *,
struct archive_entry *);
static void grow_hash(struct archive_entry_linkresolver *);
-static void insert_entry(struct archive_entry_linkresolver *,
+static struct links_entry *insert_entry(struct archive_entry_linkresolver *,
struct archive_entry *);
+static struct links_entry *next_entry(struct archive_entry_linkresolver *);
struct archive_entry_linkresolver *
archive_entry_linkresolver_new(void)
@@ -106,49 +114,43 @@ archive_entry_linkresolver_new(void)
void
archive_entry_linkresolver_set_strategy(struct archive_entry_linkresolver *res,
- int strategy)
+ int fmt)
{
- res->strategy = strategy;
-}
-
-void
-archive_entry_linkresolver_free(struct archive_entry_linkresolver *res)
-{
- size_t i;
-
- if (res->buckets == NULL)
- return;
-
- for (i = 0; i < res->number_buckets; i++) {
- while (res->buckets[i] != NULL) {
- struct links_entry *lp = res->buckets[i]->next;
- archive_entry_free(res->buckets[i]->entry);
- free(res->buckets[i]);
- res->buckets[i] = lp;
+ int fmtbase = fmt & ARCHIVE_FORMAT_BASE_MASK;
+
+ switch (fmtbase) {
+ case ARCHIVE_FORMAT_CPIO:
+ switch (fmt) {
+ case ARCHIVE_FORMAT_CPIO_SVR4_NOCRC:
+ case ARCHIVE_FORMAT_CPIO_SVR4_CRC:
+ res->strategy = ARCHIVE_ENTRY_LINKIFY_LIKE_NEW_CPIO;
+ break;
+ default:
+ res->strategy = ARCHIVE_ENTRY_LINKIFY_LIKE_OLD_CPIO;
+ break;
}
+ break;
+ case ARCHIVE_FORMAT_TAR:
+ res->strategy = ARCHIVE_ENTRY_LINKIFY_LIKE_TAR;
+ break;
+ default:
+ res->strategy = ARCHIVE_ENTRY_LINKIFY_LIKE_TAR;
+ break;
}
- free(res->buckets);
- res->buckets = NULL;
}
-/* Always uses tar-like semantics. */
-const char *
-archive_entry_linkresolve(struct archive_entry_linkresolver *res,
- struct archive_entry *entry)
+void
+archive_entry_linkresolver_free(struct archive_entry_linkresolver *res)
{
struct links_entry *le;
- /* If it has only one link, then we're done. */
- if (archive_entry_nlink(entry) == 1)
- return (NULL);
-
- /* Look it up in the hash. */
- le = find_entry(res, entry);
- if (le != NULL)
- return (archive_entry_pathname(le->entry));
- /* If it's not there, insert it. */
- insert_entry(res, entry);
- return (NULL);
+ if (res->buckets != NULL) {
+ while ((le = next_entry(res)) != NULL)
+ archive_entry_free(le->entry);
+ free(res->buckets);
+ res->buckets = NULL;
+ }
+ free(res);
}
void
@@ -160,6 +162,13 @@ archive_entry_linkify(struct archive_entry_linkresolver *res,
*f = NULL; /* Default: Don't return a second entry. */
+ if (*e == NULL) {
+ le = next_entry(res);
+ if (le != NULL)
+ *e = le->entry;
+ return;
+ }
+
/* If it has only one link, then we're done. */
if (archive_entry_nlink(*e) == 1)
return;
@@ -170,7 +179,7 @@ archive_entry_linkify(struct archive_entry_linkresolver *res,
if (le != NULL) {
archive_entry_set_size(*e, 0);
archive_entry_set_hardlink(*e,
- archive_entry_pathname(le->entry));
+ archive_entry_pathname(le->canonical));
} else
insert_entry(res, *e);
return;
@@ -180,17 +189,28 @@ archive_entry_linkify(struct archive_entry_linkresolver *res,
case ARCHIVE_ENTRY_LINKIFY_LIKE_NEW_CPIO:
le = find_entry(res, *e);
if (le != NULL) {
+ /*
+ * Put the new entry in le, return the
+ * old entry from le.
+ */
t = *e;
*e = le->entry;
le->entry = t;
+ /* Make the old entry into a hardlink. */
archive_entry_set_size(*e, 0);
archive_entry_set_hardlink(*e,
- archive_entry_pathname(le->entry));
- if (le->links == 0) {
+ archive_entry_pathname(le->canonical));
+ /* If we ran out of links, return the
+ * final entry as well. */
+ if (le->links == 0)
*f = le->entry;
- }
} else {
- insert_entry(res, *e);
+ /*
+ * If we haven't seen it, tuck it away
+ * for future use.
+ */
+ le = insert_entry(res, *e);
+ le->entry = *e;
*e = NULL;
}
return;
@@ -211,7 +231,7 @@ find_entry(struct archive_entry_linkresolver *res,
/* Free a held entry. */
if (res->spare != NULL) {
- archive_entry_free(res->spare->entry);
+ archive_entry_free(res->spare->canonical);
free(res->spare);
res->spare = NULL;
}
@@ -255,7 +275,41 @@ find_entry(struct archive_entry_linkresolver *res,
return (NULL);
}
-static void
+static struct links_entry *
+next_entry(struct archive_entry_linkresolver *res)
+{
+ struct links_entry *le;
+ size_t bucket;
+
+ /* Free a held entry. */
+ if (res->spare != NULL) {
+ archive_entry_free(res->spare->canonical);
+ free(res->spare);
+ res->spare = NULL;
+ }
+
+ /* If the links cache overflowed and got flushed, don't bother. */
+ if (res->buckets == NULL)
+ return (NULL);
+
+ /* Look for next non-empty bucket in the links cache. */
+ for (bucket = 0; bucket < res->number_buckets; bucket++) {
+ le = res->buckets[bucket];
+ if (le != NULL) {
+ /* Remove it from this hash bucket. */
+ if (le->next != NULL)
+ le->next->previous = le->previous;
+ res->buckets[bucket] = le->next;
+ res->number_entries--;
+ /* Defer freeing this entry. */
+ res->spare = le;
+ return (le);
+ }
+ }
+ return (NULL);
+}
+
+static struct links_entry *
insert_entry(struct archive_entry_linkresolver *res,
struct archive_entry *entry)
{
@@ -265,12 +319,8 @@ insert_entry(struct archive_entry_linkresolver *res,
/* Add this entry to the links cache. */
le = malloc(sizeof(struct links_entry));
if (le == NULL)
- return;
- le->entry = archive_entry_clone(entry);
- if (le->entry == NULL) {
- free(le);
- return;
- }
+ return (NULL);
+ le->entry = entry;
/* If the links cache is getting too full, enlarge the hash table. */
if (res->number_entries > res->number_buckets * 2)
@@ -288,6 +338,8 @@ insert_entry(struct archive_entry_linkresolver *res,
res->buckets[bucket] = le;
le->hash = hash;
le->links = archive_entry_nlink(entry) - 1;
+ le->canonical = archive_entry_clone(entry);
+ return (le);
}
static void
diff --git a/archivers/libarchive/files/libarchive/archive_read.3 b/archivers/libarchive/files/libarchive/archive_read.3
index 6daba3f3d11..e15c904a712 100644
--- a/archivers/libarchive/files/libarchive/archive_read.3
+++ b/archivers/libarchive/files/libarchive/archive_read.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/lib/libarchive/archive_read.3,v 1.35 2007/09/19 16:37:45 kientzle Exp $
+.\" $FreeBSD: src/lib/libarchive/archive_read.3,v 1.36 2008/03/10 14:45:29 jkoshy Exp $
.\"
.Dd August 19, 2006
.Dt archive_read 3
@@ -75,7 +75,10 @@
.Ft int
.Fn archive_read_support_compression_none "struct archive *"
.Ft int
-.Fn archive_read_support_compression_program "struct archive *" "const char *cmd"
+.Fo archive_read_support_compression_program
+.Fa "struct archive *"
+.Fa "const char *cmd"
+.Fc
.Ft int
.Fn archive_read_support_format_all "struct archive *"
.Ft int
@@ -89,15 +92,32 @@
.Ft int
.Fn archive_read_support_format_zip "struct archive *"
.Ft int
-.Fn archive_read_open "struct archive *" "void *client_data" "archive_open_callback *" "archive_read_callback *" "archive_close_callback *"
+.Fo archive_read_open
+.Fa "struct archive *"
+.Fa "void *client_data"
+.Fa "archive_open_callback *"
+.Fa "archive_read_callback *"
+.Fa "archive_close_callback *"
+.Fc
.Ft int
-.Fn archive_read_open2 "struct archive *" "void *client_data" "archive_open_callback *" "archive_read_callback *" "archive_skip_callback *" "archive_close_callback *"
+.Fo archive_read_open2
+.Fa "struct archive *"
+.Fa "void *client_data"
+.Fa "archive_open_callback *"
+.Fa "archive_read_callback *"
+.Fa "archive_skip_callback *"
+.Fa "archive_close_callback *"
+.Fc
.Ft int
.Fn archive_read_open_FILE "struct archive *" "FILE *file"
.Ft int
.Fn archive_read_open_fd "struct archive *" "int fd" "size_t block_size"
.Ft int
-.Fn archive_read_open_filename "struct archive *" "const char *filename" "size_t block_size"
+.Fo archive_read_open_filename
+.Fa "struct archive *"
+.Fa "const char *filename"
+.Fa "size_t block_size"
+.Fc
.Ft int
.Fn archive_read_open_memory "struct archive *" "void *buff" "size_t size"
.Ft int
@@ -105,7 +125,12 @@
.Ft ssize_t
.Fn archive_read_data "struct archive *" "void *buff" "size_t len"
.Ft int
-.Fn archive_read_data_block "struct archive *" "const void **buff" "size_t *len" "off_t *offset"
+.Fo archive_read_data_block
+.Fa "struct archive *"
+.Fa "const void **buff"
+.Fa "size_t *len"
+.Fa "off_t *offset"
+.Fc
.Ft int
.Fn archive_read_data_skip "struct archive *"
.\" #if ARCHIVE_API_VERSION < 3
@@ -115,9 +140,17 @@
.Ft int
.Fn archive_read_data_into_fd "struct archive *" "int fd"
.Ft int
-.Fn archive_read_extract "struct archive *" "struct archive_entry *" "int flags"
+.Fo archive_read_extract
+.Fa "struct archive *"
+.Fa "struct archive_entry *"
+.Fa "int flags"
+.Fc
.Ft void
-.Fn archive_read_extract_set_progress_callback "struct archive *" "void (*func)(void *)" "void *user_data"
+.Fo archive_read_extract_set_progress_callback
+.Fa "struct archive *"
+.Fa "void (*func)(void *)"
+.Fa "void *user_data"
+.Fc
.Ft int
.Fn archive_read_close "struct archive *"
.Ft int
@@ -136,7 +169,13 @@ order they would be used:
Allocates and initializes a
.Tn struct archive
object suitable for reading from an archive.
-.It Fn archive_read_support_compression_all , Fn archive_read_support_compression_bzip2 , Fn archive_read_support_compression_compress , Fn archive_read_support_compression_gzip , Fn archive_read_support_compression_none
+.It Xo
+.Fn archive_read_support_compression_all ,
+.Fn archive_read_support_compression_bzip2 ,
+.Fn archive_read_support_compression_compress ,
+.Fn archive_read_support_compression_gzip ,
+.Fn archive_read_support_compression_none
+.Xc
Enables auto-detection code and decompression support for the
specified compression.
Note that
@@ -150,7 +189,14 @@ Data is fed through the specified external program before being dearchived.
Note that this disables automatic detection of the compression format,
so it makes no sense to specify this in conjunction with any other
decompression option.
-.It Fn archive_read_support_format_all , Fn archive_read_support_format_cpio , Fn archive_read_support_format_empty , Fn archive_read_support_format_iso9660 , Fn archive_read_support_format_tar, Fn archive_read_support_format_zip
+.It Xo
+.Fn archive_read_support_format_all ,
+.Fn archive_read_support_format_cpio ,
+.Fn archive_read_support_format_empty ,
+.Fn archive_read_support_format_iso9660 ,
+.Fn archive_read_support_format_tar ,
+.Fn archive_read_support_format_zip
+.Xc
Enables support---including auto-detection code---for the
specified archive format.
For example,
@@ -311,14 +357,26 @@ The callback functions must match the following prototypes:
.Bl -item -offset indent
.It
.Ft typedef ssize_t
-.Fn archive_read_callback "struct archive *" "void *client_data" "const void **buffer"
+.Fo archive_read_callback
+.Fa "struct archive *"
+.Fa "void *client_data"
+.Fa "const void **buffer"
+.Fc
.It
.\" #if ARCHIVE_API_VERSION < 2
.Ft typedef int
-.Fn archive_skip_callback "struct archive *" "void *client_data" "size_t request"
+.Fo archive_skip_callback
+.Fa "struct archive *"
+.Fa "void *client_data"
+.Fa "size_t request"
+.Fc
.\" #else
.\" .Ft typedef off_t
-.\" .Fn archive_skip_callback "struct archive *" "void *client_data" "off_t request"
+.\" .Fo archive_skip_callback
+.\" .Fa "struct archive *"
+.\" .Fa "void *client_data"
+.\" .Fa "off_t request"
+.\" .Fc
.\" #endif
.It
.Ft typedef int
diff --git a/archivers/libarchive/files/libarchive/archive_read.c b/archivers/libarchive/files/libarchive/archive_read.c
index 19be77569c1..327969f4185 100644
--- a/archivers/libarchive/files/libarchive/archive_read.c
+++ b/archivers/libarchive/files/libarchive/archive_read.c
@@ -32,7 +32,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read.c,v 1.37 2008/01/03 17:54:26 des Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read.c,v 1.38 2008/03/12 04:58:32 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -64,25 +64,12 @@ struct archive *
archive_read_new(void)
{
struct archive_read *a;
- unsigned char *nulls;
a = (struct archive_read *)malloc(sizeof(*a));
if (a == NULL)
return (NULL);
memset(a, 0, sizeof(*a));
a->archive.magic = ARCHIVE_READ_MAGIC;
- a->bytes_per_block = ARCHIVE_DEFAULT_BYTES_PER_BLOCK;
-
- a->null_length = 1024;
- nulls = (unsigned char *)malloc(a->null_length);
- if (nulls == NULL) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate archive object 'nulls' element");
- free(a);
- return (NULL);
- }
- memset(nulls, 0, a->null_length);
- a->nulls = nulls;
a->archive.state = ARCHIVE_STATE_NEW;
a->entry = archive_entry_new();
@@ -660,8 +647,6 @@ archive_read_finish(struct archive *_a)
(a->formats[i].cleanup)(a);
}
- /* Casting a pointer to int allows us to remove 'const.' */
- free((void *)(uintptr_t)(const void *)a->nulls);
archive_string_free(&a->archive.error_string);
if (a->entry)
archive_entry_free(a->entry);
diff --git a/archivers/libarchive/files/libarchive/archive_read_private.h b/archivers/libarchive/files/libarchive/archive_read_private.h
index 90fb7db12e6..f4d0274b509 100644
--- a/archivers/libarchive/files/libarchive/archive_read_private.h
+++ b/archivers/libarchive/files/libarchive/archive_read_private.h
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/archive_read_private.h,v 1.4 2008/01/03 17:54:26 des Exp $
+ * $FreeBSD: src/lib/libarchive/archive_read_private.h,v 1.6 2008/03/15 11:09:16 kientzle Exp $
*/
#ifndef ARCHIVE_READ_PRIVATE_H_INCLUDED
@@ -41,10 +41,6 @@ struct archive_read {
dev_t skip_file_dev;
ino_t skip_file_ino;
- /* Utility: Pointer to a block of nulls. */
- const unsigned char *nulls;
- size_t null_length;
-
/*
* Used by archive_read_data() to track blocks and copy
* data to client buffers, filling gaps with zero bytes.
@@ -58,30 +54,9 @@ struct archive_read {
archive_open_callback *client_opener;
archive_read_callback *client_reader;
archive_skip_callback *client_skipper;
- archive_write_callback *client_writer;
archive_close_callback *client_closer;
void *client_data;
- /*
- * Blocking information. Note that bytes_in_last_block is
- * misleadingly named; I should find a better name. These
- * control the final output from all compressors, including
- * compression_none.
- */
- int bytes_per_block;
- int bytes_in_last_block;
-
- /*
- * These control whether data within a gzip/bzip2 compressed
- * stream gets padded or not. If pad_uncompressed is set,
- * the data will be padded to a full block before being
- * compressed. The pad_uncompressed_byte determines the value
- * that will be used for padding. Note that these have no
- * effect on compression "none."
- */
- int pad_uncompressed;
- int pad_uncompressed_byte; /* TODO: Support this. */
-
/* File offset of beginning of most recently-read header. */
off_t header_position;
@@ -118,17 +93,10 @@ struct archive_read {
/*
* Format detection is mostly the same as compression
- * detection, with two significant differences: The bidders
+ * detection, with one significant difference: The bidders
* use the read_ahead calls above to examine the stream rather
* than having the supervisor hand them a block of data to
- * examine, and the auction is repeated for every header.
- * Winning bidders should set the archive_format and
- * archive_format_name appropriately. Bid routines should
- * check archive_format and decline to bid if the format of
- * the last header was incompatible.
- *
- * Again, write support is considerably simpler because there's
- * no need for an auction.
+ * examine.
*/
struct archive_format_descriptor {
@@ -142,18 +110,6 @@ struct archive_read {
struct archive_format_descriptor *format; /* Active format. */
/*
- * Pointers to format-specific functions for writing. They're
- * initialized by archive_write_set_format_XXX() calls.
- */
- int (*format_init)(struct archive *); /* Only used on write. */
- int (*format_finish)(struct archive *);
- int (*format_finish_entry)(struct archive *);
- int (*format_write_header)(struct archive *,
- struct archive_entry *);
- ssize_t (*format_write_data)(struct archive *,
- const void *buff, size_t);
-
- /*
* Various information needed by archive_extract.
*/
struct extract *extract;
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_ar.c b/archivers/libarchive/files/libarchive/archive_read_support_format_ar.c
index a74791c6dae..f6e4cc7e2ab 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_format_ar.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_format_ar.c
@@ -26,7 +26,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_ar.c,v 1.8 2008/02/19 05:54:24 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_ar.c,v 1.9 2008/03/12 21:10:26 kaiw Exp $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -83,8 +83,7 @@ static int archive_read_format_ar_read_header(struct archive_read *a,
struct archive_entry *e);
static uint64_t ar_atol8(const char *p, unsigned char_cnt);
static uint64_t ar_atol10(const char *p, unsigned char_cnt);
-static int ar_parse_gnu_filename_table(struct archive_read *, struct ar *,
- const void *, size_t);
+static int ar_parse_gnu_filename_table(struct archive_read *a);
static int ar_parse_common_header(struct ar *ar, struct archive_entry *,
const char *h);
@@ -167,8 +166,8 @@ archive_read_format_ar_read_header(struct archive_read *a,
struct ar *ar;
uint64_t number; /* Used to hold parsed numbers before validation. */
ssize_t bytes_read;
- size_t bsd_name_length, entry_size;
- char *p;
+ size_t bsd_name_length, entry_size, s;
+ char *p, *st;
const void *b;
const char *h;
int r;
@@ -277,22 +276,42 @@ archive_read_format_ar_read_header(struct archive_read *a,
return (ARCHIVE_FATAL);
}
entry_size = (size_t)number;
+ if (entry_size == 0) {
+ archive_set_error(&a->archive, EINVAL,
+ "Invalid string table");
+ return (ARCHIVE_WARN);
+ }
+ if (ar->strtab != NULL) {
+ archive_set_error(&a->archive, EINVAL,
+ "More than one string tables exist");
+ return (ARCHIVE_WARN);
+ }
+
/* Read the filename table into memory. */
- bytes_read = (a->decompressor->read_ahead)(a, &b, entry_size);
- if (bytes_read <= 0)
- return (ARCHIVE_FATAL);
- if ((size_t)bytes_read < entry_size) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Truncated input file");
+ st = malloc(entry_size);
+ if (st == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate filename table buffer");
return (ARCHIVE_FATAL);
}
- /*
- * Don't consume the contents, so the client will
- * also get a shot at reading it.
- */
+ ar->strtab = st;
+ ar->strtab_size = entry_size;
+ for (s = entry_size; s > 0; s -= bytes_read) {
+ bytes_read = (a->decompressor->read_ahead)(a, &b, s);
+ if (bytes_read <= 0)
+ return (ARCHIVE_FATAL);
+ if (bytes_read > (ssize_t)s)
+ bytes_read = s;
+ memcpy(st, b, bytes_read);
+ st += bytes_read;
+ (a->decompressor->consume)(a, bytes_read);
+ }
+ /* All contents are consumed. */
+ ar->entry_bytes_remaining = 0;
+ archive_entry_set_size(entry, ar->entry_bytes_remaining);
/* Parse the filename table. */
- return (ar_parse_gnu_filename_table(a, ar, b, entry_size));
+ return (ar_parse_gnu_filename_table(a));
}
/*
@@ -492,31 +511,15 @@ archive_read_format_ar_skip(struct archive_read *a)
}
static int
-ar_parse_gnu_filename_table(struct archive_read *a, struct ar *ar,
- const void *h, size_t size)
+ar_parse_gnu_filename_table(struct archive_read *a)
{
+ struct ar *ar;
char *p;
+ size_t size;
- if (ar->strtab != NULL) {
- archive_set_error(&a->archive, EINVAL,
- "More than one string tables exist");
- return (ARCHIVE_WARN);
- }
-
- if (size == 0) {
- archive_set_error(&a->archive, EINVAL, "Invalid string table");
- return (ARCHIVE_WARN);
- }
-
- ar->strtab_size = size;
- ar->strtab = malloc(size);
- if (ar->strtab == NULL) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate string table buffer");
- return (ARCHIVE_FATAL);
- }
+ ar = (struct ar*)(a->format->data);
+ size = ar->strtab_size;
- (void)memcpy(ar->strtab, h, size);
for (p = ar->strtab; p < ar->strtab + size - 1; ++p) {
if (*p == '/') {
*p++ = '\0';
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_mtree.c b/archivers/libarchive/files/libarchive/archive_read_support_format_mtree.c
index 7db6db3377a..f1980e6bd10 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_format_mtree.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_format_mtree.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_mtree.c,v 1.2 2008/02/19 06:07:10 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_mtree.c,v 1.4 2008/03/15 11:02:47 kientzle Exp $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -76,12 +76,18 @@ struct mtree {
struct mtree_entry *this_entry;
struct archive_string current_dir;
struct archive_string contents_name;
+
+ off_t cur_size, cur_offset;
};
static int cleanup(struct archive_read *);
static int mtree_bid(struct archive_read *);
+static int parse_file(struct archive_read *, struct archive_entry *,
+ struct mtree *, struct mtree_entry *);
static void parse_escapes(char *, struct mtree_entry *);
-static int parse_setting(struct archive_read *, struct mtree *,
+static int parse_line(struct archive_read *, struct archive_entry *,
+ struct mtree *, struct mtree_entry *);
+static int parse_keyword(struct archive_read *, struct mtree *,
struct archive_entry *, char *, char *);
static int read_data(struct archive_read *a,
const void **buff, size_t *size, off_t *offset);
@@ -252,14 +258,16 @@ read_mtree(struct archive_read *a, struct mtree *mtree)
}
}
+/*
+ * Read in the entire mtree file into memory on the first request.
+ * Then use the next unused file to satisfy each header request.
+ */
static int
read_header(struct archive_read *a, struct archive_entry *entry)
{
- struct stat st;
struct mtree *mtree;
- struct mtree_entry *mentry, *mentry2;
- char *p, *q;
- int r = ARCHIVE_OK, r1;
+ char *p;
+ int r;
mtree = (struct mtree *)(a->format->data);
@@ -278,16 +286,10 @@ read_header(struct archive_read *a, struct archive_entry *entry)
a->archive.archive_format_name = mtree->archive_format_name;
for (;;) {
- mentry = mtree->this_entry;
- if (mentry == NULL) {
- mtree->this_entry = NULL;
+ if (mtree->this_entry == NULL)
return (ARCHIVE_EOF);
- }
- mtree->this_entry = mentry->next;
- if (mentry->used)
- continue;
- mentry->used = 1;
- if (strcmp(mentry->name, "..") == 0) {
+ if (strcmp(mtree->this_entry->name, "..") == 0) {
+ mtree->this_entry->used = 1;
if (archive_strlen(&mtree->current_dir) > 0) {
/* Roll back current path. */
p = mtree->current_dir.s
@@ -299,117 +301,165 @@ read_header(struct archive_read *a, struct archive_entry *entry)
mtree->current_dir.length
= p - mtree->current_dir.s + 1;
}
- continue;
}
+ if (!mtree->this_entry->used) {
+ r = parse_file(a, entry, mtree, mtree->this_entry);
+ return (r);
+ }
+ mtree->this_entry = mtree->this_entry->next;
+ }
+}
+
+/*
+ * A single file can have multiple lines contribute specifications.
+ * Parse as many lines as necessary, then pull additional information
+ * from a backing file on disk as necessary.
+ */
+static int
+parse_file(struct archive_read *a, struct archive_entry *entry,
+ struct mtree *mtree, struct mtree_entry *mentry)
+{
+ struct stat st;
+ struct mtree_entry *mp;
+ int r = ARCHIVE_OK, r1;
- mtree->filetype = AE_IFREG;
+ mentry->used = 1;
- /* Parse options. */
- p = mentry->option_start;
- while (p < mentry->option_end) {
- q = p + strlen(p);
- r1 = parse_setting(a, mtree, entry, p, q);
- if (r1 != ARCHIVE_OK)
- r = r1;
- p = q + 1;
- }
+ /* Initialize reasonable defaults. */
+ mtree->filetype = AE_IFREG;
+ archive_entry_set_size(entry, 0);
- if (mentry->full) {
- archive_entry_copy_pathname(entry, mentry->name);
- /*
- * "Full" entries are allowed to have multiple
- * lines and those lines aren't required to be
- * adjacent. We don't support multiple lines
- * for "relative" entries nor do we make any
- * attempt to merge data from separate
- * "relative" and "full" entries. (Merging
- * "relative" and "full" entries would require
- * dealing with pathname canonicalization,
- * which is a very tricky subject.)
- */
- mentry2 = mentry->next;
- while (mentry2 != NULL) {
- if (mentry2->full
- && !mentry2->used
- && strcmp(mentry->name, mentry2->name) == 0) {
- /*
- * Add those options as well;
- * later lines override
- * earlier ones.
- */
- p = mentry2->option_start;
- while (p < mentry2->option_end) {
- q = p + strlen(p);
- r1 = parse_setting(a, mtree, entry, p, q);
- if (r1 != ARCHIVE_OK)
- r = r1;
- p = q + 1;
- }
- mentry2->used = 1;
- }
- mentry2 = mentry2->next;
- }
- } else {
- /*
- * Relative entries require us to construct
- * the full path and possibly update the
- * current directory.
- */
- size_t n = archive_strlen(&mtree->current_dir);
- if (n > 0)
- archive_strcat(&mtree->current_dir, "/");
- archive_strcat(&mtree->current_dir, mentry->name);
- archive_entry_copy_pathname(entry, mtree->current_dir.s);
- if (archive_entry_filetype(entry) != AE_IFDIR)
- mtree->current_dir.length = n;
- }
+ /* Parse options from this line. */
+ r = parse_line(a, entry, mtree, mentry);
+ if (mentry->full) {
+ archive_entry_copy_pathname(entry, mentry->name);
/*
- * Try to open and stat the file to get the real size.
- * It would be nice to avoid this here so that getting
- * a listing of an mtree wouldn't require opening
- * every referenced contents file. But then we
- * wouldn't know the actual contents size, so I don't
- * see a really viable way around this. (Also, we may
- * want to someday pull other unspecified info from
- * the contents file on disk.)
+ * "Full" entries are allowed to have multiple lines
+ * and those lines aren't required to be adjacent. We
+ * don't support multiple lines for "relative" entries
+ * nor do we make any attempt to merge data from
+ * separate "relative" and "full" entries. (Merging
+ * "relative" and "full" entries would require dealing
+ * with pathname canonicalization, which is a very
+ * tricky subject.)
*/
- if (archive_strlen(&mtree->contents_name) > 0) {
- mtree->fd = open(mtree->contents_name.s,
- O_RDONLY | O_BINARY);
- if (mtree->fd < 0) {
- archive_set_error(&a->archive, errno,
- "Can't open content=\"%s\"",
- mtree->contents_name.s);
- r = ARCHIVE_WARN;
+ for (mp = mentry->next; mp != NULL; mp = mp->next) {
+ if (mp->full && !mp->used
+ && strcmp(mentry->name, mp->name) == 0) {
+ /* Later lines override earlier ones. */
+ mp->used = 1;
+ r1 = parse_line(a, entry, mtree, mp);
+ if (r1 < r)
+ r = r1;
}
- } else {
- /* If the specified path opens, use it. */
- mtree->fd = open(mtree->current_dir.s,
- O_RDONLY | O_BINARY);
- /* But don't fail if it's not there. */
}
-
+ } else {
/*
- * If there is a contents file on disk, use that size;
- * otherwise leave it as-is (it might have been set from
- * the mtree size= keyword).
+ * Relative entries require us to construct
+ * the full path and possibly update the
+ * current directory.
*/
- if (mtree->fd >= 0) {
- fstat(mtree->fd, &st);
+ size_t n = archive_strlen(&mtree->current_dir);
+ if (n > 0)
+ archive_strcat(&mtree->current_dir, "/");
+ archive_strcat(&mtree->current_dir, mentry->name);
+ archive_entry_copy_pathname(entry, mtree->current_dir.s);
+ if (archive_entry_filetype(entry) != AE_IFDIR)
+ mtree->current_dir.length = n;
+ }
+
+ /*
+ * Try to open and stat the file to get the real size
+ * and other file info. It would be nice to avoid
+ * this here so that getting a listing of an mtree
+ * wouldn't require opening every referenced contents
+ * file. But then we wouldn't know the actual
+ * contents size, so I don't see a really viable way
+ * around this. (Also, we may want to someday pull
+ * other unspecified info from the contents file on
+ * disk.)
+ */
+ mtree->fd = -1;
+ if (archive_strlen(&mtree->contents_name) > 0) {
+ mtree->fd = open(mtree->contents_name.s,
+ O_RDONLY | O_BINARY);
+ if (mtree->fd < 0) {
+ archive_set_error(&a->archive, errno,
+ "Can't open content=\"%s\"",
+ mtree->contents_name.s);
+ r = ARCHIVE_WARN;
+ }
+ } else if (archive_entry_filetype(entry) == AE_IFREG) {
+ mtree->fd = open(archive_entry_pathname(entry),
+ O_RDONLY | O_BINARY);
+ }
+
+ /*
+ * If there is a contents file on disk, use that size;
+ * otherwise leave it as-is (it might have been set from
+ * the mtree size= keyword).
+ */
+ if (mtree->fd >= 0) {
+ if (fstat(mtree->fd, &st) != 0) {
+ archive_set_error(&a->archive, errno,
+ "could not stat %s",
+ archive_entry_pathname(entry));
+ r = ARCHIVE_WARN;
+ /* If we can't stat it, don't keep it open. */
+ close(mtree->fd);
+ mtree->fd = -1;
+ } else if ((st.st_mode & S_IFMT) != S_IFREG) {
+ archive_set_error(&a->archive, errno,
+ "%s is not a regular file",
+ archive_entry_pathname(entry));
+ r = ARCHIVE_WARN;
+ /* Don't hold a non-regular file open. */
+ close(mtree->fd);
+ mtree->fd = -1;
+ } else {
archive_entry_set_size(entry, st.st_size);
+ archive_entry_set_ino(entry, st.st_ino);
+ archive_entry_set_dev(entry, st.st_dev);
+ archive_entry_set_nlink(entry, st.st_nlink);
}
+ }
+ mtree->cur_size = archive_entry_size(entry);
+ mtree->offset = 0;
- return r;
+ return r;
+}
+
+/*
+ * Each line contains a sequence of keywords.
+ */
+static int
+parse_line(struct archive_read *a, struct archive_entry *entry,
+ struct mtree *mtree, struct mtree_entry *mp)
+{
+ char *p, *q;
+ int r = ARCHIVE_OK, r1;
+
+ p = mp->option_start;
+ while (p < mp->option_end) {
+ q = p + strlen(p);
+ r1 = parse_keyword(a, mtree, entry, p, q);
+ if (r1 < r)
+ r = r1;
+ p = q + 1;
}
+ return (r);
}
+/*
+ * Parse a single keyword and its value.
+ */
static int
-parse_setting(struct archive_read *a, struct mtree *mtree, struct archive_entry *entry, char *key, char *end)
+parse_keyword(struct archive_read *a, struct mtree *mtree,
+ struct archive_entry *entry, char *key, char *end)
{
char *val;
-
if (end == key)
return (ARCHIVE_OK);
if (*key == '\0')
@@ -427,7 +477,8 @@ parse_setting(struct archive_read *a, struct mtree *mtree, struct archive_entry
switch (key[0]) {
case 'c':
- if (strcmp(key, "content") == 0) {
+ if (strcmp(key, "content") == 0
+ || strcmp(key, "contents") == 0) {
parse_escapes(val, NULL);
archive_strcpy(&mtree->contents_name, val);
break;
@@ -441,6 +492,11 @@ parse_setting(struct archive_read *a, struct mtree *mtree, struct archive_entry
archive_entry_copy_gname(entry, val);
break;
}
+ case 'l':
+ if (strcmp(key, "link") == 0) {
+ archive_entry_set_link(entry, val);
+ break;
+ }
case 'm':
if (strcmp(key, "mode") == 0) {
if (val[0] == '0') {
@@ -452,6 +508,11 @@ parse_setting(struct archive_read *a, struct mtree *mtree, struct archive_entry
"Symbolic mode \"%s\" unsupported", val);
break;
}
+ case 's':
+ if (strcmp(key, "size") == 0) {
+ archive_entry_set_size(entry, mtree_atol10(&val));
+ break;
+ }
case 't':
if (strcmp(key, "type") == 0) {
switch (val[0]) {
@@ -517,6 +578,7 @@ parse_setting(struct archive_read *a, struct mtree *mtree, struct archive_entry
static int
read_data(struct archive_read *a, const void **buff, size_t *size, off_t *offset)
{
+ size_t bytes_to_read;
ssize_t bytes_read;
struct mtree *mtree;
@@ -538,7 +600,11 @@ read_data(struct archive_read *a, const void **buff, size_t *size, off_t *offset
*buff = mtree->buff;
*offset = mtree->offset;
- bytes_read = read(mtree->fd, mtree->buff, mtree->buffsize);
+ if ((off_t)mtree->buffsize > mtree->cur_size - mtree->offset)
+ bytes_to_read = mtree->cur_size - mtree->offset;
+ else
+ bytes_to_read = mtree->buffsize;
+ bytes_read = read(mtree->fd, mtree->buff, bytes_to_read);
if (bytes_read < 0) {
archive_set_error(&a->archive, errno, "Can't read");
return (ARCHIVE_WARN);
@@ -548,7 +614,7 @@ read_data(struct archive_read *a, const void **buff, size_t *size, off_t *offset
return (ARCHIVE_EOF);
}
mtree->offset += bytes_read;
- *size = (size_t)bytes_read;
+ *size = bytes_read;
return (ARCHIVE_OK);
}
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c b/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c
index 26b2abbe578..76fda2d63c2 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_tar.c,v 1.65 2008/01/31 07:41:45 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_tar.c,v 1.67 2008/03/15 01:43:58 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -714,7 +714,7 @@ archive_block_is_null(const unsigned char *p)
{
unsigned i;
- for (i = 0; i < ARCHIVE_BYTES_PER_RECORD / sizeof(*p); i++)
+ for (i = 0; i < 512; i++)
if (*p++)
return (0);
return (1);
@@ -1258,9 +1258,11 @@ pax_header(struct archive_read *a, struct tar *tar,
archive_entry_copy_gname(entry, value);
else {
wp = utf8_decode(tar, value, strlen(value));
- if (wp == NULL)
+ if (wp == NULL) {
archive_entry_copy_gname(entry, value);
- else
+ if (err > ARCHIVE_WARN)
+ err = ARCHIVE_WARN;
+ } else
archive_entry_copy_gname_w(entry, wp);
}
}
@@ -1270,9 +1272,11 @@ pax_header(struct archive_read *a, struct tar *tar,
archive_entry_copy_link(entry, value);
else {
wp = utf8_decode(tar, value, strlen(value));
- if (wp == NULL)
+ if (wp == NULL) {
archive_entry_copy_link(entry, value);
- else
+ if (err > ARCHIVE_WARN)
+ err = ARCHIVE_WARN;
+ } else
archive_entry_copy_link_w(entry, wp);
}
}
@@ -1282,9 +1286,11 @@ pax_header(struct archive_read *a, struct tar *tar,
archive_entry_copy_pathname(entry, value);
else {
wp = utf8_decode(tar, value, strlen(value));
- if (wp == NULL)
+ if (wp == NULL) {
archive_entry_copy_pathname(entry, value);
- else
+ if (err > ARCHIVE_WARN)
+ err = ARCHIVE_WARN;
+ } else
archive_entry_copy_pathname_w(entry, wp);
}
}
@@ -1294,9 +1300,11 @@ pax_header(struct archive_read *a, struct tar *tar,
archive_entry_copy_uname(entry, value);
else {
wp = utf8_decode(tar, value, strlen(value));
- if (wp == NULL)
+ if (wp == NULL) {
archive_entry_copy_uname(entry, value);
- else
+ if (err > ARCHIVE_WARN)
+ err = ARCHIVE_WARN;
+ } else
archive_entry_copy_uname_w(entry, wp);
}
}
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_zip.c b/archivers/libarchive/files/libarchive/archive_read_support_format_zip.c
index 09e7411be86..a105297ad4f 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_format_zip.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_format_zip.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_zip.c,v 1.21 2008/02/26 07:17:47 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_zip.c,v 1.22 2008/02/27 06:05:59 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -743,7 +743,7 @@ archive_read_format_zip_read_data_skip(struct archive_read *a)
{
struct zip *zip;
const void *buff = NULL;
- ssize_t bytes_avail;
+ off_t bytes_skipped;
zip = (struct zip *)(a->format->data);
@@ -766,19 +766,10 @@ archive_read_format_zip_read_data_skip(struct archive_read *a)
* If the length is at the beginning, we can skip the
* compressed data much more quickly.
*/
- while (zip->entry_bytes_remaining > 0) {
- bytes_avail = (a->decompressor->read_ahead)(a, &buff, 1);
- if (bytes_avail <= 0) {
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_FILE_FORMAT,
- "Truncated ZIP file body");
- return (ARCHIVE_FATAL);
- }
- if (bytes_avail > zip->entry_bytes_remaining)
- bytes_avail = zip->entry_bytes_remaining;
- (a->decompressor->consume)(a, bytes_avail);
- zip->entry_bytes_remaining -= bytes_avail;
- }
+ bytes_skipped = (a->decompressor->skip)(a, zip->entry_bytes_remaining);
+ if (bytes_skipped < 0)
+ return (ARCHIVE_FATAL);
+
/* This entry is finished and done. */
zip->end_of_entry_cleanup = zip->end_of_entry = 1;
return (ARCHIVE_OK);
diff --git a/archivers/libarchive/files/libarchive/archive_string.h b/archivers/libarchive/files/libarchive/archive_string.h
index 596db9a1482..f56c50fe42a 100644
--- a/archivers/libarchive/files/libarchive/archive_string.h
+++ b/archivers/libarchive/files/libarchive/archive_string.h
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/archive_string.h,v 1.9 2007/05/29 01:00:19 kientzle Exp $
+ * $FreeBSD: src/lib/libarchive/archive_string.h,v 1.10 2008/03/14 22:00:09 kientzle Exp $
*
*/
@@ -116,4 +116,7 @@ void __archive_string_vsprintf(struct archive_string *, const char *,
va_list);
#define archive_string_vsprintf __archive_string_vsprintf
+void __archive_string_sprintf(struct archive_string *, const char *, ...);
+#define archive_string_sprintf __archive_string_sprintf
+
#endif
diff --git a/archivers/libarchive/files/libarchive/archive_string_sprintf.c b/archivers/libarchive/files/libarchive/archive_string_sprintf.c
index 763e75dcd84..6f77a36a1b8 100644
--- a/archivers/libarchive/files/libarchive/archive_string_sprintf.c
+++ b/archivers/libarchive/files/libarchive/archive_string_sprintf.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_string_sprintf.c,v 1.9 2007/07/15 19:13:59 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_string_sprintf.c,v 1.10 2008/03/14 22:00:09 kientzle Exp $");
/*
* The use of printf()-family functions can be troublesome
@@ -44,6 +44,16 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_string_sprintf.c,v 1.9 2007/07/15
#include "archive_string.h"
#include "archive_private.h"
+void
+__archive_string_sprintf(struct archive_string *as, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ archive_string_vsprintf(as, fmt, ap);
+ va_end(ap);
+}
+
/*
* Like 'vsprintf', but ensures the target is big enough, resizing if
* necessary.
diff --git a/archivers/libarchive/files/libarchive/archive_util.3 b/archivers/libarchive/files/libarchive/archive_util.3
index b8a030e4932..b315c55e515 100644
--- a/archivers/libarchive/files/libarchive/archive_util.3
+++ b/archivers/libarchive/files/libarchive/archive_util.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/lib/libarchive/archive_util.3,v 1.7 2007/05/29 01:00:19 kientzle Exp $
+.\" $FreeBSD: src/lib/libarchive/archive_util.3,v 1.8 2008/03/10 14:44:40 jkoshy Exp $
.\"
.Dd January 8, 2005
.Dt archive_util 3
@@ -57,7 +57,12 @@
.Ft const char *
.Fn archive_format_name "struct archive *"
.Ft void
-.Fn archive_set_error "struct archive *" "int error_code" "const char *fmt" "..."
+.Fo archive_set_error
+.Fa "struct archive *"
+.Fa "int error_code"
+.Fa "const char *fmt"
+.Fa "..."
+.Fc
.Sh DESCRIPTION
These functions provide access to various information about the
.Tn struct archive
diff --git a/archivers/libarchive/files/libarchive/archive_util.c b/archivers/libarchive/files/libarchive/archive_util.c
index 413199a360f..55dd1fa10c3 100644
--- a/archivers/libarchive/files/libarchive/archive_util.c
+++ b/archivers/libarchive/files/libarchive/archive_util.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_util.c,v 1.16 2007/12/30 04:58:21 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_util.c,v 1.17 2008/03/14 22:31:57 kientzle Exp $");
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -38,29 +38,49 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_util.c,v 1.16 2007/12/30 04:58:21
#include "archive.h"
#include "archive_private.h"
+#include "archive_string.h"
+#if ARCHIVE_VERSION_NUMBER < 3000000
+/* These disappear in libarchive 3.0 */
+/* Deprecated. */
int
archive_api_feature(void)
{
return (ARCHIVE_API_FEATURE);
}
+/* Deprecated. */
int
archive_api_version(void)
{
return (ARCHIVE_API_VERSION);
}
+/* Deprecated synonym for archive_version_number() */
int
archive_version_stamp(void)
{
- return (ARCHIVE_VERSION_STAMP);
+ return (archive_version_number());
}
+/* Deprecated synonym for archive_version_string() */
const char *
archive_version(void)
{
- return (ARCHIVE_LIBRARY_VERSION);
+ return (archive_version_string());
+}
+#endif
+
+int
+archive_version_number(void)
+{
+ return (ARCHIVE_VERSION_NUMBER);
+}
+
+const char *
+archive_version_string(void)
+{
+ return (ARCHIVE_VERSION_STRING);
}
int
diff --git a/archivers/libarchive/files/libarchive/archive_write.3 b/archivers/libarchive/files/libarchive/archive_write.3
index c07b6b570ea..253b39e7826 100644
--- a/archivers/libarchive/files/libarchive/archive_write.3
+++ b/archivers/libarchive/files/libarchive/archive_write.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/lib/libarchive/archive_write.3,v 1.22 2007/05/29 01:00:19 kientzle Exp $
+.\" $FreeBSD: src/lib/libarchive/archive_write.3,v 1.23 2008/03/10 14:44:41 jkoshy Exp $
.\"
.Dd August 19, 2006
.Dt archive_write 3
@@ -70,7 +70,10 @@
.Ft int
.Fn archive_write_set_compression_none "struct archive *"
.Ft int
-.Fn archive_write_set_compression_program "struct archive *" "const char * cmd"
+.Fo archive_write_set_compression_program
+.Fa "struct archive *"
+.Fa "const char * cmd"
+.Fc
.Ft int
.Fn archive_write_set_format_cpio "struct archive *"
.Ft int
@@ -84,7 +87,13 @@
.Ft int
.Fn archive_write_set_format_ustar "struct archive *"
.Ft int
-.Fn archive_write_open "struct archive *" "void *client_data" "archive_open_callback *" "archive_write_callback *" "archive_close_callback *"
+.Fo archive_write_open
+.Fa "struct archive *"
+.Fa "void *client_data"
+.Fa "archive_open_callback *"
+.Fa "archive_write_callback *"
+.Fa "archive_close_callback *"
+.Fc
.Ft int
.Fn archive_write_open_fd "struct archive *" "int fd"
.Ft int
@@ -92,7 +101,12 @@
.Ft int
.Fn archive_write_open_filename "struct archive *" "const char *filename"
.Ft int
-.Fn archive_write_open_memory "struct archive *" "void *buffer" "size_t bufferSize" "size_t *outUsed"
+.Fo archive_write_open_memory
+.Fa "struct archive *"
+.Fa "void *buffer"
+.Fa "size_t bufferSize"
+.Fa "size_t *outUsed"
+.Fc
.Ft int
.Fn archive_write_header "struct archive *" "struct archive_entry *"
.Ft ssize_t
@@ -150,7 +164,14 @@ functions, this function can be called after the archive is opened.
.It Fn archive_write_get_bytes_in_last_block
Retrieve the currently-set value for last block size.
A value of -1 here indicates that the library should use default values.
-.It Fn archive_write_set_format_cpio , Fn archive_write_set_format_pax , Fn archive_write_set_format_pax_restricted , Fn archive_write_set_format_shar , Fn archive_write_set_format_shar_binary , Fn archive_write_set_format_ustar
+.It Xo
+.Fn archive_write_set_format_cpio ,
+.Fn archive_write_set_format_pax ,
+.Fn archive_write_set_format_pax_restricted ,
+.Fn archive_write_set_format_shar ,
+.Fn archive_write_set_format_shar_binary ,
+.Fn archive_write_set_format_ustar
+.Xc
Sets the format that will be used for the archive.
The library can write
POSIX octet-oriented cpio format archives,
@@ -174,7 +195,11 @@ filenames, linknames, uids, sizes, etc.
is the library default; this is the same as pax format, but suppresses
the pax extended header for most normal files.
In most cases, this will result in ordinary ustar archives.
-.It Fn archive_write_set_compression_bzip2 , Fn archive_write_set_compression_gzip , Fn archive_write_set_compression_none
+.It Xo
+.Fn archive_write_set_compression_bzip2 ,
+.Fn archive_write_set_compression_gzip ,
+.Fn archive_write_set_compression_none
+.Xc
The resulting archive will be compressed as specified.
Note that the compressed output is always properly blocked.
.It Fn archive_write_set_compression_program
@@ -310,7 +335,12 @@ to register an error code and message and return
.Bl -item -offset indent
.It
.Ft typedef ssize_t
-.Fn archive_write_callback "struct archive *" "void *client_data" "void *buffer" "size_t length"
+.Fo archive_write_callback
+.Fa "struct archive *"
+.Fa "void *client_data"
+.Fa "void *buffer"
+.Fa "size_t length"
+.Fc
.El
.Pp
The write callback is invoked whenever the library
diff --git a/archivers/libarchive/files/libarchive/archive_write.c b/archivers/libarchive/files/libarchive/archive_write.c
index 2977063979d..1a3ddc9a5e6 100644
--- a/archivers/libarchive/files/libarchive/archive_write.c
+++ b/archivers/libarchive/files/libarchive/archive_write.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write.c,v 1.26 2007/05/29 01:00:19 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_write.c,v 1.27 2008/03/14 23:09:02 kientzle Exp $");
/*
* This file contains the "essential" portions of the write API, that
@@ -97,7 +97,12 @@ archive_write_new(void)
a->archive.magic = ARCHIVE_WRITE_MAGIC;
a->archive.state = ARCHIVE_STATE_NEW;
a->archive.vtable = archive_write_vtable();
- a->bytes_per_block = ARCHIVE_DEFAULT_BYTES_PER_BLOCK;
+ /*
+ * The value 10240 here matches the traditional tar default,
+ * but is otherwise arbitrary.
+ * TODO: Set the default block size from the format selected.
+ */
+ a->bytes_per_block = 10240;
a->bytes_in_last_block = -1; /* Default */
/* Initialize a block of nulls for padding purposes. */
diff --git a/archivers/libarchive/files/libarchive/archive_write_disk.3 b/archivers/libarchive/files/libarchive/archive_write_disk.3
index 880a399b949..5d836e105e3 100644
--- a/archivers/libarchive/files/libarchive/archive_write_disk.3
+++ b/archivers/libarchive/files/libarchive/archive_write_disk.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/lib/libarchive/archive_write_disk.3,v 1.1 2007/03/03 07:37:36 kientzle Exp $
+.\" $FreeBSD: src/lib/libarchive/archive_write_disk.3,v 1.2 2008/03/10 14:44:41 jkoshy Exp $
.\"
.Dd March 2, 2007
.Dt archive_write_disk 3
@@ -49,11 +49,21 @@
.Ft int
.Fn archive_write_disk_set_skip_file "struct archive *" "dev_t" "ino_t"
.Ft int
-.Fn archive_write_disk_set_group_lookup "struct archive *" "void *" "gid_t (*)(void *, const char *gname, gid_t gid)" "void (*cleanup)(void *)"
+.Fo archive_write_disk_set_group_lookup
+.Fa "struct archive *"
+.Fa "void *"
+.Fa "gid_t (*)(void *, const char *gname, gid_t gid)"
+.Fa "void (*cleanup)(void *)"
+.Fc
.Ft int
.Fn archive_write_disk_set_standard_lookup "struct archive *"
.Ft int
-.Fn archive_write_disk_set_user_lookup "struct archive *" "void *" "uid_t (*)(void *, const char *uname, uid_t uid)" "void (*cleanup)(void *)"
+.Fo archive_write_disk_set_user_lookup
+.Fa "struct archive *"
+.Fa "void *"
+.Fa "uid_t (*)(void *, const char *uname, uid_t uid)"
+.Fa "void (*cleanup)(void *)"
+.Fc
.Ft int
.Fn archive_write_header "struct archive *" "struct archive_entry *"
.Ft ssize_t
@@ -160,7 +170,10 @@ Note that paths ending in
.Pa ..
always cause an error, regardless of this flag.
.El
-.It Fn archive_write_disk_set_group_lookup , Fn archive_write_disk_set_user_lookup
+.It Xo
+.Fn archive_write_disk_set_group_lookup ,
+.Fn archive_write_disk_set_user_lookup
+.Xc
The
.Tn struct archive_entry
objects contain both names and ids that can be used to identify users
diff --git a/archivers/libarchive/files/libarchive/archive_write_disk.c b/archivers/libarchive/files/libarchive/archive_write_disk.c
index dfb6d35aec8..620beac48ed 100644
--- a/archivers/libarchive/files/libarchive/archive_write_disk.c
+++ b/archivers/libarchive/files/libarchive/archive_write_disk.c
@@ -25,7 +25,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.22 2008/02/19 05:39:35 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.24 2008/03/15 04:20:50 kientzle Exp $");
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -1167,7 +1167,7 @@ check_symlinks(struct archive_write_disk *a)
struct stat st;
/*
- * Gaurd against symlink tricks. Reject any archive entry whose
+ * Guard against symlink tricks. Reject any archive entry whose
* destination would be altered by a symlink.
*/
/* Whatever we checked last time doesn't need to be re-checked. */
@@ -1611,7 +1611,7 @@ set_mode(struct archive_write_disk *a, int mode)
if (a->pst != NULL) {
/* Already have stat() data available. */
#ifdef HAVE_FSTAT
- } else if (fd >= 0 && fstat(fd, &a->st) == 0) {
+ } else if (a->fd >= 0 && fstat(a->fd, &a->st) == 0) {
a->pst = &a->st;
#endif
} else if (stat(a->name, &a->st) == 0) {
diff --git a/archivers/libarchive/files/libarchive/archive_write_private.h b/archivers/libarchive/files/libarchive/archive_write_private.h
index 82935f4627a..55c24ad96ca 100644
--- a/archivers/libarchive/files/libarchive/archive_write_private.h
+++ b/archivers/libarchive/files/libarchive/archive_write_private.h
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/archive_write_private.h,v 1.2 2007/05/29 01:00:19 kientzle Exp $
+ * $FreeBSD: src/lib/libarchive/archive_write_private.h,v 1.3 2008/03/15 11:04:45 kientzle Exp $
*/
#ifndef ARCHIVE_WRITE_PRIVATE_H_INCLUDED
@@ -82,13 +82,6 @@ struct archive_write {
} compressor;
/*
- * Again, write support is considerably simpler because there's
- * no need for an auction.
- */
- int archive_format;
- const char *archive_format_name;
-
- /*
* Pointers to format-specific functions for writing. They're
* initialized by archive_write_set_format_XXX() calls.
*/
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_compression_compress.c b/archivers/libarchive/files/libarchive/archive_write_set_compression_compress.c
new file mode 100644
index 00000000000..f913a23c53b
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/archive_write_set_compression_compress.c
@@ -0,0 +1,494 @@
+/*-
+ * Copyright (c) 2008 Joerg Sonnenberger
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1985, 1986, 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Diomidis Spinellis and James A. Woods, derived from original
+ * work by Spencer Thomas and Joseph Orost.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_compression_compress.c,v 1.1 2008/03/14 20:35:37 kientzle Exp $");
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include "archive.h"
+#include "archive_private.h"
+#include "archive_write_private.h"
+
+#define HSIZE 69001 /* 95% occupancy */
+#define HSHIFT 8 /* 8 - trunc(log2(HSIZE / 65536)) */
+#define CHECK_GAP 10000 /* Ratio check interval. */
+
+#define MAXCODE(bits) ((1 << (bits)) - 1)
+
+/*
+ * the next two codes should not be changed lightly, as they must not
+ * lie within the contiguous general code space.
+ */
+#define FIRST 257 /* First free entry. */
+#define CLEAR 256 /* Table clear output code. */
+
+struct private_data {
+ off_t in_count, out_count, checkpoint;
+
+ int code_len; /* Number of bits/code. */
+ int cur_maxcode; /* Maximum code, given n_bits. */
+ int max_maxcode; /* Should NEVER generate this code. */
+ int hashtab [HSIZE];
+ unsigned short codetab [HSIZE];
+ int first_free; /* First unused entry. */
+ int compress_ratio;
+
+ int cur_code, cur_fcode;
+
+ int bit_offset;
+ unsigned char bit_buf;
+
+ unsigned char *compressed;
+ size_t compressed_buffer_size;
+ size_t compressed_offset;
+};
+
+static int archive_compressor_compress_finish(struct archive_write *);
+static int archive_compressor_compress_init(struct archive_write *);
+static int archive_compressor_compress_write(struct archive_write *,
+ const void *, size_t);
+
+/*
+ * Allocate, initialize and return a archive object.
+ */
+int
+archive_write_set_compression_compress(struct archive *_a)
+{
+ struct archive_write *a = (struct archive_write *)_a;
+ __archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
+ ARCHIVE_STATE_NEW, "archive_write_set_compression_compress");
+ a->compressor.init = &archive_compressor_compress_init;
+ a->archive.compression_code = ARCHIVE_COMPRESSION_COMPRESS;
+ a->archive.compression_name = "compress";
+ return (ARCHIVE_OK);
+}
+
+/*
+ * Setup callback.
+ */
+static int
+archive_compressor_compress_init(struct archive_write *a)
+{
+ int ret;
+ struct private_data *state;
+
+ a->archive.compression_code = ARCHIVE_COMPRESSION_COMPRESS;
+ a->archive.compression_name = "compress";
+
+ if (a->bytes_per_block < 4) {
+ archive_set_error(&a->archive, EINVAL,
+ "Can't write Compress header as single block");
+ return (ARCHIVE_FATAL);
+ }
+
+ if (a->client_opener != NULL) {
+ ret = (a->client_opener)(&a->archive, a->client_data);
+ if (ret != ARCHIVE_OK)
+ return (ret);
+ }
+
+ state = (struct private_data *)malloc(sizeof(*state));
+ if (state == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate data for compression");
+ return (ARCHIVE_FATAL);
+ }
+ memset(state, 0, sizeof(*state));
+
+ state->compressed_buffer_size = a->bytes_per_block;
+ state->compressed = malloc(state->compressed_buffer_size);
+
+ if (state->compressed == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate data for compression buffer");
+ free(state);
+ return (ARCHIVE_FATAL);
+ }
+
+ a->compressor.write = archive_compressor_compress_write;
+ a->compressor.finish = archive_compressor_compress_finish;
+
+ state->max_maxcode = 0x10000; /* Should NEVER generate this code. */
+ state->in_count = 0; /* Length of input. */
+ state->bit_buf = 0;
+ state->bit_offset = 0;
+ state->out_count = 3; /* Includes 3-byte header mojo. */
+ state->compress_ratio = 0;
+ state->checkpoint = CHECK_GAP;
+ state->code_len = 9;
+ state->cur_maxcode = MAXCODE(state->code_len);
+ state->first_free = FIRST;
+
+ memset(state->hashtab, 0xff, sizeof(state->hashtab));
+
+ /* Prime output buffer with a gzip header. */
+ state->compressed[0] = 0x1f; /* Compress */
+ state->compressed[1] = 0x9d;
+ state->compressed[2] = 0x90; /* Block mode, 16bit max */
+ state->compressed_offset = 3;
+
+ a->compressor.data = state;
+ return (0);
+}
+
+/*-
+ * Output the given code.
+ * Inputs:
+ * code: A n_bits-bit integer. If == -1, then EOF. This assumes
+ * that n_bits =< (long)wordsize - 1.
+ * Outputs:
+ * Outputs code to the file.
+ * Assumptions:
+ * Chars are 8 bits long.
+ * Algorithm:
+ * Maintain a BITS character long buffer (so that 8 codes will
+ * fit in it exactly). Use the VAX insv instruction to insert each
+ * code in turn. When the buffer fills up empty it and start over.
+ */
+
+static unsigned char rmask[9] =
+ {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
+
+static int
+output_byte(struct archive_write *a, unsigned char c)
+{
+ struct private_data *state = a->compressor.data;
+ ssize_t bytes_written;
+
+ state->compressed[state->compressed_offset++] = c;
+ ++state->out_count;
+
+ if (state->compressed_buffer_size == state->compressed_offset) {
+ bytes_written = (a->client_writer)(&a->archive,
+ a->client_data,
+ state->compressed, state->compressed_buffer_size);
+ if (bytes_written <= 0)
+ return ARCHIVE_FATAL;
+ a->archive.raw_position += bytes_written;
+ state->compressed_offset = 0;
+ }
+
+ return ARCHIVE_OK;
+}
+
+static int
+output_code(struct archive_write *a, int ocode)
+{
+ struct private_data *state = a->compressor.data;
+ int bits, ret, clear_flg, bit_offset;
+
+ clear_flg = ocode == CLEAR;
+ bits = state->code_len;
+
+ /*
+ * Since ocode is always >= 8 bits, only need to mask the first
+ * hunk on the left.
+ */
+ bit_offset = state->bit_offset % 8;
+ state->bit_buf |= (ocode << bit_offset) & 0xff;
+ output_byte(a, state->bit_buf);
+
+ bits = state->code_len - (8 - bit_offset);
+ ocode >>= 8 - bit_offset;
+ /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
+ if (bits >= 8) {
+ output_byte(a, ocode & 0xff);
+ ocode >>= 8;
+ bits -= 8;
+ }
+ /* Last bits. */
+ state->bit_offset += state->code_len;
+ state->bit_buf = ocode & rmask[bits];
+ if (state->bit_offset == state->code_len * 8)
+ state->bit_offset = 0;
+
+ /*
+ * If the next entry is going to be too big for the ocode size,
+ * then increase it, if possible.
+ */
+ if (clear_flg || state->first_free > state->cur_maxcode) {
+ /*
+ * Write the whole buffer, because the input side won't
+ * discover the size increase until after it has read it.
+ */
+ if (state->bit_offset > 0) {
+ while (state->bit_offset < state->code_len * 8) {
+ ret = output_byte(a, state->bit_buf);
+ if (ret != ARCHIVE_OK)
+ return ret;
+ state->bit_offset += 8;
+ state->bit_buf = 0;
+ }
+ }
+ state->bit_buf = 0;
+ state->bit_offset = 0;
+
+ if (clear_flg) {
+ state->code_len = 9;
+ state->cur_maxcode = MAXCODE(state->code_len);
+ } else {
+ state->code_len++;
+ if (state->code_len == 16)
+ state->cur_maxcode = state->max_maxcode;
+ else
+ state->cur_maxcode = MAXCODE(state->code_len);
+ }
+ }
+
+ return (ARCHIVE_OK);
+}
+
+static int
+output_flush(struct archive_write *a)
+{
+ struct private_data *state = a->compressor.data;
+ int ret;
+
+ /* At EOF, write the rest of the buffer. */
+ if (state->bit_offset % 8) {
+ state->code_len = (state->bit_offset % 8 + 7) / 8;
+ ret = output_byte(a, state->bit_buf);
+ if (ret != ARCHIVE_OK)
+ return ret;
+ }
+
+ return (ARCHIVE_OK);
+}
+
+/*
+ * Write data to the compressed stream.
+ */
+static int
+archive_compressor_compress_write(struct archive_write *a, const void *buff,
+ size_t length)
+{
+ struct private_data *state;
+ int i;
+ int ratio;
+ int c, disp, ret;
+ const unsigned char *bp;
+
+ state = (struct private_data *)a->compressor.data;
+ if (a->client_writer == NULL) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
+ "No write callback is registered? "
+ "This is probably an internal programming error.");
+ return (ARCHIVE_FATAL);
+ }
+
+ if (length == 0)
+ return ARCHIVE_OK;
+
+ bp = buff;
+
+ if (state->in_count == 0) {
+ state->cur_code = *bp++;
+ ++state->in_count;
+ --length;
+ }
+
+ while (length--) {
+ c = *bp++;
+ state->in_count++;
+ state->cur_fcode = (c << 16) + state->cur_code;
+ i = ((c << HSHIFT) ^ state->cur_code); /* Xor hashing. */
+
+ if (state->hashtab[i] == state->cur_fcode) {
+ state->cur_code = state->codetab[i];
+ continue;
+ }
+ if (state->hashtab[i] < 0) /* Empty slot. */
+ goto nomatch;
+ /* Secondary hash (after G. Knott). */
+ if (i == 0)
+ disp = 1;
+ else
+ disp = HSIZE - i;
+ probe:
+ if ((i -= disp) < 0)
+ i += HSIZE;
+
+ if (state->hashtab[i] == state->cur_fcode) {
+ state->cur_code = state->codetab[i];
+ continue;
+ }
+ if (state->hashtab[i] >= 0)
+ goto probe;
+ nomatch:
+ ret = output_code(a, state->cur_code);
+ if (ret != ARCHIVE_OK)
+ return ret;
+ state->cur_code = c;
+ if (state->first_free < state->max_maxcode) {
+ state->codetab[i] = state->first_free++; /* code -> hashtable */
+ state->hashtab[i] = state->cur_fcode;
+ continue;
+ }
+ if (state->in_count < state->checkpoint)
+ continue;
+
+ state->checkpoint = state->in_count + CHECK_GAP;
+
+ if (state->in_count <= 0x007fffff)
+ ratio = state->in_count * 256 / state->out_count;
+ else if ((ratio = state->out_count / 256) == 0)
+ ratio = 0x7fffffff;
+ else
+ ratio = state->in_count / ratio;
+
+ if (ratio > state->compress_ratio)
+ state->compress_ratio = ratio;
+ else {
+ state->compress_ratio = 0;
+ memset(state->hashtab, 0xff, sizeof(state->hashtab));
+ state->first_free = FIRST;
+ ret = output_code(a, CLEAR);
+ if (ret != ARCHIVE_OK)
+ return ret;
+ }
+ }
+
+ return (ARCHIVE_OK);
+}
+
+
+/*
+ * Finish the compression...
+ */
+static int
+archive_compressor_compress_finish(struct archive_write *a)
+{
+ ssize_t block_length, target_block_length, bytes_written;
+ int ret;
+ struct private_data *state;
+ unsigned tocopy;
+
+ state = (struct private_data *)a->compressor.data;
+ ret = 0;
+ if (a->client_writer == NULL) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
+ "No write callback is registered? "
+ "This is probably an internal programming error.");
+ ret = ARCHIVE_FATAL;
+ goto cleanup;
+ }
+
+ /* By default, always pad the uncompressed data. */
+ if (a->pad_uncompressed) {
+ while (state->in_count % a->bytes_per_block != 0) {
+ tocopy = a->bytes_per_block -
+ (state->in_count % a->bytes_per_block);
+ if (tocopy > a->null_length)
+ tocopy = a->null_length;
+ ret = archive_compressor_compress_write(a, a->nulls,
+ tocopy);
+ if (ret != ARCHIVE_OK)
+ goto cleanup;
+ }
+ }
+
+ ret = output_code(a, state->cur_code);
+ if (ret != ARCHIVE_OK)
+ goto cleanup;
+ ret = output_flush(a);
+ if (ret != ARCHIVE_OK)
+ goto cleanup;
+
+ /* Optionally, pad the final compressed block. */
+ block_length = state->compressed_offset;
+
+ /* Tricky calculation to determine size of last block. */
+ if (a->bytes_in_last_block <= 0)
+ /* Default or Zero: pad to full block */
+ target_block_length = a->bytes_per_block;
+ else
+ /* Round length to next multiple of bytes_in_last_block. */
+ target_block_length = a->bytes_in_last_block *
+ ( (block_length + a->bytes_in_last_block - 1) /
+ a->bytes_in_last_block);
+ if (target_block_length > a->bytes_per_block)
+ target_block_length = a->bytes_per_block;
+ if (block_length < target_block_length) {
+ memset(state->compressed + state->compressed_offset, 0,
+ target_block_length - block_length);
+ block_length = target_block_length;
+ }
+
+ /* Write the last block */
+ bytes_written = (a->client_writer)(&a->archive, a->client_data,
+ state->compressed, block_length);
+ if (bytes_written <= 0)
+ ret = ARCHIVE_FATAL;
+ else
+ a->archive.raw_position += bytes_written;
+
+cleanup:
+ free(state->compressed);
+ free(state);
+ return (ret);
+}
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_ar.c b/archivers/libarchive/files/libarchive/archive_write_set_format_ar.c
index 2e77f1bd89a..313d0b390f9 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_format_ar.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_format_ar.c
@@ -26,7 +26,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_ar.c,v 1.5 2008/01/31 08:11:01 kaiw Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_ar.c,v 1.6 2008/03/15 11:04:45 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -87,8 +87,8 @@ archive_write_set_format_ar_bsd(struct archive *_a)
struct archive_write *a = (struct archive_write *)_a;
int r = archive_write_set_format_ar(a);
if (r == ARCHIVE_OK) {
- a->archive_format = ARCHIVE_FORMAT_AR_BSD;
- a->archive_format_name = "ar (BSD)";
+ a->archive.archive_format = ARCHIVE_FORMAT_AR_BSD;
+ a->archive.archive_format_name = "ar (BSD)";
}
return (r);
}
@@ -99,8 +99,8 @@ archive_write_set_format_ar_svr4(struct archive *_a)
struct archive_write *a = (struct archive_write *)_a;
int r = archive_write_set_format_ar(a);
if (r == ARCHIVE_OK) {
- a->archive_format = ARCHIVE_FORMAT_AR_GNU;
- a->archive_format_name = "ar (GNU/SVR4)";
+ a->archive.archive_format = ARCHIVE_FORMAT_AR_GNU;
+ a->archive.archive_format_name = "ar (GNU/SVR4)";
}
return (r);
}
@@ -204,7 +204,7 @@ archive_write_ar_header(struct archive_write *a, struct archive_entry *entry)
return (ARCHIVE_WARN);
}
- if (a->archive_format == ARCHIVE_FORMAT_AR_GNU) {
+ if (a->archive.archive_format == ARCHIVE_FORMAT_AR_GNU) {
/*
* SVR4/GNU variant use a "/" to mark then end of the filename,
* make it possible to have embedded spaces in the filename.
@@ -261,7 +261,7 @@ archive_write_ar_header(struct archive_write *a, struct archive_entry *entry)
return (ARCHIVE_WARN);
}
}
- } else if (a->archive_format == ARCHIVE_FORMAT_AR_BSD) {
+ } else if (a->archive.archive_format == ARCHIVE_FORMAT_AR_BSD) {
/*
* BSD variant: for any file name which is more than
* 16 chars or contains one or more embedded space(s), the
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_cpio.c b/archivers/libarchive/files/libarchive/archive_write_set_format_cpio.c
index 45cb4e74b64..61042999efa 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_format_cpio.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_format_cpio.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_cpio.c,v 1.13 2007/12/30 04:58:22 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_cpio.c,v 1.14 2008/03/15 11:04:45 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -97,8 +97,8 @@ archive_write_set_format_cpio(struct archive *_a)
a->format_finish_entry = archive_write_cpio_finish_entry;
a->format_finish = archive_write_cpio_finish;
a->format_destroy = archive_write_cpio_destroy;
- a->archive_format = ARCHIVE_FORMAT_CPIO_POSIX;
- a->archive_format_name = "POSIX cpio";
+ a->archive.archive_format = ARCHIVE_FORMAT_CPIO_POSIX;
+ a->archive.archive_format_name = "POSIX cpio";
return (ARCHIVE_OK);
}
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_cpio_newc.c b/archivers/libarchive/files/libarchive/archive_write_set_format_cpio_newc.c
index d11176c1c1e..b5a2a028419 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_format_cpio_newc.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_format_cpio_newc.c
@@ -25,7 +25,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_cpio_newc.c,v 1.3 2008/01/23 05:43:25 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_cpio_newc.c,v 1.4 2008/03/15 11:04:45 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -102,8 +102,8 @@ archive_write_set_format_cpio_newc(struct archive *_a)
a->format_finish_entry = archive_write_newc_finish_entry;
a->format_finish = archive_write_newc_finish;
a->format_destroy = archive_write_newc_destroy;
- a->archive_format = ARCHIVE_FORMAT_CPIO_SVR4_NOCRC;
- a->archive_format_name = "SVR4 cpio nocrc";
+ a->archive.archive_format = ARCHIVE_FORMAT_CPIO_SVR4_NOCRC;
+ a->archive.archive_format_name = "SVR4 cpio nocrc";
return (ARCHIVE_OK);
}
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_pax.c b/archivers/libarchive/files/libarchive/archive_write_set_format_pax.c
index a1bd6881156..d6e3e6c4b03 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_format_pax.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_format_pax.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_pax.c,v 1.42 2007/12/30 04:58:22 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_pax.c,v 1.46 2008/03/15 11:04:45 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -85,8 +85,8 @@ archive_write_set_format_pax_restricted(struct archive *_a)
struct archive_write *a = (struct archive_write *)_a;
int r;
r = archive_write_set_format_pax(&a->archive);
- a->archive_format = ARCHIVE_FORMAT_TAR_PAX_RESTRICTED;
- a->archive_format_name = "restricted POSIX pax interchange";
+ a->archive.archive_format = ARCHIVE_FORMAT_TAR_PAX_RESTRICTED;
+ a->archive.archive_format_name = "restricted POSIX pax interchange";
return (r);
}
@@ -116,8 +116,8 @@ archive_write_set_format_pax(struct archive *_a)
a->format_finish = archive_write_pax_finish;
a->format_destroy = archive_write_pax_destroy;
a->format_finish_entry = archive_write_pax_finish_entry;
- a->archive_format = ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE;
- a->archive_format_name = "POSIX pax interchange";
+ a->archive.archive_format = ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE;
+ a->archive.archive_format_name = "POSIX pax interchange";
return (ARCHIVE_OK);
}
@@ -701,7 +701,7 @@ archive_write_pax_header(struct archive_write *a,
* already set (we're already generating an extended header, so
* may as well include these).
*/
- if (a->archive_format != ARCHIVE_FORMAT_TAR_PAX_RESTRICTED ||
+ if (a->archive.archive_format != ARCHIVE_FORMAT_TAR_PAX_RESTRICTED ||
need_extension) {
if (archive_entry_mtime(entry_main) < 0 ||
@@ -764,7 +764,7 @@ archive_write_pax_header(struct archive_write *a,
* Pax-restricted does not store data for hardlinks, in order
* to improve compatibility with ustar.
*/
- if (a->archive_format != ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE &&
+ if (a->archive.archive_format != ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE &&
hardlink != NULL)
archive_entry_set_size(entry_main, 0);
@@ -1060,7 +1060,13 @@ build_ustar_entry_name(char *dest, const char *src, size_t src_length,
/*
* The ustar header for the pax extended attributes must have a
- * reasonable name: SUSv3 suggests 'dirname'/PaxHeader/'filename'
+ * reasonable name: SUSv3 requires 'dirname'/PaxHeader.'pid'/'filename'
+ * where 'pid' is the PID of the archiving process. Unfortunately,
+ * that makes testing a pain since the output varies for each run,
+ * so I'm sticking with the simpler 'dirname'/PaxHeader/'filename'
+ * for now. (Someday, I'll make this settable. Then I can use the
+ * SUS recommendation as default and test harnesses can override it
+ * to get predictable results.)
*
* Joerg Schilling has argued that this is unnecessary because, in
* practice, if the pax extended attributes get extracted as regular
@@ -1071,19 +1077,14 @@ build_ustar_entry_name(char *dest, const char *src, size_t src_length,
* recommendation, but I'm not entirely convinced. I'm also
* uncomfortable with the fact that "/tmp" is a Unix-ism.
*
- * GNU tar uses 'dirname'/PaxHeader.<pid>/'filename', where the PID is
- * the PID of the archiving process. This seems unnecessarily complex
- * to me, as I don't see much value to separating the headers from
- * extracting multiple versions of an archive.
- *
- * The following routine implements the SUSv3 recommendation, and is
- * much simpler because build_ustar_entry_name() above already does
- * most of the work (we just need to give it an extra path element to
- * insert and handle a few pathological cases).
+ * The following routine leverages build_ustar_entry_name() above and
+ * so is simpler than you might think. It just needs to provide the
+ * additional path element and handle a few pathological cases).
*/
static char *
build_pax_attribute_name(char *dest, const char *src)
{
+ char buff[64];
const char *p;
/* Handle the null filename case. */
@@ -1122,8 +1123,19 @@ build_pax_attribute_name(char *dest, const char *src)
return (dest);
}
+ /*
+ * TODO: Push this string into the 'pax' structure to avoid
+ * recomputing it every time. That will also open the door
+ * to having clients override it.
+ */
+#if HAVE_GETPID && 0 /* Disable this for now; see above comment. */
+ sprintf(buff, "PaxHeader.%d", getpid());
+#else
+ /* If the platform can't fetch the pid, don't include it. */
+ strcpy(buff, "PaxHeader");
+#endif
/* General case: build a ustar-compatible name adding "/PaxHeader/". */
- build_ustar_entry_name(dest, src, p - src, "PaxHeader");
+ build_ustar_entry_name(dest, src, p - src, buff);
return (dest);
}
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_shar.c b/archivers/libarchive/files/libarchive/archive_write_set_format_shar.c
index f26ba028ea5..b5d16e09d13 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_format_shar.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_format_shar.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_shar.c,v 1.18 2007/05/29 01:00:19 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_shar.c,v 1.19 2008/03/15 11:04:45 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -113,8 +113,8 @@ archive_write_set_format_shar(struct archive *_a)
a->format_destroy = archive_write_shar_destroy;
a->format_write_data = archive_write_shar_data_sed;
a->format_finish_entry = archive_write_shar_finish_entry;
- a->archive_format = ARCHIVE_FORMAT_SHAR_BASE;
- a->archive_format_name = "shar";
+ a->archive.archive_format = ARCHIVE_FORMAT_SHAR_BASE;
+ a->archive.archive_format_name = "shar";
return (ARCHIVE_OK);
}
@@ -134,8 +134,8 @@ archive_write_set_format_shar_dump(struct archive *_a)
shar = (struct shar *)a->format_data;
shar->dump = 1;
a->format_write_data = archive_write_shar_data_uuencode;
- a->archive_format = ARCHIVE_FORMAT_SHAR_DUMP;
- a->archive_format_name = "shar dump";
+ a->archive.archive_format = ARCHIVE_FORMAT_SHAR_DUMP;
+ a->archive.archive_format_name = "shar dump";
return (ARCHIVE_OK);
}
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_ustar.c b/archivers/libarchive/files/libarchive/archive_write_set_format_ustar.c
index a7d26c90579..c2c0011aee2 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_format_ustar.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_format_ustar.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_ustar.c,v 1.25 2007/12/30 04:58:22 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_ustar.c,v 1.26 2008/03/15 11:04:45 kientzle Exp $");
#ifdef HAVE_ERRNO_H
@@ -186,8 +186,8 @@ archive_write_set_format_ustar(struct archive *_a)
a->format_finish = archive_write_ustar_finish;
a->format_destroy = archive_write_ustar_destroy;
a->format_finish_entry = archive_write_ustar_finish_entry;
- a->archive_format = ARCHIVE_FORMAT_TAR_USTAR;
- a->archive_format_name = "POSIX ustar";
+ a->archive.archive_format = ARCHIVE_FORMAT_TAR_USTAR;
+ a->archive.archive_format_name = "POSIX ustar";
return (ARCHIVE_OK);
}
diff --git a/archivers/libarchive/files/libarchive/config_freebsd.h b/archivers/libarchive/files/libarchive/config_freebsd.h
index 83a85996a84..97127a19be8 100644
--- a/archivers/libarchive/files/libarchive/config_freebsd.h
+++ b/archivers/libarchive/files/libarchive/config_freebsd.h
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/config_freebsd.h,v 1.6 2008/02/19 05:40:28 kientzle Exp $
+ * $FreeBSD: src/lib/libarchive/config_freebsd.h,v 1.8 2008/03/15 04:20:50 kientzle Exp $
*/
/* FreeBSD 5.0 and later have ACL support. */
@@ -53,8 +53,10 @@
#define HAVE_FCHOWN 1
#define HAVE_FCNTL_H 1
#define HAVE_FSEEKO 1
+#define HAVE_FSTAT 1
#define HAVE_FUTIMES 1
#define HAVE_GETEUID 1
+#define HAVE_GETPID 1
#define HAVE_GRP_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_LCHFLAGS 1
diff --git a/archivers/libarchive/files/libarchive/config_windows.h b/archivers/libarchive/files/libarchive/config_windows.h
index c5200655b14..64eb15f3317 100644
--- a/archivers/libarchive/files/libarchive/config_windows.h
+++ b/archivers/libarchive/files/libarchive/config_windows.h
@@ -4,10 +4,10 @@
#define CONFIG_H_INCLUDED
/* Version number of bsdcpio */
-#define BSDCPIO_VERSION_STRING "0.3.0"
+#define BSDCPIO_VERSION_STRING "0.9.9"
/* Version number of bsdtar */
-#define BSDTAR_VERSION_STRING "2.4.12"
+#define BSDTAR_VERSION_STRING "2.5.0"
/* Define to 1 if you have the `acl_create_entry' function. */
/* #undef HAVE_ACL_CREATE_ENTRY */
@@ -396,10 +396,10 @@
/* #undef HAVE_ZLIB_H */
/* Version number of libarchive as a single integer */
-#define LIBARCHIVE_VERSION "2004012"
+#define LIBARCHIVE_VERSION_NUMBER "2005000"
/* Version number of libarchive */
-#define LIBARCHIVE_VERSION_STRING "2.4.12"
+#define LIBARCHIVE_VERSION_STRING "2.5.0b"
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
slash. */
@@ -464,7 +464,7 @@
/* #undef const */
/* Define to `int' if <sys/types.h> doesn't define. */
-//#define gid_t int
+#define gid_t int
/* Define to `unsigned long' if <sys/types.h> does not define. */
#define id_t int
@@ -478,7 +478,7 @@
#define intmax_t long long
/* Define to `int' if <sys/types.h> does not define. */
-//#define mode_t unsigned short
+#define mode_t unsigned short
/* Define to `long long' if <sys/types.h> does not define. */
/* #undef off_t */
@@ -487,7 +487,7 @@
/* #undef size_t */
/* Define to `int' if <sys/types.h> doesn't define. */
-//#define uid_t int
+#define uid_t int
/* Define to the type of an unsigned integer type of width exactly 64 bits if
such a type exists and the standard includes do not define it. */
@@ -505,6 +505,6 @@
#define uint32_t unsigned long
#define uint16_t unsigned short
-//#define ssize_t long
+#define ssize_t long
#endif /* CONFIG_H_INCLUDED */
diff --git a/archivers/libarchive/files/libarchive/mtree.5 b/archivers/libarchive/files/libarchive/mtree.5
index 613de6a5dae..2341626d877 100644
--- a/archivers/libarchive/files/libarchive/mtree.5
+++ b/archivers/libarchive/files/libarchive/mtree.5
@@ -121,7 +121,7 @@ separated by whitespace.
.Ss Keywords
After the filename, a full or relative entry consists of zero
or more whitespace-separated keyword definitions.
-Each such definitions consists of a key from the following
+Each such definition consists of a key from the following
list immediately followed by an '=' sign
and a value.
Software programs reading mtree files should warn about
@@ -145,17 +145,36 @@ for information on these names.
If no flags are to be set the string
.Dq none
may be used to override the current default.
-.It Cm ignore
-Ignore any file hierarchy below this file.
.It Cm gid
The file group as a numeric value.
.It Cm gname
The file group as a symbolic name.
+.It Cm ignore
+Ignore any file hierarchy below this file.
+.It Cm link
+The file the symbolic link is expected to reference.
.It Cm md5
The MD5 message digest of the file.
.It Cm md5digest
A synonym for
.Cm md5 .
+.It Cm mode
+The current file's permissions as a numeric (octal) or symbolic
+value.
+.It Cm nlink
+The number of hard links the file is expected to have.
+.It Cm nochange
+Make sure this file or directory exists but otherwise ignore all attributes.
+.It Cm ripemd160digest
+The
+.Tn RIPEMD160
+message digest of the file.
+.It Cm rmd160
+A synonym for
+.Cm ripemd160digest .
+.It Cm rmd160digest
+A synonym for
+.Cm ripemd160digest .
.It Cm sha1
The
.Tn FIPS
@@ -174,31 +193,8 @@ message digest of the file.
.It Cm sha256digest
A synonym for
.Cm sha256 .
-.It Cm ripemd160digest
-The
-.Tn RIPEMD160
-message digest of the file.
-.It Cm rmd160
-A synonym for
-.Cm ripemd160digest .
-.It Cm rmd160digest
-A synonym for
-.Cm ripemd160digest .
-.It Cm mode
-The current file's permissions as a numeric (octal) or symbolic
-value.
-.It Cm nlink
-The number of hard links the file is expected to have.
-.It Cm nochange
-Make sure this file or directory exists but otherwise ignore all attributes.
-.It Cm uid
-The file owner as a numeric value.
-.It Cm uname
-The file owner as a symbolic name.
.It Cm size
The size, in bytes, of the file.
-.It Cm link
-The file the symbolic link is expected to reference.
.It Cm time
The last modification time of the file.
.It Cm type
@@ -220,6 +216,10 @@ symbolic link
.It Cm socket
socket
.El
+.It Cm uid
+The file owner as a numeric value.
+.It Cm uname
+The file owner as a symbolic name.
.El
.Pp
.Sh SEE ALSO
diff --git a/archivers/libarchive/files/libarchive/test/list.h b/archivers/libarchive/files/libarchive/test/list.h
index fdd56335dc9..c44dcfce831 100644
--- a/archivers/libarchive/files/libarchive/test/list.h
+++ b/archivers/libarchive/files/libarchive/test/list.h
@@ -39,6 +39,7 @@ DEFINE_TEST(test_read_position)
DEFINE_TEST(test_read_truncated)
DEFINE_TEST(test_tar_filenames)
DEFINE_TEST(test_tar_large)
+DEFINE_TEST(test_write_compress)
DEFINE_TEST(test_write_compress_program)
DEFINE_TEST(test_write_disk)
DEFINE_TEST(test_write_disk_hardlink)
diff --git a/archivers/libarchive/files/libarchive/test/main.c b/archivers/libarchive/files/libarchive/test/main.c
index 0b56cc64156..3977803278f 100644
--- a/archivers/libarchive/files/libarchive/test/main.c
+++ b/archivers/libarchive/files/libarchive/test/main.c
@@ -24,23 +24,26 @@
*/
/*
- * This same file is used pretty much verbatim for all test harnesses.
- *
- * The next line is used to define various environment variables, etc.
- *
- * The tar and cpio test harnesses are identical except for this line;
- * the libarchive test harness omits some code that is needed only for
- * testing standalone executables.
+ * Various utility routines useful for test programs.
+ * Each test program is linked against this file.
*/
-#define PROGRAM "LIBARCHIVE"
-
#include <errno.h>
#include <locale.h>
#include <stdarg.h>
#include <time.h>
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/main.c,v 1.10 2008/02/19 05:52:30 kientzle Exp $");
+
+/*
+ * This same file is used pretty much verbatim for all test harnesses.
+ *
+ * The next few lines are the only differences.
+ */
+#undef PROGRAM /* Testing a library, not a program. */
+#define ENVBASE "LIBARCHIVE" /* Prefix for environment variables. */
+#define EXTRA_DUMP(x) archive_error_string((struct archive *)(x))
+#define EXTRA_VERSION archive_version()
+__FBSDID("$FreeBSD: src/lib/libarchive/test/main.c,v 1.11 2008/03/12 05:12:23 kientzle Exp $");
/*
* "list.h" is simply created by "grep DEFINE_TEST"; it has
@@ -51,7 +54,7 @@ __FBSDID("$FreeBSD: src/lib/libarchive/test/main.c,v 1.10 2008/02/19 05:52:30 ki
* test functions.
*/
#undef DEFINE_TEST
-#define DEFINE_TEST(name) void name(void);
+#define DEFINE_TEST(name) void name(void);
#include "list.h"
/* Interix doesn't define these in a standard header. */
@@ -71,6 +74,9 @@ static int skips = 0;
/* Cumulative count of assertions. */
static int assertions = 0;
+/* Directory where uuencoded reference files can be found. */
+static char *refdir;
+
/*
* My own implementation of the standard assert() macro emits the
* message in the same format as GCC (file:line: message).
@@ -90,7 +96,7 @@ static char msg[4096];
* For each test source file, we remember how many times each
* failure was reported.
*/
-static const char *failed_filename;
+static const char *failed_filename = NULL;
static struct line {
int line;
int count;
@@ -163,9 +169,13 @@ report_failure(void *extra)
fprintf(stderr, " Description: %s\n", msg);
msg[0] = '\0';
}
- if (extra != NULL) {
- fprintf(stderr, " archive error: %s\n", archive_error_string((struct archive *)extra));
- }
+
+#ifdef EXTRA_DUMP
+ if (extra != NULL)
+ fprintf(stderr, " detail: %s\n", EXTRA_DUMP(extra));
+#else
+ (void)extra; /* UNUSED */
+#endif
if (dump_on_failure) {
fprintf(stderr,
@@ -241,27 +251,28 @@ test_assert(const char *file, int line, int value, const char *condition, void *
}
/* assertEqualInt() displays the values of the two integers. */
-void
+int
test_assert_equal_int(const char *file, int line,
int v1, const char *e1, int v2, const char *e2, void *extra)
{
++assertions;
if (v1 == v2) {
msg[0] = '\0';
- return;
+ return (1);
}
failures ++;
if (previous_failures(file, line))
- return;
+ return (0);
fprintf(stderr, "%s:%d: Assertion failed: Ints not equal\n",
file, line);
fprintf(stderr, " %s=%d\n", e1, v1);
fprintf(stderr, " %s=%d\n", e2, v2);
report_failure(extra);
+ return (0);
}
/* assertEqualString() displays the values of the two strings. */
-void
+int
test_assert_equal_string(const char *file, int line,
const char *v1, const char *e1,
const char *v2, const char *e2,
@@ -271,24 +282,25 @@ test_assert_equal_string(const char *file, int line,
if (v1 == NULL || v2 == NULL) {
if (v1 == v2) {
msg[0] = '\0';
- return;
+ return (1);
}
} else if (strcmp(v1, v2) == 0) {
msg[0] = '\0';
- return;
+ return (1);
}
failures ++;
if (previous_failures(file, line))
- return;
+ return (0);
fprintf(stderr, "%s:%d: Assertion failed: Strings not equal\n",
file, line);
fprintf(stderr, " %s = \"%s\"\n", e1, v1);
fprintf(stderr, " %s = \"%s\"\n", e2, v2);
report_failure(extra);
+ return (0);
}
/* assertEqualWString() displays the values of the two strings. */
-void
+int
test_assert_equal_wstring(const char *file, int line,
const wchar_t *v1, const char *e1,
const wchar_t *v2, const char *e2,
@@ -297,16 +309,17 @@ test_assert_equal_wstring(const char *file, int line,
++assertions;
if (wcscmp(v1, v2) == 0) {
msg[0] = '\0';
- return;
+ return (1);
}
failures ++;
if (previous_failures(file, line))
- return;
+ return (0);
fprintf(stderr, "%s:%d: Assertion failed: Unicode strings not equal\n",
file, line);
fwprintf(stderr, L" %s = \"%ls\"\n", e1, v1);
fwprintf(stderr, L" %s = \"%ls\"\n", e2, v2);
report_failure(extra);
+ return (0);
}
/*
@@ -326,7 +339,7 @@ hexdump(const char *p, const char *ref, size_t l, size_t offset)
for (j = 0; j < 16 && i + j < l; j++) {
if (ref != NULL && p[i + j] != ref[i + j])
sep = '_';
- fprintf(stderr, "%c%02x", sep, p[i+j]);
+ fprintf(stderr, "%c%02x", sep, 0xff & (int)p[i+j]);
if (ref != NULL && p[i + j] == ref[i + j])
sep = ' ';
}
@@ -348,7 +361,7 @@ hexdump(const char *p, const char *ref, size_t l, size_t offset)
/* assertEqualMem() displays the values of the two memory blocks. */
/* TODO: For long blocks, hexdump the first bytes that actually differ. */
-void
+int
test_assert_equal_mem(const char *file, int line,
const char *v1, const char *e1,
const char *v2, const char *e2,
@@ -358,15 +371,15 @@ test_assert_equal_mem(const char *file, int line,
if (v1 == NULL || v2 == NULL) {
if (v1 == v2) {
msg[0] = '\0';
- return;
+ return (1);
}
} else if (memcmp(v1, v2, l) == 0) {
msg[0] = '\0';
- return;
+ return (1);
}
failures ++;
if (previous_failures(file, line))
- return;
+ return (0);
fprintf(stderr, "%s:%d: Assertion failed: memory not equal\n",
file, line);
fprintf(stderr, " size %s = %d\n", ld, (int)l);
@@ -376,14 +389,19 @@ test_assert_equal_mem(const char *file, int line,
hexdump(v2, v1, l < 32 ? l : 32, 0);
fprintf(stderr, "\n");
report_failure(extra);
+ return (0);
}
-void
+int
test_assert_empty_file(const char *f1fmt, ...)
{
+ char buff[1024];
char f1[1024];
struct stat st;
va_list ap;
+ ssize_t s;
+ int fd;
+
va_start(ap, f1fmt);
vsprintf(f1, f1fmt, ap);
@@ -392,16 +410,32 @@ test_assert_empty_file(const char *f1fmt, ...)
if (stat(f1, &st) != 0) {
fprintf(stderr, "%s:%d: Could not stat: %s\n", test_filename, test_line, f1);
report_failure(NULL);
- } else if (st.st_size > 0) {
- fprintf(stderr, "%s:%d: File not empty: %s\n", test_filename, test_line, f1);
- fprintf(stderr, " File size: %d\n", (int)st.st_size);
- report_failure(NULL);
}
+ if (st.st_size == 0)
+ return (1);
+
+ failures ++;
+ if (previous_failures(test_filename, test_line))
+ return (0);
+
+ fprintf(stderr, "%s:%d: File not empty: %s\n", test_filename, test_line, f1);
+ fprintf(stderr, " File size: %d\n", (int)st.st_size);
+ fprintf(stderr, " Contents:\n");
+ fd = open(f1, O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, " Unable to open %s\n", f1);
+ } else {
+ s = sizeof(buff) < st.st_size ? sizeof(buff) : st.st_size;
+ s = read(fd, buff, s);
+ hexdump(buff, NULL, s, 0);
+ }
+ report_failure(NULL);
+ return (0);
}
/* assertEqualFile() asserts that two files have the same contents. */
/* TODO: hexdump the first bytes that actually differ. */
-void
+int
test_assert_equal_file(const char *f1, const char *f2pattern, ...)
{
char f2[1024];
@@ -423,16 +457,58 @@ test_assert_equal_file(const char *f1, const char *f2pattern, ...)
if (n1 != n2)
break;
if (n1 == 0 && n2 == 0)
- return;
+ return (1);
if (memcmp(buff1, buff2, n1) != 0)
break;
}
- fprintf(stderr, "%s:%d: Files are not identical\n", test_filename, test_line);
+ failures ++;
+ if (previous_failures(test_filename, test_line))
+ return (0);
+ fprintf(stderr, "%s:%d: Files are not identical\n",
+ test_filename, test_line);
fprintf(stderr, " file1=\"%s\"\n", f1);
fprintf(stderr, " file2=\"%s\"\n", f2);
report_failure(test_extra);
+ return (0);
}
+/* assertFileContents() asserts the contents of a file. */
+int
+test_assert_file_contents(const void *buff, int s, const char *fpattern, ...)
+{
+ char f[1024];
+ va_list ap;
+ char *contents;
+ int fd;
+ int n;
+
+ va_start(ap, fpattern);
+ vsprintf(f, fpattern, ap);
+ va_end(ap);
+
+ fd = open(f, O_RDONLY);
+ contents = malloc(s * 2);
+ n = read(fd, contents, s * 2);
+ if (n == s && memcmp(buff, contents, s) == 0) {
+ free(contents);
+ return (1);
+ }
+ failures ++;
+ if (!previous_failures(test_filename, test_line)) {
+ fprintf(stderr, "%s:%d: File contents don't match\n",
+ test_filename, test_line);
+ fprintf(stderr, " file=\"%s\"\n", f);
+ if (n > 0)
+ hexdump(contents, buff, n, 0);
+ else {
+ fprintf(stderr, " File empty, contents should be:\n");
+ hexdump(buff, NULL, s, 0);
+ }
+ report_failure(test_extra);
+ }
+ free(contents);
+ return (0);
+}
/*
* Call standard system() call, but build up the command line using
@@ -510,7 +586,7 @@ slurpfile(size_t * sizep, const char *fmt, ...)
* We reuse it here to define a list of all tests (functions and names).
*/
#undef DEFINE_TEST
-#define DEFINE_TEST(n) { n, #n },
+#define DEFINE_TEST(n) { n, #n },
struct { void (*func)(void); const char *name; } tests[] = {
#include "list.h"
};
@@ -572,6 +648,10 @@ static void usage(const char *program)
printf("Options:\n");
printf(" -k Keep running after failures.\n");
printf(" Default: Core dump after any failure.\n");
+#ifdef PROGRAM
+ printf(" -p <path> Path to executable to be tested.\n");
+ printf(" Default: path taken from " ENVBASE " environment variable.\n");
+#endif
printf(" -q Quiet.\n");
printf(" -r <dir> Path to dir containing reference files.\n");
printf(" Default: Current directory.\n");
@@ -581,6 +661,66 @@ static void usage(const char *program)
exit(1);
}
+#define UUDECODE(c) (((c) - 0x20) & 0x3f)
+
+void
+extract_reference_file(const char *name)
+{
+ char buff[1024];
+ FILE *in, *out;
+
+ sprintf(buff, "%s/%s.uu", refdir, name);
+ in = fopen(buff, "r");
+ failure("Couldn't open reference file %s", buff);
+ assert(in != NULL);
+ if (in == NULL)
+ return;
+ /* Read up to and including the 'begin' line. */
+ for (;;) {
+ if (fgets(buff, sizeof(buff), in) == NULL) {
+ /* TODO: This is a failure. */
+ return;
+ }
+ if (memcmp(buff, "begin ", 6) == 0)
+ break;
+ }
+ /* Now, decode the rest and write it. */
+ /* Not a lot of error checking here; the input better be right. */
+ out = fopen(name, "w");
+ while (fgets(buff, sizeof(buff), in) != NULL) {
+ char *p = buff;
+ int bytes;
+
+ if (memcmp(buff, "end", 3) == 0)
+ break;
+
+ bytes = UUDECODE(*p++);
+ while (bytes > 0) {
+ int n = 0;
+ /* Write out 1-3 bytes from that. */
+ if (bytes > 0) {
+ n = UUDECODE(*p++) << 18;
+ n |= UUDECODE(*p++) << 12;
+ fputc(n >> 16, out);
+ --bytes;
+ }
+ if (bytes > 0) {
+ n |= UUDECODE(*p++) << 6;
+ fputc((n >> 8) & 0xFF, out);
+ --bytes;
+ }
+ if (bytes > 0) {
+ n |= UUDECODE(*p++);
+ fputc(n & 0xFF, out);
+ --bytes;
+ }
+ }
+ }
+ fclose(out);
+ fclose(in);
+}
+
+
int main(int argc, char **argv)
{
static const int limit = sizeof(tests) / sizeof(tests[0]);
@@ -602,17 +742,33 @@ int main(int argc, char **argv)
++p;
}
+#ifdef PROGRAM
+ /* Get the target program from environment, if available. */
+ testprog = getenv(ENVBASE);
+#endif
+
+ /* Allow -k to be controlled through the environment. */
+ if (getenv(ENVBASE "_KEEP_GOING") != NULL)
+ dump_on_failure = 0;
+
/* Get the directory holding test files from environment. */
- refdir = getenv(PROGRAM "_TEST_FILES");
+ refdir = getenv(ENVBASE "_TEST_FILES");
/*
* Parse options.
*/
- while ((opt = getopt(argc, argv, "kqr:")) != -1) {
+ while ((opt = getopt(argc, argv, "kp:qr:")) != -1) {
switch (opt) {
case 'k':
dump_on_failure = 0;
break;
+ case 'p':
+#ifdef PROGRAM
+ testprog = optarg;
+#else
+ usage(progname);
+#endif
+ break;
case 'q':
quiet_flag++;
break;
@@ -628,6 +784,14 @@ int main(int argc, char **argv)
argv += optind;
/*
+ * Sanity-check that our options make sense.
+ */
+#ifdef PROGRAM
+ if (testprog == NULL)
+ usage(progname);
+#endif
+
+ /*
* Create a temp directory for the following tests.
* Include the time the tests started as part of the name,
* to make it easier to track the results of multiple tests.
@@ -667,7 +831,12 @@ int main(int argc, char **argv)
if (!quiet_flag) {
printf("Running tests in: %s\n", tmpdir);
printf("Reference files will be read from: %s\n", refdir);
- printf("Exercising %s\n", archive_version());
+#ifdef PROGRAM
+ printf("Running tests on: %s\n", testprog);
+#endif
+ printf("Exercising: ");
+ fflush(stdout);
+ printf("%s\n", EXTRA_VERSION);
}
/*
diff --git a/archivers/libarchive/files/libarchive/test/test.h b/archivers/libarchive/files/libarchive/test/test.h
index 72d611d77d1..dcb190ff3fe 100644
--- a/archivers/libarchive/files/libarchive/test/test.h
+++ b/archivers/libarchive/files/libarchive/test/test.h
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/test/test.h,v 1.8 2008/02/19 05:52:30 kientzle Exp $
+ * $FreeBSD: src/lib/libarchive/test/test.h,v 1.9 2008/03/12 05:12:23 kientzle Exp $
*/
/* Every test program should #include "test.h" as the first thing. */
@@ -35,6 +35,7 @@
#define _FILE_OFFSET_BITS 64
#endif
+#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@@ -116,12 +117,13 @@ void failure(const char *fmt, ...);
void test_setup(const char *, int);
void test_skipping(const char *fmt, ...);
int test_assert(const char *, int, int, const char *, void *);
-void test_assert_empty_file(const char *, ...);
-void test_assert_equal_file(const char *, const char *, ...);
-void test_assert_equal_int(const char *, int, int, const char *, int, const char *, void *);
-void test_assert_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *);
-void test_assert_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
-void test_assert_equal_mem(const char *, int, const char *, const char *, const char *, const char *, size_t, const char *, void *);
+int test_assert_empty_file(const char *, ...);
+int test_assert_equal_file(const char *, const char *, ...);
+int test_assert_equal_int(const char *, int, int, const char *, int, const char *, void *);
+int test_assert_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *);
+int test_assert_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
+int test_assert_equal_mem(const char *, int, const char *, const char *, const char *, const char *, size_t, const char *, void *);
+int test_assert_file_contents(const void *, int, const char *, ...);
/* Like sprintf, then system() */
int systemf(const char * fmt, ...);
@@ -130,12 +132,8 @@ int systemf(const char * fmt, ...);
/* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */
char *slurpfile(size_t *, const char *fmt, ...);
-/*
- * Global vars
- */
-
-/* Directory holding reference files. */
-char *refdir;
+/* Extracts named reference file to the current directory. */
+void extract_reference_file(const char *);
/*
* Special interfaces for libarchive test harness.
diff --git a/archivers/libarchive/files/libarchive/test/test_archive_api_feature.c b/archivers/libarchive/files/libarchive/test/test_archive_api_feature.c
index 432d902b6a5..a22bdcc7961 100644
--- a/archivers/libarchive/files/libarchive/test/test_archive_api_feature.c
+++ b/archivers/libarchive/files/libarchive/test/test_archive_api_feature.c
@@ -23,10 +23,34 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_archive_api_feature.c,v 1.3 2007/07/06 15:43:11 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_archive_api_feature.c,v 1.4 2008/03/14 22:31:57 kientzle Exp $");
DEFINE_TEST(test_archive_api_feature)
{
+ char buff[128];
+ char *p;
+
+ /* This is the (hopefully) final versioning API. */
+ assertEqualInt(ARCHIVE_VERSION_NUMBER, archive_version_number());
+ sprintf(buff, "libarchive %d.%d.%d",
+ archive_version_number() / 1000000,
+ (archive_version_number() / 1000) % 1000,
+ archive_version_number() % 1000);
+ failure("Version string is: %s, computed is: %s",
+ archive_version_string(), buff);
+ assert(memcmp(buff, archive_version_string(), strlen(buff)) == 0);
+ if (strlen(buff) < strlen(archive_version_string())) {
+ p = archive_version_string() + strlen(buff);
+ failure("Version string is: %s", archive_version_string());
+ assert(*p == 'a' || *p == 'b' || *p == 'c' || *p == 'd');
+ ++p;
+ failure("Version string is: %s", archive_version_string());
+ assert(*p == '\0');
+ }
+
+/* This is all scheduled to disappear in libarchive 3.0 */
+#if ARCHIVE_VERSION_NUMBER < 3000000
+ assertEqualInt(ARCHIVE_VERSION_STAMP, ARCHIVE_VERSION_NUMBER);
assertEqualInt(ARCHIVE_API_FEATURE, archive_api_feature());
assertEqualInt(ARCHIVE_API_VERSION, archive_api_version());
/*
@@ -48,4 +72,5 @@ DEFINE_TEST(test_archive_api_feature)
skipping("archive_version_stamp()");
#endif
assertEqualString(ARCHIVE_LIBRARY_VERSION, archive_version());
+#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_gtar.c b/archivers/libarchive/files/libarchive/test/test_compat_gtar.c
index 3451a76ebbc..66cd7b02e87 100644
--- a/archivers/libarchive/files/libarchive/test/test_compat_gtar.c
+++ b/archivers/libarchive/files/libarchive/test/test_compat_gtar.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_compat_gtar.c,v 1.1 2008/01/01 22:28:04 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_compat_gtar.c,v 1.2 2008/03/12 05:12:23 kientzle Exp $");
/*
* Verify our ability to read sample files created by GNU tar.
@@ -40,14 +40,14 @@ __FBSDID("$FreeBSD: src/lib/libarchive/test/test_compat_gtar.c,v 1.1 2008/01/01
static void
test_compat_gtar_1(void)
{
- char name[1024];
+ char name[] = "test_compat_gtar_1.tgz";
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
- sprintf(name, "%s/test_compat_gtar_1.tgz", refdir);
+ extract_reference_file(name);
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240));
/* Read first entry. */
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_tar_hardlink.c b/archivers/libarchive/files/libarchive/test/test_compat_tar_hardlink.c
index 103b349da0e..ae71e9232c5 100644
--- a/archivers/libarchive/files/libarchive/test/test_compat_tar_hardlink.c
+++ b/archivers/libarchive/files/libarchive/test/test_compat_tar_hardlink.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_compat_tar_hardlink.c,v 1.1 2008/01/31 07:47:38 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_compat_tar_hardlink.c,v 1.2 2008/03/12 05:12:23 kientzle Exp $");
/*
* Background: There are two written standards for the tar file format.
@@ -46,14 +46,14 @@ __FBSDID("$FreeBSD: src/lib/libarchive/test/test_compat_tar_hardlink.c,v 1.1 200
static void
test_compat_tar_hardlink_1(void)
{
- char name[1024];
+ char name[] = "test_compat_tar_hardlink_1.tar";
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
- sprintf(name, "%s/test_compat_tar_hardlink_1.tar", refdir);
+ extract_reference_file(name);
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240));
/* Read first entry, which is a regular file. */
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_zip.c b/archivers/libarchive/files/libarchive/test/test_compat_zip.c
index 0f6d1d00b1b..fdeb9c64ac1 100644
--- a/archivers/libarchive/files/libarchive/test/test_compat_zip.c
+++ b/archivers/libarchive/files/libarchive/test/test_compat_zip.c
@@ -23,20 +23,20 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_compat_zip.c,v 1.1 2008/01/01 22:28:04 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_compat_zip.c,v 1.2 2008/03/12 05:12:23 kientzle Exp $");
/* Copy this function for each test file and adjust it accordingly. */
static void
test_compat_zip_1(void)
{
- char name[1024];
+ char name[] = "test_compat_zip_1.zip";
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
- sprintf(name, "%s/test_compat_zip_1.zip", refdir);
+ extract_reference_file(name);
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240));
/* Read first entry. */
diff --git a/archivers/libarchive/files/libarchive/test/test_empty_write.c b/archivers/libarchive/files/libarchive/test/test_empty_write.c
index 540ddf110ba..6a9f3f9c8d5 100644
--- a/archivers/libarchive/files/libarchive/test/test_empty_write.c
+++ b/archivers/libarchive/files/libarchive/test/test_empty_write.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_empty_write.c,v 1.1 2008/01/01 22:28:04 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_empty_write.c,v 1.2 2008/03/15 11:06:15 kientzle Exp $");
DEFINE_TEST(test_empty_write)
{
@@ -47,6 +47,7 @@ DEFINE_TEST(test_empty_write)
archive_entry_set_mode(ae, S_IFREG | 0755);
archive_entry_set_size(ae, 0);
assertA(0 == archive_write_header(a, ae));
+ archive_entry_free(ae);
/* THE TEST: write zero bytes to this entry. */
/* This used to crash. */
@@ -76,6 +77,7 @@ DEFINE_TEST(test_empty_write)
archive_entry_set_mode(ae, S_IFREG | 0755);
archive_entry_set_size(ae, 0);
assertA(0 == archive_write_header(a, ae));
+ archive_entry_free(ae);
/* THE TEST: write zero bytes to this entry. */
assertEqualIntA(a, 0, archive_write_data(a, "", 0));
@@ -104,6 +106,7 @@ DEFINE_TEST(test_empty_write)
archive_entry_set_mode(ae, S_IFREG | 0755);
archive_entry_set_size(ae, 0);
assertA(0 == archive_write_header(a, ae));
+ archive_entry_free(ae);
/* THE TEST: write zero bytes to this entry. */
assertEqualIntA(a, 0, archive_write_data(a, "", 0));
diff --git a/archivers/libarchive/files/libarchive/test/test_entry.c b/archivers/libarchive/files/libarchive/test/test_entry.c
index bf41aac4891..29edae7ffd8 100644
--- a/archivers/libarchive/files/libarchive/test/test_entry.c
+++ b/archivers/libarchive/files/libarchive/test/test_entry.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_entry.c,v 1.2 2007/07/06 15:43:11 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_entry.c,v 1.5 2008/03/14 23:19:46 kientzle Exp $");
#include <locale.h>
@@ -122,8 +122,37 @@ DEFINE_TEST(test_entry)
#else
skipping("archive_entry_ino()");
#endif
+
/* link */
- /* TODO: implement these tests. */
+ archive_entry_set_hardlink(e, "hardlinkname");
+ archive_entry_set_symlink(e, NULL);
+ archive_entry_set_link(e, "link");
+ assertEqualString(archive_entry_hardlink(e), "link");
+ assertEqualString(archive_entry_symlink(e), NULL);
+ archive_entry_copy_link(e, "link2");
+ assertEqualString(archive_entry_hardlink(e), "link2");
+ assertEqualString(archive_entry_symlink(e), NULL);
+ archive_entry_copy_link_w(e, L"link3");
+ assertEqualString(archive_entry_hardlink(e), "link3");
+ assertEqualString(archive_entry_symlink(e), NULL);
+ archive_entry_set_hardlink(e, NULL);
+ archive_entry_set_symlink(e, "symlink");
+ archive_entry_set_link(e, "link");
+ assertEqualString(archive_entry_hardlink(e), NULL);
+ assertEqualString(archive_entry_symlink(e), "link");
+ archive_entry_copy_link(e, "link2");
+ assertEqualString(archive_entry_hardlink(e), NULL);
+ assertEqualString(archive_entry_symlink(e), "link2");
+ archive_entry_copy_link_w(e, L"link3");
+ assertEqualString(archive_entry_hardlink(e), NULL);
+ assertEqualString(archive_entry_symlink(e), "link3");
+ /* Arbitrarily override hardlink if both hardlink and symlink set. */
+ archive_entry_set_hardlink(e, "hardlink");
+ archive_entry_set_symlink(e, "symlink");
+ archive_entry_set_link(e, "link");
+ assertEqualString(archive_entry_hardlink(e), "hardlink");
+ assertEqualString(archive_entry_symlink(e), "link");
+
/* mode */
archive_entry_set_mode(e, 0123456);
assertEqualInt(archive_entry_mode(e), 0123456);
@@ -215,10 +244,16 @@ DEFINE_TEST(test_entry)
assertEqualInt(1, archive_entry_xattr_count(e));
assertEqualInt(ARCHIVE_WARN,
archive_entry_xattr_next(e, &xname, &xval, &xsize));
+ assertEqualString(xname, NULL);
+ assertEqualString(xval, NULL);
+ assertEqualInt(xsize, 0);
archive_entry_xattr_clear(e);
assertEqualInt(0, archive_entry_xattr_reset(e));
assertEqualInt(ARCHIVE_WARN,
archive_entry_xattr_next(e, &xname, &xval, &xsize));
+ assertEqualString(xname, NULL);
+ assertEqualString(xval, NULL);
+ assertEqualInt(xsize, 0);
archive_entry_xattr_add_entry(e, "xattr1", "xattrvalue1", 12);
assertEqualInt(1, archive_entry_xattr_reset(e));
archive_entry_xattr_add_entry(e, "xattr2", "xattrvalue2", 12);
@@ -227,6 +262,9 @@ DEFINE_TEST(test_entry)
assertEqualInt(0, archive_entry_xattr_next(e, &xname, &xval, &xsize));
assertEqualInt(ARCHIVE_WARN,
archive_entry_xattr_next(e, &xname, &xval, &xsize));
+ assertEqualString(xname, NULL);
+ assertEqualString(xval, NULL);
+ assertEqualInt(xsize, 0);
/*
@@ -350,6 +388,11 @@ DEFINE_TEST(test_entry)
assertEqualString(xname, "xattr1");
assertEqualString(xval, "xattrvalue");
assertEqualInt(xsize, 11);
+ assertEqualInt(ARCHIVE_WARN,
+ archive_entry_xattr_next(e2, &xname, &xval, &xsize));
+ assertEqualString(xname, NULL);
+ assertEqualString(xval, NULL);
+ assertEqualInt(xsize, 0);
#endif
/* Change the original */
@@ -455,6 +498,14 @@ DEFINE_TEST(test_entry)
assertEqualInt(tag, ARCHIVE_ENTRY_ACL_USER);
assertEqualInt(qual, 77);
assertEqualString(name, "user77");
+ assertEqualInt(1, archive_entry_acl_next(e2,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ &type, &permset, &tag, &qual, &name));
+ assertEqualInt(type, 0);
+ assertEqualInt(permset, 0);
+ assertEqualInt(tag, 0);
+ assertEqualInt(qual, -1);
+ assertEqualString(name, NULL);
#endif
#if ARCHIVE_VERSION_STAMP < 1009000
skipping("xattr preserved in archive_entry copy");
diff --git a/archivers/libarchive/files/libarchive/test/test_link_resolver.c b/archivers/libarchive/files/libarchive/test/test_link_resolver.c
index 24827b0f222..a51e4a4ddc9 100644
--- a/archivers/libarchive/files/libarchive/test/test_link_resolver.c
+++ b/archivers/libarchive/files/libarchive/test/test_link_resolver.c
@@ -25,40 +25,6 @@
#include "test.h"
__FBSDID("$FreeBSD$");
-static void test_link_resolver_basic(void)
-{
- struct archive_entry *entry;
- struct archive_entry_linkresolver *resolver;
-
- /* Initialize the resolver. */
- assert(NULL != (resolver = archive_entry_linkresolver_new()));
-
- /* Create an entry with only 1 link and try to register it. */
- assert(NULL != (entry = archive_entry_new()));
- archive_entry_set_pathname(entry, "test1");
- archive_entry_set_ino(entry, 1);
- archive_entry_set_dev(entry, 2);
- archive_entry_set_nlink(entry, 1);
-
- /* Shouldn't match anything. */
- assertEqualString(NULL, archive_entry_linkresolve(resolver, entry));
- /* Still shouldn't match anything. */
- assertEqualString(NULL, archive_entry_linkresolve(resolver, entry));
-
- archive_entry_set_nlink(entry, 2);
- archive_entry_set_ino(entry, 2);
- /* Shouldn't match, since we haven't seen it before. */
- assertEqualString(NULL, archive_entry_linkresolve(resolver, entry));
- /* Should match, since we have seen it once before. */
- archive_entry_set_pathname(entry, "test2");
- assertEqualString("test1", archive_entry_linkresolve(resolver, entry));
- /* Should not match, since we've seen both links. */
- assertEqualString(NULL, archive_entry_linkresolve(resolver, entry));
-
- archive_entry_free(entry);
- archive_entry_linkresolver_free(resolver);
-}
-
static void test_linkify_tar(void)
{
struct archive_entry *entry, *e2;
@@ -67,7 +33,7 @@ static void test_linkify_tar(void)
/* Initialize the resolver. */
assert(NULL != (resolver = archive_entry_linkresolver_new()));
archive_entry_linkresolver_set_strategy(resolver,
- ARCHIVE_ENTRY_LINKIFY_LIKE_TAR);
+ ARCHIVE_FORMAT_TAR_USTAR);
/* Create an entry with only 1 link and try to linkify it. */
assert(NULL != (entry = archive_entry_new()));
@@ -114,7 +80,7 @@ static void test_linkify_old_cpio(void)
/* Initialize the resolver. */
assert(NULL != (resolver = archive_entry_linkresolver_new()));
archive_entry_linkresolver_set_strategy(resolver,
- ARCHIVE_ENTRY_LINKIFY_LIKE_OLD_CPIO);
+ ARCHIVE_FORMAT_CPIO_POSIX);
/* Create an entry with 2 link and try to linkify it. */
assert(NULL != (entry = archive_entry_new()));
@@ -149,7 +115,7 @@ static void test_linkify_new_cpio(void)
/* Initialize the resolver. */
assert(NULL != (resolver = archive_entry_linkresolver_new()));
archive_entry_linkresolver_set_strategy(resolver,
- ARCHIVE_ENTRY_LINKIFY_LIKE_NEW_CPIO);
+ ARCHIVE_FORMAT_CPIO_SVR4_NOCRC);
/* Create an entry with only 1 link and try to linkify it. */
assert(NULL != (entry = archive_entry_new()));
@@ -215,7 +181,6 @@ static void test_linkify_new_cpio(void)
DEFINE_TEST(test_link_resolver)
{
- test_link_resolver_basic();
test_linkify_tar();
test_linkify_old_cpio();
test_linkify_new_cpio();
diff --git a/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.c b/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.c
index 770c6e3b136..b11be58a07e 100644
--- a/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.c
+++ b/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_pax_filename_encoding.c,v 1.1 2008/03/15 01:43:59 kientzle Exp $");
#include <locale.h>
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
DEFINE_TEST(test_pax_filename_encoding)
{
+ static const char testname[] = "test_pax_filename_encoding.tar.gz";
char buff[65536];
/*
* \314\214 is a valid 2-byte UTF-8 sequence.
@@ -55,6 +56,34 @@ DEFINE_TEST(test_pax_filename_encoding)
struct archive_entry *entry;
/*
+ * Read an archive that has non-UTF8 pax filenames in it.
+ */
+ extract_reference_file(testname);
+ a = archive_read_new();
+ assertEqualInt(ARCHIVE_OK, archive_read_support_format_tar(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_support_compression_gzip(a));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_open_filename(a, testname, 10240));
+ /*
+ * First entry in this test archive has an invalid UTF-8 sequence
+ * in it, but the header is not marked as hdrcharset=BINARY, so that
+ * requires a warning.
+ */
+ failure("An invalid UTF8 pathname in a pax archive should be read\n"
+ " without conversion but with a warning");
+ assertEqualInt(ARCHIVE_WARN, archive_read_next_header(a, &entry));
+ assertEqualString(filename, archive_entry_pathname(entry));
+ /*
+ * Second entry is identical except that it does have
+ * hdrcharset=BINARY, so no warning should be generated.
+ */
+ failure("A pathname with hdrcharset=BINARY can have invalid UTF8\n"
+ " characters in it without generating a warning");
+ assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &entry));
+ assertEqualString(filename, archive_entry_pathname(entry));
+ archive_read_finish(a);
+
+ /*
* We need a starting locale which has invalid sequences.
* de_DE.UTF-8 seems to be commonly supported.
*/
diff --git a/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.tar.gz.uu b/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.tar.gz.uu
new file mode 100644
index 00000000000..7191aac5849
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.tar.gz.uu
@@ -0,0 +1,10 @@
+begin 644 test_pax_filename_encoding.tar.gz
+M'XL(`)4;VT<``^V6STK#0!#&<\Y3[!/HS/Z-ASVHEQ1$BE[L<4T6$DP32:-$
+MG\%'\Y%Z,*7$UEJLE"91NK_+P.P>OF'X^&9LZM":V):GYCYZ?YOFQ5W]\NH=
+M%`"0G).FHA*P7I>@E`1!22E!`9,$4#"0'JD/*V,[3[/*E(V4*IW^^&_7^W(4
+M\EG_"13)HZD2W6Y_WFS?IT"B9EZKD8(0+)"!6/3,EQZ5/BIR>QF.KB8GL7W6
+M0>!3VC;2O-"<H>#\S,>@[>99FC]H](>>VM'2G>M7[/(_@-CP/V-4>`2Z$K3.
+MD?L_M%E6#"W",1CC;_D_[SW_*;+-_!><N?SO@R;_D[B,$E/.;*4O1M?G-Q/_
+L%T<!1\7V/@IP\<T=!7^![ER_8H_\%PI=_O>!RW^'P^$X3CX`98.>C@`4````
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_ar.c b/archivers/libarchive/files/libarchive/test/test_read_format_ar.c
index 306da6fa1cb..0c01a2bb713 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_ar.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_ar.c
@@ -26,7 +26,7 @@
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_ar.c,v 1.4 2007/07/06 15:43:11 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_ar.c,v 1.5 2008/03/12 21:10:26 kaiw Exp $");
#if ARCHIVE_VERSION_STAMP >= 1009000
/*
@@ -75,9 +75,7 @@ DEFINE_TEST(test_read_format_ar)
assertEqualInt(0, archive_entry_mtime(ae));
assertEqualInt(0, archive_entry_uid(ae));
assertEqualInt(0, archive_entry_gid(ae));
- assertEqualInt(40, archive_entry_size(ae));
- assertEqualIntA(a, 40, archive_read_data(a, buff, 50));
- assert(0 == memcmp(buff, "yyytttsssaaafff.o/\nhhhhjjjjkkkkllll.o/\n\n", 40));
+ assertEqualInt(0, archive_entry_size(ae));
/* First Entry */
assertA(0 == archive_read_next_header(a, &ae));
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c
index ef3c5d25d30..b7efea5b82a 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_gtar_sparse.c,v 1.7 2008/01/01 22:28:04 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_gtar_sparse.c,v 1.8 2008/03/12 05:12:23 kientzle Exp $");
struct contents {
@@ -181,7 +181,6 @@ struct archive_contents {
static void
verify_archive_file(const char *name, struct archive_contents *ac)
{
- char path[512];
struct archive_entry *ae;
int err;
/* data, size, offset of next expected block. */
@@ -190,13 +189,13 @@ verify_archive_file(const char *name, struct archive_contents *ac)
struct contents actual;
struct archive *a;
- sprintf(path, "%s/%s", refdir, name);
+ extract_reference_file(name);
assert((a = archive_read_new()) != NULL);
assert(0 == archive_read_support_compression_all(a));
assert(0 == archive_read_support_format_tar(a));
- failure("Can't open %s", path);
- assert(0 == archive_read_open_filename(a, path, 3));
+ failure("Can't open %s", name);
+ assert(0 == archive_read_open_filename(a, name, 3));
while (ac->filename != NULL) {
struct contents *cts = ac->contents;
diff --git a/archivers/libarchive/files/libarchive/test/test_write_compress.c b/archivers/libarchive/files/libarchive/test/test_write_compress.c
new file mode 100644
index 00000000000..6f8ef3565fe
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_write_compress.c
@@ -0,0 +1,102 @@
+/*-
+ * Copyright (c) 2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "test.h"
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_compress.c,v 1.2 2008/03/15 11:05:49 kientzle Exp $");
+
+/*
+ * A basic exercise of compress reading and writing.
+ *
+ * TODO: Add a reference file and make sure we can decompress that.
+ */
+
+DEFINE_TEST(test_write_compress)
+{
+ struct archive_entry *ae;
+ struct archive* a;
+ char *buff, *data;
+ size_t buffsize, datasize;
+ char path[16];
+ size_t used;
+ int i;
+
+ buffsize = 1000000;
+ assert(NULL != (buff = (char *)malloc(buffsize)));
+
+ datasize = 10000;
+ assert(NULL != (data = (char *)malloc(datasize)));
+ memset(data, 0, datasize);
+
+ assert((a = archive_write_new()) != NULL);
+ assertA(0 == archive_write_set_format_ustar(a));
+ assertA(0 == archive_write_set_compression_compress(a));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used));
+
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, path);
+ archive_entry_set_size(ae, datasize);
+ archive_entry_set_filetype(ae, AE_IFREG);
+ assertA(0 == archive_write_header(a, ae));
+ assertA(datasize == (size_t)archive_write_data(a, data, datasize));
+ archive_entry_free(ae);
+ }
+
+
+ archive_write_close(a);
+#if ARCHIVE_API_VERSION > 1
+ assert(0 == archive_write_finish(a));
+#else
+ archive_write_finish(a);
+#endif
+
+ /*
+ * Now, read the data back.
+ */
+ assert((a = archive_read_new()) != NULL);
+ assertA(0 == archive_read_support_format_all(a));
+ assertA(0 == archive_read_support_compression_all(a));
+ assertA(0 == archive_read_open_memory(a, buff, used));
+
+
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+ assertEqualString(path, archive_entry_pathname(ae));
+ assertEqualInt(datasize, archive_entry_size(ae));
+ }
+
+ assert(0 == archive_read_close(a));
+#if ARCHIVE_API_VERSION > 1
+ assert(0 == archive_read_finish(a));
+#else
+ archive_read_finish(a);
+#endif
+
+ free(data);
+ free(buff);
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_ar.c b/archivers/libarchive/files/libarchive/test/test_write_format_ar.c
index 2de670f68ef..6c7a4462a90 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_format_ar.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_format_ar.c
@@ -26,7 +26,7 @@
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_format_ar.c,v 1.5 2007/07/06 15:43:11 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_format_ar.c,v 1.6 2008/03/12 21:10:26 kaiw Exp $");
char buff[4096];
char buff2[64];
@@ -119,9 +119,7 @@ DEFINE_TEST(test_write_format_ar)
assertA(0 == archive_read_next_header(a, &ae));
assertEqualInt(0, archive_entry_mtime(ae));
assertEqualString("//", archive_entry_pathname(ae));
- assertEqualInt(strlen(strtab), archive_entry_size(ae));
- assertEqualIntA(a, strlen(strtab), archive_read_data(a, buff2, 100));
- assert(0 == memcmp(buff2, strtab, strlen(strtab)));
+ assertEqualInt(0, archive_entry_size(ae));
assertA(0 == archive_read_next_header(a, &ae));
assert(1 == archive_entry_mtime(ae));