wasmer_wasix/journal/effector/syscalls/
fd_advise.rs

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

impl JournalEffector {
    pub fn save_fd_advise(
        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
        fd: Fd,
        offset: Filesize,
        len: Filesize,
        advice: Advice,
    ) -> anyhow::Result<()> {
        Self::save_event(
            ctx,
            JournalEntry::FileDescriptorAdviseV1 {
                fd,
                offset,
                len,
                advice,
            },
        )
    }

    pub fn apply_fd_advise(
        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
        fd: Fd,
        offset: Filesize,
        len: Filesize,
        advice: Advice,
    ) -> anyhow::Result<()> {
        crate::syscalls::fd_advise_internal(ctx, fd, offset, len, advice).map_err(|err| {
            anyhow::format_err!(
                "journal restore error: failed to advise file descriptor (fd={}, offset={}, len={}, advice={:?}) - {}",
                fd,
                offset,
                len,
                advice,
                err
            )
        })?;
        Ok(())
    }
}