On Mon, Jun 23, 2025 at 10:52 AM Corinna Vinschen
<corinna-cyg...@cygwin.com> wrote:
>
> On Jun 20 13:33, Sebastian Feld wrote:
> > On Fri, Jun 20, 2025 at 12:03 PM Johannes Schindelin
> > <johannes.schinde...@gmx.de> wrote:
> > >  winsup/cygwin/path.cc | 21 ++++++++++++++++-----
> > >  1 file changed, 16 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
> > > index 42919a7cf5..ed08398930 100644
> > > --- a/winsup/cygwin/path.cc
> > > +++ b/winsup/cygwin/path.cc
> > > @@ -1855,9 +1855,18 @@ symlink_native (const char *oldpath, path_conv 
> > > &win32_newpath)
> > >        while (towupper (*++c_old) == towupper (*++c_new))
> >
> > 1 unrelated issue:
> > I think this towupper() code is WRONG if the filesystem (e.g. WSL) is
> > case-sensitive!
>
> The preceding comment tries to explain why we always compare case
> insensitive.  There's a high probability that the symlink will be used
> by native (non-Cygwin) processes which are insensitive.

OK, but this is at least bad for performance.

Some stats from a profiling tool I am working on:
German language, multibyte locale, codepage 65001:
Each towupper() traverses 11 functions, covering between 8002 and
11722 instructions, and between 260 and 469 branches, on 64bit.
If the code could just use the per-volume case sensitive flag, then
this could be reduced to 20-30 instructions just to do the indirect
load (2 times) and compare.

> > How can code in cygwin.dll test whether the current path is on a
> > case-sensitive volume, or not?
>
> There's a twist here.  NTFS or ReFS or other filesystems (but not FAT)
> are usually case sensitive.  It's the OS which makes them case insensitve
> by using a specific flag at open time, combined with a kernel registry
> key.  So apart from FAT, the creator of a file decides if it's created
> sensitive or insensitive, and the one searching for and opening a file
> is deciding if the search/open is sensitive or insensitive.
>
> Also, we're creating the symlink via CreateSymbolicLinkW, which is
> probably acting case insensitive anyway...
>
> What if the perr-dir case-sensitive
> > feature is ON, should that be probed and handled too?
>
> ...unless the symlink is created in a case sensitive dir, I assume.
>
> Right now we don't handle case sensitive dirs in the path_conv code.  We
> only check for the kernel registry key and the FILE_CASE_SENSITIVE_SEARCH
> filesystem flag.
>
> To add the sensitive dirs to the picture, path_conv() would have to
> check every directory on NTFS for
> NtQueryInformationFile(FileCaseSensitiveInformation). It would then
> set the path_conv::caseinsensitive flag accordingly.

Yikes. Does Windows cache this per-dir info somewhere?

Sebi
-- 
Sebastian Feld - IT security consultant

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to