From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 6CBC6385841A; Wed, 20 Mar 2024 16:49:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6CBC6385841A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1710953379; bh=WI8mDUtlS4DoUFrbdlWGybP4Nefe4kDmIothiQU9BhA=; h=From:To:Subject:Date:From; b=iw/xqgXxbGu7SZ5/4tnSiJjeRGjFy22vRAuYFGYeNPMWhnsMtafTEl7QFkCxijVod nxYzoraOMTaBW/aEBHjoW3H3GTF00eNOt5g82P250P0W2RB8C94/cdGciivh1dXKh0 PWblwPmrjfz9T1h7yN2dL/Yy7nX884vH3yT3O8kA= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: readdir: drop support for NT4/Win2K shares and Samba < 3.0.22 X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: 8bd6ba8f16ec7ae07118d5f0d552efe421b008a5 X-Git-Newrev: b9ed33dec0cbc2f3d64cffc420a7038649dce049 Message-Id: <20240320164939.6CBC6385841A@sourceware.org> Date: Wed, 20 Mar 2024 16:49:39 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Db9ed33dec0c= bc2f3d64cffc420a7038649dce049 commit b9ed33dec0cbc2f3d64cffc420a7038649dce049 Author: Corinna Vinschen AuthorDate: Wed Mar 20 17:45:41 2024 +0100 Commit: Corinna Vinschen CommitDate: Wed Mar 20 17:45:41 2024 +0100 Cygwin: readdir: drop support for NT4/Win2K shares and Samba < 3.0.22 =20 These systems are at least 18 years old and so buggy that they are hopefully not used anymore. =20 Signed-off-by: Corinna Vinschen 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/d= isk_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 =3D=3D 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 !=3D 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 =3D=3D STATUS_INVALID_LEVEL || status =3D=3D STATUS_NOT_SUPPORTED || status =3D=3D STATUS_INVALID_PARAMETER || status =3D=3D STATUS_INVALID_NETWORK_RESPONSE || status =3D=3D STATUS_INVALID_INFO_CLASS)) dir->__flags &=3D ~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 =3D=3D STATUS_INVALID_LEVEL && dir->__d_position) - { - d_cachepos (dir) =3D 0; - for (int cnt =3D 0; cnt < dir->__d_position; ++cnt) - { - if (d_cachepos (dir) =3D=3D 0) - { - status =3D NtQueryDirectoryFile (get_handle (), NULL, NULL, - NULL, &io, d_cache (dir), - DIR_BUF_SIZE, - FileBothDirectoryInformation, - FALSE, NULL, cnt =3D=3D 0); - if (!NT_SUCCESS (status)) - goto go_ahead; - } - buf =3D (PFILE_ID_BOTH_DIR_INFORMATION) (d_cache (dir) - + d_cachepos (dir)); - if (buf->NextEntryOffset =3D=3D 0) - d_cachepos (dir) =3D 0; - else - d_cachepos (dir) +=3D 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 =3D=3D 0); } =20 -go_ahead: - if (status =3D=3D 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. =20 -- Drop support for NT4 and Samba < 3.0. +- Drop support for NT4 and Samba < 3.0.22. =20 - Now that SMBv1 is ultimately deprecated and not installed by default on latest Windows versions, enumerating network servers in // and shares