From: Paul Eggert Date: Fri, 23 Sep 2005 19:18:06 +0000 (+0000) Subject: * lib/utimens.c (futimens): Use futimesat if available. X-Git-Tag: cvs-readonly~2903 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=9a66010992ca6ea590f26fc89362b5b288e5ffbd;p=gnulib.git * 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. --- diff --git a/lib/utimens.c b/lib/utimens.c index 3f4d5e616..0b2f3e4d0 100644 --- a/lib/utimens.c +++ b/lib/utimens.c @@ -25,6 +25,7 @@ #include "utimens.h" #include +#include #if HAVE_UTIME_H # include @@ -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 diff --git a/m4/utimens.m4 b/m4/utimens.m4 index bb446c820..10f682191 100644 --- a/m4/utimens.m4 +++ b/m4/utimens.m4 @@ -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]) ])