4

I have the following test code

func main() {
    path, err := os.Getwd()
    log.Println(path, err)
    files, err := ioutil.ReadDir("/etc/dse")
    log.Println(files, err)
}

I compile it to wasm using

tinygo build -target wasi -o list.wasm list.go

Then I executeit using

wasmtime list.wasm

The output is

2023/05/05 16:00:50 / <nil>
2023/05/05 16:00:50 [] open /etc/dse: errno 76

At the same time, the directory /etc/dse exists and has permissions 777.

What is the source of this error and how to fix this?

1 Answer 1

2

errno 76 means capabilities insufficient.

You have to give it capabilities to access files in the requisite directories, with the wasmtime option --dir (see wasmtime WASI tutorial):

The --dir= option instructs wasmtime to preopen a directory, and make it available to the program as a capability which can be used to open files inside that directory.

$ wasmtime --dir=/etc/dse list.wasm
2023/05/06 01:36:31 / <nil>
2023/05/06 01:36:31 [] readdir unimplemented : errno 54

Unfortunately, readdir is not implemented in TinyGo yet.

References:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.