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
use super::*;

impl<'a, 'c> JournalSyscallPlayer<'a, 'c> {
    #[allow(clippy::result_large_err)]
    pub(crate) unsafe fn action_fd_dup(
        &mut self,
        original_fd: u32,
        copied_fd: u32,
    ) -> Result<(), WasiRuntimeError> {
        tracing::trace!(%original_fd, %copied_fd, "Replay journal - FdDuplicate");
        self.real_fd.insert(copied_fd);
        if original_fd != copied_fd {
            self.stdout_fds.remove(&copied_fd);
            self.stderr_fds.remove(&copied_fd);
        }
        if self.stdout_fds.contains(&original_fd) {
            self.stdout_fds.insert(copied_fd);
        }
        if self.stderr_fds.contains(&original_fd) {
            self.stderr_fds.insert(copied_fd);
        }
        JournalEffector::apply_fd_duplicate(&mut self.ctx, original_fd, copied_fd)
            .map_err(anyhow_err_to_runtime_err)?;
        Ok(())
    }
}