A small correction to this new code:

2017-05-07 Bruno Haible  <br...@clisp.org>

        utimens: Improve error code on native Windows.
        * lib/utimens.c (fdutimens): If fd was not opened with O_RDWR, fail with
        error code EACCES, not EINVAL.

diff --git a/lib/utimens.c b/lib/utimens.c
index 5f3a846..b027cfb 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -349,11 +349,19 @@ fdutimens (int fd, char const *file, struct timespec 
const timespec[2])
         return 0;
       else
         {
-          #if 0
           DWORD sft_error = GetLastError ();
-          fprintf (stderr, "utime SetFileTime error 0x%x\n", (unsigned int) 
sft_error);
+          #if 0
+          fprintf (stderr, "fdutimens SetFileTime error 0x%x\n", (unsigned 
int) sft_error);
           #endif
-          errno = EINVAL;
+          switch (sft_error)
+            {
+            case ERROR_ACCESS_DENIED: /* fd was opened without O_RDWR */
+              errno = EACCES; /* not specified by POSIX */
+              break;
+            default:
+              errno = EINVAL;
+              break;
+            }
           return -1;
         }
     }


Reply via email to