DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 55N8PuZ33577376 Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 55N8PuZ33577376 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=vGl/BbAA X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08A9A38844CA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1750667154; bh=2/sskQYDajAGy6azFbqFSUZaanWQyPUbZGcHjgGBM1U=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=vGl/BbAAlp1PgEwD7vkO+WytBm7bqisqgOqYQM7+mTOyyx+matdHHhJ00Lr4daJ3P aYYkGWsSJ3vEm8vkl9cWj/5yqs/IXcwT/SuVYAAVRG1OtoaseNFkI/3iz+PVQxsXKN yl0rgqFLvU+kdL14ox/qVv9dkYooRfCq06tzfDW8= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C672A388223B Date: Mon, 23 Jun 2025 10:24:48 +0200 To: cygwin-patches AT cygwin DOT com, cygwin AT cygwin DOT com Subject: Re: symlink_native() bug with case-sensitive file-systems Re: [PATCH] symlink_native: allow linking to `..` Message-ID: Mail-Followup-To: cygwin-patches AT cygwin DOT com, cygwin AT cygwin DOT com References: <6058889e2ae8c9c827a8d6678f09b3b1741e2fcf DOT 1750413578 DOT git DOT johannes DOT schindelin AT gmx DOT de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Corinna Vinschen via Cygwin Reply-To: cygwin-patches AT cygwin DOT com Cc: Corinna Vinschen Content-Type: text/plain; charset="utf-8" Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 55N8PuZ33577376 On Jun 20 13:33, Sebastian Feld wrote: > On Fri, Jun 20, 2025 at 12:03 PM Johannes Schindelin > 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. > 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. Corinna -- 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