From a44e961d8cc1ddd1b5814fe1a0897f440c13f579 Mon Sep 17 00:00:00 2001 From: Peter Avalos Date: Mon, 24 Sep 2007 02:40:39 +0000 Subject: [PATCH] Import libarchive-2.3.2. --- contrib/libarchive-2/NEWS | 17 +- contrib/libarchive-2/libarchive/archive.h.in | 54 ++--- .../libarchive-2/libarchive/archive_entry.c | 23 +- .../libarchive-2/libarchive/archive_entry.h | 34 ++- .../libarchive/archive_entry_link_resolver.c | 222 ++++++++++++++++++ .../libarchive/archive_entry_private.h | 2 + .../libarchive/archive_entry_strmode.c | 83 +++++++ .../libarchive/archive_platform.h | 2 +- .../libarchive-2/libarchive/archive_read.3 | 4 +- .../libarchive-2/libarchive/archive_util.c | 2 +- .../libarchive/archive_write_disk.c | 15 +- .../libarchive/archive_write_set_format_pax.c | 13 +- .../archive_write_set_format_ustar.c | 13 +- contrib/libarchive-2/libarchive/filter_fork.c | 2 + contrib/libarchive-2/tar/bsdtar.c | 11 +- contrib/libarchive-2/tar/bsdtar.h | 1 - contrib/libarchive-2/tar/read.c | 5 +- contrib/libarchive-2/tar/util.c | 50 ---- contrib/libarchive-2/version | 2 +- 19 files changed, 436 insertions(+), 119 deletions(-) create mode 100644 contrib/libarchive-2/libarchive/archive_entry_link_resolver.c create mode 100644 contrib/libarchive-2/libarchive/archive_entry_strmode.c diff --git a/contrib/libarchive-2/NEWS b/contrib/libarchive-2/NEWS index 9f621a9d08..b967b76054 100644 --- a/contrib/libarchive-2/NEWS +++ b/contrib/libarchive-2/NEWS @@ -1,4 +1,19 @@ +Sep 20, 2007: libarchive 2.3.2 released +Sep 20, 2007: libarchive 2.3.1 broke bsdtar because the archive_write_data() + fix was implemented incorrectly. + +Sep 16, 2007: libarchive 2.3.1 released +Sep 16, 2007: Many fixes to bsdcpio 0.3: handle hardlinks with -p, recognize + block size on writing, fix a couple of segfaults. +Sep 16, 2007: Fixed return value from archive_write_data() when used + with archive_write_disk() to match the documentation and other + instances of this same function. +Sep 15, 2007: Add archive_entry_link_resolver, archive_entry_strmode + +Sep 11, 2007: libarchive 2.2.8 released +Sep 09, 2007: bsdcpio 0.2 supports most (not yet all) of the old POSIX spec. + Sep 01, 2007: libarchive 2.2.7 released Aug 31, 2007: Support for reading mtree files, including an mtree.5 manpage (A little experimental still.) @@ -7,10 +22,8 @@ Aug 13, 2007: Refined suid/sgid restore handling; it is no longer an error if suid/sgid bits are dropped when you request perm restore but don't request owner restore. Aug 06, 2007: Use --enable-bsdcpio if you want to try bsdcpio - (Still very incomplete!) Aug 05, 2007: libarchive 2.2.6 released - Aug 05, 2007: New configure option --disable-bsdtar, thanks to Joerg Sonnenberger. Aug 05, 2007: Several bug fixes from FreeBSD CVS repo. diff --git a/contrib/libarchive-2/libarchive/archive.h.in b/contrib/libarchive-2/libarchive/archive.h.in index eb374437d1..e21a7105e7 100644 --- a/contrib/libarchive-2/libarchive/archive.h.in +++ b/contrib/libarchive-2/libarchive/archive.h.in @@ -60,39 +60,9 @@ extern "C" { /* * Textual name/version of the library, useful for version displays. */ -#define ARCHIVE_LIBRARY_VERSION "libarchive @ARCHIVE_VERSION@" +#define ARCHIVE_LIBRARY_VERSION "libarchive @LIBARCHIVE_VERSION_STRING@" const char * archive_version(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. - */ -#define ARCHIVE_API_VERSION @ARCHIVE_API_MAJOR@ -int archive_api_version(void); - -/* - * Minor version number: ARCHIVE_API_FEATURE is incremented with each - * significant feature addition, so you can test (at compile or run - * time) if a particular feature is implemented. It's no big deal if - * ARCHIVE_API_FEATURE != archive_api_feature(), as long as both are - * high enough to include the features you're relying on. Specific - * values of FEATURE are documented here: - * - * 1 - Version tests are available. - * 2 - archive_{read,write}_close available separately from _finish. - * 3 - open_memory, open_memory2, open_FILE, open_fd available - * 5 - archive_write_disk interface available - * - * Unfortunately, this count resets whenever ARCHIVE_API_VERSION changes, - * making it awkward to use in practice. For that reason, it is deprecated - * in favor of the more-accurate version stamp below. It will eventually - * be removed. - */ -#define ARCHIVE_API_FEATURE @ARCHIVE_API_MINOR@ -int archive_api_feature(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 @@ -102,16 +72,34 @@ int archive_api_feature(void); * 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: + * libarchive versions (which defined API_VERSION and API_FEATURE): * * #ifndef ARCHIVE_VERSION_STAMP * #define ARCHIVE_VERSION_STAMP \ * (ARCHIVE_API_VERSION * 1000000 + ARCHIVE_API_FEATURE * 1000) * #endif */ -#define ARCHIVE_VERSION_STAMP @ARCHIVE_VERSION_STAMP@ +#define ARCHIVE_VERSION_STAMP @LIBARCHIVE_VERSION@ int archive_version_stamp(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. + */ +#define ARCHIVE_API_VERSION (ARCHIVE_VERSION_STAMP / 1000000) +int archive_api_version(void); + +/* + * Minor version number. This is deprecated and will be removed. + * Use ARCHIVE_VERSION_STAMP to adapt to libarchive API variations. + */ +#define ARCHIVE_API_FEATURE ((ARCHIVE_VERSION_STAMP / 1000) % 1000) +int archive_api_feature(void); + #define ARCHIVE_BYTES_PER_RECORD 512 #define ARCHIVE_DEFAULT_BYTES_PER_BLOCK 10240 diff --git a/contrib/libarchive-2/libarchive/archive_entry.c b/contrib/libarchive-2/libarchive/archive_entry.c index 6b83abb4fb..5c78c92f11 100644 --- a/contrib/libarchive-2/libarchive/archive_entry.c +++ b/contrib/libarchive-2/libarchive/archive_entry.c @@ -34,9 +34,6 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_entry.c,v 1.44 2007/07/15 19:10:3 #endif #ifdef MAJOR_IN_MKDEV #include -# if !defined makedev && (defined mkdev || defined _WIN32 || defined __WIN32__) -# define makedev mkdev -# endif #else #ifdef MAJOR_IN_SYSMACROS #include @@ -74,6 +71,22 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_entry.c,v 1.44 2007/07/15 19:10:3 #undef max #define max(a, b) ((a)>(b)?(a):(b)) +/* Play games to come up with a suitable makedev() definition. */ +#ifdef __QNXNTO__ +/* QNX. */ +#include +#define ae_makedev(maj, min) makedev(ND_LOCAL_NODE, (maj), (min)) +#elif defined makedev +/* There's a "makedev" macro. */ +#define ae_makedev(maj, min) makedev((maj), (min)) +#elif defined mkdev || defined _WIN32 || defined __WIN32__ +/* Windows. */ +#define ae_makedev(maj, min) mkdev((maj), (min)) +#else +/* There's a "makedev" function. */ +#define ae_makedev(maj, min) makedev((maj), (min)) +#endif + static void aes_clean(struct aes *); static void aes_copy(struct aes *dest, struct aes *src); static const char * aes_get_mbs(struct aes *); @@ -402,7 +415,7 @@ dev_t archive_entry_dev(struct archive_entry *entry) { if (entry->ae_stat.aest_dev_is_broken_down) - return makedev(entry->ae_stat.aest_devmajor, + return ae_makedev(entry->ae_stat.aest_devmajor, entry->ae_stat.aest_devminor); else return (entry->ae_stat.aest_dev); @@ -548,7 +561,7 @@ dev_t archive_entry_rdev(struct archive_entry *entry) { if (entry->ae_stat.aest_rdev_is_broken_down) - return makedev(entry->ae_stat.aest_rdevmajor, + return ae_makedev(entry->ae_stat.aest_rdevmajor, entry->ae_stat.aest_rdevminor); else return (entry->ae_stat.aest_rdev); diff --git a/contrib/libarchive-2/libarchive/archive_entry.h b/contrib/libarchive-2/libarchive/archive_entry.h index 95fe8c61c7..33c5649a9f 100644 --- a/contrib/libarchive-2/libarchive/archive_entry.h +++ b/contrib/libarchive-2/libarchive/archive_entry.h @@ -62,6 +62,7 @@ struct archive_entry; #define AE_IFMT 0170000 #define AE_IFREG 0100000 #define AE_IFLNK 0120000 +#define AE_IFSOCK 0140000 #define AE_IFCHR 0020000 #define AE_IFBLK 0060000 #define AE_IFDIR 0040000 @@ -108,6 +109,7 @@ dev_t archive_entry_rdev(struct archive_entry *); dev_t archive_entry_rdevmajor(struct archive_entry *); dev_t archive_entry_rdevminor(struct archive_entry *); int64_t archive_entry_size(struct archive_entry *); +const char *archive_entry_strmode(struct archive_entry *); const char *archive_entry_symlink(struct archive_entry *); const wchar_t *archive_entry_symlink_w(struct archive_entry *); uid_t archive_entry_uid(struct archive_entry *); @@ -261,11 +263,6 @@ int archive_entry_acl_count(struct archive_entry *, int want_type); int __archive_entry_acl_parse_w(struct archive_entry *, const wchar_t *, int type); - -#ifdef __cplusplus -} -#endif - /* * extended attributes */ @@ -284,5 +281,32 @@ int archive_entry_xattr_reset(struct archive_entry *); int archive_entry_xattr_next(struct archive_entry *, const char **name, const void **value, size_t *); +/* + * Utility to detect hardlinks. + * + * The 'struct archive_hardlink_lookup' is a cache of entry + * names and dev/ino numbers. Here's how to use it: + * 1. Create a lookup object with archive_hardlink_lookup_new() + * 2. Hand each archive_entry to archive_hardlink_lookup(). + * That function will return NULL (this is not a hardlink to + * a previous entry) or the pathname of the first entry + * that matched this. + * 3. Use archive_hardlink_lookup_free() to release the cache. + * + * To make things more efficient, be sure that each entry has a valid + * nlinks value. The hardlink cache uses this to track when all links + * have been found. If the nlinks value is zero, it will keep every + * name in the cache indefinitely, which can use a lot of memory. + */ +struct archive_entry_linkresolver; + +struct archive_entry_linkresolver *archive_entry_linkresolver_new(void); +void archive_entry_linkresolver_free(struct archive_entry_linkresolver *); +const char *archive_entry_linkresolve(struct archive_entry_linkresolver *, + struct archive_entry *); + +#ifdef __cplusplus +} +#endif #endif /* !ARCHIVE_ENTRY_H_INCLUDED */ diff --git a/contrib/libarchive-2/libarchive/archive_entry_link_resolver.c b/contrib/libarchive-2/libarchive/archive_entry_link_resolver.c new file mode 100644 index 0000000000..0f07e068e0 --- /dev/null +++ b/contrib/libarchive-2/libarchive/archive_entry_link_resolver.c @@ -0,0 +1,222 @@ +/*- + * Copyright (c) 2003-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. + * 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 "archive_platform.h" +__FBSDID("$FreeBSD$"); + +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_ERRNO_H +#include +#endif +#include +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif + +#include "archive_entry.h" + +/* Initial size of link cache. */ +#define links_cache_initial_size 1024 + +struct archive_entry_linkresolver { + char *last_name; + unsigned long number_entries; + size_t number_buckets; + struct links_entry **buckets; +}; + +struct links_entry { + struct links_entry *next; + struct links_entry *previous; + int links; + dev_t dev; + ino_t ino; + char *name; +}; + +struct archive_entry_linkresolver * +archive_entry_linkresolver_new(void) +{ + struct archive_entry_linkresolver *links_cache; + size_t i; + + links_cache = malloc(sizeof(struct archive_entry_linkresolver)); + if (links_cache == NULL) + return (NULL); + memset(links_cache, 0, sizeof(struct archive_entry_linkresolver)); + links_cache->number_buckets = links_cache_initial_size; + links_cache->buckets = malloc(links_cache->number_buckets * + sizeof(links_cache->buckets[0])); + if (links_cache->buckets == NULL) { + free(links_cache); + return (NULL); + } + for (i = 0; i < links_cache->number_buckets; i++) + links_cache->buckets[i] = NULL; + return (links_cache); +} + +void +archive_entry_linkresolver_free(struct archive_entry_linkresolver *links_cache) +{ + size_t i; + + if (links_cache->buckets == NULL) + return; + + for (i = 0; i < links_cache->number_buckets; i++) { + while (links_cache->buckets[i] != NULL) { + struct links_entry *lp = links_cache->buckets[i]->next; + if (links_cache->buckets[i]->name != NULL) + free(links_cache->buckets[i]->name); + free(links_cache->buckets[i]); + links_cache->buckets[i] = lp; + } + } + free(links_cache->buckets); + links_cache->buckets = NULL; +} + +const char * +archive_entry_linkresolve(struct archive_entry_linkresolver *links_cache, + struct archive_entry *entry) +{ + struct links_entry *le, **new_buckets; + int hash; + size_t i, new_size; + dev_t dev; + ino_t ino; + int nlinks; + + + /* Free a held name. */ + free(links_cache->last_name); + links_cache->last_name = NULL; + + /* If the links cache overflowed and got flushed, don't bother. */ + if (links_cache->buckets == NULL) + return (NULL); + + dev = archive_entry_dev(entry); + ino = archive_entry_ino(entry); + nlinks = archive_entry_nlink(entry); + + /* An entry with one link can't be a hard link. */ + if (nlinks == 1) + return (NULL); + + /* If the links cache is getting too full, enlarge the hash table. */ + if (links_cache->number_entries > links_cache->number_buckets * 2) + { + /* Try to enlarge the bucket list. */ + new_size = links_cache->number_buckets * 2; + new_buckets = malloc(new_size * sizeof(struct links_entry *)); + + if (new_buckets != NULL) { + memset(new_buckets, 0, + new_size * sizeof(struct links_entry *)); + for (i = 0; i < links_cache->number_buckets; i++) { + while (links_cache->buckets[i] != NULL) { + /* Remove entry from old bucket. */ + le = links_cache->buckets[i]; + links_cache->buckets[i] = le->next; + + /* Add entry to new bucket. */ + hash = (le->dev ^ le->ino) % new_size; + + if (new_buckets[hash] != NULL) + new_buckets[hash]->previous = + le; + le->next = new_buckets[hash]; + le->previous = NULL; + new_buckets[hash] = le; + } + } + free(links_cache->buckets); + links_cache->buckets = new_buckets; + links_cache->number_buckets = new_size; + } + } + + /* Try to locate this entry in the links cache. */ + hash = ( dev ^ ino ) % links_cache->number_buckets; + for (le = links_cache->buckets[hash]; le != NULL; le = le->next) { + if (le->dev == dev && le->ino == ino) { + /* + * Decrement link count each time and release + * the entry if it hits zero. This saves + * memory and is necessary for detecting + * missed links. + */ + --le->links; + if (le->links > 0) + return (le->name); + /* + * When we release the entry, save the name + * until the next call. + */ + links_cache->last_name = le->name; + /* + * Release the entry. + */ + if (le->previous != NULL) + le->previous->next = le->next; + if (le->next != NULL) + le->next->previous = le->previous; + if (links_cache->buckets[hash] == le) + links_cache->buckets[hash] = le->next; + links_cache->number_entries--; + free(le); + return (links_cache->last_name); + } + } + + /* Add this entry to the links cache. */ + le = malloc(sizeof(struct links_entry)); + if (le == NULL) + return (NULL); + le->name = strdup(archive_entry_pathname(entry)); + if (le->name == NULL) { + free(le); + return (NULL); + } + + /* If we could allocate the entry, record it. */ + if (links_cache->buckets[hash] != NULL) + links_cache->buckets[hash]->previous = le; + links_cache->number_entries++; + le->next = links_cache->buckets[hash]; + le->previous = NULL; + links_cache->buckets[hash] = le; + le->dev = dev; + le->ino = ino; + le->links = nlinks - 1; + return (NULL); +} diff --git a/contrib/libarchive-2/libarchive/archive_entry_private.h b/contrib/libarchive-2/libarchive/archive_entry_private.h index 234ba47e84..50ad7b9064 100644 --- a/contrib/libarchive-2/libarchive/archive_entry_private.h +++ b/contrib/libarchive-2/libarchive/archive_entry_private.h @@ -149,6 +149,8 @@ struct archive_entry { struct ae_xattr *xattr_head; struct ae_xattr *xattr_p; + + char strmode[11]; }; diff --git a/contrib/libarchive-2/libarchive/archive_entry_strmode.c b/contrib/libarchive-2/libarchive/archive_entry_strmode.c new file mode 100644 index 0000000000..1a018734bc --- /dev/null +++ b/contrib/libarchive-2/libarchive/archive_entry_strmode.c @@ -0,0 +1,83 @@ +/*- + * Copyright (c) 2003-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. + * 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 "archive_platform.h" +__FBSDID("$FreeBSD$"); + +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif + +#include "archive_entry.h" +#include "archive_entry_private.h" + +const char * +archive_entry_strmode(struct archive_entry *entry) +{ + static const char *perms = "?rwxrwxrwx "; + static const mode_t permbits[] = + { 0400, 0200, 0100, 0040, 0020, 0010, 0004, 0002, 0001 }; + char *bp = entry->strmode; + mode_t mode; + int i; + + /* Fill in a default string, then selectively override. */ + strcpy(bp, perms); + + mode = archive_entry_mode(entry); + switch (archive_entry_filetype(entry)) { + case AE_IFREG: bp[0] = '-'; break; + case AE_IFBLK: bp[0] = 'b'; break; + case AE_IFCHR: bp[0] = 'c'; break; + case AE_IFDIR: bp[0] = 'd'; break; + case AE_IFLNK: bp[0] = 'l'; break; + case AE_IFSOCK: bp[0] = 's'; break; + case AE_IFIFO: bp[0] = 'p'; break; + } + + for (i = 0; i < 9; i++) + if (!(mode & permbits[i])) + bp[i+1] = '-'; + + if (mode & S_ISUID) { + if (mode & S_IXUSR) bp[3] = 's'; + else bp[3] = 'S'; + } + if (mode & S_ISGID) { + if (mode & S_IXGRP) bp[6] = 's'; + else bp[6] = 'S'; + } + if (mode & S_ISVTX) { + if (mode & S_IXOTH) bp[9] = 't'; + else bp[9] = 'T'; + } + if (archive_entry_acl_count(entry, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)) + bp[10] = '+'; + + return (bp); +} diff --git a/contrib/libarchive-2/libarchive/archive_platform.h b/contrib/libarchive-2/libarchive/archive_platform.h index 0f8a170166..70cc037c3a 100644 --- a/contrib/libarchive-2/libarchive/archive_platform.h +++ b/contrib/libarchive-2/libarchive/archive_platform.h @@ -122,4 +122,4 @@ #define ARCHIVE_ERRNO_MISC (-1) #endif -#endif /* !ARCHIVE_H_INCLUDED */ +#endif /* !ARCHIVE_PLATFORM_H_INCLUDED */ diff --git a/contrib/libarchive-2/libarchive/archive_read.3 b/contrib/libarchive-2/libarchive/archive_read.3 index 9e4f878dc1..6daba3f3d1 100644 --- a/contrib/libarchive-2/libarchive/archive_read.3 +++ b/contrib/libarchive-2/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.34 2007/05/29 01:00:18 kientzle Exp $ +.\" $FreeBSD: src/lib/libarchive/archive_read.3,v 1.35 2007/09/19 16:37:45 kientzle Exp $ .\" .Dd August 19, 2006 .Dt archive_read 3 @@ -267,7 +267,7 @@ to create the entry on disk and copy data into it. The .Va flags argument is passed unmodified to -.Xr archiv_write_disk_set_options 3 . +.Xr archive_write_disk_set_options 3 . .It Fn archive_read_extract_set_progress_callback Sets a pointer to a user-defined callback that can be used for updating progress displays during extraction. diff --git a/contrib/libarchive-2/libarchive/archive_util.c b/contrib/libarchive-2/libarchive/archive_util.c index d73366357d..2bc2844abc 100644 --- a/contrib/libarchive-2/libarchive/archive_util.c +++ b/contrib/libarchive-2/libarchive/archive_util.c @@ -60,7 +60,7 @@ archive_version_stamp(void) const char * archive_version(void) { - return (PACKAGE_NAME " " PACKAGE_VERSION); + return (ARCHIVE_LIBRARY_VERSION); } int diff --git a/contrib/libarchive-2/libarchive/archive_write_disk.c b/contrib/libarchive-2/libarchive/archive_write_disk.c index e3b3a328cc..bc0f4c1919 100644 --- a/contrib/libarchive-2/libarchive/archive_write_disk.c +++ b/contrib/libarchive-2/libarchive/archive_write_disk.c @@ -25,7 +25,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.14 2007/08/12 17:35:05 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.17 2007/09/21 04:52:42 kientzle Exp $"); #ifdef HAVE_SYS_TYPES_H #include @@ -448,8 +448,10 @@ _archive_write_data_block(struct archive *_a, __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, ARCHIVE_STATE_DATA, "archive_write_disk_block"); - if (a->fd < 0) - return (ARCHIVE_OK); + if (a->fd < 0) { + archive_set_error(&a->archive, 0, "File not open"); + return (ARCHIVE_WARN); + } archive_clear_error(&a->archive); /* Seek if necessary to the specified offset. */ @@ -478,12 +480,17 @@ static ssize_t _archive_write_data(struct archive *_a, const void *buff, size_t size) { struct archive_write_disk *a = (struct archive_write_disk *)_a; + int r; + __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, ARCHIVE_STATE_DATA, "archive_write_data"); if (a->fd < 0) return (ARCHIVE_OK); - return (_archive_write_data_block(_a, buff, size, a->offset)); + r = _archive_write_data_block(_a, buff, size, a->offset); + if (r < ARCHIVE_OK) + return (r); + return (size); } static int diff --git a/contrib/libarchive-2/libarchive/archive_write_set_format_pax.c b/contrib/libarchive-2/libarchive/archive_write_set_format_pax.c index 471feb8307..cedbfd75c9 100644 --- a/contrib/libarchive-2/libarchive/archive_write_set_format_pax.c +++ b/contrib/libarchive-2/libarchive/archive_write_set_format_pax.c @@ -418,12 +418,15 @@ archive_write_pax_header(struct archive_write *a, p = archive_entry_pathname(entry_original); if (p[strlen(p) - 1] != '/') { t = (char *)malloc(strlen(p) + 2); - if (t != NULL) { - strcpy(t, p); - strcat(t, "/"); - archive_entry_copy_pathname(entry_original, t); - free(t); + if (t == NULL) { + archive_set_error(&a->archive, ENOMEM, + "Can't allocate pax data"); + return(ARCHIVE_FATAL); } + strcpy(t, p); + strcat(t, "/"); + archive_entry_copy_pathname(entry_original, t); + free(t); } break; default: diff --git a/contrib/libarchive-2/libarchive/archive_write_set_format_ustar.c b/contrib/libarchive-2/libarchive/archive_write_set_format_ustar.c index 61c90d5041..287afe0657 100644 --- a/contrib/libarchive-2/libarchive/archive_write_set_format_ustar.c +++ b/contrib/libarchive-2/libarchive/archive_write_set_format_ustar.c @@ -216,12 +216,15 @@ archive_write_ustar_header(struct archive_write *a, struct archive_entry *entry) p = archive_entry_pathname(entry); if (p[strlen(p) - 1] != '/') { t = (char *)malloc(strlen(p) + 2); - if (t != NULL) { - strcpy(t, p); - strcat(t, "/"); - archive_entry_copy_pathname(entry, t); - free(t); + if (t == NULL) { + archive_set_error(&a->archive, ENOMEM, + "Can't allocate ustar data"); + return(ARCHIVE_FATAL); } + strcpy(t, p); + strcat(t, "/"); + archive_entry_copy_pathname(entry, t); + free(t); } } diff --git a/contrib/libarchive-2/libarchive/filter_fork.c b/contrib/libarchive-2/libarchive/filter_fork.c index ac3f75c5d9..c71cf6883f 100644 --- a/contrib/libarchive-2/libarchive/filter_fork.c +++ b/contrib/libarchive-2/libarchive/filter_fork.c @@ -30,6 +30,8 @@ __FBSDID("$FreeBSD: src/lib/libarchive/filter_fork.c,v 1.1 2007/05/29 01:00:20 k #if defined(HAVE_POLL) # if defined(HAVE_POLL_H) # include +# elif defined(HAVE_SYS_POLL_H) +# include # endif #elif defined(HAVE_SELECT) # if defined(HAVE_SYS_SELECT_H) diff --git a/contrib/libarchive-2/tar/bsdtar.c b/contrib/libarchive-2/tar/bsdtar.c index 4ff4267e40..d20a60dffa 100644 --- a/contrib/libarchive-2/tar/bsdtar.c +++ b/contrib/libarchive-2/tar/bsdtar.c @@ -24,7 +24,7 @@ */ #include "bsdtar_platform.h" -__FBSDID("$FreeBSD: src/usr.bin/tar/bsdtar.c,v 1.76 2007/08/01 03:15:35 kientzle Exp $"); +__FBSDID("$FreeBSD: src/usr.bin/tar/bsdtar.c,v 1.77 2007/09/09 00:07:18 kientzle Exp $"); #ifdef HAVE_SYS_PARAM_H #include @@ -151,6 +151,7 @@ enum { OPTION_NO_SAME_PERMISSIONS, OPTION_NULL, OPTION_ONE_FILE_SYSTEM, + OPTION_POSIX, OPTION_STRIP_COMPONENTS, OPTION_TOTALS, OPTION_USE_COMPRESS_PROGRAM, @@ -202,6 +203,7 @@ static const struct option tar_longopts[] = { { "no-same-permissions",no_argument, NULL, OPTION_NO_SAME_PERMISSIONS }, { "null", no_argument, NULL, OPTION_NULL }, { "one-file-system", no_argument, NULL, OPTION_ONE_FILE_SYSTEM }, + { "posix", no_argument, NULL, OPTION_POSIX }, { "preserve-permissions", no_argument, NULL, 'p' }, { "read-full-blocks", no_argument, NULL, 'B' }, { "same-permissions", no_argument, NULL, 'p' }, @@ -489,6 +491,9 @@ main(int argc, char **argv) bsdtar->extract_flags |= ARCHIVE_EXTRACT_XATTR; bsdtar->extract_flags |= ARCHIVE_EXTRACT_FFLAGS; break; + case OPTION_POSIX: /* GNU tar */ + bsdtar->create_format = "pax"; + break; case 'r': /* SUSv2 */ set_mode(bsdtar, opt); break; @@ -787,7 +792,9 @@ usage(struct bsdtar *bsdtar) static void version(void) { - printf("bsdtar %s - %s\n", PACKAGE_VERSION, archive_version()); + printf("bsdtar %s - %s\n", + BSDTAR_VERSION_STRING, + archive_version()); exit(1); } diff --git a/contrib/libarchive-2/tar/bsdtar.h b/contrib/libarchive-2/tar/bsdtar.h index 3117d6664f..50f61681a8 100644 --- a/contrib/libarchive-2/tar/bsdtar.h +++ b/contrib/libarchive-2/tar/bsdtar.h @@ -99,7 +99,6 @@ struct bsdtar { void bsdtar_errc(struct bsdtar *, int _eval, int _code, const char *fmt, ...); -void bsdtar_strmode(struct archive_entry *entry, char *bp); void bsdtar_warnc(struct bsdtar *, int _code, const char *fmt, ...); void cleanup_exclusions(struct bsdtar *); void do_chdir(struct bsdtar *); diff --git a/contrib/libarchive-2/tar/read.c b/contrib/libarchive-2/tar/read.c index b52c1ee0d5..a942e85b18 100644 --- a/contrib/libarchive-2/tar/read.c +++ b/contrib/libarchive-2/tar/read.c @@ -291,8 +291,9 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) } if (!now) time(&now); - bsdtar_strmode(entry, tmp); - fprintf(out, "%s %d ", tmp, (int)(st->st_nlink)); + fprintf(out, "%s %d ", + archive_entry_strmode(entry), + (int)(st->st_nlink)); /* Use uname if it's present, else uid. */ p = archive_entry_uname(entry); diff --git a/contrib/libarchive-2/tar/util.c b/contrib/libarchive-2/tar/util.c index d4a92c9bef..c43e461eb2 100644 --- a/contrib/libarchive-2/tar/util.c +++ b/contrib/libarchive-2/tar/util.c @@ -199,56 +199,6 @@ yes(const char *fmt, ...) return (0); } -void -bsdtar_strmode(struct archive_entry *entry, char *bp) -{ - static const char *perms = "?rwxrwxrwx "; - static const mode_t permbits[] = - { S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IWGRP, S_IXGRP, - S_IROTH, S_IWOTH, S_IXOTH }; - mode_t mode; - int i; - - /* Fill in a default string, then selectively override. */ - strcpy(bp, perms); - - mode = archive_entry_mode(entry); - switch (mode & S_IFMT) { - case S_IFREG: bp[0] = '-'; break; - case S_IFBLK: bp[0] = 'b'; break; - case S_IFCHR: bp[0] = 'c'; break; - case S_IFDIR: bp[0] = 'd'; break; - case S_IFLNK: bp[0] = 'l'; break; - case S_IFSOCK: bp[0] = 's'; break; -#ifdef S_IFIFO - case S_IFIFO: bp[0] = 'p'; break; -#endif -#ifdef S_IFWHT - case S_IFWHT: bp[0] = 'w'; break; -#endif - } - - for (i = 0; i < 9; i++) - if (!(mode & permbits[i])) - bp[i+1] = '-'; - - if (mode & S_ISUID) { - if (mode & S_IXUSR) bp[3] = 's'; - else bp[3] = 'S'; - } - if (mode & S_ISGID) { - if (mode & S_IXGRP) bp[6] = 's'; - else bp[6] = 'S'; - } - if (mode & S_ISVTX) { - if (mode & S_IXOTH) bp[9] = 't'; - else bp[9] = 'T'; - } - if (archive_entry_acl_count(entry, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)) - bp[10] = '+'; -} - - /* * Read lines from file and do something with each one. If option_null * is set, lines are terminated with zero bytes; otherwise, they're diff --git a/contrib/libarchive-2/version b/contrib/libarchive-2/version index b539adea59..e7034819f6 100644 --- a/contrib/libarchive-2/version +++ b/contrib/libarchive-2/version @@ -1 +1 @@ -2.2.7 \ No newline at end of file +2.3.2 \ No newline at end of file -- 2.41.0