wasmer_wasix/syscalls/journal/actions/
fd_write.rs

1use super::*;
2
3impl<'a> JournalSyscallPlayer<'a, '_> {
4    #[allow(clippy::result_large_err)]
5    pub(crate) unsafe fn action_fd_write(
6        &mut self,
7        fd: u32,
8        offset: u64,
9        data: Cow<'a, [u8]>,
10        is_64bit: bool,
11    ) -> Result<(), WasiRuntimeError> {
12        tracing::trace!(%fd, %offset, "Replay journal - FdWrite");
13        if self.stdout_fds.contains(&fd) {
14            if let Some(x) = self.stdout.as_mut() {
15                x.push(JournalStdIoWrite {
16                    offset,
17                    data,
18                    is_64bit,
19                });
20            }
21            return Ok(());
22        }
23        if self.stderr_fds.contains(&fd) {
24            if let Some(x) = self.stdout.as_mut() {
25                x.push(JournalStdIoWrite {
26                    offset,
27                    data,
28                    is_64bit,
29                });
30            }
31            return Ok(());
32        }
33
34        if is_64bit {
35            JournalEffector::apply_fd_write::<Memory64>(&mut self.ctx, fd, offset, data)
36        } else {
37            JournalEffector::apply_fd_write::<Memory32>(&mut self.ctx, fd, offset, data)
38        }
39        .map_err(anyhow_err_to_runtime_err)?;
40        Ok(())
41    }
42}