1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use super::*;

impl<'a, 'c> JournalSyscallPlayer<'a, 'c> {
    #[allow(clippy::result_large_err)]
    pub(crate) unsafe fn action_fd_write(
        &mut self,
        fd: u32,
        offset: u64,
        data: Cow<'a, [u8]>,
        is_64bit: bool,
    ) -> Result<(), WasiRuntimeError> {
        tracing::trace!(%fd, %offset, "Replay journal - FdWrite");
        if self.stdout_fds.contains(&fd) {
            self.stdout.push((offset, data, is_64bit));
            return Ok(());
        }
        if self.stderr_fds.contains(&fd) {
            self.stderr.push((offset, data, is_64bit));
            return Ok(());
        }

        if is_64bit {
            JournalEffector::apply_fd_write::<Memory64>(&self.ctx, fd, offset, data)
        } else {
            JournalEffector::apply_fd_write::<Memory32>(&self.ctx, fd, offset, data)
        }
        .map_err(anyhow_err_to_runtime_err)?;
        Ok(())
    }
}