Slightly tweaked the patch contributed by Heikki Lindholm.
AC_TYPE_GETGROUPS
AC_CHECK_MEMBERS([struct stat.st_rdev,
struct stat.st_mtimensec,
+ struct stat.st_mtimespec.tv_nsec,
struct stat.st_mtim.tv_nsec],,,[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
if (file_length > 0xFFFFFFFFu && S_ISREG(mode))
extra_len += EXTRA_LEN;
#endif
-#ifdef HAVE_UTIMENSAT
+#ifdef CAN_SET_NSEC
if (modtime_nsec)
extra_len += EXTRA_LEN;
#endif
file->flags |= FLAG_HLINKED;
#endif
file->modtime = (time_t)modtime;
-#ifdef HAVE_UTIMENSAT
+#ifdef CAN_SET_NSEC
if (modtime_nsec) {
file->flags |= FLAG_MOD_NSEC;
OPT_EXTRA(file, 0)->unum = modtime_nsec;
#include <utime.h>
#endif
-#if defined HAVE_UTIMENSAT || defined HAVE_LUTIMES
+#if defined HAVE_UTIMENSAT || defined HAVE_LUTIMES || defined HAVE_SETATTRLIST
#define CAN_SET_SYMLINK_TIMES 1
#endif
#define CAN_CHMOD_SYMLINK 1
#endif
-#ifdef HAVE_UTIMENSAT
+#if defined HAVE_UTIMENSAT || defined HAVE_SETATTRLIST
+#define CAN_SET_NSEC 1
+#endif
+
+#ifdef CAN_SET_NSEC
#ifdef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
#define ST_MTIME_NSEC st_mtim.tv_nsec
#elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC)
#define ST_MTIME_NSEC st_mtimensec
+#elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
+#define ST_MTIME_NSEC st_mtimespec.tv_nsec
#endif
#endif
#endif
}
+#ifdef HAVE_SETATTRLIST
+int do_setattrlist_times(const char *fname, time_t modtime, uint32 mod_nsec)
+{
+ struct attrlist attrList;
+ struct timespec ts;
+
+ if (dry_run) return 0;
+ RETURN_ERROR_IF_RO_OR_LO;
+
+ ts.tv_sec = modtime;
+ ts.tv_nsec = mod_nsec;
+
+ memset(&attrList, 0, sizeof attrList);
+ attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
+ attrList.commonattr = ATTR_CMN_MODTIME;
+ return setattrlist(fname, &attrList, &ts, sizeof ts, FSOPT_NOFOLLOW);
+}
+#endif
+
#ifdef HAVE_UTIMENSAT
int do_utimensat(const char *fname, time_t modtime, uint32 mod_nsec)
{
}
switch (switch_step) {
+#ifdef HAVE_SETATTRLIST
+#include "case_N.h"
+ if (do_setattrlist_times(fname, modtime, mod_nsec) == 0)
+ break;
+ if (errno != ENOSYS)
+ return -1;
+ switch_step++;
+ /* FALLTHROUGH */
+#endif
+
#ifdef HAVE_UTIMENSAT
#include "case_N.h"
if (do_utimensat(fname, modtime, mod_nsec) == 0)