Implement Metadata:from_statx for Linux MetadataExt trait#156269
Implement Metadata:from_statx for Linux MetadataExt trait#156269asder8215 wants to merge 2 commits into
Metadata:from_statx for Linux MetadataExt trait#156269Conversation
|
r? @jhpratt rustbot has assigned @jhpratt. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
You can provide a single public const
It's an unsafe function; you have to pass it a valid pointer. We could panic if we get null, as a precaution, but I'm not sure we should; I think we should just assume the pointer is valid. The function should return a |
|
r? libs |
| /// Currently [`Metadata::from_statx`] is only supported on Linux platforms with a target | ||
| /// environment of GNU. |
There was a problem hiding this comment.
I was planning to wait for #154981 before implementing this to avoid this clause.
There was a problem hiding this comment.
Got you. I think the order doesn't matter right now since this function would automatically have musl support once #154981 lands as the PR updates the cfg_has_statx macro. The only thing that needs to be updated is the documentation for this function, which I'm down to keep my eyes on #154981 to see it get merged in.
This PR implements the
Metadata::from_statxfor LinuxMetadataExtACP. You can create astd::fs::Metadatafrom a*const c_voidpopulated by thestatxsyscall.The tracking issue for this ACP is here.
I had a couple of questions regarding to what Josh said in the ACP:
Metadatastruct with the*const c_voidpointer containing the statx info? I'm assuming it's possible that not all of the fields from ourstatxbufwill be submitted or given toMetadatastat fields (since I understood that this function is supposed to be flexible), so we risk accessing something not initialized?Result<Metadata>? Should I be checking whether the given*const c_voidis a null pointer or not, and returning anErrorif it is?Documentation for this function is a WIP. There's probably a lot more I have to say for this function.