diff options
author | Jim Meyering <jim@meyering.net> | 2005-01-14 13:33:26 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2005-01-14 13:33:26 +0000 |
commit | 14f7a72f5a88f64ae7101a9d4a4a723041c94366 (patch) | |
tree | 9837cbd3cab9a0775cafd91feb8df35b92c10468 | |
parent | ec597a0f84cd726686f32c61c84870a30fb4d396 (diff) | |
download | coreutils-14f7a72f5a88f64ae7101a9d4a4a723041c94366.tar.xz |
Work around tests/touch/empty-file failure on a system
(sparc64, Linux-2.4.28, glibc-2.3.3) that didn't honor utimes'
NULL-means-set-to-current-time semantics.
Remove temporary file immediately, rather than waiting
for configure's at-exit trap code to do it.
-rw-r--r-- | m4/utimes.m4 | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/m4/utimes.m4 b/m4/utimes.m4 index dae46f00e..784516cc3 100644 --- a/m4/utimes.m4 +++ b/m4/utimes.m4 @@ -3,6 +3,8 @@ # First, there was a bug that would make utimes set mtime # and atime to zero (1970-01-01) unconditionally. # Then, there was code to round rather than truncate. +# Then, there was an implementation (sparc64, Linux-2.4.28, glibc-2.3.3) +# that didn't honor the NULL-means-set-to-current-time semantics. # # From Jim Meyering, with suggestions from Paul Eggert. @@ -15,6 +17,7 @@ AC_DEFUN([gl_FUNC_UTIMES], #include <sys/types.h> #include <sys/stat.h> #include <sys/time.h> +#include <time.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> @@ -27,13 +30,29 @@ main () struct stat sbuf; char const *file = "conftest.utimes"; FILE *f; + time_t now; - exit ( ! ((f = fopen (file, "w")) + int ok = ((f = fopen (file, "w")) && fclose (f) == 0 && utimes (file, timeval) == 0 && lstat (file, &sbuf) == 0 && sbuf.st_atime == timeval[0].tv_sec - && sbuf.st_mtime == timeval[1].tv_sec) ); + && sbuf.st_mtime == timeval[1].tv_sec); + unlink (file); + if (!ok) + exit (1); + + ok = + ((f = fopen (file, "w")) + && fclose (f) == 0 + && time (&now) != (time_t)-1 + && utimes (file, NULL) == 0 + && lstat (file, &sbuf) == 0 + && now - sbuf.st_atime <= 2 + && now - sbuf.st_mtime <= 2); + unlink (file); + + exit (!ok); } ]])], [gl_cv_func_working_utimes=yes], |