wasmer_wasix/journal/effector/syscalls/
fd_renumber.rs

1use super::*;
2
3impl JournalEffector {
4    pub fn save_fd_renumber(
5        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
6        from: Fd,
7        to: Fd,
8    ) -> anyhow::Result<()> {
9        Self::save_event(
10            ctx,
11            JournalEntry::RenumberFileDescriptorV1 {
12                old_fd: from,
13                new_fd: to,
14            },
15        )
16    }
17
18    pub fn apply_fd_renumber(
19        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
20        from: Fd,
21        to: Fd,
22    ) -> anyhow::Result<()> {
23        let ret = crate::syscalls::fd_renumber_internal(ctx, from, to);
24        if !matches!(ret, Ok(Errno::Success)) {
25            bail!(
26                "journal restore error: failed to renumber descriptor (from={}, to={}) - {}",
27                from,
28                to,
29                ret.unwrap_or(Errno::Unknown)
30            );
31        }
32        Ok(())
33    }
34}