From: Jim Meyering Date: Mon, 26 Sep 2005 09:10:50 +0000 (+0000) Subject: (gl_FUNC_UTIMES): Detect the version of utimes X-Git-Tag: v5.90~44 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=99fa7a0e8e14a0e0711ec1d549668c65ed047b4c;p=thirdparty%2Fcoreutils.git (gl_FUNC_UTIMES): Detect the version of utimes from glibc-2.2.5 that fails for read-only files. --- diff --git a/m4/utimes.m4 b/m4/utimes.m4 index ba74b3f6e3..7efb2b026c 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); }