https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9c4113f0c78d0872e1f5691e40a19f620a98cfec

commit 9c4113f0c78d0872e1f5691e40a19f620a98cfec
Author: Corinna Vinschen <[email protected]>
Date:   Thu Aug 4 11:13:57 2016 +0200

    Workaround for filesystems with broken FileAllInformation info class (NcFsd)
    
    See discussion starting at 
https://cygwin.com/ml/cygwin/2016-07/msg00350.html
    
    Signed-off-by: Corinna Vinschen <[email protected]>

Diff:
---
 winsup/cygwin/path.cc | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 970a0fe..4ffe5f9 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -1305,8 +1305,31 @@ file_get_fai (HANDLE h, PFILE_ALL_INFORMATION pfai)
   /* Some FSes (Netapps) don't implement FileNetworkOpenInformation. */
   status = NtQueryInformationFile (h, &io, pfai, sizeof *pfai,
                                   FileAllInformation);
-  if (status == STATUS_BUFFER_OVERFLOW)
+  if (likely (status == STATUS_BUFFER_OVERFLOW))
     status = STATUS_SUCCESS;
+  /* Filesystems with broken FileAllInformation exist, too.  See the thread
+     starting with https://cygwin.com/ml/cygwin/2016-07/msg00350.html. */
+  else if (!NT_SUCCESS (status) && status != STATUS_ACCESS_DENIED)
+    {
+      memset (pfai, 0, sizeof *pfai);
+      status = NtQueryInformationFile (h, &io, &pfai->BasicInformation,
+                                      sizeof pfai->BasicInformation,
+                                      FileBasicInformation);
+      if (NT_SUCCESS (status))
+       {
+         /* The return value of FileInternalInformation is largely ignored.
+            We only make absolutely sure the inode number is set to 0 in
+            case it fails. */
+         status = NtQueryInformationFile (h, &io, &pfai->InternalInformation,
+                                          sizeof pfai->InternalInformation,
+                                          FileInternalInformation);
+         if (!NT_SUCCESS (status))
+           pfai->InternalInformation.IndexNumber.QuadPart = 0LL;
+         status = NtQueryInformationFile (h, &io, &pfai->StandardInformation,
+                                          sizeof pfai->StandardInformation,
+                                          FileStandardInformation);
+       }
+    }
   return status;
 }

Reply via email to