wasmer-wasix 0.702.0

WASI and WASIX implementation library for Wasmer WebAssembly runtime
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={fd}, offset={offset}, len={len}, advice={advice:?}) - {err}")
        })?;
        Ok(())
    }
}