bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH v7 10/11] utimes: detect utimes() correctly on OS/2 kLIBC


From: Paul Eggert
Subject: Re: [PATCH v7 10/11] utimes: detect utimes() correctly on OS/2 kLIBC
Date: Thu, 14 Jan 2016 16:19:33 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

On 01/13/2016 06:23 PM, KO Myung-Hun wrote:
address@hidden
+On OS/2, this funciton cannot set timestamp earlier than 1980 year in local
+time.
address@hidden
+On OS/2, this function cannot set timestamp in odd seconds.

Misspelled "function", and some grammar issues. Please change to something like this:

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.


+  /* On OS/2, a file date should be since 1980 year in local time
+     and even seconds.  */

Reword to "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,15 +86,18 @@ main ()
            result |= 1;
          else if (fstat (fd, &st0) != 0)
            result |= 1;
+        else if (write (fd, "\n", 1) != 1)
+          result |= 1;
+        else if (fstat (fd, &st1) != 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)
-          result |= 1;
-        else if (write (fd, "\n", 1) != 1)
-          result |= 1;
-        else if (fstat (fd, &st2) != 0)
+        else if (lstat (file, &st2) != 0)
            result |= 1;
          else if (time (&t2) == (time_t) -1)
            result |= 1;
@@ -103,7 +110,8 @@ main ()
              if (! (m_ok_POSIX || m_ok_NFS))
                result |= 32;
            }
-        if (close (fd) != 0)
+        /* Ensure to close fd, but ignore an error if already closed. */
+        if (close (fd) != 0 && errno != EBADF)
            result |= 1;
        }
      if (unlink (file) != 0)

This doesn't look right, as the original order of updating the file's time stamps is needed to tickle the NFS bug. Instead, please change the code to attempt utimes() on the opened file, and if this fails the way that kLIBC fails, then close the file, invoke utimes on the file, and reopen the file. That way, the order will be preserved and there should be no need for any EBADF check.



reply via email to

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