RFR: 8350869: os::stat doesn't follow symlinks on Windows

David Holmes dholmes at openjdk.org
Thu May 15 12:21:52 UTC 2025


On Thu, 15 May 2025 09:55:57 GMT, Anton Artemov <duke at openjdk.org> wrote:

>> src/hotspot/os/windows/os_windows.cpp line 4620:
>> 
>>> 4618:   const bool result = fd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && fd.dwReserved0 == IO_REPARSE_TAG_SYMLINK;
>>> 4619:   if (0 == ::FindClose(f)) {
>>> 4620:     errno = ::GetLastError();
>> 
>> I had not noticed this kind of error handling before. It is not obvious that `errno` is able to accept all the values `GetLastError` may report - or perhaps more accurately that anyone checking `errno` would expect to see them.
>> 
>> https://learn.microsoft.com/en-us/cpp/c-runtime-library/errno-constants?view=msvc-170
>
> This mechanism is used throughout the entire os_windows.cpp. For instance,`os::stat()` makes a call to `::GetLastError() `and stores the result in `errno`. Same with `os::open()` In other places, where the error type is known by the programmer, there are explicit assignments to `errno ` of particular error codes. For instance in `os::realpath()`. I just followed the existing pattern.

Yes I can see you followed what already existed in a three places, but my concern is that the existing pattern is actually incorrect. As I said I had not noticed this usage before.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25233#discussion_r2091044524


More information about the hotspot-runtime-dev mailing list