From eec73b70f45e15e48be592009b12a692e4c5b4c1 Mon Sep 17 00:00:00 2001 From: Christoph Herzog Date: Wed, 31 May 2023 17:29:02 +0200 Subject: [PATCH] Actually mount when mapping into / --- lib/virtual-fs/src/tmp_fs.rs | 11 +++++++++++ lib/wasi/src/runners/wasi_common.rs | 1 + 2 files changed, 12 insertions(+) diff --git a/lib/virtual-fs/src/tmp_fs.rs b/lib/virtual-fs/src/tmp_fs.rs index ebad58c4b7c..e72c8d33b9d 100644 --- a/lib/virtual-fs/src/tmp_fs.rs +++ b/lib/virtual-fs/src/tmp_fs.rs @@ -42,6 +42,17 @@ impl TmpFileSystem { self.fs.union(other) } + /// See [`mem_fs::FileSystem::mount_directory_entries`]. + pub fn mount_directory_entries( + &self, + target_path: &Path, + other: &Arc, + source_path: &Path, + ) -> Result<()> { + self.fs + .mount_directory_entries(target_path, other, source_path) + } + pub fn mount( &self, src_path: PathBuf, diff --git a/lib/wasi/src/runners/wasi_common.rs b/lib/wasi/src/runners/wasi_common.rs index 6cb70499c37..257d115baaf 100644 --- a/lib/wasi/src/runners/wasi_common.rs +++ b/lib/wasi/src/runners/wasi_common.rs @@ -121,6 +121,7 @@ fn prepare_filesystem( })?; if guest_path == Path::new("/") { + root_fs.mount_directory_entries(&guest_path, &host_fs, &host_path)?; } else { if let Some(parent) = guest_path.parent() { create_dir_all(&root_fs, parent).with_context(|| {