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 ENAMETOOLONG even if that is not defined FS.OpenFile in the interface documentation #2104

Closed
karelbilek opened this issue Feb 29, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@karelbilek
Copy link
Contributor

This is similar to #2101 but it's more general and it basically contains all other errnos.

Basically, dirFS can return a lot more other errnos - not just the few defined here

https://github.com/tetratelabs/wazero/blob/ba569623fcb7b32bb8fc64dadc842672befd6819/imports/wasi_snapshot_preview1/fs.go#L1534...L1540

when the os returns them as a syscall error, and it's in the list here

func syscallToErrno(err error) (Errno, bool) {

A trivial repro on macOS (need to run from somewhere where you have access to internal/sysfs/dirfs)

rootFS := dirfs.DirFS("/")
res, err := rootFS.OpenFile("tmp/"+strings.Repeat("a", 400), sys.O_CREAT, 0)
fmt.Println(res, err)

This should not be possible according to FS.OpenFile documentation:

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

Again I hit this when I implement my own FS implementation and I am not sure if I should adhere to the doc with the errnos, or just return whatever.

(Sorry if this is duplicate of #2101 and should not be a different issue)

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

The same repro should work on Linux, max filename length is 255.

@evacchi
Copy link
Contributor

evacchi commented Feb 29, 2024

I'd say it is not necessary to open an issue for each new error that is not documented :D let's keep it tidy, as I think I have mentioned in #2076 this feature is still experimental so you might find more of these idiosyncrasies. We can continue on this or #2101, as essentially the issue boils down to limited documentation and/or unspecified behavior.

Do follow up with your questions and feedback, all it's welcome.

@karelbilek
Copy link
Contributor Author

karelbilek commented Feb 29, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants