Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix so that conditional_union works again #3976

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/wasix/src/bin_factory/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ pub async fn spawn_exec(
};

// If the file system has not already been union'ed then do so
env.state.fs.conditional_union(&binary);
env.state
.fs
.conditional_union(&binary)
.await
.map_err(|err| {
tracing::error!("failed to union file system - {}", err);
SpawnError::InternalError
})?;
tracing::debug!("{:?}", env.state.fs);

// Now run the module
Expand Down
24 changes: 14 additions & 10 deletions lib/wasix/src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,21 +489,25 @@ impl WasiFs {

/// Will conditionally union the binary file system with this one
/// if it has not already been unioned
pub fn conditional_union(&self, binary: &BinaryPackage) -> bool {
let sandbox_fs = match &self.root_fs {
WasiFsRoot::Sandbox(fs) => fs,
WasiFsRoot::Backing(_) => {
tracing::error!("can not perform a union on a backing file system");
return false;
}
};
pub async fn conditional_union(
&self,
binary: &BinaryPackage,
) -> Result<(), virtual_fs::FsError> {
let package_name = binary.package_name.to_string();
let mut guard = self.has_unioned.lock().unwrap();
if !guard.contains(&package_name) {
guard.insert(package_name);
sandbox_fs.union(&binary.webc_fs);

match self.root_fs {
WasiFsRoot::Sandbox(ref sandbox_fs) => {
sandbox_fs.union(&binary.webc_fs);
}
WasiFsRoot::Backing(ref fs) => {
merge_filesystems(&binary.webc_fs, fs.deref()).await?;
}
}
}
true
Ok(())
}

/// Created for the builder API. like `new` but with more information
Expand Down