- int result = utimensat (AT_FDCWD, file, ts, 0);
-# ifdef __linux__
- /* Work around a kernel bug:
- http://bugzilla.redhat.com/442352
- http://bugzilla.redhat.com/449910
- It appears that utimensat can mistakenly return 280 rather
- than -1 upon failure.
- FIXME: remove in 2010 or whenever the offending kernels
- are no longer in common use. */
- if (0 < result)
- errno = ENOSYS;
-# endif
-
- if (result == 0 || errno != ENOSYS)
- return result;
+# if HAVE_UTIMENSAT
+ if (fd < 0)
+ {
+ int result = utimensat (AT_FDCWD, file, ts, 0);
+# ifdef __linux__
+ /* Work around a kernel bug:
+ http://bugzilla.redhat.com/442352
+ http://bugzilla.redhat.com/449910
+ It appears that utimensat can mistakenly return 280 rather
+ than -1 upon ENOSYS failure.
+ FIXME: remove in 2010 or whenever the offending kernels
+ are no longer in common use. */
+ if (0 < result)
+ errno = ENOSYS;
+# endif /* __linux__ */
+ if (result == 0 || errno != ENOSYS)
+ {
+ utimensat_works_really = 1;
+ return result;
+ }
+ }
+# endif /* HAVE_UTIMENSAT */
+# if HAVE_FUTIMENS
+ {
+ int result = futimens (fd, timespec);
+# ifdef __linux__
+ /* Work around the same bug as above. */
+ if (0 < result)
+ errno = ENOSYS;
+# endif /* __linux__ */
+ if (result == 0 || errno != ENOSYS)
+ {
+ utimensat_works_really = 1;
+ return result;
+ }
+ }
+# endif /* HAVE_FUTIMENS */