[crac] RFR: Adapted some FileDescriptor tests for Win
Roman Marchenko
rmarchenko at openjdk.org
Mon Jul 24 08:25:11 UTC 2023
On Mon, 24 Jul 2023 07:36:56 GMT, Radim Vansa <rvansa at openjdk.org> wrote:
>> Made changes regarding FileDescriptor for Win platorm, adapted some tests.
>
> src/java.base/windows/native/libjava/FileDescriptor_md.c line 118:
>
>> 116: }
>> 117:
>> 118: typedef NTSTATUS(WINAPI* NtQueryObjectFunc)(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG, PULONG);
>
> Rather than using a non-public function, would `GetFileInformationByHandle` work here? You can just test the file attributes matching https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants
GetFileInformationByHandle doesn't work for sockets. The closest appropriate function would be GetFileType, however it operates with integer file type codes, and has too few codes to distiguidh types. Additionally, since I'd like to dump type name into a native description string, I have taken NtQueryObject.
> src/java.base/windows/native/libjava/FileDescriptor_md.c line 119:
>
>> 117:
>> 118: typedef NTSTATUS(WINAPI* NtQueryObjectFunc)(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG, PULONG);
>> 119: typedef BOOL(WINAPI* GetFinalPathNameByHandleFunc)(HANDLE, LPSTR, DWORD, DWORD);
>
> Do you need to load this function dynamically? Contrary to `NtQueryObject` it should be public, present in `fileapi.h`... https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getvolumepathnamesforvolumenamew?redirectedfrom=MSDN
Good point, thanks
-------------
PR Review Comment: https://git.openjdk.org/crac/pull/91#discussion_r1271912577
PR Review Comment: https://git.openjdk.org/crac/pull/91#discussion_r1271912427
More information about the crac-dev
mailing list