libarchive/libarchive-2.5.5_handle_ENOSYS_from_lutimes.patch

60 lines
1.8 KiB
Diff

---
cpio/cpio.c | 10 +++++++---
libarchive/archive_write_disk.c | 8 +++++---
2 files changed, 12 insertions(+), 6 deletions(-)
Index: cpio/cpio.c
===================================================================
--- cpio/cpio.c.orig
+++ cpio/cpio.c
@@ -38,8 +38,11 @@ __FBSDID("$FreeBSD: src/usr.bin/cpio/cpi
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
+#ifdef HAVE_SYS_UTIME_H
+#include <sys/utime.h>
+#endif
+#ifdef HAVE_UTIME_H
+#include <utime.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -786,7 +789,8 @@ restore_time(struct cpio *cpio, struct a
}
#ifdef HAVE_LUTIMES
- if (lutimes(name, times) != 0)
+ if ((lutimes(name, times) != 0) && (errno==ENOSYS) &&
+ (!S_ISLNK(archive_entry_mode(entry)) && utimes(name, times) != 0))
#else
if ((AE_IFLNK != archive_entry_filetype(entry))
&& utimes(name, times) != 0)
Index: libarchive/archive_write_disk.c
===================================================================
--- libarchive/archive_write_disk.c.orig
+++ libarchive/archive_write_disk.c
@@ -1265,7 +1265,9 @@ _archive_write_close(struct archive *_a)
times[1].tv_sec = p->mtime;
times[1].tv_usec = p->mtime_nanos / 1000;
#ifdef HAVE_LUTIMES
- lutimes(p->name, times);
+ if ((lutimes(p->name, times) != 0) && (errno==ENOSYS) && (!S_ISLNK(p->mode))) {
+ utimes(p->name, times);
+ }
#else
utimes(p->name, times);
#endif
@@ -1886,8 +1888,8 @@ set_time(int fd, int mode, const char *n
(void)fd; /* UNUSED */
#endif
#ifdef HAVE_LUTIMES
- (void)mode; /* UNUSED */
- return (lutimes(name, times));
+ return ((lutimes(name, times) != 0) && (errno==ENOSYS) &&
+ (!S_ISLNK(mode)) && (utimes(name,mode) != 0));
#else
if (S_ISLNK(mode))
return (0);