wasmer_wasix/journal/effector/syscalls/
fd_set_rights.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
use super::*;

impl JournalEffector {
    pub fn save_fd_set_rights(
        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
        fd: Fd,
        fs_rights_base: Rights,
        fs_rights_inheriting: Rights,
    ) -> anyhow::Result<()> {
        Self::save_event(
            ctx,
            JournalEntry::FileDescriptorSetRightsV1 {
                fd,
                fs_rights_base,
                fs_rights_inheriting,
            },
        )
    }

    pub fn apply_fd_set_rights(
        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
        fd: Fd,
        fs_rights_base: Rights,
        fs_rights_inheriting: Rights,
    ) -> anyhow::Result<()> {
        crate::syscalls::fd_fdstat_set_rights_internal(ctx, fd, fs_rights_base, fs_rights_inheriting)
            .map_err(|err| {
                anyhow::format_err!(
                    "journal restore error: failed to set file rights (fd={}, fs_rights_base={:?}, fs_rights_inheriting={:?}) - {}",
                    fd,
                    fs_rights_base,
                    fs_rights_inheriting,
                    err
                )
            })?;
        Ok(())
    }
}