testsuite tests for Cygwin<->Win32 process interaction
Jeremy Drake
cygwin@jdrake.com
Thu Jun 26 16:59:37 GMT 2025
On Thu, 26 Jun 2025, Corinna Vinschen wrote:
> On Jun 25 16:15, Jeremy Drake via Cygwin-developers wrote:
> > This turned out to be more complicated than I expected,
> > GetFileInformationByHandleEx(FileNameInfo) sucks badly, and seems to only
> > actually work for regular files.
>
> This is unexpected. GetFileInformationByHandleEx is basically just a
> wrapper for NtQueryInformationFile and that goes especially for the
> FileNameInfo class which even neglects to prepend a drive letter or
> UNC path to make the result useful in a DOS Path environment.
>
> But naturally it should work for files and dirs the same.
>
> I attached a Q&D(*) STC. The output shows that it works the same for
> files and dirs:
>
> $ tests/x86_64/ntfilename xxx
> NtOpenFile(\??\C:\cygwin64\home\corinna\xxx)
> NtQueryObject: "\Device\HarddiskVolume3\cygwin64\home\corinna\xxx"
> FileNameInformation: "\cygwin64\home\corinna\xxx"
> FileNormalizedNameInformation: "\cygwin64\home\corinna\xxx"
> FileNameInfo: "\cygwin64\home\corinna\xxx"
>
> $ tests/x86_64/ntfilename .
> NtOpenFile(\??\C:\cygwin64\home\corinna)
> NtQueryObject: "\Device\HarddiskVolume3\cygwin64\home\corinna"
> FileNameInformation: "\cygwin64\home\corinna"
> FileNormalizedNameInformation: "\cygwin64\home\corinna"
> FileNameInfo: "\cygwin64\home\corinna"
>
> So, my question at this point would be, what is the *real* problem here?
>
> > Which is probably why Cygwin uses
> > NtQueryObject(ObjectNameInformation) instead, which I switched to
>
> Uh, we use NtQueryObject in cases where we want valid return values
> for real NT objects or device paths like \Device\Null.
Sorry, I meant that it didn't work for handles to \Device\Null (or console
handles, but they are not part of the tests). I used /dev/null /dev/zero
and /dev/full in tests, and they all seem to turn into \Device\Null when
redirected to/from a Windows executable. I didn't try with directory
handles, because they didn't make sense in the context of redirecting
stdin/out/err. I guess I could add a test for that and see what the
result is (EISDIR?).
>
> > This
> > has the downside of giving NT native paths (\Device\HarddiskVolumeN\path).
>
> Downside? *grin*
>
Downside for me because cygwin_conv_path doesn't produce such paths,
making it more difficult to pass the expected path to the child for
verification.
More information about the Cygwin-developers
mailing list