mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
* lib/utimens.c (futimens): Use futimesat if available.
Prefer it to futimes since it doesn't have the futimes bug. * m4/utimens.m4 (gl_UTIMENS): Check for futimesat.
This commit is contained in:
1 parent
d6ed244c5a
commit
b9830cafa1
2 files changed
+10
-4
No files matched your search
+9
-3
@@ -25,6 +25,7 @@
|
||||
#include "utimens.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#if HAVE_UTIME_H
|
||||
# include <utime.h>
|
||||
@@ -61,7 +62,7 @@ futimens (int fd ATTRIBUTE_UNUSED,
|
||||
/* There's currently no interface to set file timestamps with
|
||||
nanosecond resolution, so do the best we can, discarding any
|
||||
fractional part of the timestamp. */
|
||||
#if HAVE_WORKING_UTIMES
|
||||
#if HAVE_FUTIMESAT || HAVE_WORKING_UTIMES
|
||||
struct timeval timeval[2];
|
||||
struct timeval const *t;
|
||||
if (timespec)
|
||||
@@ -74,7 +75,11 @@ futimens (int fd ATTRIBUTE_UNUSED,
|
||||
}
|
||||
else
|
||||
t = NULL;
|
||||
# if HAVE_FUTIMES
|
||||
|
||||
# if HAVE_FUTIMESAT
|
||||
return fd < 0 ? futimesat (AT_FDCWD, file, t) : futimesat (fd, NULL, t);
|
||||
# else
|
||||
# if HAVE_FUTIMES
|
||||
if (0 <= fd)
|
||||
{
|
||||
if (futimes (fd, t) == 0)
|
||||
@@ -92,8 +97,9 @@ futimens (int fd ATTRIBUTE_UNUSED,
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
return utimes (file, t);
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
|
||||
+1
-1
@@ -13,5 +13,5 @@ AC_DEFUN([gl_UTIMENS],
|
||||
AC_REQUIRE([gl_FUNC_UTIMES])
|
||||
AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
|
||||
AC_REQUIRE([gl_CHECK_TYPE_STRUCT_UTIMBUF])
|
||||
AC_CHECK_FUNCS_ONCE(futimes)
|
||||
AC_CHECK_FUNCS_ONCE([futimes futimesat])
|
||||
])
|
||||
Reference in new issue
Block a user