X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Futimes.m4;h=7efb2b026c9ddf2bf9b4075ff1672e299f24d7ec;hb=8eaac7a51d093dbcecc0c2b42a5762a882b4517b;hp=ba74b3f6e3a4d6becd406df6eb20cdc6f4b67fd4;hpb=48bde603f0ddf53ffad933b5fd4229bae039206e;p=gnulib.git diff --git a/m4/utimes.m4 b/m4/utimes.m4 index ba74b3f6e..7efb2b026 100644 --- a/m4/utimes.m4 +++ b/m4/utimes.m4 @@ -12,6 +12,8 @@ dnl with or without modifications, as long as this notice is preserved. # 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. +# Finally, there was also a version of utimes that failed on read-only +# files, while utime worked fine (linux-2.2.20, glibc-2.2.5). # # From Jim Meyering, with suggestions from Paul Eggert. @@ -23,6 +25,7 @@ AC_DEFUN([gl_FUNC_UTIMES], AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include +#include #include #include #include @@ -38,6 +41,7 @@ main () char const *file = "conftest.utimes"; FILE *f; time_t now; + int fd; int ok = ((f = fopen (file, "w")) && fclose (f) == 0 @@ -58,6 +62,13 @@ main () && now - sbuf.st_atime <= 2 && now - sbuf.st_mtime <= 2); unlink (file); + if (!ok) + exit (1); + + ok = (0 <= (fd = open (file, O_WRONLY|O_CREAT, 0444)) + && close (fd) == 0 + && utimes (file, NULL) == 0); + unlink (file); exit (!ok); }