summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2007-03-13 06:04:24 +0000
committerkientzle <kientzle@FreeBSD.org>2007-03-13 06:04:24 +0000
commit847bf0fdc9b7822157bcc1b36b6570e2ad05bb14 (patch)
tree81849ae05e3816b7b29a5544620173a3f1cb7d99 /lib
parentc2c65e0dd6f06d53bf32829de24c93b1ab6453d6 (diff)
downloadFreeBSD-src-847bf0fdc9b7822157bcc1b36b6570e2ad05bb14.zip
FreeBSD-src-847bf0fdc9b7822157bcc1b36b6570e2ad05bb14.tar.gz
When ARCHIVE_EXTRACT_UNLINK is requested:
* Only try to remove the existing item if we're not restoring a directory. * If unlink fails, try rmdir next. This should fix the broken --unlink option in bsdtar. Thanks again to: Kris Kennaway, for beating up bsdtar on pointyhat.
Diffstat (limited to 'lib')
-rw-r--r--lib/libarchive/Makefile2
-rw-r--r--lib/libarchive/archive_write_disk.c14
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/libarchive/Makefile b/lib/libarchive/Makefile
index a3f35b1..e66d374 100644
--- a/lib/libarchive/Makefile
+++ b/lib/libarchive/Makefile
@@ -9,7 +9,7 @@ LDADD= -lbz2 -lz
# Major: Bumped ONLY when API/ABI breakage happens (see SHLIB_MAJOR)
# Minor: Bumped when significant new features are added
# Revision: Bumped on any notable change
-VERSION= 2.0.23
+VERSION= 2.0.24
ARCHIVE_API_MAJOR!= echo ${VERSION} | sed -e 's/[^0-9]/./g' -e 's/\..*//'
ARCHIVE_API_MINOR!= echo ${VERSION} | sed -e 's/[^0-9]/./g' -e 's/[0-9]*\.//' -e 's/\..*//'
diff --git a/lib/libarchive/archive_write_disk.c b/lib/libarchive/archive_write_disk.c
index 1f8f0ce..02fabd6 100644
--- a/lib/libarchive/archive_write_disk.c
+++ b/lib/libarchive/archive_write_disk.c
@@ -659,14 +659,20 @@ restore_entry(struct archive_write_disk *a)
{
int ret = ARCHIVE_OK, en;
- if (a->flags & ARCHIVE_EXTRACT_UNLINK)
- if (unlink(a->name) != 0 && errno != ENOENT) {
- /* If the file doesn't exist, that's okay. */
- /* Anything else is a problem. */
+ if (a->flags & ARCHIVE_EXTRACT_UNLINK && !S_ISDIR(a->mode)) {
+ if (unlink(a->name) == 0) {
+ /* We removed it, we're done. */
+ } else if (errno == ENOENT) {
+ /* File didn't exist, that's just as good. */
+ } else if (rmdir(a->name) == 0) {
+ /* It was a dir, but now it's gone. */
+ } else {
+ /* We tried, but couldn't get rid of it. */
archive_set_error(&a->archive, errno,
"Could not unlink");
return(ARCHIVE_WARN);
}
+ }
/* Try creating it first; if this fails, we'll try to recover. */
en = create_filesystem_object(a);
OpenPOWER on IntegriCloud