bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 11/12] utimes: detect utimes() correctly on OS/2 kLIBC


From: KO Myung-Hun
Subject: [PATCH 11/12] utimes: detect utimes() correctly on OS/2 kLIBC
Date: Wed, 27 May 2015 21:45:49 +0900

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 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.
---
 m4/utimes.m4 | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/m4/utimes.m4 b/m4/utimes.m4
index e26a576..a6f00c1 100644
--- a/m4/utimes.m4
+++ b/m4/utimes.m4
@@ -1,5 +1,5 @@
 # Detect some bugs in glibc's implementation of utimes.
-# serial 3
+# serial 4
 
 dnl Copyright (C) 2003-2005, 2009-2015 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
@@ -45,7 +45,10 @@ main ()
 {
   int result = 0;
   char const *file = "conftest.utimes";
-  static struct timeval timeval[2] = {{9, 10}, {999999, 999999}};
+  /* On OS/2, a file date should be since 1980 year in local time
+     and even seconds.  */
+  static struct timeval timeval[2] = {{315620000 + 10, 10},
+                                      {315620000 + 1000000, 999998}};
 
   /* Test whether utimes() essentially works.  */
   {
@@ -82,11 +85,16 @@ main ()
           result |= 1;
         else if (fstat (fd, &st0) != 0)
           result |= 1;
+        /* utimes() of OS/2 kLIBC does not work on an opened file */
+        else if (close (fd) != 0)
+          result |= 1;
         else if (utimes (file, timeval) != 0)
           result |= 2;
         else if (utimes (file, NULL) != 0)
           result |= 8;
-        else if (fstat (fd, &st1) != 0)
+        else if (lstat (file, &st1) != 0)
+          result |= 1;
+        else if ((fd = open (file, O_WRONLY)) < 0)
           result |= 1;
         else if (write (fd, "\n", 1) != 1)
           result |= 1;
-- 
1.9.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]