aboutsummaryrefslogtreecommitdiff
path: root/lib/libarchive/archive_platform.h
diff options
context:
space:
mode:
authorTim Kientzle <kientzle@FreeBSD.org>2005-05-21 19:45:56 +0000
committerTim Kientzle <kientzle@FreeBSD.org>2005-05-21 19:45:56 +0000
commitb33c1067f883feaa980adfa44ae0d2ea06e435ae (patch)
tree204b4462e048dc1ac7dd860da0d069286d7ae4c6 /lib/libarchive/archive_platform.h
parent21805f33bfc10c11a5f7f7ef29c0c5641e548019 (diff)
downloadsrc-b33c1067f883feaa980adfa44ae0d2ea06e435ae.tar.gz
src-b33c1067f883feaa980adfa44ae0d2ea06e435ae.zip
Start to address the race issue between restoring a file's contents
and restoring the metadata. In particular, the metadata-restore functions now all accept a file descriptor and a pathname. If the file descriptor is set and the platform supports the appropriate syscall, restore the metadata through the file descriptor. Otherwise, restore it through the pathname. This is complicated by varying syscall support (FreeBSD has an fchmod(2) but no fchflags(2), for example) and because non-file entries don't have an fd to use in restoring attributes (for example, mknod(2) doesn't return a file handle). MFC after: 14 days
Notes
Notes: svn path=/head/; revision=146471
Diffstat (limited to 'lib/libarchive/archive_platform.h')
-rw-r--r--lib/libarchive/archive_platform.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/libarchive/archive_platform.h b/lib/libarchive/archive_platform.h
index 770d8082c23c..4140df28e938 100644
--- a/lib/libarchive/archive_platform.h
+++ b/lib/libarchive/archive_platform.h
@@ -46,6 +46,8 @@
#if __FreeBSD__ > 4
#define HAVE_ACL_CREATE_ENTRY 1
#define HAVE_ACL_INIT 1
+#define HAVE_ACL_SET_FD 1
+#define HAVE_ACL_SET_FD_NP 1
#define HAVE_ACL_SET_FILE 1
#endif
#define HAVE_BZLIB_H 1
@@ -55,7 +57,10 @@
#define HAVE_EILSEQ 1
#define HAVE_ERRNO_H 1
#define HAVE_FCHDIR 1
+#define HAVE_FCHMOD 1
+#define HAVE_FCHOWN 1
#define HAVE_FCNTL_H 1
+#define HAVE_FUTIMES 1
#define HAVE_INTTYPES_H 1
#define HAVE_LCHMOD 1
#define HAVE_LCHOWN 1
@@ -123,6 +128,14 @@
#define HAVE_POSIX_ACL 1
#endif
+/*
+ * If we can't restore metadata using a file descriptor, then
+ * for compatibility's sake, close files before trying to restore metadata.
+ */
+#if defined(HAVE_FCHMOD) || defined(HAVE_FUTIMES) || defined(HAVE_ACL_SET_FD) || defined(HAVE_ACL_SET_FD_NP) || defined(HAVE_FCHOWN)
+#define CAN_RESTORE_METADATA_FD
+#endif
+
/* Set up defaults for internal error codes. */
#ifndef ARCHIVE_ERRNO_FILE_FORMAT
#if HAVE_EFTYPE