diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2005-09-23 19:18:27 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2005-09-23 19:18:27 +0000 |
commit | b9830cafa127d8a3e072bd1abb90feb9181423f7 (patch) | |
tree | d685b570d72657296c19a3f628fb2b795b88b231 /lib/utimens.c | |
parent | d6ed244c5a34c9a0ec3c6c26586d9279440e7316 (diff) | |
download | coreutils-b9830cafa127d8a3e072bd1abb90feb9181423f7.tar.xz |
* 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.
Diffstat (limited to 'lib/utimens.c')
-rw-r--r-- | lib/utimens.c | 12 |
1 files changed, 9 insertions, 3 deletions
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 <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 |