bug-gnulib
[Top][All Lists]
Advanced

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

Re: utimens: support for native Windows


From: Bruno Haible
Subject: Re: utimens: support for native Windows
Date: Mon, 08 May 2017 11:59:33 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-75-generic; KDE/5.18.0; x86_64; ; )

A small correction to this new code:


2017-05-07 Bruno Haible  <address@hidden>

        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

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