RFR: 8338851: Hoist os::Posix::realpath() to os::realpath() and implement on Windows [v13]
David Holmes
dholmes at openjdk.org
Mon Sep 23 02:16:40 UTC 2024
On Fri, 20 Sep 2024 13:14:54 GMT, Simon Tooke <stooke at openjdk.org> wrote:
>> This PR changes the status of realpath() from a Posix-specific API to a globally available API, i.e. adding it to the "Hotspot Porting API". Code would refer to os::realpath() instead of os::Posix::realpath().
>>
>> This requires a Windows implementation of realpath(), using Windows _fullpath(), and renaming os::Posix::realpath() to os::realpath().
>>
>> The main difference between POSIX and Windows behaviour is that POSIX actually requires an existing accessible file, while Windows will happily work with made-up filenames.
>>
>> Please note that guidelines for doing this appear in src/hotspot/share/runtime/os.hpp
>
> Simon Tooke has updated the pull request incrementally with one additional commit since the last revision:
>
> delete commented out code
Changes requested by dholmes (Reviewer).
test/hotspot/gtest/runtime/test_os.cpp line 434:
> 432: #if defined(_WINDOWS)
> 433: EXPECT_TRUE(returnedBuffer == buffer);
> 434: EXPECT_TRUE(errno == 0);
I thought we concluded you cannot guarantee that errno==0 after a successful call?
test/hotspot/gtest/runtime/test_os.cpp line 442:
> 440: errno = 0;
> 441: returnedBuffer = os::realpath(tmppath, buffer, MAX_PATH);
> 442: EXPECT_TRUE(returnedBuffer != nullptr);
Why the change?
test/hotspot/gtest/runtime/test_os.cpp line 452:
> 450: EXPECT_TRUE(returnedBuffer == nullptr);
> 451: EXPECT_TRUE(errno == ENAMETOOLONG);
> 452: #endif
I think it would be better to increase the buffer size on macOS so this remains a positive test for all platforms.
test/hotspot/gtest/runtime/test_os.cpp line 460:
> 458:
> 459: /* the following tests cause an assert in fastdebug mode */
> 460: DEBUG_ONLY(if (false)) {
Suggestion:
#ifndef ASSERT
no need for a runtime check.
test/hotspot/gtest/runtime/test_os.cpp line 467:
> 465:
> 466: errno = 0;
> 467: returnedBuffer = os::realpath(tmppath, buffer, sizeof(buffer));
This is still not an EINVAL case - the buffer should be null.
Suggestion:
returnedBuffer = os::realpath(tmppath, nullptr, sizeof(buffer));
-------------
PR Review: https://git.openjdk.org/jdk/pull/20683#pullrequestreview-2321034429
PR Review Comment: https://git.openjdk.org/jdk/pull/20683#discussion_r1770713210
PR Review Comment: https://git.openjdk.org/jdk/pull/20683#discussion_r1770713938
PR Review Comment: https://git.openjdk.org/jdk/pull/20683#discussion_r1770716883
PR Review Comment: https://git.openjdk.org/jdk/pull/20683#discussion_r1770717314
PR Review Comment: https://git.openjdk.org/jdk/pull/20683#discussion_r1770717227
More information about the serviceability-dev
mailing list