(
ctx: &mut VmCtx,
v_dir_fd: u32,
dirflags: u32,
pathname: u32,
path_len: u32,
oflags: u32,
fdflags: i32,
)
| 36 | #[ensures(ctx_safe(ctx))] |
| 37 | #[ensures(trace_safe(trace, ctx))] |
| 38 | pub fn wasi_path_open( |
| 39 | ctx: &mut VmCtx, |
| 40 | v_dir_fd: u32, |
| 41 | dirflags: u32, |
| 42 | pathname: u32, |
| 43 | path_len: u32, |
| 44 | oflags: u32, |
| 45 | fdflags: i32, |
| 46 | ) -> RuntimeResult<u32> { |
| 47 | let dirflags = LookupFlags::new(dirflags); |
| 48 | let oflags = OFlags::new(oflags); |
| 49 | let fdflags = FdFlags::from(fdflags); |
| 50 | let should_follow = dirflags.should_follow(); |
| 51 | |
| 52 | if v_dir_fd != HOMEDIR_FD { |
| 53 | return Err(Enotcapable); |
| 54 | } |
| 55 | let fd = ctx.homedir_host_fd; |
| 56 | |
| 57 | let host_pathname = ctx.translate_path(pathname, path_len, should_follow, fd); |
| 58 | unwrap_result!(host_pathname); |
| 59 | |
| 60 | let dflags = dirflags.to_openat_posix(); |
| 61 | let flags = bitwise_or(bitwise_or(dflags, oflags.to_posix()), fdflags.to_posix()); |
| 62 | |
| 63 | if flag_set(flags, libc::O_NOFOLLOW) == should_follow { |
| 64 | // this should never happen, but adding an extra dynamic check let me |
| 65 | // avoid reasoning about bitwise operation math (which prusti does not support well) |
| 66 | // in the proof |
| 67 | return Err(Einval); |
| 68 | } |
| 69 | |
| 70 | let fd = trace_openat(ctx, fd, host_pathname, flags)?; |
| 71 | ctx.fdmap.create(HostFd::from_raw(fd)) |
| 72 | } |
| 73 | |
| 74 | // https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#fd_close |
| 75 | // modifies: fdmap |
no test coverage detected