|
1 | 1 | use crate::cli::{StdinStream, StdoutStream, WasiCliCtx}; |
2 | 2 | use crate::clocks::{HostMonotonicClock, HostWallClock, WasiClocksCtx}; |
| 3 | +use crate::filesystem::WasiFilesystemCtx; |
3 | 4 | use crate::p2::filesystem::Dir; |
4 | 5 | use crate::random::WasiRandomCtx; |
5 | 6 | use crate::sockets::{SocketAddrCheck, SocketAddrUse, WasiSocketsCtx}; |
@@ -38,10 +39,9 @@ use tokio::io::{stderr, stdin, stdout}; |
38 | 39 | pub struct WasiCtxBuilder { |
39 | 40 | cli: WasiCliCtx, |
40 | 41 | clocks: WasiClocksCtx, |
| 42 | + filesystem: WasiFilesystemCtx, |
41 | 43 | random: WasiRandomCtx, |
42 | 44 | sockets: WasiSocketsCtx, |
43 | | - allow_blocking_current_thread: bool, |
44 | | - preopens: Vec<(Dir, String)>, |
45 | 45 | built: bool, |
46 | 46 | } |
47 | 47 |
|
@@ -164,7 +164,7 @@ impl WasiCtxBuilder { |
164 | 164 | /// |
165 | 165 | /// [`Config::async_support`]: https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.async_support |
166 | 166 | pub fn allow_blocking_current_thread(&mut self, enable: bool) -> &mut Self { |
167 | | - self.allow_blocking_current_thread = enable; |
| 167 | + self.filesystem.allow_blocking_current_thread = enable; |
168 | 168 | self |
169 | 169 | } |
170 | 170 |
|
@@ -305,13 +305,13 @@ impl WasiCtxBuilder { |
305 | 305 | if dir_perms.contains(DirPerms::MUTATE) { |
306 | 306 | open_mode |= OpenMode::WRITE; |
307 | 307 | } |
308 | | - self.preopens.push(( |
| 308 | + self.filesystem.preopens.push(( |
309 | 309 | Dir::new( |
310 | 310 | dir, |
311 | 311 | dir_perms, |
312 | 312 | file_perms, |
313 | 313 | open_mode, |
314 | | - self.allow_blocking_current_thread, |
| 314 | + self.filesystem.allow_blocking_current_thread, |
315 | 315 | ), |
316 | 316 | guest_path.as_ref().to_owned(), |
317 | 317 | )); |
@@ -435,21 +435,19 @@ impl WasiCtxBuilder { |
435 | 435 | let Self { |
436 | 436 | cli, |
437 | 437 | clocks, |
| 438 | + filesystem, |
438 | 439 | random, |
439 | 440 | sockets, |
440 | | - allow_blocking_current_thread, |
441 | | - preopens, |
442 | 441 | built: _, |
443 | 442 | } = mem::replace(self, Self::new()); |
444 | 443 | self.built = true; |
445 | 444 |
|
446 | 445 | WasiCtx { |
447 | 446 | cli, |
448 | 447 | clocks, |
449 | | - sockets, |
| 448 | + filesystem, |
450 | 449 | random, |
451 | | - allow_blocking_current_thread, |
452 | | - preopens, |
| 450 | + sockets, |
453 | 451 | } |
454 | 452 | } |
455 | 453 | /// Builds a WASIp1 context instead of a [`WasiCtx`]. |
@@ -519,12 +517,11 @@ impl WasiCtxBuilder { |
519 | 517 | /// ``` |
520 | 518 | #[derive(Default)] |
521 | 519 | pub struct WasiCtx { |
522 | | - pub(crate) random: WasiRandomCtx, |
523 | | - pub(crate) clocks: WasiClocksCtx, |
524 | 520 | pub(crate) cli: WasiCliCtx, |
| 521 | + pub(crate) clocks: WasiClocksCtx, |
| 522 | + pub(crate) filesystem: WasiFilesystemCtx, |
| 523 | + pub(crate) random: WasiRandomCtx, |
525 | 524 | pub(crate) sockets: WasiSocketsCtx, |
526 | | - pub(crate) allow_blocking_current_thread: bool, |
527 | | - pub(crate) preopens: Vec<(Dir, String)>, |
528 | 525 | } |
529 | 526 |
|
530 | 527 | impl WasiCtx { |
|
0 commit comments