]> Savannah Git Hosting - gnulib.git/commitdiff
utimes: detect utimes() correctly on OS/2 kLIBC
authorKO Myung-Hun <komh@chollian.net>
Fri, 28 Nov 2014 07:43:14 +0000 (16:43 +0900)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 15 Jan 2016 18:09:00 +0000 (10:09 -0800)
utimes() of OS/2 kLIBC has some limitations.

1. OS/2 itself supports a file date since 1980 year in local time.
2. OS/2 itself supports only even seconds for a file time.
3. utimes() of OS/2 kLIBC does not work on an opened file.

* m4/utimes.m4: Detect utimes() correctly on OS/2 kLIBC.
* doc/posix-functions/utimes.texi: Document the above limitations of
utimes() on OS/2 kLIBC.

ChangeLog
doc/posix-functions/utimes.texi
m4/utimes.m4

index 8a5aed6979ae5afa20b495bf05b2ff993d4a9fd0..5bedafaf0be30792e5d18a5231a39ddc48bb4d0f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2016-01-15  KO Myung-Hun  <komh@chollian.net>
+
+       utimes: detect utimes() correctly on OS/2 kLIBC
+       utimes() of OS/2 kLIBC has some limitations.
+       1. OS/2 itself supports a file date since 1980 year in local time.
+       2. OS/2 itself supports only even seconds for a file time.
+       3. utimes() of OS/2 kLIBC does not work on an opened file.
+       * m4/utimes.m4: Detect utimes() correctly on OS/2 kLIBC.
+       * doc/posix-functions/utimes.texi: Document the above limitations of
+       utimes() on OS/2 kLIBC.
+
 2016-01-15  Paul Eggert  <eggert@cs.ucla.edu>
             KO Myung-Hun  <komh@chollian.net>
 
index 0db82c974a28fc08630b2a8149eab48d46652a6c..e9bf2726e0c1c530fe391bf4cca058db41168211 100644 (file)
@@ -35,6 +35,14 @@ glibc 2.3.3.
 On some platforms, @code{utimes} failed on read-only files when
 @code{utime} worked fine.
 glibc 2.2.5.
+@item
+On OS/2, this function cannot set the timestamp to earlier than the
+year 1980 in local time.
+@item
+On OS/2, this function cannot set the timestamp to an odd number of
+seconds.
+@item
+On OS/2, this function does not work on an opened file.
 @end itemize
 
 Extension: Gnulib provides a module @samp{utimens} that works around these
index a016723e24ae713ff27ce2bc8ef28620c6099ccd..1876bec7996714b57cf578c3ad59f5271cf6f899 100644 (file)
@@ -1,5 +1,5 @@
 # Detect some bugs in glibc's implementation of utimes.
-# serial 3
+# serial 4
 
 dnl Copyright (C) 2003-2005, 2009-2016 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
@@ -33,6 +33,7 @@ AC_DEFUN([gl_FUNC_UTIMES],
 #include <stdlib.h>
 #include <stdio.h>
 #include <utime.h>
+#include <errno.h>
 
 static int
 inorder (time_t a, time_t b, time_t c)
@@ -45,7 +46,10 @@ main ()
 {
   int result = 0;
   char const *file = "conftest.utimes";
-  static struct timeval timeval[2] = {{9, 10}, {999999, 999999}};
+  /* On OS/2, file timestamps must be on or after 1980 in local time,
+     with an even number of seconds.  */
+  static struct timeval timeval[2] = {{315620000 + 10, 10},
+                                      {315620000 + 1000000, 999998}};
 
   /* Test whether utimes() essentially works.  */
   {
@@ -82,9 +86,19 @@ main ()
           result |= 1;
         else if (fstat (fd, &st0) != 0)
           result |= 1;
-        else if (utimes (file, timeval) != 0)
+        else if (utimes (file, timeval) != 0
+                 && (errno != EACCES
+                     /* OS/2 kLIBC utimes fails on opened files.  */
+                     || close (fd) != 0
+                     || utimes (file, timeval) != 0
+                     || (fd = open (file, O_WRONLY)) < 0))
           result |= 2;
-        else if (utimes (file, NULL) != 0)
+        else if (utimes (file, NULL) != 0
+                 && (errno != EACCES
+                     /* OS/2 kLIBC utimes fails on opened files.  */
+                     || close (fd) != 0
+                     || utimes (file, NULL) != 0
+                     || (fd = open (file, O_WRONLY)) < 0))
           result |= 8;
         else if (fstat (fd, &st1) != 0)
           result |= 1;