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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use super::*;

impl JournalEffector {
    pub fn save_epoll_ctl(
        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
        epfd: Fd,
        op: EpollCtl,
        fd: Fd,
        event: Option<EpollEventCtl>,
    ) -> anyhow::Result<()> {
        Self::save_event(
            ctx,
            JournalEntry::EpollCtlV1 {
                epfd,
                op,
                fd,
                event,
            },
        )
    }

    pub fn apply_epoll_ctl(
        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
        pfd: Fd,
        op: EpollCtl,
        fd: Fd,
        event: Option<EpollEventCtl>,
    ) -> anyhow::Result<()> {
        crate::syscalls::epoll_ctl_internal(ctx, pfd, op, fd, event.as_ref())
            .map_err(|err| {
                anyhow::format_err!(
                    "journal restore error: failed to epoll ctl (pfd={}, op={:?}, fd={}) - {}",
                    pfd,
                    op,
                    fd,
                    err
                )
            })?
            .map_err(|err| {
                anyhow::format_err!(
                    "journal restore error: failed to epoll ctl (pfd={}, op={:?}, fd={}) - {}",
                    pfd,
                    op,
                    fd,
                    err
                )
            })?;

        Ok(())
    }
}