diff --git a/configure.ac b/configure.ac index 7570742..0ebfa3a 100644 --- a/configure.ac +++ b/configure.ac @@ -564,6 +564,10 @@ case "$ac_cv_search__obstack_free" in esac AC_SUBST([obstack_LIBS]) +dnl Check for futimes +AC_CHECK_FUNCS([futimes]) +AC_CHECK_FUNCS([futimens]) + dnl The directories with content. dnl Documentation. diff --git a/src/ar.c b/src/ar.c index ab6098f..1a5bf5d 100644 --- a/src/ar.c +++ b/src/ar.c @@ -676,7 +676,13 @@ do_oper_extract (int oper, const char *arfname, char **argv, int argc, tv[1].tv_sec = arhdr->ar_date; tv[1].tv_nsec = 0; - if (unlikely (futimens (xfd, tv) != 0)) + int success; +#ifdef HAVE_FUTIMENS + success = futimens (xfd, tv); +#else + success = utimensat (AT_FDCWD, arhdr->ar_name, tv, 0); +#endif + if (unlikely (success != 0)) { error (0, errno, _("cannot change modification time of %s"), diff --git a/src/strip.c b/src/strip.c index 6e6c0a3..99fe89e 100644 --- a/src/strip.c +++ b/src/strip.c @@ -2687,7 +2687,13 @@ while computing checksum for debug information")); /* If requested, preserve the timestamp. */ if (tvp != NULL) { - if (futimens (fd, tvp) != 0) + int success; +#ifdef HAVE_FUTIMENS + success = futimens (fd, tvp); +#else + success = utimensat(AT_FDCWD, output_fname ?: fname, tvp, 0); +#endif + if (success != 0) { error (0, errno, _("\ cannot set access and modification date of '%s'"), @@ -2763,7 +2769,13 @@ handle_ar (int fd, Elf *elf, const char *prefix, const char *fname, if (tvp != NULL) { - if (unlikely (futimens (fd, tvp) != 0)) + int success; +#ifdef HAVE_FUTIMENS + success = futimens (fd, tvp); +#else + success = utimensat (AT_FDCWD, fname, tvp, 0); +#endif + if (unlikely (success != 0)) { error (0, errno, _("\ cannot set access and modification date of '%s'"), fname); diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index c875ee6..34c0286 100644--- a/debuginfod/debuginfod-client.c +++ b/debuginfod/debuginfod-client.c @@ -1343,7 +1343,12 @@ debuginfod_query_server (debuginfod_client *c, struct timeval tvs[2]; tvs[0].tv_sec = tvs[1].tv_sec = mtime; tvs[0].tv_usec = tvs[1].tv_usec = 0; - (void) futimes (fd, tvs); /* best effort */ + +#ifdef HAVE_FUTIMES + futimes (fd, tvs); /* best effort */ +#else + utimes (target_cache_tmppath, tvs); /* best effort */ +#endif /* PR27571: make cache files casually unwriteable; dirs are already 0700 */ (void) fchmod(fd, 0400); diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx index 521cb52..a597182 100644 --- a/debuginfod/debuginfod.cxx +++ b/debuginfod/debuginfod.cxx @@ -1710,7 +1710,12 @@ handle_buildid_r_match (bool internal_req_p, struct timeval tvs[2]; tvs[0].tv_sec = tvs[1].tv_sec = archive_entry_mtime(e); tvs[0].tv_usec = tvs[1].tv_usec = 0; + +#ifdef HAVE_FUTIMES (void) futimes (fd, tvs); /* best effort */ +#else + (void) utimes(tmppath, tvs); +#endif if (r != 0) // stage 3 {