public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin/main] Cygwin: readdir: drop support for NT4/Win2K shares and Samba < 3.0.22
Date: Wed, 20 Mar 2024 16:49:39 +0000 (GMT)	[thread overview]
Message-ID: <20240320164939.6CBC6385841A@sourceware.org> (raw)

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

commit b9ed33dec0cbc2f3d64cffc420a7038649dce049
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Wed Mar 20 17:45:41 2024 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Wed Mar 20 17:45:41 2024 +0100

    Cygwin: readdir: drop support for NT4/Win2K shares and Samba < 3.0.22
    
    These systems are at least 18 years old and so buggy that they are
    hopefully not used anymore.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler/disk_file.cc | 60 +++----------------------------------
 winsup/cygwin/release/3.6.0         |  2 +-
 2 files changed, 5 insertions(+), 57 deletions(-)

diff --git a/winsup/cygwin/fhandler/disk_file.cc b/winsup/cygwin/fhandler/disk_file.cc
index f1ac29d329ac..865a05ad95a2 100644
--- a/winsup/cygwin/fhandler/disk_file.cc
+++ b/winsup/cygwin/fhandler/disk_file.cc
@@ -2463,66 +2463,16 @@ fhandler_disk_file::readdir (DIR *dir, dirent *de)
 					 d_cache (dir), DIR_BUF_SIZE,
 					 FileIdBothDirectoryInformation,
 					 FALSE, NULL, dir->__d_position == 0);
-	  /* FileIdBothDirectoryInformation isn't supported for remote drives
-	     on NT4 and 2K systems.  There are also hacked versions of
-	     Samba 3.0.x out there (Debian-based it seems), which return
-	     STATUS_NOT_SUPPORTED rather than handling this info class.
-	     We just fall back to using a standard directory query in
-	     this case and note this case using the dirent_get_d_ino flag. */
-	  if (!NT_SUCCESS (status) && status != STATUS_NO_MORE_FILES
+	  /* FileIdBothDirectoryInformation isn't supported on some
+	     remote drives, but we don't know every system out there.
+	     Check various status codes indicating this. */
+	  if (!NT_SUCCESS (status)
 	      && (status == STATUS_INVALID_LEVEL
 		  || status == STATUS_NOT_SUPPORTED
 		  || status == STATUS_INVALID_PARAMETER
 		  || status == STATUS_INVALID_NETWORK_RESPONSE
 		  || status == STATUS_INVALID_INFO_CLASS))
 	    dir->__flags &= ~dirent_get_d_ino;
-	  /* Something weird happens on Samba up to version 3.0.21c, which is
-	     fixed in 3.0.22.  FileIdBothDirectoryInformation seems to work
-	     nicely, but only up to the 128th entry in the directory.  After
-	     reaching this entry, the next call to NtQueryDirectoryFile
-	     (FileIdBothDirectoryInformation) returns STATUS_INVALID_LEVEL.
-	     Why should we care, we can just switch to
-	     FileBothDirectoryInformation, isn't it?  Nope!  The next call to
-	     NtQueryDirectoryFile(FileBothDirectoryInformation) actually
-	     returns STATUS_NO_MORE_FILES, regardless how many files are left
-	     unread in the directory.  This does not happen when using
-	     FileBothDirectoryInformation right from the start, but since
-	     we can't decide whether the server we're talking with has this
-	     bug or not, we end up serving Samba shares always in the slow
-	     mode using FileBothDirectoryInformation.  So, what we do here is
-	     to implement the solution suggested by Andrew Tridgell,  we just
-	     reread all entries up to dir->d_position using
-	     FileBothDirectoryInformation.
-	     However, We do *not* mark this server as broken and fall back to
-	     using FileBothDirectoryInformation further on.  This would slow
-	     down every access to such a server, even for directories under
-	     128 entries.  Also, bigger dirs only suffer from one additional
-	     call per full directory scan, which shouldn't be too big a hit.
-	     This can easily be changed if necessary. */
-	  if (status == STATUS_INVALID_LEVEL && dir->__d_position)
-	    {
-	      d_cachepos (dir) = 0;
-	      for (int cnt = 0; cnt < dir->__d_position; ++cnt)
-		{
-		  if (d_cachepos (dir) == 0)
-		    {
-		      status = NtQueryDirectoryFile (get_handle (), NULL, NULL,
-					   NULL, &io, d_cache (dir),
-					   DIR_BUF_SIZE,
-					   FileBothDirectoryInformation,
-					   FALSE, NULL, cnt == 0);
-		      if (!NT_SUCCESS (status))
-			goto go_ahead;
-		    }
-		  buf = (PFILE_ID_BOTH_DIR_INFORMATION) (d_cache (dir)
-							 + d_cachepos (dir));
-		  if (buf->NextEntryOffset == 0)
-		    d_cachepos (dir) = 0;
-		  else
-		    d_cachepos (dir) += buf->NextEntryOffset;
-		}
-	      goto go_ahead;
-	    }
 	}
       /* NFS must use FileNamesInformation!  Any other information class
 	 skips all symlinks. */
@@ -2535,8 +2485,6 @@ fhandler_disk_file::readdir (DIR *dir, dirent *de)
 				       FALSE, NULL, dir->__d_position == 0);
     }
 
-go_ahead:
-
   if (status == STATUS_NO_MORE_FILES)
     /*nothing*/;
   else if (!NT_SUCCESS (status))
diff --git a/winsup/cygwin/release/3.6.0 b/winsup/cygwin/release/3.6.0
index fee186e69b20..b5bdceebe430 100644
--- a/winsup/cygwin/release/3.6.0
+++ b/winsup/cygwin/release/3.6.0
@@ -20,7 +20,7 @@ What changed:
 - ps -f now prints the commandline rather than the full path to the
   executable.
 
-- Drop support for NT4 and Samba < 3.0.
+- Drop support for NT4 and Samba < 3.0.22.
 
 - Now that SMBv1 is ultimately deprecated and not installed by default
   on latest Windows versions, enumerating network servers in // and shares

                 reply	other threads:[~2024-03-20 16:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240320164939.6CBC6385841A@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).