Skip to content
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

dirfs.OpenFile can return EEXIST even if that is not defined FS.OpenFile in the interface documentation #2101

Open
karelbilek opened this issue Feb 28, 2024 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@karelbilek
Copy link
Contributor

In the interface FS.OpenFile, you have defined a set of errors that OpenFile can return.

https://github.com/tetratelabs/wazero/blob/ba569623fcb7b32bb8fc64dadc842672befd6819/experimental/sys/fs.go#L34...L39

However, if you follow what DirFS can return, there are more possible errors

https://github.com/tetratelabs/wazero/blob/ba569623fcb7b32bb8fc64dadc842672befd6819/experimental/sys/error.go#L10...L30

For example, if one opens file with O_CREAT and O_EXCL, but the file exists already, POSIX OS will return EEXIST.

I am implementing a custom FS, and I am not sure what to follow; there is a mismatch between the docs say and what the DirFS actually does.

@karelbilek karelbilek added the bug Something isn't working label Feb 28, 2024
@karelbilek
Copy link
Contributor Author

@evacchi
Copy link
Contributor

evacchi commented Feb 28, 2024

indeed, there are case where we return EEXIST https://github.com/tetratelabs/wazero/blame/main/experimental/sys/fs.go when we do it is usually because there is a test that requires it; e.g. in wasi-testsuite or other test suites. I will double check the docs to make sure they are up to date.

@karelbilek
Copy link
Contributor Author

karelbilek commented Feb 29, 2024

As written in #2104 I figured out there are other errors that are not in the docs.

I wanted to make a PR with all the possible errnos, but then I realized, all I am doing is rewriting https://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html (the ERRORS part) to godoc format.

At which point I realized I might be even breaking copyright, as POSIX docs are copyrighted.

Wouldn't it be better to just link to the posix errors and say "here, there is a list"? It's documented better than will be here... the list on POSIX docs is very exhaustive.

Or, just rewrite the docs from "The below are expected otherwise..." to "Some possible errors: ..."?

@karelbilek
Copy link
Contributor Author

karelbilek commented Feb 29, 2024

Hm, but only SOME of those actually matter here. Hm. I guess I get back to rewriting. (But in my own words.)

edit: hm, no, I will not rewrite this, I can just copy-paste that

A component of the path prefix names an existing file that is neither a directory nor a symbolic link to a directory; or O_CREAT and O_EXCL are not specified, the path argument contains at least one non- character and ends with one or more trailing characters, and the last pathname component names an existing file that is neither a directory nor a symbolic link to a directory; or O_DIRECTORY was specified and the path argument resolves to a non-directory file.

@ncruces ncruces added documentation Improvements or additions to documentation and removed bug Something isn't working labels Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants