1 --- coreutils-6.12/lib/utimens.c 2008-05-29 09:21:57.000000000 -0400
2 +++ coreutils/lib/utimens.c 2008-06-07 11:36:50.000000000 -0400
6 /* POSIX 200x added two interfaces to set file timestamps with
7 - nanosecond resolution. */
8 + nanosecond resolution. We provide a fallback for ENOSYS (for
9 + example, compiling against Linux 2.6.25 kernel headers and glibc
10 + 2.7, but running on Linux 2.6.18 kernel). */
13 - return utimensat (AT_FDCWD, file, timespec, 0);
15 + int result = utimensat (AT_FDCWD, file, timespec, 0);
17 + /* Work around what might be a kernel bug:
18 + http://bugzilla.redhat.com/442352
19 + http://bugzilla.redhat.com/449910
20 + It appears that utimensat can mistakenly return 280 rather
21 + than 0 to indicate success.
22 + FIXME: remove in 2010 or whenever the offending kernels
23 + are no longer in common use. */
28 + if (result == 0 || errno != ENOSYS)
33 - return futimens (fd, timespec);
36 + int result = futimens (fd, timespec);
37 + if (result == 0 || errno != ENOSYS)
42 /* The platform lacks an interface to set file timestamps with
43 nanosecond resolution, so do the best we can, discarding any
44 fractional part of the timestamp. */
46 -# if HAVE_FUTIMESAT || HAVE_WORKING_UTIMES
47 +#if HAVE_FUTIMESAT || HAVE_WORKING_UTIMES
48 struct timeval timeval[2];
49 struct timeval const *t;
57 return futimesat (AT_FDCWD, file, t);
64 worth optimizing, and who knows what other messed-up systems
65 are out there? So play it safe and fall back on the code
69 if (futimesat (fd, NULL, t) == 0)
73 if (futimes (fd, t) == 0)
78 -# endif /* HAVE_FUTIMESAT || HAVE_WORKING_UTIMES */
79 +#endif /* HAVE_FUTIMESAT || HAVE_WORKING_UTIMES */
83 -# if ! (HAVE_FUTIMESAT || (HAVE_WORKING_UTIMES && HAVE_FUTIMES))
84 +#if ! (HAVE_FUTIMESAT || (HAVE_WORKING_UTIMES && HAVE_FUTIMES))
89 /* Prefer EBADF to ENOSYS if both error numbers apply. */
95 -# if HAVE_WORKING_UTIMES
96 +#if HAVE_WORKING_UTIMES
97 return utimes (file, t);
101 struct utimbuf utimbuf;
102 struct utimbuf const *ut;
105 return utime (file, ut);
107 -# endif /* !HAVE_WORKING_UTIMES */
108 +#endif /* !HAVE_WORKING_UTIMES */
110 -#endif /* !HAVE_FUTIMENS */
113 /* Set the access and modification time stamps of FILE to be