summaryrefslogtreecommitdiff
path: root/lib/utimens.c
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-11-18 06:59:44 -0700
committerEric Blake <ebb9@byu.net>2009-11-18 06:59:44 -0700
commit0883405cc751858a633bebc56acb75381a6e50c8 (patch)
tree69103ad2238a720bc15605d834aadd55d349503b /lib/utimens.c
parent6038ee4b827caaf05fa37dbb2304fedb9d0cd6c7 (diff)
downloadgnulib-0883405cc751858a633bebc56acb75381a6e50c8.tar.gz
utimens: fix regression on Solaris
Revert commit 26c5fd742f. Solaris lacks futimens and futimes, so futimesat is the only way to change fd timestamps. But since FreeBSD futimesat can't change fd timestamps, we need a configure check to avoid the crash there. * m4/utimens.m4 (gl_UTIMENS): Check for BSD bug. * lib/utimens.c (fdutimens): Revert 2009-11-08 change; Solaris 10 can only change fd timestamps via futimesat. Instead, use an additional witness macro to avoid BSD bug. Reported by Jim Meyering. Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'lib/utimens.c')
-rw-r--r--lib/utimens.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/utimens.c b/lib/utimens.c
index bd482d7d01..eb63487c43 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -280,9 +280,9 @@ fdutimens (char const *file, int fd, struct timespec const timespec[2])
}
else
{
- /* If futimesat (above) or futimes fails here, don't try to speed
- things up by returning right away. glibc can incorrectly fail
- with errno == ENOENT if /proc isn't mounted. Also, Mandrake 10.0
+ /* If futimesat or futimes fails here, don't try to speed things
+ up by returning right away. glibc can incorrectly fail with
+ errno == ENOENT if /proc isn't mounted. Also, Mandrake 10.0
in high security mode doesn't allow ordinary users to read
/proc/self, so glibc incorrectly fails with errno == EACCES.
If errno == EIO, EPERM, or EROFS, it's probably safe to fail
@@ -290,7 +290,10 @@ fdutimens (char const *file, int fd, struct timespec const timespec[2])
worth optimizing, and who knows what other messed-up systems
are out there? So play it safe and fall back on the code
below. */
-# if HAVE_FUTIMES
+# if HAVE_FUTIMESAT && !FUTIMESAT_NULL_BUG
+ if (futimesat (fd, NULL, t) == 0)
+ return 0;
+# elif HAVE_FUTIMES
if (futimes (fd, t) == 0)
return 0;
# endif
@@ -299,7 +302,8 @@ fdutimens (char const *file, int fd, struct timespec const timespec[2])
if (!file)
{
-#if ! (HAVE_FUTIMESAT || (HAVE_WORKING_UTIMES && HAVE_FUTIMES))
+#if ! ((HAVE_FUTIMESAT && !FUTIMESAT_NULL_BUG) \
+ || (HAVE_WORKING_UTIMES && HAVE_FUTIMES))
errno = ENOSYS;
#endif
return -1;