-
Notifications
You must be signed in to change notification settings - Fork 36
Add a number of native calls to prepare for stat in PowerShell #32
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
Add a number of native calls to prepare for stat in PowerShell #32
Conversation
The goal is to create a stat call which can be called from any non-Windows platform. CommonStat is a stat like structure which has common elements from stat on all systems and uses the largest type for structure members to allow values from any platform
Added lstat fstat probably not needed.
Fix incorrect time references
Create tests for lstat and add a couple more tests for stat
Add tests for new bits Add clean up for getlinkcount test which was leaving files behind
@JamesWTruher Tests failing on Alpine. Please have a look. |
On Alpine it seems to be in /bin
Add empty line to end of files where they belong
@adityapatwardhan I think I've got it (passing on all platforms) - please take a look. |
|
||
// Provide a common structure for the various different stat structures. | ||
// This should be safe to call on all platforms | ||
int GetCommonLStat(const char* path, struct CommonStat* commonStat) |
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 is difficult to see a difference GetCommonLStat vs GetCommonStat. Also name of returned struct CommonStat
says all we want. I see short names GetLStat
and GetStat
is used already. We could use name like GetStatC
or even one common name with the third bool parameter UseSymbolicLink - in last case we will have only single P/Invoke entry in C#.
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.
Since in this project, all the APIs have a 1 to 1 mapping with the native APIs, we should have two APIs namely GetCommonStat
-> stat
and GetCommonLStat
-> lstat
if (errno == ERANGE) | ||
{ | ||
free(buf); | ||
buflen *= 2; | ||
goto allocate; | ||
} |
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.
Maybe add a check like buflen < 2048
?
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 are you attempting to do with this check? ERANGE
is only returned if the buffer is too small
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.
Upper boundary. Or we can support the buffer without upper limit?
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.
we should support whatever sysctl says it is. This can be set in the OS, while I don't believe there are any OSs which have larger than this, I don't know.
Co-Authored-By: Ilya <darpa@yandex.ru>
In preparation for adding a more unix output for Get-ChildItem, I'm adding a number of native calls in support of that:
These return a synthetic stat structure which may be used on all our non-Windows platforms
This returns the group name for a gid
These are used by GetCommonStat and GetCommonLStat