You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -58,16 +58,16 @@ Our wasm file should be compiled to `target/wasm32-wasi/debug/wasi_hello_world.w
58
58
59
59
To do this, we can use the Wasmtime CLI, which we mentioned should be installed at the beginning of this tutorial. However, there is one thing to note that was mentioned in the code comments. **We need to give our program explicit access to create files on our host, because our program creates a new file**. As mentioned in the [WASI Introduction](/example-redirect?exampleName=wasi-introduction), our guest will not have this capability unless we give them the capability.
60
60
61
-
To grant the capability to write in a directory using the Wasmtime CLI, we need to use the `--mapdir` flag. `--mapdir` will allow us to map the `/helloworld` directory on the guest's virtual filesystem, to the current directory (`.`) on the host fileystem. For example:
61
+
To grant the capability to write in a directory using the Wasmtime CLI, we need to use the `--dir` flag. `--dir` will allow us to map the `/helloworld` directory on the guest's virtual filesystem, to the current directory (`.`) on the host fileystem. For example:
You should then see "Hello World!" logged in your terminal. You should also notice that a `helloworld.txt` file was created in your current directory, with the contents of "Hello World!".
@@ -58,16 +58,16 @@ O nosso arquivo wasm deveria ser compilado a `target/wasm32-wasi/debug/wasi_hell
58
58
59
59
Para isso, podemos usar a linha de comando do Wasmtime, que lhe pedimos para instalar no início deste tutorial. No entanto, há uma coisa a notar que foi mencionada nos comentários do programa. **Precisamos explicitamente dar ao nosso programa acesso à criação de arquivos no nosso host, pois o nosso programa cria um novo arquivo**. Como mencionado na [Introdução à WASI](/example-redirect?exampleName=wasi-introduction), o nosso guest não tem essa capacidade a menos que nós lhe demos tal capacidade.
60
60
61
-
Para autorizar o uso da capacidade de escrever em um diretório usando a linha de comando do Wasmtime, precisamos passar o parâmetro `--mapdir`. `--mapdir` nos permite mapear o diretório `/helloworld` no sistema de arquivos virtual do guest, ao diretório atual (`.`) no sistema de arquivos do host. Por exemplo:
61
+
Para autorizar o uso da capacidade de escrever em um diretório usando a linha de comando do Wasmtime, precisamos passar o parâmetro `--dir`. `--dir` nos permite mapear o diretório `/helloworld` no sistema de arquivos virtual do guest, ao diretório atual (`.`) no sistema de arquivos do host. Por exemplo:
Você deve então ver "Hello World!" escrito na tela do seu terminal. E também deve notar que um novo arquivo `helloworld.txt` apareceu no seu diretório atual, com o conteúdo "Hello World!".
Copy file name to clipboardExpand all lines: examples/wasi-introduction/wasi-introduction.all.en-us.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ I also think it'd be worth getting some key terms out of the way. This will make
33
33
- The host is able to provide additional functionality to guest, by doing tasks on the guests' behalf. This functionality is offered by passing functions to the importObject ([Similar to how we do this for the browser in the "Importing Javascript Functions Into Webassembly"](/example-redirect?exampleName=importing-javascript-functions-into-webassembly)).
34
34
- This brings us back to WASI, as WASI is a standardized set of APIs for hosts to do system level actions (such as filystem operations) for the guest WebAssembly module. Therefore, this allows developers to write WebAssembly modules that can access system resources!
35
35
36
-
The last thing worth mentioning is that WASI uses a [capability based security model](https://github.com/bytecodealliance/wasmtime/blob/master/docs/WASI-capabilities.md). Meaning, the host must explicitly grant a capability to a guest module in order for the guest module to perform an action. For example in [Wasmtime](https://wasmtime.dev/), by default, the guest module cannot access any part of the host's filesystem. The user that invokes Wasmtime must pass in the `--mapdir` or `--dir` flag to grant modules the capability to access directories in the host filesystem.
36
+
The last thing worth mentioning is that WASI uses a [capability based security model](https://github.com/bytecodealliance/wasmtime/blob/master/docs/WASI-capabilities.md). Meaning, the host must explicitly grant a capability to a guest module in order for the guest module to perform an action. For example in [Wasmtime](https://wasmtime.dev/), by default, the guest module cannot access any part of the host's filesystem. The user that invokes Wasmtime must pass in the `--dir` flag to grant modules the capability to access directories in the host filesystem.
37
37
38
38
At the time of this writing, a lot of WASI is still in proposals and things. Other system resources, like networking, are not yet part of the WASI standard, though they will be one day. So, if you're hoping to `bind()` to a socket in your WebAssembly module, WASI hosts don't yet expose those capabilities. Only a few features of what WASI is hoping to acheive is fully implemented and standardized. One of those features is filesystem access!
Copy file name to clipboardExpand all lines: examples/wasi-introduction/wasi-introduction.all.pt-br.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ Eu também acho que valeria a pena já aprender alguns termos chaves. Eles vão
33
33
- O host é capaz de prover funcionalidades extras ao guest, ao executar tarefas no lugar do guest. Essa prestação se oferece passando funções ao importObject ([Similar a quando fizemos isso no browser usando `importObject` com o JavaScript no exemplo "Como Importar Funções do Javascript Em WebAssembly"](/example-redirect?exampleName=importing-javascript-functions-into-webassembly)).
34
34
- E isto nos remete de volta à WASI, já que a WASI é o conjunto padrão de APIs para que os hosts façam as ações de sistema (tais como as ações de operações do sistema de arquivos) para o módulo guest de WebAssembly. Portanto, isso permite que os programadores escrevam módulos WebAssembly que podem acessar os recursos de sistema!
35
35
36
-
A última coisa que vale a pena mencionar é que a WASI usa um [modelo de segurança baseado em capacidade](https://github.com/bytecodealliance/wasmtime/blob/master/docs/WASI-capabilities.md). Significa que o host deve oferecer explicitamente uma capacidade ao módulo guest para que ele possa realizar uma ação. Por exemplo, no [Wasmtime](https://wasmtime.dev/), por padrão, o módulo guest não pode acessar qualquer parte do sistema de arquivos do host. O usuário que invoca o Wasmtime deve passar os parâmetros `--mapdir` ou`--dir` para autorizar aos módulos a capacidade de acessar diretórios no sistema de arquivos do host.
36
+
A última coisa que vale a pena mencionar é que a WASI usa um [modelo de segurança baseado em capacidade](https://github.com/bytecodealliance/wasmtime/blob/master/docs/WASI-capabilities.md). Significa que o host deve oferecer explicitamente uma capacidade ao módulo guest para que ele possa realizar uma ação. Por exemplo, no [Wasmtime](https://wasmtime.dev/), por padrão, o módulo guest não pode acessar qualquer parte do sistema de arquivos do host. O usuário que invoca o Wasmtime deve passar o parâmetro`--dir` para autorizar aos módulos a capacidade de acessar diretórios no sistema de arquivos do host.
37
37
38
38
No momento em que escrevemos esta introdução, grande parte da WASI ainda são propostas em discussão. Outros recursos de sistema, tais como rede, ainda não são parte do padrão WASI, mas um dia serão. Então, se você estiver esperando fazer o `bind()` de um socket no seu módulo WebAssembly, os hosts WASI ainda não expõem essa capacidade. Apenas algumas poucas funcionalidades das que a WASI espera atingir estão completamente implementadas e padronizadas. Uma dessas funcionalidades é o acesso ao sistema de arquivos!
0 commit comments