delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2024/12/09/08:50:53

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 4B9Dortl824204
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 4B9Dortl824204
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=ZW36J9RB
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 37BCB385840C
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1733752251;
bh=/UyIWh8EJXnkOiHayVPyF8+Z82wTn/TvesxoKjaatqI=;
h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
From;
b=ZW36J9RBU2Izfa36/XzJXe1HnfP1jmLatV4nDXzrhFPvhlu5dpP7EHtSj0lZx51Qn
f0PE4cluK3HmPCZCOSWV+e4sBgKvYvX1TvOc7TilkKLOUHTN971oFjNP3DuYuFIJGs
yXbJ1fTdBPM1ihobeIQNSEAMwMOA3q+koZTI/ZQI=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 129093858D34
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 129093858D34
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1733752088; cv=none;
b=Ox/JOxNPp2YZ3I+JRfc6Ecw9RMrMcdLfY1loULGzXp68FSUfYobxdhwPoJg6Q1/nNWbxz2bUPLzt7+VAglkRbi6cBXN0wmjJ/WUyrjJtOJCwc0+02mvOfLSNQw6pLqbH4PMvGMK35h69cNHtV7mf5CZcJekEhwLncX+aJTut8DQ=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1733752088; c=relaxed/simple;
bh=I/Sp8ou5pYC9xZFUwUXGaigVQQ8W/APlgrVOTxjmUWU=;
h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;
b=rXhzckQzSs+svvk3foSQtH4AJWrV8DiqmaQ0S/WothZ8ceyCwYbGY6jpPGowFmVzOf/WNStoRAOu4dhjwQy8N1q9K7WkPbpo3khJDQjSgfvO6OCSQ+hQwxhA2LZGr5QRdqQ4yy76wCBMFJXOkVw4PzfMc1JhxjFOLRby7+2wTCU=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 129093858D34
Message-ID: <16f5e717-2271-4107-b1b3-f28c3a1ca47d@kircheis.it>
Date: Mon, 9 Dec 2024 14:48:01 +0100
MIME-Version: 1.0
Subject: Re: cygpath and unc paths
To: cygwin AT cygwin DOT com
References: <ee626000-a159-4482-a897-da725f02b28c AT kircheis DOT it>
<Z1bYfmvPYc6yFEJr AT calimero DOT vinschen DOT de>
<053d21b3-ee11-4858-a60d-54cd154fd98c AT kircheis DOT it>
<Z1buBnm2WlNEG8t1 AT calimero DOT vinschen DOT de>
In-Reply-To: <Z1buBnm2WlNEG8t1@calimero.vinschen.de>
X-Rspamd-Queue-Id: 4Y6NVC0zfGz9t29
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Federico Kircheis via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Federico Kircheis <federico AT kircheis DOT it>
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>

On 09/12/2024 14.17, Corinna Vinschen via Cygwin wrote:
> On Dec  9 13:47, Federico Kircheis via Cygwin wrote:
>> On 09/12/2024 12.46, Corinna Vinschen via Cygwin wrote:
>>> On Dec  6 13:23, Federico Kircheis via Cygwin wrote:
>>>> Hello,
>>>>
>>>> was it considered to add a flag to cygpath to output a path in unc format?
>>>
>>> No.  But it wouldn't be much work.
>>
>> It would be very nice if it ever happens.
>>
>>>> For example, the folder
>>>>
>>>> C:\test.
>>>>
>>>> cannot be accessed from many Windows applications (powershell and cmd
>>>> included) because of the trailing dot, while cygwin has no issue creating,
>>>> accessing and deleting such files/folders.
>>>>
>>>> Using an unc path
>>>>
>>>> \\?\C:\test.
>>>>
>>>> solves the issue for some programs, but cygpath currently misses an option
>>>> for creating such path.
>>>
>>> As a workaround you can just prepend the long path prefix:
>>>
>>>     echo -n '\\?\'; cygpath ...
>>
>> Which is what I'm doing, plus special-casing
>>
>> 1)
>> root path, like C:\ , because for whatever reason \\?\C:\ is not valid, it
>> has to be a subfolder (and trying to trick it with \\?\C:\\ does not work
>> either).
> 
> In which scenario?  \\?\C:\ is just the same as \??\C:\ in NT speak, and
> that's a perfectly valid directory path.

I've never seen \??\C:\.

My test case, from powershell (which I do definitively _not_ know well 
enough, otherwise I wouldn't be using cygwin) was

cd C:\             # success
cd \\?\C:\         # fail
cd C:\windows      # success
cd \\?\C:\windows  # success

and repeat the same operation with dir instead of ls.

The error message is that the "value of argument path is not valid"

I did some further testing: no amount of quoting (with ", ' and `) 
helps, also replacing \ with / does not change any outcome.

For cd, the parameter -literal makes a difference

cd -literal \\?\C:\  # success

for dir, I did not find anything yet.

So I guess you are correct, although support from basic tools (cd and 
dir at least) seems very suboptimal...

>> 2)
>> unmounted network drives (\\server\path)
> 
> Yeah, those have a different prefix:
> 
>    \\?\UNC\server\share
> 
>> I'm not sure how a --unc should handle those cases.
>> For all things I have in mind, not appending \\?\ is preferred, but someone
>> might expect a hard error.
>>
>> Either way, it is another reason why it makes sense for cygpath to handle
>> those cases, currently I have to parse it's output before prepending '\\?\'.
> 
> I'll take a look.
> 
>>>> Notice that creating a dos path leads to an error.
>>>
>>> I don't understand. Creating which DOS path with which application?
>>
>> I meant that it is not possible to create a DOS path to C:\test., thus using
>> a dos path is not a viable workaround to unc:
>>
>> ----
>>> cd 'C:/test.'
>>> cygpath -ws .
>> cygpath: cannot create short name of .
>> ----
> 
> Don't use -s, it's just for the old short name style of DOS paths.
> Nobody should actually need this nowadays, and sometimes short paths
> don't even exist.  It's a functionality inside the FS driver, afaik, and
> it can be switched off in the system.
> 
> In your example, standard filenames work:
> 
>    $ cd /cygdrive/c
>    $ mkdir test.
>    $ cd test.
>    $ cygpath -ws .
>    cygpath: cannot create short name of C:\test.
>    $ cygpath -wa .
>    C:\test.

Yes, -wa works; I wanted to point out that DOS paths are not a viable 
workaround.
I could have left it out from my first mail, we agree no need to iterate 
further ;)


-- 
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019