tetratelabs / wazero

wazero: the zero dependency WebAssembly runtime for Go developers

Home Page:https://wazero.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

karelbilek opened this issue · comments

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)

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

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.