-
Notifications
You must be signed in to change notification settings - Fork 5.2k
CleanUp GetFileAttribute(Ex) in PAL #116096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/native/minipal/file.c
Outdated
| // The normalization examples are : | ||
| // C:\foo\<long>\bar => \\?\C:\foo\<long>\bar | ||
| // \\server\<long>\bar => \\?\UNC\server\<long>\bar | ||
| static WCHAR* NormalizePath(const WCHAR* path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is yet-another duplicate of the path normalization algorithm:
corehost\hostmisc\longfile.native.cpp, implemented withstd::wstringutilcode\longfilepathwrappers.cpp, implemented withSStringPathInternal.EnsureExtendedPrefixIfNeeded, implemented with managed string
When we eventually move all Win32 API to minipal, the utilcode version should be replaced by minipal version. Implementing this in pure C is really error-prone and unpleasable.
src/native/minipal/file.c
Outdated
| if (ret) | ||
| { | ||
| attributes->size = stat_data.st_size; | ||
| attributes->lastWriteTime = UnixTimeToWin32FileTime(stat_data.st_mtim); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minipal/time is already requiring timespec, let's see if all platforms are having timespec available in stat.
src/native/minipal/file.c
Outdated
| attributes->size = stat_data.st_size; | ||
| attributes->lastWriteTime = UnixTimeToWin32FileTime(stat_data.st_mtim); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This somehow overlaps with libs/pal_io.c, the differences are:
- The UTF16/UTF8 transformation is done at managed side for libs, but minipal needs cross-platform representation which prefers UTF16
- This only includes the portion needed for native runtime, in libs there are much more information exposed.
Thus I think it's better to keep them separated.
src/native/minipal/file.h
Outdated
| uint64_t lastWriteTime; // Windows FILETIME precision | ||
| } minipal_file_attr_t; | ||
|
|
||
| bool minipal_file_get_attributes_utf16(const char16_t* path, minipal_file_attr_t* attributes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pal/mstypes.h defines WCHAR as char16_t, which is incompatible with unsigned short from minipal/types.h. Since pal uses char16_t unconditionally, I assume it's broad available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which is incompatible with
unsigned short
What was the error when you used CHAR16_T? You may need to sprinkle a few (CHAR16_T*)var at call sites like we did for utf conversion API call sites.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just char16_t* and unsigned short* is incompatible. Yes there are casts like
| return minipal_u16_strlen((CHAR16_T*)str); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Windows, it is defined as wchar_t, while on Unix it is defined as unsigned short because char16_t is not available everywhere (as seen in current CI errors). I checked various platform headers when defining CHAR16_T and unsigned short was close enough (they use some flexible type but this assumption just works across our supported platforms).
src/coreclr/md/compiler/mdutil.cpp
Outdated
|
|
||
| // The cache is locked for read, so the list will not change. | ||
|
|
||
| // Figure out the size and timestamp of this file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this cache used for? Do we still need it? Would it be better to delete it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's called by IMetaDataDispenser::OpenScope and reusing the same object for same file. I don't get a good insight for its impact and performance of creating new RegMeta instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am deleting it in #116126. Once that change goes through, we should not need GetFileAttributes in the minipal.
|
I/O for core runtime should fall into two categories:
Things that do not fall into any of these two categories - like the metadata cache you have changed - look suspect. They should be scrutinized heavily. |
I did some attempt for that. For CRT I/O, the biggest problem is the string encoding of |
JIT has |
|
|
||
| //To delete file need to make it normal | ||
| if(!SetFileAttributesA(szReadOnlyFile,FILE_ATTRIBUTE_NORMAL)) | ||
| if((last_error = chmod(szReadOnlyFile, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this also have the != 0 like above?
src/coreclr/pal/inc/pal.h
Outdated
| #define GetFileAttributes GetFileAttributesA | ||
| #endif | ||
|
|
||
| typedef enum _GET_FILEEX_INFO_LEVELS { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete these as well enums/types as well
|
/azp run runtime-coreclr outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
It's a missed case of #115986. Is the automated trigger for PAL pipeline enabled now? |
|
Missing #116096 (comment). |
|
/azp run runtime-coreclr outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
FAILED: file_io/errorpathnotfound/test2/paltest_errorpathnotfound_test2. Exit code: 1 Thread waited for 2138803459 ms! (Acceptable delta: 300) |
This is removed but missed from test list.
This doesn't look related. |
|
/azp run runtime-coreclr outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
jkotas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
First step of moving file IO to minipal.