Conversation
|
@gkgoat1 Thank you for this contribution! I like this idea 👍 The PR is currently really hard to review, because it's almost impossible to see what was actually changed. Could you please avoid /revert the irrelevant re-formatting? |
Do you have a |
|
@gkgoat1 No, I don't use clang format, it might be worth investigating. Thank you for removing the re-formatting, it's now clear what you're trying to add. I'll open a follow up PR to improve the API a bit and address some of the problems. |
|
Are you still looking at this PR? You mentioned a follow-up PR, so I assumed this would be merged. |
turbolent
left a comment
There was a problem hiding this comment.
I had a look through all places where the descriptor's fd, path, and dir fields are accessed and it looks like the following functions still need to handle non-native descriptors:
wasiFdFdstatGetwasiPathFilestatGetwasiPathRenamewasiPathUnlinkFilewasiPathRemoveDirectorywasiPathCreateDirectorywasiPathSymlinkwasiPathReadlinkwasiFDReaddirwasiDirectorySet
What if there is no distinction between native and non-native descriptors, and the callback are only used if they are set (e.g. when reading, writing, etc.)?
wasi/wasi.c
Outdated
|
|
||
| bool | ||
| WARN_UNUSED_RESULT | ||
| wasiFileDescriptorAddStruct( |
There was a problem hiding this comment.
It looks like this is duplicating the last part of wasiFileDescriptorsAdd, adding the descriptor to the descriptors.
Maybe refactor the existing code a bit more:
- Rename this function to
wasiFileDescriptorsAdd - Rename the existing
wasiFileDescriptorsAddto something that indicates it is adding a native descriptor. MaybewasiFileDescriptorAddNative? - Rename this new function to something that indicates it is adding the non-native/callbacks descriptor
wasi/wasi.h
Outdated
| }; | ||
| } WasiFileDescriptor; | ||
|
|
||
| #define wasiIsNative(d) d.fd != -2 |
There was a problem hiding this comment.
What is the magic number -2 here? Is the idea that wasiFileDescriptorAddStruct is called with fd = -2 when the callbacks are set?
There was a problem hiding this comment.
It is a tag indicating the descriptor is non-native
The goal of this PR is to create streaming file descriptors without a native file backing it, so either we distinguish native and non-native descriptors, or implement a complete VFS all in one PR--a hard-to-review almost-full refactor. That may be something we consider later on, but right now having this distinction would enforce the stream-like nature of non-native descriptors. |
This adds custom socket-like FDs to w2c2, which is useful for virtualization.
This code has been reformatted, but there was no
clang-formatfile. In addition, I do not know if the code is still C89; Please comment if any of those issues come up.