wasmer_wasix/journal/effector/syscalls/
path_open.rs1use super::*;
2
3impl JournalEffector {
4 #[allow(clippy::too_many_arguments)]
5 pub fn save_path_open(
6 ctx: &mut FunctionEnvMut<'_, WasiEnv>,
7 fd: Fd,
8 dirfd: Fd,
9 dirflags: LookupFlags,
10 path: String,
11 o_flags: Oflags,
12 fs_rights_base: Rights,
13 fs_rights_inheriting: Rights,
14 fs_flags: Fdflags,
15 fd_flags: Fdflagsext,
16 ) -> anyhow::Result<()> {
17 Self::save_event(
18 ctx,
19 JournalEntry::OpenFileDescriptorV2 {
20 fd,
21 dirfd,
22 dirflags,
23 path: path.into(),
24 o_flags,
25 fs_rights_base,
26 fs_rights_inheriting,
27 fs_flags,
28 fd_flags,
29 },
30 )
31 }
32
33 #[allow(clippy::too_many_arguments)]
34 pub fn apply_path_open(
35 ctx: &mut FunctionEnvMut<'_, WasiEnv>,
36 fd: Fd,
37 dirfd: Fd,
38 dirflags: LookupFlags,
39 path: &str,
40 o_flags: Oflags,
41 fs_rights_base: Rights,
42 fs_rights_inheriting: Rights,
43 fs_flags: Fdflags,
44 fd_flags: Fdflagsext,
45 ) -> anyhow::Result<()> {
46 let res = crate::syscalls::path_open_internal(
47 ctx.data(),
48 dirfd,
49 dirflags,
50 path,
51 o_flags,
52 fs_rights_base,
53 fs_rights_inheriting,
54 fs_flags,
55 fd_flags,
56 Some(fd),
57 );
58 match res? {
59 Ok(fd) => fd,
60 Err(err) => {
61 bail!(
62 "journal restore error: failed to open descriptor (fd={fd}, path={path}) - {err}"
63 );
64 }
65 };
66 Ok(())
67 }
68}