-
Notifications
You must be signed in to change notification settings - Fork 256
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
Rename FD to "handle" #62
Comments
My words - see #1 (comment) and #1 (comment) . |
In the IoT space and even more limited environments is possible that a FS-like system exists, but it implements something very different than the typical tree-based FS. For instance, flash filesystems could be targeting raw flash, or rely on HW existing as a translation layer. Similarly, one can envision an EEPROM-based thin layer FS that does wear leveling and only "exposes" a few files to store some calibration info for some sensors (e.g. the TooDry-TooWet markers for a moisture sensor for an automated plat watering system) for multiple units. For such a system, it could be presented as files "plant1.data", "plant2.data" etc. or they could be even lighter like inode=123, inode=789 or, even nicer, abstracted out as a file handle. Needless to say, the string-based names make for friendly interfaces, but they would be unnecessary overhead for such a simple system. I am aware this poses a reasonable question regarding how you get from a human readable identifier to a handler, but I guess naming the "files" in the code as "1", "2", "3" could be an acceptable compromise, and it would be the WASI runtime's job to map the actual names to handlers, but the key point is: once the translation from human-readable names was done by the WASI runtime, assumptions about the implementation and what the returned type is should be limited to "we don't know, it's a black box", and the semantics could be implemented correctly by WASI runtime, whatever definition of "correctly" might apply. I'm not sure I get all the aspects of the discussion above, but I hope this helps a little |
To me the words From a type system POV I think it would be nice if the first argument to file API function was not just a generic handle but some sort of |
I like the term This way, the existing We should then make a new error enum value We could then discuss refactoring the path apis to use a subtype of In the presentation I gave at the WASI http meeting yesterday, I proposed introducing a handful of types of kind handle (including polymorphic types!), which would be represented using the same u32 index space as fd. However, in that presentation, I called them I'm not a fan of calling them |
Here's my take on why this naming is a problem: The problem is not whether it's So maybe we could call it As for the type system POV mentioned by @sbc100, I agree typing is good, so we should have |
Besides the name (I like both I suppose (and am implementing) a WASI host app which forwards the output to its view when WASI modules write some bytes onto stdout/stderr. But one thing to note: in addition to this change, we should add |
* Update to the latest WASI snapshot1 definition This pulls in `sock_accept()` and some minor documentation updates. Signed-off-by: Nathaniel McCallum <[email protected]> * Bump to 0.10.3 Signed-off-by: Nathaniel McCallum <[email protected]>
WASIp2 is based on the component model which has built in handle types. wasi-filesystem for its part calls its "fd" resource just "descriptor". |
The current design has a hidden table of implementation-defined objects that are indexed by the integer "file descriptors" exposed through the API.
These "file descriptors" could be more generally called handles, and the table of implementation-defined objects generalized to include other kinds of objects: processes, threads, mutexes, clocks, etc.
This would allow, for example, WASI APIs that work with process objects without exposing a global process ID namespace, and without adding a separate "process descriptor" table that maps indices to process objects.
The impact on the current API would be pretty minimal:
And everywhere the API currently takes a
__wasi_fd_t
would be changed to take a__wasi_handle_t
.EBADF
could be aliased asEBADHANDLE
, and returned when using an invalid handle.ENOTCAPABLE
could returned when using an API function with a handle that references the wrong kind of object (as presumably the handle will not have the capabilities corresponding to the API function), or a distinct error code could be added.This would apply the same if the integer handles are replaced by
anyref
:typedef anyref __wasi_handle_t
The text was updated successfully, but these errors were encountered: