PERFORCE change 154401 for review
Anselm Strauss
strauss at FreeBSD.org
Tue Dec 9 08:21:21 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=154401
Change 154401 by strauss at strauss_silversurfer on 2008/12/09 16:20:34
integrated latest changes from libarchive-portable
Affected files ...
.. //depot/projects/soc2008/strauss_libarchive/Makefile.am#13 integrate
.. //depot/projects/soc2008/strauss_libarchive/NEWS#8 integrate
.. //depot/projects/soc2008/strauss_libarchive/configure.ac#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/cpio/Makefile#8 integrate
.. //depot/projects/soc2008/strauss_libarchive/cpio/cmdline.c#9 integrate
.. //depot/projects/soc2008/strauss_libarchive/cpio/config_freebsd.h#7 integrate
.. //depot/projects/soc2008/strauss_libarchive/cpio/cpio.c#10 integrate
.. //depot/projects/soc2008/strauss_libarchive/cpio/cpio.h#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/cpio/cpio_platform.h#7 integrate
.. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_option_t.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/cpio/test/test_option_tv.stdout.uu#3 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/Makefile#8 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive.h#9 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_check_magic.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_endian.h#5 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry.h#7 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_platform.h#10 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_private.h#5 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_private.h#4 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_compression_all.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_compression_bzip2.c#7 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_compression_compress.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_compression_gzip.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_compression_lzma.c#2 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_compression_none.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_compression_program.c#8 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_format_ar.c#7 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_format_cpio.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_format_empty.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_format_iso9660.c#8 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_format_mtree.c#9 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_format_tar.c#9 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_format_zip.c#10 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_string.c#8 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_string.h#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_disk.c#10 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/Makefile#8 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_acl_freebsd.c#2 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_compat_bzip2.c#1 branch
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_compat_bzip2_1.tbz.uu#1 branch
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_compat_bzip2_2.tbz.uu#1 branch
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_compat_gzip.c#1 branch
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_compat_gzip_1.tgz.uu#1 branch
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_compat_gzip_2.tgz.uu#1 branch
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_fuzz.c#1 branch
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_fuzz_1.iso.uu#1 branch
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_format_cpio_bin_bz2.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_format_gtar_sparse.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_read_pax_truncated.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_write_disk_perms.c#7 integrate
.. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_write_format_cpio.c#6 integrate
.. //depot/projects/soc2008/strauss_libarchive/tar/Makefile#8 integrate
.. //depot/projects/soc2008/strauss_libarchive/tar/cmdline.c#2 integrate
.. //depot/projects/soc2008/strauss_libarchive/tar/config_freebsd.h#7 integrate
.. //depot/projects/soc2008/strauss_libarchive/tar/test/Makefile#7 integrate
.. //depot/projects/soc2008/strauss_libarchive/tar/test/test_strip_components.c#1 branch
.. //depot/projects/soc2008/strauss_libarchive/tar/tree.c#5 integrate
.. //depot/projects/soc2008/strauss_libarchive/tar/tree.h#3 integrate
.. //depot/projects/soc2008/strauss_libarchive/tar/util.c#7 integrate
.. //depot/projects/soc2008/strauss_libarchive/tar/write.c#10 integrate
.. //depot/projects/soc2008/strauss_libarchive/version#5 integrate
.. //depot/projects/soc2008/strauss_libarchive/windows/vc90/libarchive.vcproj#2 integrate
Differences ...
==== //depot/projects/soc2008/strauss_libarchive/Makefile.am#13 (text+ko) ====
@@ -182,11 +182,14 @@
libarchive/test/test_acl_pax.c \
libarchive/test/test_archive_api_feature.c \
libarchive/test/test_bad_fd.c \
+ libarchive/test/test_compat_bzip2.c \
libarchive/test/test_compat_gtar.c \
+ libarchive/test/test_compat_gzip.c \
libarchive/test/test_compat_tar_hardlink.c \
libarchive/test/test_compat_zip.c \
libarchive/test/test_empty_write.c \
libarchive/test/test_entry.c \
+ libarchive/test/test_fuzz.c \
libarchive/test/test_entry_strmode.c \
libarchive/test/test_link_resolver.c \
libarchive/test/test_pax_filename_encoding.c \
@@ -255,9 +258,14 @@
libarchive_TESTS_ENVIRONMENT= LIBARCHIVE_TEST_FILES=`cd $(top_srcdir);/bin/pwd`/libarchive/test
libarchive_test_EXTRA_DIST=\
+ libarchive/test/test_compat_bzip2_1.tbz.uu \
+ libarchive/test/test_compat_bzip2_2.tbz.uu \
libarchive/test/test_compat_gtar_1.tgz.uu \
+ libarchive/test/test_compat_gzip_1.tgz.uu \
+ libarchive/test/test_compat_gzip_2.tgz.uu \
libarchive/test/test_compat_tar_hardlink_1.tar.uu \
libarchive/test/test_compat_zip_1.zip.uu \
+ libarchive/test/test_fuzz_1.iso.uu \
libarchive/test/test_pax_filename_encoding.tar.gz.uu \
libarchive/test/test_read_format_gtar_sparse_1_13.tgz.uu \
libarchive/test/test_read_format_gtar_sparse_1_17.tgz.uu \
@@ -329,6 +337,7 @@
tar/test/test_option_T.c \
tar/test/test_patterns.c \
tar/test/test_stdio.c \
+ tar/test/test_strip_components.c \
tar/test/test_symlink_dir.c \
tar/test/test_version.c
==== //depot/projects/soc2008/strauss_libarchive/NEWS#8 (text+ko) ====
@@ -1,3 +1,5 @@
+
+Dec 04, 2008: libarchive 2.5.903a released
Nov 09, 2008: libarchive 2.5.902a released
Nov 08, 2008: libarchive 2.5.901a released
Nov 08, 2008: Start of pre-release testing for libarchive 2.6
==== //depot/projects/soc2008/strauss_libarchive/configure.ac#6 (text+ko) ====
@@ -4,8 +4,8 @@
dnl In particular, this allows the version macro to be used in AC_INIT
dnl These first two version numbers are updated automatically on each release.
-m4_define([LIBARCHIVE_VERSION_S],[2.5.902a])
-m4_define([LIBARCHIVE_VERSION_N],[2005902])
+m4_define([LIBARCHIVE_VERSION_S],[2.5.903a])
+m4_define([LIBARCHIVE_VERSION_N],[2005903])
dnl bsdtar versioning tracks libarchive
m4_define([BSDTAR_VERSION_S],LIBARCHIVE_VERSION_S())
@@ -162,17 +162,37 @@
AC_HEADER_STDC
AC_HEADER_DIRENT
AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([bzlib.h errno.h ext2fs/ext2_fs.h fcntl.h grp.h])
+AC_CHECK_HEADERS([errno.h ext2fs/ext2_fs.h fcntl.h grp.h])
AC_CHECK_HEADERS([inttypes.h langinfo.h limits.h linux/fs.h])
-AC_CHECK_HEADERS([locale.h lzmadec.h paths.h poll.h pwd.h regex.h stdarg.h])
+AC_CHECK_HEADERS([locale.h paths.h poll.h pwd.h regex.h stdarg.h])
AC_CHECK_HEADERS([stdint.h stdlib.h string.h sys/acl.h sys/ioctl.h])
AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/select.h sys/time.h sys/utime.h])
-AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h zlib.h])
+AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h])
# Checks for libraries.
-AC_CHECK_LIB(bz2,BZ2_bzDecompressInit)
-AC_CHECK_LIB(z,inflate)
-AC_CHECK_LIB(lzmadec,lzmadec_decode)
+AC_ARG_WITH([zlib],
+ AS_HELP_STRING([--without-zlib], [Don't build support for gzip through zlib]))
+
+if test "x$with_zlib" != "xno"; then
+ AC_CHECK_HEADERS([zlib.h])
+ AC_CHECK_LIB(z,inflate)
+fi
+
+AC_ARG_WITH([bz2lib],
+ AS_HELP_STRING([--without-bz2lib], [Don't build support for bzip2 through bz2lib]))
+
+if test "x$with_bz2lib" != "xno"; then
+ AC_CHECK_HEADERS([bzlib.h])
+ AC_CHECK_LIB(bz2,BZ2_bzDecompressInit)
+fi
+
+AC_ARG_WITH([lzmadec],
+ AS_HELP_STRING([--without-lzmadec], [Don't build support for lzma through lzmadec]))
+
+if test "x$with_lzmadec" != "xno"; then
+ AC_CHECK_HEADERS([lzmadec.h])
+ AC_CHECK_LIB(lzmadec,lzmadec_decode)
+fi
# TODO: Give the user the option of using a pre-existing system
# libarchive. This will define HAVE_LIBARCHIVE which will cause
==== //depot/projects/soc2008/strauss_libarchive/cpio/Makefile#8 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/usr.bin/cpio/Makefile,v 1.5 2008/07/05 05:17:33 kientzle Exp $
+# $FreeBSD: src/usr.bin/cpio/Makefile,v 1.6 2008/12/06 07:30:40 kientzle Exp $
.include <bsd.own.mk>
==== //depot/projects/soc2008/strauss_libarchive/cpio/cmdline.c#9 (ktext) ====
@@ -26,7 +26,7 @@
#include "cpio_platform.h"
-__FBSDID("$FreeBSD: src/usr.bin/cpio/cmdline.c,v 1.4 2008/07/29 15:23:31 kientzle Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/cpio/cmdline.c,v 1.5 2008/12/06 07:30:40 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
==== //depot/projects/soc2008/strauss_libarchive/cpio/config_freebsd.h#7 (ktext) ====
@@ -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/usr.bin/cpio/config_freebsd.h,v 1.2 2008/07/05 05:15:07 kientzle Exp $
+ * $FreeBSD: src/usr.bin/cpio/config_freebsd.h,v 1.3 2008/12/06 07:30:40 kientzle Exp $
*/
/* A default configuration for FreeBSD, used if there is no config.h. */
==== //depot/projects/soc2008/strauss_libarchive/cpio/cpio.c#10 (ktext) ====
@@ -26,7 +26,7 @@
#include "cpio_platform.h"
-__FBSDID("$FreeBSD: src/usr.bin/cpio/cpio.c,v 1.13 2008/09/04 05:20:46 kientzle Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/cpio/cpio.c,v 1.15 2008/12/06 07:30:40 kientzle Exp $");
#include <sys/types.h>
#include <archive.h>
@@ -41,6 +41,12 @@
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
+#ifdef HAVE_GRP_H
+#include <grp.h>
+#endif
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+#endif
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#endif
@@ -58,11 +64,32 @@
#include "cpio.h"
#include "matching.h"
+/* Fixed size of uname/gname caches. */
+#define name_cache_size 101
+
+struct name_cache {
+ int probes;
+ int hits;
+ size_t size;
+ struct {
+ id_t id;
+ char *name;
+ } cache[name_cache_size];
+};
+
static int copy_data(struct archive *, struct archive *);
static const char *cpio_rename(const char *name);
static int entry_to_archive(struct cpio *, struct archive_entry *);
static int file_to_archive(struct cpio *, const char *);
+static void free_cache(struct name_cache *cache);
+static void list_item_verbose(struct cpio *, struct archive_entry *);
static void long_help(void);
+static const char *lookup_gname(struct cpio *, gid_t gid);
+static int lookup_gname_helper(struct cpio *,
+ const char **name, id_t gid);
+static const char *lookup_uname(struct cpio *, uid_t uid);
+static int lookup_uname_helper(struct cpio *,
+ const char **name, id_t uid);
static void mode_in(struct cpio *);
static void mode_list(struct cpio *);
static void mode_out(struct cpio *);
@@ -268,6 +295,8 @@
"Must specify at least one of -i, -o, or -p");
}
+ free_cache(cpio->gname_cache);
+ free_cache(cpio->uname_cache);
return (0);
}
@@ -798,18 +827,9 @@
}
if (excluded(cpio, archive_entry_pathname(entry)))
continue;
- if (cpio->verbose) {
- /* TODO: uname/gname lookups */
- /* TODO: Clean this up. */
- fprintf(stdout,
- "%s%3d %8s%8s " CPIO_FILESIZE_PRINTF " %s\n",
- archive_entry_strmode(entry),
- archive_entry_nlink(entry),
- archive_entry_uname(entry),
- archive_entry_gname(entry),
- (CPIO_FILESIZE_TYPE)archive_entry_size(entry),
- archive_entry_pathname(entry));
- } else
+ if (cpio->verbose)
+ list_item_verbose(cpio, entry);
+ else
fprintf(stdout, "%s\n", archive_entry_pathname(entry));
}
r = archive_read_close(a);
@@ -825,7 +845,74 @@
exit(0);
}
+/*
+ * Display information about the current file.
+ *
+ * The format here roughly duplicates the output of 'ls -l'.
+ * This is based on SUSv2, where 'tar tv' is documented as
+ * listing additional information in an "unspecified format,"
+ * and 'pax -l' is documented as using the same format as 'ls -l'.
+ */
static void
+list_item_verbose(struct cpio *cpio, struct archive_entry *entry)
+{
+ char size[32];
+ char date[32];
+ const char *uname, *gname;
+ FILE *out = stdout;
+ const struct stat *st;
+ const char *fmt;
+ time_t tim;
+ static time_t now;
+
+ st = archive_entry_stat(entry);
+
+ if (!now)
+ time(&now);
+
+ /* Use uname if it's present, else uid. */
+ uname = archive_entry_uname(entry);
+ if (uname == NULL)
+ uname = lookup_uname(cpio, archive_entry_uid(entry));
+
+ /* Use gname if it's present, else gid. */
+ gname = archive_entry_gname(entry);
+ if (gname == NULL)
+ gname = lookup_gname(cpio, archive_entry_gid(entry));
+
+ /* Print device number or file size. */
+ if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode)) {
+ snprintf(size, sizeof(size), "%lu,%lu",
+ (unsigned long)major(st->st_rdev),
+ (unsigned long)minor(st->st_rdev)); /* ls(1) also casts here. */
+ } else {
+ snprintf(size, sizeof(size), CPIO_FILESIZE_PRINTF,
+ (CPIO_FILESIZE_TYPE)st->st_size);
+ }
+
+ /* Format the time using 'ls -l' conventions. */
+ tim = (time_t)st->st_mtime;
+ if (abs(tim - now) > (365/2)*86400)
+ fmt = cpio->day_first ? "%e %b %Y" : "%b %e %Y";
+ else
+ fmt = cpio->day_first ? "%e %b %H:%M" : "%b %e %H:%M";
+ strftime(date, sizeof(date), fmt, localtime(&tim));
+
+ fprintf(out, "%s%3d %-8s %-8s %8s %12s %s",
+ archive_entry_strmode(entry),
+ archive_entry_nlink(entry),
+ uname, gname, size, date,
+ archive_entry_pathname(entry));
+
+ /* Extra information for links. */
+ if (archive_entry_hardlink(entry)) /* Hard link */
+ fprintf(out, " link to %s", archive_entry_hardlink(entry));
+ else if (archive_entry_symlink(entry)) /* Symbolic link */
+ fprintf(out, " -> %s", archive_entry_symlink(entry));
+ fprintf(out, "\n");
+}
+
+static void
mode_pass(struct cpio *cpio, const char *destdir)
{
unsigned long blocks;
@@ -1033,3 +1120,123 @@
free(lr->pathname);
free(lr);
}
+
+static void
+free_cache(struct name_cache *cache)
+{
+ size_t i;
+
+ if (cache != NULL) {
+ for (i = 0; i < cache->size; i++)
+ free(cache->cache[i].name);
+ free(cache);
+ }
+}
+
+/*
+ * Lookup uname/gname from uid/gid, return NULL if no match.
+ */
+static const char *
+lookup_name(struct cpio *cpio, struct name_cache **name_cache_variable,
+ int (*lookup_fn)(struct cpio *, const char **, id_t), id_t id)
+{
+ char asnum[16];
+ struct name_cache *cache;
+ const char *name;
+ int slot;
+
+
+ if (*name_cache_variable == NULL) {
+ *name_cache_variable = malloc(sizeof(struct name_cache));
+ if (*name_cache_variable == NULL)
+ cpio_errc(1, ENOMEM, "No more memory");
+ memset(*name_cache_variable, 0, sizeof(struct name_cache));
+ (*name_cache_variable)->size = name_cache_size;
+ }
+
+ cache = *name_cache_variable;
+ cache->probes++;
+
+ slot = id % cache->size;
+ if (cache->cache[slot].name != NULL) {
+ if (cache->cache[slot].id == id) {
+ cache->hits++;
+ return (cache->cache[slot].name);
+ }
+ free(cache->cache[slot].name);
+ cache->cache[slot].name = NULL;
+ }
+
+ if (lookup_fn(cpio, &name, id) == 0) {
+ if (name == NULL || name[0] == '\0') {
+ /* If lookup failed, format it as a number. */
+ snprintf(asnum, sizeof(asnum), "%u", (unsigned)id);
+ name = asnum;
+ }
+ cache->cache[slot].name = strdup(name);
+ if (cache->cache[slot].name != NULL) {
+ cache->cache[slot].id = id;
+ return (cache->cache[slot].name);
+ }
+ /*
+ * Conveniently, NULL marks an empty slot, so
+ * if the strdup() fails, we've just failed to
+ * cache it. No recovery necessary.
+ */
+ }
+ return (NULL);
+}
+
+static const char *
+lookup_uname(struct cpio *cpio, uid_t uid)
+{
+ return (lookup_name(cpio, &cpio->uname_cache,
+ &lookup_uname_helper, (id_t)uid));
+}
+
+static int
+lookup_uname_helper(struct cpio *cpio, const char **name, id_t id)
+{
+ struct passwd *pwent;
+
+ (void)cpio; /* UNUSED */
+
+ errno = 0;
+ pwent = getpwuid((uid_t)id);
+ if (pwent == NULL) {
+ *name = NULL;
+ if (errno != 0)
+ cpio_warnc(errno, "getpwuid(%d) failed", id);
+ return (errno);
+ }
+
+ *name = pwent->pw_name;
+ return (0);
+}
+
+static const char *
+lookup_gname(struct cpio *cpio, gid_t gid)
+{
+ return (lookup_name(cpio, &cpio->gname_cache,
+ &lookup_gname_helper, (id_t)gid));
+}
+
+static int
+lookup_gname_helper(struct cpio *cpio, const char **name, id_t id)
+{
+ struct group *grent;
+
+ (void)cpio; /* UNUSED */
+
+ errno = 0;
+ grent = getgrgid((gid_t)id);
+ if (grent == NULL) {
+ *name = NULL;
+ if (errno != 0)
+ cpio_warnc(errno, "getgrgid(%d) failed", id);
+ return (errno);
+ }
+
+ *name = grent->gr_name;
+ return (0);
+}
==== //depot/projects/soc2008/strauss_libarchive/cpio/cpio.h#6 (text+ko) ====
@@ -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/usr.bin/cpio/cpio.h,v 1.4 2008/08/04 01:25:48 cperciva Exp $
+ * $FreeBSD: src/usr.bin/cpio/cpio.h,v 1.7 2008/12/06 07:30:40 kientzle Exp $
*/
#ifndef CPIO_H_INCLUDED
@@ -68,6 +68,7 @@
char *pass_destpath;
int uid_override;
int gid_override;
+ int day_first; /* true if locale prefers day/mon */
/* If >= 0, then close this when done. */
int fd;
@@ -79,6 +80,9 @@
int return_value; /* Value returned by main() */
struct archive_entry_linkresolver *linkresolver;
+ struct name_cache *uname_cache;
+ struct name_cache *gname_cache;
+
/* Work data. */
struct matching *matching;
char *buff;
==== //depot/projects/soc2008/strauss_libarchive/cpio/cpio_platform.h#7 (ktext) ====
@@ -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$
+ * $FreeBSD: src/usr.bin/cpio/cpio_platform.h,v 1.2 2008/12/06 07:15:42 kientzle Exp $
*/
/*
==== //depot/projects/soc2008/strauss_libarchive/cpio/test/test_option_t.c#6 (ktext) ====
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$Id$ $Change: 142961 $ $DateTime$ $Author$");
+__FBSDID("$FreeBSD$");
DEFINE_TEST(test_option_t)
@@ -43,5 +43,9 @@
assertEqualInt(r, 0);
assertFileContents("1 block\n", 8, "tv.err");
extract_reference_file("test_option_tv.stdout");
- assertEqualFile("tv.out", "test_option_tv.stdout");
+
+ /* This doesn't work because the usernames on different systems
+ * are different and cpio now looks up numeric UIDs on
+ * the local system. */
+ /* assertEqualFile("tv.out", "test_option_tv.stdout"); */
}
==== //depot/projects/soc2008/strauss_libarchive/cpio/test/test_option_tv.stdout.uu#3 (text+ko) ====
@@ -1,5 +1,6 @@
-$FreeBSD$
+$FreeBSD: src/usr.bin/cpio/test/test_option_tv.stdout.uu,v 1.2 2008/11/29 20:22:02 kientzle Exp $
begin 644 test_option_tv.stdout
-G+7)W+7(M+7(M+2`@(#$@("`H;G5L;"D@("AN=6QL*2`P(&9I;&4*
+M+7)W+7(M+7(M+2`@(#$@=&EM("`@("`@=&EM("`@("`@("`@("`@(#`@1&5C
+/(#,Q("`Q.38Y(&9I;&4*
`
end
==== //depot/projects/soc2008/strauss_libarchive/libarchive/Makefile#8 (text+ko) ====
@@ -16,9 +16,6 @@
# Headers to be installed in /usr/include
INCS= archive.h archive_entry.h
-# TODO: LZMA reader needs to be converted to the new filter architecture...
-# archive_read_support_compression_lzma.c \
-
# Sources to be compiled.
SRCS= archive_check_magic.c \
archive_entry.c \
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive.h#9 (ktext) ====
@@ -113,13 +113,13 @@
* (ARCHIVE_API_VERSION * 1000000 + ARCHIVE_API_FEATURE * 1000)
* #endif
*/
-#define ARCHIVE_VERSION_NUMBER 2005902
+#define ARCHIVE_VERSION_NUMBER 2005903
__LA_DECL int archive_version_number(void);
/*
* Textual name/version of the library, useful for version displays.
*/
-#define ARCHIVE_VERSION_STRING "libarchive 2.5.902a"
+#define ARCHIVE_VERSION_STRING "libarchive 2.5.903a"
__LA_DECL const char * archive_version_string(void);
#if ARCHIVE_VERSION_NUMBER < 3000000
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_check_magic.c#6 (ktext) ====
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_check_magic.c,v 1.8 2007/04/02 00:15:45 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_check_magic.c,v 1.9 2008/12/06 05:52:01 kientzle Exp $");
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_endian.h#5 (ktext) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/archive_endian.h,v 1.3 2008/05/26 17:00:22 kientzle Exp $
+ * $FreeBSD: src/lib/libarchive/archive_endian.h,v 1.4 2008/12/06 06:12:24 kientzle Exp $
*
* Borrowed from FreeBSD's <sys/endian.h>
*/
@@ -41,8 +41,10 @@
* - SGI MIPSpro
* - Microsoft Visual C++ 6.0 (supposedly newer versions too)
*/
-#if defined(__WATCOMC__) || defined(__sgi) || defined(_MSC_VER)
+#if defined(__WATCOMC__) || defined(__sgi)
#define inline
+#elif defined(_MSC_VER)
+#define inline __inline
#endif
/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_entry.h#7 (ktext) ====
@@ -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.30 2008/09/30 03:53:03 kientzle Exp $
+ * $FreeBSD: src/lib/libarchive/archive_entry.h,v 1.31 2008/12/06 06:18:46 kientzle Exp $
*/
#ifndef ARCHIVE_ENTRY_H_INCLUDED
@@ -441,7 +441,7 @@
* Note that archive_entry_size() is reset to zero if the file
* body should not be written to the archive. Pay attention!
*/
-__LA_DECL struct archive_entry_linkresolver;
+struct archive_entry_linkresolver;
/*
* There are three different strategies for marking hardlinks.
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_platform.h#10 (ktext) ====
@@ -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_platform.h,v 1.31 2008/09/12 04:03:34 kientzle Exp $
+ * $FreeBSD: src/lib/libarchive/archive_platform.h,v 1.32 2008/12/06 05:53:05 kientzle Exp $
*/
/*
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_private.h#5 (ktext) ====
@@ -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_private.h,v 1.30 2008/08/04 01:25:48 cperciva Exp $
+ * $FreeBSD: src/lib/libarchive/archive_private.h,v 1.32 2008/12/06 06:23:37 kientzle Exp $
*/
#ifndef ARCHIVE_PRIVATE_H_INCLUDED
@@ -40,13 +40,13 @@
#define ARCHIVE_WRITE_MAGIC (0xb0c5c0deU)
#define ARCHIVE_READ_MAGIC (0xdeb0c5U)
-#define ARCHIVE_WRITE_DISK_MAGIC (0xc001b0c5U)
+#define ARCHIVE_WRITE_DISK_MAGIC (0xc001b0c5U)
#define ARCHIVE_STATE_ANY 0xFFFFU
#define ARCHIVE_STATE_NEW 1U
#define ARCHIVE_STATE_HEADER 2U
#define ARCHIVE_STATE_DATA 4U
-#define ARCHIVE_STATE_DATA_END 8U
+#define ARCHIVE_STATE_DATA_END 8U
#define ARCHIVE_STATE_EOF 0x10U
#define ARCHIVE_STATE_CLOSED 0x20U
#define ARCHIVE_STATE_FATAL 0x8000U
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read.c#6 (ktext) ====
@@ -32,7 +32,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read.c,v 1.38 2008/03/12 04:58:32 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read.c,v 1.39 2008/12/06 06:45:15 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -793,7 +793,8 @@
size_t tocopy;
if (a->fatal) {
- *avail = ARCHIVE_FATAL;
+ if (avail)
+ *avail = ARCHIVE_FATAL;
return (NULL);
}
@@ -861,10 +862,7 @@
/* Return whatever we do have. */
if (avail != NULL)
*avail = a->avail;
- return (a->next);
- /* TODO: I want to change this to
- * return(0) as an eof marker, but a little
- * more work is needed first. */
+ return (NULL);
}
a->archive.raw_position += bytes_read;
a->client_total = bytes_read;
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_private.h#4 (ktext) ====
@@ -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.6 2008/03/15 11:09:16 kientzle Exp $
+ * $FreeBSD: src/lib/libarchive/archive_read_private.h,v 1.7 2008/12/06 06:45:15 kientzle Exp $
*/
#ifndef ARCHIVE_READ_PRIVATE_H_INCLUDED
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_compression_all.c#6 (ktext) ====
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_all.c,v 1.6 2007/01/09 08:05:55 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_all.c,v 1.7 2008/12/06 06:45:15 kientzle Exp $");
#include "archive.h"
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_compression_bzip2.c#7 (ktext) ====
@@ -25,7 +25,7 @@
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_bzip2.c,v 1.18 2008/05/26 17:00:22 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_bzip2.c,v 1.19 2008/12/06 06:45:15 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -53,7 +53,7 @@
bz_stream stream;
char *out_block;
size_t out_block_size;
- int64_t total_out;
+ char valid; /* True = decompressor is initialized */
char eof; /* True = found end of compressed data. */
};
@@ -200,7 +200,6 @@
void *out_block;
struct archive_read_source *self;
struct private_data *state;
- int ret;
(void)reader; /* UNUSED */
@@ -242,49 +241,7 @@
state->stream.next_out = state->out_block;
state->stream.avail_out = state->out_block_size;
- /* Initialize compression library. */
- ret = BZ2_bzDecompressInit(&(state->stream),
- 0 /* library verbosity */,
- 0 /* don't use slow low-mem algorithm */);
-
- /* If init fails, try using low-memory algorithm instead. */
- if (ret == BZ_MEM_ERROR) {
- ret = BZ2_bzDecompressInit(&(state->stream),
- 0 /* library verbosity */,
- 1 /* do use slow low-mem algorithm */);
- }
-
- if (ret == BZ_OK)
- return (self);
-
- /* Library setup failed: Clean up. */
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Internal error initializing %s library",
- a->archive.compression_name);
-
- /* Override the error message if we know what really went wrong. */
- switch (ret) {
- case BZ_PARAM_ERROR:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Internal error initializing compression library: "
- "invalid setup parameter");
- break;
- case BZ_MEM_ERROR:
- archive_set_error(&a->archive, ENOMEM,
- "Internal error initializing compression library: "
- "out of memory");
- break;
- case BZ_CONFIG_ERROR:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Internal error initializing compression library: "
- "mis-compiled library");
- break;
- }
-
- free(state->out_block);
- free(state);
- free(self);
- return (NULL);
+ return (self);
}
/*
@@ -301,6 +258,11 @@
state = (struct private_data *)self->data;
read_avail = 0;
+ if (state->eof) {
+ *p = NULL;
+ return (0);
+ }
+
/* Empty our output buffer. */
state->stream.next_out = state->out_block;
state->stream.avail_out = state->out_block_size;
@@ -319,39 +281,85 @@
return (ARCHIVE_FATAL);
/* There is no more data, return whatever we have. */
if (ret == 0) {
+ state->eof = 1;
*p = state->out_block;
decompressed = state->stream.next_out
- state->out_block;
- state->total_out += decompressed;
return (decompressed);
}
state->stream.avail_in = ret;
}
+ if (!state->valid) {
+ if (state->stream.next_in[0] != 'B') {
+ state->eof = 1;
+ *p = state->out_block;
+ decompressed = state->stream.next_out
+ - state->out_block;
+ return (decompressed);
+ }
+ /* Initialize compression library. */
+ ret = BZ2_bzDecompressInit(&(state->stream),
+ 0 /* library verbosity */,
+ 0 /* don't use low-mem algorithm */);
+
+ /* If init fails, try low-memory algorithm instead. */
+ if (ret == BZ_MEM_ERROR)
+ ret = BZ2_bzDecompressInit(&(state->stream),
+ 0 /* library verbosity */,
+ 1 /* do use low-mem algo */);
+
+ if (ret != BZ_OK) {
+ const char *detail = NULL;
+ int err = ARCHIVE_ERRNO_MISC;
+ switch (ret) {
+ case BZ_PARAM_ERROR:
+ detail = "invalid setup parameter";
+ break;
+ case BZ_MEM_ERROR:
+ err = ENOMEM;
+ detail = "out of memory";
+ break;
+ case BZ_CONFIG_ERROR:
+ detail = "mis-compiled library";
+ break;
+ }
+ archive_set_error(&self->archive->archive, err,
+ "Internal error initializing decompressor%s%s",
+ detail == NULL ? "" : ": ",
+ detail);
+ return (ARCHIVE_FATAL);
+ }
+ state->valid = 1;
+ }
+
/* Decompress as much as we can in one pass. */
ret = BZ2_bzDecompress(&(state->stream));
switch (ret) {
case BZ_STREAM_END: /* Found end of stream. */
- /* TODO: Peek ahead to see if there's another
- * stream so we can mimic the behavior of gunzip
- * on concatenated streams. */
- state->eof = 1;
+ switch (BZ2_bzDecompressEnd(&(state->stream))) {
+ case BZ_OK:
+ break;
+ default:
+ archive_set_error(&(self->archive->archive),
+ ARCHIVE_ERRNO_MISC,
+ "Failed to clean up decompressor");
+ return (ARCHIVE_FATAL);
+ }
+ state->valid = 0;
+ /* FALLTHROUGH */
case BZ_OK: /* Decompressor made some progress. */
/* If we filled our buffer, update stats and return. */
- if (state->eof || state->stream.avail_out == 0) {
+ if (state->stream.avail_out == 0) {
*p = state->out_block;
decompressed = state->stream.next_out
- state->out_block;
- state->total_out += decompressed;
return (decompressed);
}
break;
- default:
- /* Return an error. */
+ default: /* Return an error. */
archive_set_error(&self->archive->archive,
- ARCHIVE_ERRNO_MISC,
- "%s decompression failed",
- self->archive->archive.compression_name);
+ ARCHIVE_ERRNO_MISC, "bzip decompression failed");
return (ARCHIVE_FATAL);
}
}
@@ -364,25 +372,26 @@
bzip2_source_close(struct archive_read_source *self)
{
struct private_data *state;
- int ret;
+ int ret = ARCHIVE_OK;
state = (struct private_data *)self->data;
- ret = ARCHIVE_OK;
- switch (BZ2_bzDecompressEnd(&(state->stream))) {
- case BZ_OK:
- break;
- default:
- archive_set_error(&(self->archive->archive),
- ARCHIVE_ERRNO_MISC,
- "Failed to clean up %s compressor",
- self->archive->archive.compression_name);
- ret = ARCHIVE_FATAL;
+
+ if (state->valid) {
+ switch (BZ2_bzDecompressEnd(&state->stream)) {
+ case BZ_OK:
+ break;
+ default:
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Failed to clean up decompressor");
+ ret = ARCHIVE_FATAL;
+ }
}
free(state->out_block);
free(state);
free(self);
- return (ret);
+ return (ARCHIVE_OK);
}
#endif /* HAVE_BZLIB_H */
==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_read_support_compression_compress.c#6 (ktext) ====
@@ -64,7 +64,7 @@
#include "archive_platform.h"
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list