delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/01/21/13:34:56

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:content-type
:content-transfer-encoding:date:from:to:subject:in-reply-to
:references:message-id; q=dns; s=default; b=eF3uQYBgZY1LakOuyKIL
G7feK/j6romvXzqEpJuK8lfBsIYaszo+p56jhr0D9GgzI0KMUau0vfkCh8B2gNzm
A3wA8dXuk8UXgFiWBCCbEi+jidz0aCHhdzAuuyrIgei6AdwLLZjWQm7nJnU/VuIT
HJ45xV3okScSXDBHOGVAwGw=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:content-type
:content-transfer-encoding:date:from:to:subject:in-reply-to
:references:message-id; s=default; bh=4nZP42LLb2qu7KlL+Fn0u5yg4i
Q=; b=Vf9j9Dd0nOxgL1m0jyzE4Memk4jBjGcIc0Bw2TTuiLs5m0yoqNxEShUFpd
AQVbi/rdL8LvtGb4Y/wPdP5aaBkYDL4boAwK/OSzmYAxvcrvJjOwkQ3EWkTiV6e6
dIfTooiFgT3qFiEyC047ObNSqBrsQLbsg9ld+v1fO8lmYztKo=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_05,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=mystery, angry, sk:invalid, WRONG
X-HELO: lb3-smtp-cloud3.xs4all.net
MIME-Version: 1.0
Date: Thu, 21 Jan 2016 19:34:33 +0100
From: Houder <houder AT xs4all DOT nl>
To: cygwin AT cygwin DOT com
Subject: Re: cygpath 2.4.0 (32-bits) in error?
In-Reply-To: <20160121154209.GA12461@calimero.vinschen.de>
References: <d62c155805db0d69643e95de1709635f AT xs4all DOT nl> <loom DOT 20160121T160854-114 AT post DOT gmane DOT org> <20160121154209 DOT GA12461 AT calimero DOT vinschen DOT de>
Message-ID: <892d9876668c7f8a417ed63db8befa8a@xs4all.nl>
X-Sender: houder AT xs4all DOT nl (JwZWcNYoRTbAdDKfX+6nqw==)
User-Agent: XS4ALL Webmail
X-IsSubscribed: yes

On 2016-01-21 16:42, Corinna Vinschen wrote:
> On Jan 21 15:11, Achim Gratz wrote:
>> Houder <houder <at> xs4all.nl> writes:
>> > %% uname -a
>> > CYGWIN_NT-6.1-WOW Seven 2.4.0(0.293/5/3) 2016-01-15 16:14 i686 Cygwin
>> >
>> > %% /usr/bin/cygpath -S -u
>> > /drv/c/Windows/SysWOW64 <==== Nice, the truth is out! ... but do we want
>> > it here?
>> > %% /usr/bin/cygpath -S -w
>> > C:\Windows\system32
>> > %%
>> > %% /usr/bin/cygpath -S -U
>> > /proc/cygdrive/c/Windows/SysWOW64 <==== ditto
>> 
>> Well
>> 
>> /usr/bin/cygpath -u $( /usr/bin/cygpath -Sw )
>> 
>> delivers the right result.  I guess an option to chose which result to 
>> get
>> might be nice, but I can cope either way.
> 
> I hate this path redirection stuff.  Patches welcome.  Maybe we should
> simply replace SysWOW64 with System32, a simple string operation.

Hi Corinna,

Did not mean to get you angry ...

do_sysfolders() in cygpath.cc has changed between 2.3.1 and 2.4.0 where
it attempts to ascertain the 'system directory'.

The postprocessing after GetSystemDirectoryW() is different ...

The call to NtQueryInformationFile() in 2.4.0 spoils the result that has
been obtained by GetSystemDirectoryW() call.

Reverting your modification makes cygpath correct again (tested: 
32-bits).

It is clear from the commentary what you are attempting to achieve after
the call to GetSystemDirectoryW() ...

However, the code after the call to GetSystemDirectoryW() is a mystery 
to
me. Sorry.

Regards,
Henri

do_sysfolders() in cygpath.cc

-----
2.3.1
     case 'S':
       {
	HANDLE fh;
	WIN32_FIND_DATAW w32_fd;

	GetSystemDirectoryW (wbuf, MAX_PATH);
	/* The path returned by GetSystemDirectoryW is not case preserving.
	   The below code is a trick to get the correct case of the system
	   directory from Windows. */
	if ((fh = FindFirstFileW (wbuf, &w32_fd)) != INVALID_HANDLE_VALUE)
	  {
	    FindClose (fh);
	    wcscpy (wcsrchr (wbuf, L'\\') + 1, w32_fd.cFileName);
	  }
       }
       break;

-----
2.4.0:
     case 'S':
       {
	GetSystemDirectoryW (wbuf, MAX_PATH);
...
       if (iswalpha (wbuf[0]) && wbuf[1] == L':' && wbuf[2] == L'\\')
	{
	  OBJECT_ATTRIBUTES attr;
	  NTSTATUS status;
	  HANDLE h;
	  IO_STATUS_BLOCK io;
	  UNICODE_STRING upath;
	  const ULONG size = sizeof (FILE_NAME_INFORMATION)
			     + PATH_MAX * sizeof (WCHAR);
	  PFILE_NAME_INFORMATION pfni = (PFILE_NAME_INFORMATION) alloca (size);

	  /* Avoid another buffer, reuse pfni. */
	  wcpcpy (wcpcpy (pfni->FileName, L"\\??\\"), wbuf);
wprintf (L" 1: pfni->FileName: %S\n", pfni->FileName); // still correct
	  RtlInitUnicodeString (&upath, pfni->FileName);
wprintf (L" 2: pfni->FileName: %S\n", pfni->FileName); // still correct
	  InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE,
				      NULL, NULL);
	  status = NtOpenFile (&h, READ_CONTROL, &attr, &io,
			       FILE_SHARE_VALID_FLAGS, FILE_OPEN_REPARSE_POINT);
	  if (NT_SUCCESS (status))
	    {
	      status = NtQueryInformationFile (h, &io, pfni, size,
					       FileNameInformation); // returns the wrong path
wprintf (L" 3: pfni->FileName: %S\n", pfni->FileName); // WRONG
	      if (NT_SUCCESS (status))
		{
		  pfni->FileName[pfni->FileNameLength / sizeof (WCHAR)] = L'\0';
wprintf (L" 4: pfni->FileName: %S\n", pfni->FileName);
		  wcscpy (wbuf + 2, pfni->FileName);
wprintf (L"wcscpy(): %S\n", wbuf);
		}
	      NtClose (h);
	    }
	}

=====



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

- Raw text -


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