text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_suffix|>ng::trace!(%fd, %offset, %len, ?advice, "Replay journal - FdAdvise"); JournalEffector::apply_fd_advise(&mut self.ctx, fd, offset, len, advice) .map_err(anyhow_err_to_runtime_err)?; Ok(()) } } <|fim_prefix|>use super::*; impl JournalSyscallPlayer<'_, '_> { #[allow(clipp...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; impl JournalSyscallPlayer<'_, '_> { #[allow(clippy::result_large_err)] pub(crate) unsafe fn action_fd_allocate( <|fim_suffix|>llocate(&mut self.ctx, fd, offset, len) .map_err(anyhow_err_to_runtime_err)?; Ok(()) } } <|fim_middle|> &mut self, fd:...
fim
wasmerio/wasmer
rust
<|fim_suffix|>err_fds.remove(&fd); JournalEffector::apply_fd_close(&mut self.ctx, fd).map_err(anyhow_err_to_runtime_err)?; Ok(()) } } <|fim_prefix|>use super::*; impl JournalSyscallPlayer<'_, '_> { #[allow(clippy::result_large<|fim_middle|>_err)] pub(crate) unsafe fn action_fd_close(&mut se...
fim
wasmerio/wasmer
rust
<|fim_suffix|>me_err)?; Ok(()) } } <|fim_prefix|>use super::*; impl JournalSyscallPlayer<'_, '_> { #[allow(clippy::result_large_err)] pub(crate) unsafe fn action_fd_dup( &mut self, original_fd: u32, copied_fd: u32, cloexec: bool, ) -> Result<(), WasiRuntimeError>...
fim
wasmerio/wasmer
rust
<|fim_suffix|> "Replay journal - FdOpen {}", path); JournalEffector::apply_path_open( &mut self.ctx, fd, dirfd, dirflags, &path, o_flags, fs_rights_base, fs_rights_inheriting, fs_flags, fd_fla...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; impl JournalSyscallPlayer<'_, '_> { #[allow(clippy::result_large_err)] pub(crate) unsafe fn action_fd_renumber( &mut self, old_fd: u32, new_fd: u32, ) -> Result<(), WasiRuntimeError> { tracing::trace!(%old_fd, %new_fd, "Replay journal - FdRenumber...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; impl JournalSyscallPlayer<'_, '_> { #[allow(clippy::result_large_err)] pub(crate) unsafe fn action_fd_seek( &mut self, fd: u32, offset: i64, whence: Whence, ) -> Result<(), WasiRuntimeEr<|fim_suffix|>::trace!(%fd, %offset, ?whence, "Replay journal...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; impl JournalSyscallPlayer<'_, '_> { #[allow(cli<|fim_suffix|>] pub(crate) unsafe fn action_fd_set_fdflags( &mut self, fd: Fd, flags: Fdflagsext, ) -> Result<(), WasiRuntimeError> { tracing::trace!(%fd, ?flags, "Replay journal - FdSetFlags"); ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; impl JournalSyscallPlayer<'_, '_> { #[allow(clippy::result_large_err)] pub(crate) unsafe fn a<|fim_suffix|>ow_err_to_runtime_err)?; Ok(()) } } <|fim_middle|>ction_fd_set_flags( &mut self, fd: Fd, flags: Fdflags, ) -> Result<(), WasiRuntimeErro...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; impl JournalSyscallPlayer<'_, '_> { #[allow(clippy::result_large_err)] pub(crate) unsafe fn action_fd_set_rights( &mut self, fd: Fd, fs_rights_base: Rights, <|fim_suffix|>&mut self.ctx, fd, fs_rights_base, fs_rights_i...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; impl JournalSyscallPlayer<'_, '_> { #[allow(clippy::result_large_err)] pub(crate) unsafe fn action_fd_set_size( &mut self, fd: Fd, <|fim_suffix|> %st_size, "Replay journal - FdSetSize"); JournalEffector::apply_fd_set_size(&mut self.ctx, fd, st_size) ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; impl JournalSyscal<|fim_suffix|> st_mtim: Timestamp, fst_flags: Fstflags, ) -> Result<(), WasiRuntimeError> { tracing::trace!(%fd, %st_atim, %st_mtim, ?fst_flags, "Replay journal - FdSetTimes"); JournalEffector::apply_fd_set_times(&mut self.ctx, fd, st_ati...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; impl<'a> JournalSyscallPlayer<'a, '_> { #[allow(clippy::result_large_err)] pub(crate) unsafe fn action_fd_write( &mut self, fd: u32, offset: u64, data: Cow<'a, [u8]>, is_64bit: bool, ) -> Result<(), WasiRuntimeError> { tracing::tra...
fim
wasmerio/wasmer
rust
<|fim_suffix|>ear_ethereal(differ_ethereal); self.differ_memory.clear(); self.journal_module_hash.replace(wasm_hash); Ok(()) } } <|fim_prefix|>use super::*; impl<'a> JournalSyscallPlayer<'a, '_> { #[allow(clippy::result_large_err)] pub(crate) unsafe fn action_init_module( &m...
fim
wasmerio/wasmer
rust
<|fim_suffix|>i::Fd; use wasmer_wasix_types::wasi::Filesize; use wasmer_wasix_types::wasi::Tty; use wasmer_wasix_types::wasi::Whence; use wasmer_wasix_types::wasi::{Fdflags, Fdflagsext}; use wasmer_wasix_types::wasi::{Fstflags, LookupFlags, Timestamp}; use wasmer_wasix_types::wasi::{Oflags, Rights}; use wasmer_wasix_ty...
fim
wasmerio/wasmer
rust
<|fim_suffix|> ) -> Result<(), WasiRuntimeError> { tracing::trace!(%fd, "Replay journal - PathSetTimes"); JournalEffector::apply_path_set_times( &mut self.ctx, fd, flags, &path, st_atim, st_mtim, fst_flags, )...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; impl<'a> JournalSyscallPla<|fim_suffix|> self.differ_memory.clear(); self.rewind = None; } else { unsafe { JournalEffector::apply_process_exit(&mut self.ctx, exit_code) } .map_err(anyhow_err_to_runtime_err)?; } Ok(()...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; impl<'a> JournalSyscallPlayer<'a, '_> { #[allow(clippy::result_large_err)] pub(crate) unsafe fn action_set_thread( &mut self, id: u32, call_stack: Cow<'a, [u8]>, memory_stack: Cow<'a, [u8]>, store_data: Cow<'a, [u8]>, is_64bit: bool, ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; impl<'a> JournalSyscallPlayer<'a, '_> { #[allow(clippy::result_large_err)] pub(crate) unsafe fn action_snapshot( &mut self, when: SystemTime, trigger: SnapshotTrigger, differ_ethereal: Option<&mut Vec<JournalEntry<'a>>>, ) -> Result<(), WasiRuntim...
fim
wasmerio/wasmer
rust
use super::*; impl JournalSyscallPlayer<'_, '_> { #[allow(clippy::result_large_err)] pub(crate) unsafe fn action_tty_set( &mut self, tty: Tty, line_feeds: bool, ) -> Result<(), WasiRuntimeError> { tracing::trace!("Replay journal - TtySet"); let state = crate::WasiTty...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; impl<'a> JournalSyscallPlayer<'a, '_> { #[allow(clippy::result_large_err)] pub(crate) unsafe fn action_update_compressed_memory( &mut self, region: Range<u64>, compressed_data: Cow<'a, [u8]>, differ_ethereal: Option<&mut Vec<JournalEntry<'a>>>, ) ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>r_each(|e| e.clear()); self.staged_differ_memory.clear(); } } <|fim_prefix|>use super::*; impl<'a> JournalSyscallPlayer<'a, '_> { pub(super) fn clear_ethereal( &mut self, mut differ_ethereal: Option<&mut Vec<JournalEntry<'a>>>, <|fim_middle|>) { tracing::trace!...
fim
wasmerio/wasmer
rust
<|fim_suffix|>wake(); } process.1.notify_all(); } <|fim_prefix|>use crate::os::task::process::LockableWasiProcessInner; use super::WasiProcessCheckpoint; pub(crate) fn do_checkpoint_from_outside( process: &LockableWasiProcessInner, checkpoint: WasiProcessCheckpoint, ) { let mut guard = process.0.l...
fim
wasmerio/wasmer
rust
<|fim_suffix|> pub fn maybe_snapshot<M: MemorySize>( ctx: FunctionEnvMut<'_, WasiEnv>, ) -> WasiResult<FunctionEnvMut<'_, WasiEnv>> { Ok(Ok(ctx)) } #[cfg(feature = "journal")] pub fn maybe_snapshot<M: MemorySize>( mut ctx: FunctionEnvMut<'_, WasiEnv>, ) -> WasiResult<FunctionEnvMut<'_, WasiEnv>> { use ...
fim
wasmerio/wasmer
rust
use super::*; #[allow(clippy::extra_unused_type_parameters)] #[cfg(not(feature = "journal"))] pub fn maybe_snapshot_many<M: MemorySize>( ctx: FunctionEnvMut<'_, WasiEnv>, _trigger: crate::journal::SnapshotTrigger, ) -> WasiResult<FunctionEnvMut<'_, WasiEnv>> { Ok(Ok(ctx)) } #[cfg(feature = "journal")] pub...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; #[allow(clippy::extra_unused_type_parameters)] #[cfg(not(feature = "journal"))] pub fn maybe_snapshot_once<M: MemorySize>( ctx: FunctionEnvMut<'_, WasiEnv>, _trigger: crate::journal::SnapshotTrigger, ) -> WasiResult<FunctionEnvMut<'_, WasiEnv>> { Ok(Ok(ctx)) } #[cfg(feature = "...
fim
wasmerio/wasmer
rust
<|fim_suffix|>ind: None, connected_sockets_are_dead: true, spawn_threads: Default::default(), staged_differ_memory: Default::default(), differ_memory: Default::default(), // We capture stdout and stderr while we replay stdout_fds: [1 as WasiFd].int...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use std::ops::Range; use super::*; impl<'a> JournalSyscallPlayer<'a, '_> { #[allow(clippy::result_large_err)] pub(super) unsafe fn play_event( &mut self, next: JournalEntry<'a>, differ_ethereal: Option<&mut Vec<JournalEntry<'a>>>, ) -> Result<(), WasiRuntimeError> { ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; /// Safety: This function manipulates the memory of the process and thus must /// be executed by the WASM process thread itself. /// #[cfg(feature = "journal")] #[allow(clippy::result_large_err)] #[tracing::instrument(skip_all)] pub unsafe fn restore_snapshot( mut ctx: FunctionEnvMut<'_...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; pub fn wait_for_snapshot(env: &WasiEnv) -> Pin<Box<dyn F<|fim_suffix|> env.process.wait_for_checkpoint() } <|fim_middle|>uture<Output = ()> + Send + Sync>> { <|endoftext|>
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! These modules provide wrappers and implementations for older versi<|fim_suffix|>I. //! //! If you are relying on legacy WASI, please upgrade for the best experience. pub mod snapshot0; <|fim_middle|>on of WAS<|endoftext|>
fim
wasmerio/wasmer
rust
<|fim_prefix|>#![allow(clippy::result_large_err)] use tracing::{field, instrument, trace_span}; use wasmer::{AsStoreMut, AsStoreRef, FunctionEnvMut, Memory, WasmPtr}; use wasmer_wasix_types::wasi::{ Errno, Event, EventFdReadwrite, Eventrwflags, Eventtype, ExitCode, Fd, Filesize, Filestat, Filetype, Snapshot0Ev...
fim
wasmerio/wasmer
rust
<|fim_prefix|>#![allow( unused, clippy::too_many_arguments, clippy::cognitive_complexity, clippy::result_large_err )] pub mod types { pub use wasmer_wasix_types::{types::*, wasi}; } #[cfg(any( target_os = "freebsd", target_os = "linux", target_os = "android", target_vendor = "apple...
fim
wasmerio/wasmer
rust
<|fim_suffix|>> CLOCK_REALTIME, Snapshot0Clockid::ThreadCputimeId => CLOCK_THREAD_CPUTIME_ID, _ => return Err(Errno::Inval), }; let (output, timespec_out) = unsafe { let mut timespec_out: timespec = timespec { tv_sec: 0, tv_nsec: 0, }; ( ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::syscalls::*; /// ### `args_get()` /// Read command-line argument data. /// The sizes of the buffers should match that returned by [`args_sizes_get()`](#args_sizes_get). /// Inputs: /// - `char **argv` /// A pointer to a buffer to write the argument pointers. /// - `char *argv...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::syscalls::*; /// ### `args_sizes_get()` /// Return command-line argument data sizes. /// Outputs: /// - `size_t *argc` /// The number of arguments. /// - `size_t *argv_buf_size<|fim_suffix|> let (memory, mut state) = unsafe { env.get_memory_and_wasi_state(&ctx, 0) }; l...
fim
wasmerio/wasmer
rust
<|fim_suffix|>et out_addr = resolution.deref(&memory); let t_out = wasi_try!(platform_clock_res_get(clock_id, out_addr)); wasi_try_mem!(resolution.write(&memory, t_out as Timestamp)); Errno::Success } <|fim_prefix|>use super::*; use crate::syscalls::*; /// ### `clock_res_get()` /// Get the resolution of th...
fim
wasmerio/wasmer
rust
<|fim_suffix|> guard = env.state.clock_offset.lock().unwrap(); if let Some(offset) = guard.get(&clock_id) { t_out += *offset; } }; wasi_try_mem_ok!(time.write(&memory, t_out as Timestamp)); Ok(Errno::Success) } <|fim_prefix|>use super::*; use crate::syscalls::*; // NOTE: This sy...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::syscalls::*; /// ### `clock_time_set()` /// Set the time of the specified clock /// Inputs: /// - `Clockid clock_id` /// The ID of the clock to query /// - `Timest<|fim_suffix|>id, time: Timestamp, ) -> Result<Errno, WasiError> { WasiEnv::do_pending_operations(&mut ct...
fim
wasmerio/wasmer
rust
<|fim_suffix|>ock().unwrap(); Ok(write_buffer_array(&memory, &envs, environ, environ_buf)) } <|fim_prefix|>use super::*; use crate::{journal::SnapshotTrigger, syscalls::*}; /// ### `environ_get()` /// Read environment variable data. /// The sizes of the buffers should match that returned by [`environ_sizes_get()`]...
fim
wasmerio/wasmer
rust
<|fim_suffix|>lt<Errno, WasiError> { ctx = wasi_try_ok!(maybe_snapshot_once::<M>( ctx, SnapshotTrigger::FirstEnviron )?); let env = ctx.data(); let (memory, mut state) = unsafe { env.get_memory_and_wasi_state(&ctx, 0) }; let environ_count = environ_count.deref(&memory); let env...
fim
wasmerio/wasmer
rust
<|fim_suffix|>nal( ctx: &mut FunctionEnvMut<'_, WasiEnv>, fd: WasiFd, offset: Filesize, len: Filesize, advice: Advice, ) -> Result<(), Errno> { // Instead of unconditionally returning OK. This barebones implementation // only performs basic fd and rights checks. let env = ctx.data(); ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>nv = ctx.data(); let (_, mut state) = unsafe { env.get_memory_and_wasi_state(&ctx, 0) }; let fd_entry = state.fs.get_fd(fd)?; let inode = fd_entry.inode; if !fd_entry.inner.rights.contains(Rights::FD_ALLOCATE) { return Err(Errno::Access); } let new_size = offset.checked_ad...
fim
wasmerio/wasmer
rust
<|fim_suffix|> | Err(Errno::Isdir) | Err(Errno::Io) | Err(Errno::Access) // EINVAL is returned by e.g. pipe-backed stdio and is safe to ignore. | Err(Errno::Inval) => Ok(Errno::Success), Err(e) => Ok(e), } } /// ### `fd_close()` /// Close an open file descriptor /// Fo...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::fs::Flu<|fim_suffix|>y(&mut ctx, None, async move { FlushPoller { file }.await.map(|_| Errno::Success) })?)) } <|fim_middle|>shPoller; use crate::syscalls::*; /// ### `fd_datasync()` /// Synchronize the file data to disk /// Inputs: /// - `Fd fd` /// The file desc...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::syscalls::*; /// ### `fd_dup()` /// Duplicates the file handle /// Inputs: /// - `Fd fd` /// File handle to be cloned /// Outputs: /// - `Fd fd` /// The new file handle that is a duplicate of the original #[instrument(level = "trace", skip_all, fields(%fd, ret_fd = field::Emp...
fim
wasmerio/wasmer
rust
<|fim_suffix|>no, WasiError> { WasiEnv::do_pending_operations(&mut ctx)?; let fd = wasi_try_ok!(fd_event_internal(&mut ctx, initial_val, flags, None)?); let env = ctx.data(); let (memory, state, _) = unsafe { env.get_memory_and_wasi_state_and_inodes(&ctx, 0) }; Span::current().record("ret_fd", fd)...
fim
wasmerio/wasmer
rust
<|fim_suffix|> inodes) = unsafe { env.get_memory_and_wasi_state_and_inodes(&ctx, 0) }; let stat = wasi_try_ok!(state.fs.fdstat(fd)); let buf = buf_ptr.deref(&memory); wasi_try_mem_ok!(buf.write(stat)); Ok(Errno::Success) } <|fim_prefix|>use super::*; use crate::syscalls::*; /// ### `fd_fdstat_get()`...
fim
wasmerio/wasmer
rust
<|fim_suffix|>= unsafe { env.get_memory_and_wasi_state(&ctx, 0) }; let mut fd_map = state.fs.fd_map.write().unwrap(); let fd_entry = wasi_try_ok!(fd_map.get_mut(fd).ok_or(Errno::Badf)); if !fd_entry.rights.contains(Rights::FD_FDSTAT_SET_FLAGS) { return Ok(Errno::Access); } fd_entry.flags =...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::syscalls::*; /// ### `fd_fdstat_set_rights()` /// Set the rights of a file descriptor. This can only be used to remove rights /// Inputs: /// - `Fd fd` /// The file descriptor to apply the new rights to /// - `Rights fs_rights_base` /// The rights to apply to `fd` /// - ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::syscalls::*; use crate::types::wasi::Snapshot0Filestat; /// ### `fd_filestat_get()` /// Get the metadata of an open file /// /// Input: /// - `Fd fd` /// The open file descriptor whose metadata will be read /// /// Output: /// - `Filestat *buf` /// Where the metadata from `fd...
fim
wasmerio/wasmer
rust
<|fim_suffix|>} | Kind::Root { .. } => return Err(Errno::Isdir), } } inode.stat.write().unwrap().st_size = st_size; Ok(()) } <|fim_prefix|>use super::*; use crate::syscalls::*; /// ### `fd_filestat_set_size()` /// Change the size of an open file, zeroing out any new bytes /// Inputs: /// - `Fd fd`...
fim
wasmerio/wasmer
rust
<|fim_suffix|>time_to_set); } if fst_flags.contains(Fstflags::SET_MTIM) || fst_flags.contains(Fstflags::SET_MTIM_NOW) { let time_to_set = if fst_flags.contains(Fstflags::SET_MTIM) { st_mtim } else { get_current_time_in_nanos()? }; inode.stat.write().unwra...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::syscalls::*; #[instrument(level = "trace", skip_all, fields(%fd, path = field::Empty), ret)] pub fn fd_prestat_dir_name<M: MemorySize>( ctx: FunctionEnvMut<'_, WasiEnv>, fd: WasiFd, path: WasmPtr<u8, M>, path_len: M::Offset, ) -> Errno { let env = ctx.data(); ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::sysca<|fim_suffix|>)))); Errno::Success } <|fim_middle|>lls::*; /// ### `fd_prestat_get()` /// Get metadata about a preopened file descriptor /// Input: /// - `Fd fd` /// The preopened file descriptor to query /// Output: /// - `__wasi_prestat *buf` /// Where the met...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use std::{collections::VecDeque, task::Waker}; use virtual_fs::{AsyncReadExt, DeviceFile, ReadBuf}; use super::*; use crate::{ fs::NotificationInner, journal::SnapshotTrigger, net::socket::TimeType, os::task::process::{MaybeCheckpointResult, WasiProcessCheckpoint, WasiProcessInner}, ...
fim
wasmerio/wasmer
rust
<|fim_suffix|> let stat = inode.stat.read().unwrap(); ( format!("/{}", inode.name.read().unwrap().as_ref()), stat.st_filetype, stat.st_ino, ) }) ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>turn Ok(errno), Ok(flush_target) => flush_target, }; // Best-effort flush of the replaced entry; result depends only on map updates. if let Some(file) = flush_target { let _ = __asyncify_light(env, None, FlushPoller { file })?; } Ok(Errno::Success) } <|fim_prefix|>use...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::syscalls::*; /// ### `fd_seek()` /// Update file descriptor offset /// Inputs: /// - `Fd fd` /// File descriptor to mutate /// - `FileDelta offset` /// Number of bytes to adjust offset by /// - `Whence whence` /// What the offset is relative to /// Output: /// - `File...
fim
wasmerio/wasmer
rust
<|fim_suffix|>fs.get_fd(fd)); if !fd_entry.inner.rights.contains(Rights::FD_SYNC) { return Ok(Errno::Access); } let inode = fd_entry.inode; // TODO: implement this for more than files { let mut guard = inode.write(); match guard.deref_mut() { Kind::File { handle,...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::syscalls::*; /// ### `fd_tell()` /// Get the offset of the file descriptor /// Inputs: /// - `Fd fd` /// The file descriptor to access /// Output: /// - `Filesize *offset` /// The offset <|fim_suffix|>t().record("offset", offset); wasi_try_mem_ok!(offset_ref.write(off...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use std::task::Waker; use super::*; #[cfg(feature = "journal")] use crate::{ journal::{JournalEffector, JournalEntry}, utils::map_snapshot_err, }; use crate::{net::socket::TimeType, syscalls::*}; /// ### `fd_write()` /// Write data to the file descriptor /// Inputs: /// - `Fd` /// File descr...
fim
wasmerio/wasmer
rust
<|fim_prefix|>mod args_get; mod args_sizes_get; mod clock_res_get; mod clock_time_get; mod clock_time_set; mod environ_get; mod environ_sizes_get; mod fd_advise; mod fd_allocate; mod fd_close; mod fd_datasync; mod fd_dup; mod fd_event; mod fd_fdstat_get; mod fd_fdstat_set_flags; mod fd_fdstat_set_rights; mod fd_filesta...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use std::{ path::{Component, PathBuf}, str::FromStr, }; use super::*; use crate::syscalls::*; /// ### `path_create_directory()` /// Create directory at a path /// Inputs: /// - `Fd fd` /// The directory that the path is relative to /// - `const <|fim_suffix|>ew_dir_path = path.clone(); ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::syscalls::*; use crate::types::wasi::Snapshot0Filestat; /// ### `path_filestat_get()` /// Access metadata about a file or directory /// Inputs: /// - `Fd fd` /// The directory that `path` is relative to /// - `LookupFlags flags` /// Flags to control how `path` is understo...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::syscalls::*; /// ### `path_filestat_set_times()` /// Update time metadata on a file or directory /// Inputs: /// - `Fd fd` /// The directory relative to which the path is resolved /// - `LookupFlags flags` /// Flags to control how the path is understood /// - `const char ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::syscalls::*; /// ### `path_link()` /// Create a hard link /// Inputs: /// - `Fd old_fd` /// The directory relative to which the `old_path` is /// - `LookupFlags old_flags` /// Flags to control how `old_path` is understood /// - `const char *old_path` /// String contai...
fim
wasmerio/wasmer
rust
use super::*; use crate::syscalls::*; /// ### `path_open()` /// Open file located at the given path /// Inputs: /// - `Fd dirfd` /// The fd corresponding to the directory that the file is in /// - `LookupFlags dirflags` /// Flags specifying how the path will be resolved /// - `char *path` /// The path of t...
fim
wasmerio/wasmer
rust
<|fim_suffix|>ut ctx: FunctionEnvMut<'_, WasiEnv>, dir_fd: WasiFd, path: WasmPtr<u8, M>, path_len: M::Offset, buf: WasmPtr<u8, M>, buf_len: M::Offset, buf_used: WasmPtr<M::Offset, M>, ) -> Result<Errno, WasiError> { WasiEnv::do_pending_operations(&mut ctx)?; let env = ctx.data(); le...
fim
wasmerio/wasmer
rust
<|fim_suffix|> lock", ); Ok(()) } Kind::Root { .. } => { trace!("directories directly in the root node can not be removed"); Err(Errno::Access) } _ => { trace!("path is not a directory"); Err(Errno::Notdir) ...
fim
wasmerio/wasmer
rust
use std::path::PathBuf; use anyhow::Context; use super::*; use crate::syscalls::*; /// ### `path_rename()` /// Rename a file or directory /// Inputs: /// - `Fd old_fd` /// The base directory for `old_path` /// - `const char* old_path` /// Pointer to UTF8 bytes, the file to be renamed /// - `u32 old_path_len`...
fim
wasmerio/wasmer
rust
<|fim_suffix|> } crate::fs::PosixPath::from_path(path) .join(&crate::fs::PosixPath::new(&entry_name)) .into_path_buf() } Kind::Root { .. } => return Err(Errno::Notcapable), Kind::Socket { .. } | Kind::PipeRx {...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::syscalls::*; /// ### `path_unlink_file()` /// Unlink a file, deleting if the number of hardlinks is 1 /// Inputs: /// - `Fd fd` /// The base file descriptor from which the path is understood /// - `const char *path` /// Array of UTF-8 bytes representing the path /// - `u3...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use serde::{Deserialize, Serialize}; use wasmer_wasix_types::wasi::{Subclockflags, SubscriptionClock, Userdata}; use super::*; use crate::{ fs::{InodeValFilePollGuard, InodeValFilePollGuardJoin}, state::PollEventSet, syscalls::*, }; /// An event that occurred. #[derive(Serialize, Deserialize...
fim
wasmerio/wasmer
rust
<|fim_suffix|>set and magic will happen // 2. We are in a setjmp/longjmp vfork, in which case we need to error out as returning from proc_exit is not allowed if in_asyncify_based_vfork { return Ok(()); } tracing::error!( "Calling proc_exit in a vfork is undefined behaviour. Call _exit ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>nterval( mut ctx: FunctionEnvMut<'_, WasiEnv>, sig: Signal, interval: Timestamp, repeat: Bool, ) -> Result<Errno, WasiError> { let env = ctx.data(); let interval = match interval { 0 => None, a => Some(Duration::from_millis(a)), }; let repeat = matches!(repe...
fim
wasmerio/wasmer
rust
<|fim_suffix|>/// A pointer to a buffer where the random bytes will be written /// - `size_t buf_len` /// The number of bytes that will be written #[instrument(level = "trace", skip_all, fields(%buf_len), ret)] pub fn random_get<M: MemorySize>( ctx: FunctionEnvMut<'_, WasiEnv>, buf: WasmPtr<u8, M>, ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::syscalls::*; use wasmer::Memory; use wasmer_wasix_types::wasi::ThreadStart; /// ### `thread_spawn()` /// Creates a new thread by spawning that shares the same /// memory address space, file handles and main event loops. /// /// ## Parameters /// /// * `start_ptr` - Pointer to th...
fim
wasmerio/wasmer
rust
use super::*; use crate::syscalls::*; use wasmer::Type; use wasmer::ValueType; macro_rules! write_value { ($memory:expr, $offset:expr, $max:expr, $strict:expr, $value:expr) => {{ let bytes = $value.to_le_bytes(); if $offset + bytes.len() as u64 <= $max { $memory.write($offset, &bytes)?;...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::syscalls::*; /// ### `callback_signal()` /// Sets the callback to invoke signals /// /// ### Parameters /// /// * `name` - Name of the function that will be invoked #[instrument(level = "trace", skip_all, fields(name = field::Empty, funct_is_some = field::Empty), ret)] pub fn cal...
fim
wasmerio/wasmer
rust
<|fim_suffix|>resolved non-root directories, the final `read_dir` check refreshes the /// backing filesystem view enough to reject stale cached directories that can no /// longer be listed. pub fn chdir_internal(env: &WasiEnv, path: &str) -> Result<(), Errno> { let state = &env.state; if path.is_empty() { ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use crate::syscalls::*; /// Allocate a new slot in the __indirect_function_table for a closure /// /// Until the slot is prepared with [`closure_prepare`], it is undefined behavior to call the function at the given index. /// /// The slot should be freed with [`closure_free`] when <|fim_suffix|> let...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use crate::syscalls::*; /// Free a previously allocated slot for a closure in the `__indirect_function_table` /// /// After calling this it is undefined behavior to call the function at the given index. #[instrument(level = "trace", fields(%closure), ret)] pub fn clos<|fim_suffix|>u32, ) -> Result<Errno,...
fim
wasmerio/wasmer
rust
<|fim_prefix|>//! Closures provide a way to generate a WASM function that wraps a generic function and an environment. //! //! A typical usage of this API is as follows: //! //! 1. Allocate a function pointer for your closure with [`closure_allocate`] //! 2. Prepare the closure with [`closure_prepare`] //! 3. Call func...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use crate::{WasiEnv, WasiError}; use futures::FutureExt; use tracing::instrument; use wasmer::{ AsStoreRef, Function, FunctionEnvMut, MemorySize, RuntimeError, StoreMut, TypedFunction, Value, WasmPtr, }; use wasmer_wasix_types::wasi::Errno; /// Return the function corresponding to the given entry...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use crate::{WasiEnv, WasiError}; use tracing::instrument; use wasmer::{AsStoreRef, FunctionEnvMut, MemoryView}; use wasmer_wasix_types::wasi::Errno; /// Destroy a suspended or terminated context /// /// After a successful call its identifier becomes invalid and its /// resources are released. Destroying ...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use crate::{WasiEnv, WasiError, state::context_switching::ContextSwitchError}; use futures::FutureExt; use tracing::instrument; use wasmer::{AsyncFunctionEnvMut, FunctionEnvMut, RuntimeError}; use wasmer_wasix_types::wasi::Errno; /// Suspend the active context and resume another /// /// The resumed conte...
fim
wasmerio/wasmer
rust
<|fim_suffix|>(if is_valid { Errno::Success } else { Errno::Noexec }) } <|fim_prefix|>use state::ModuleHandle; use super::*; use crate::syscalls::*; #[instrument(level = "trace", skip_all, fields(path = field::Empty), ret)] pub fn dl_invalid_handle( mut ctx: FunctionEnvMut<'_, WasiEnv>, ...
fim
wasmerio/wasmer
rust
use super::*; use crate::{state::DlModuleSpec, syscalls::*}; // TODO: add journal events for dl-related syscalls #[instrument(level = "trace", skip_all, fields(path = field::Empty, ld_library_path = field::Empty, flags), ret)] pub fn dlopen<M: MemorySize>( mut ctx: FunctionEnvMut<'_, WasiEnv>, path: WasmPtr<u8...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use state::MAIN_MODULE_HANDLE; use super::*; use crate::{ state::{ModuleHandle, ResolvedExport}, syscalls::*, }; #[instrument(level = "trace", skip_all, fields(symbol = fiel<|fim_suffix|>let handle = if handle == 0 { None } else { Some(ModuleHandle::from(handle)) }; l...
fim
wasmerio/wasmer
rust
use serde::{Deserialize, Serialize}; use wasmer_wasix_types::wasi::{SubscriptionClock, Userdata}; use super::*; use crate::{ WasiInodes, fs::{InodeValFilePollGuard, InodeValFilePollGuardJoin}, os::epoll::EpollState, state::PollEventSet, syscalls::*, }; use std::sync::Arc; /// ### `epoll_create()` ...
fim
wasmerio/wasmer
rust
use wasmer_wasix_types::wasi::{EpollCtl, EpollEvent, EpollEventCtl, SubscriptionClock, Userdata}; use super::*; use crate::{ WasiInodes, fs::{InodeValFilePollGuard, InodeValFilePollGuardJoin}, os::epoll::register_epoll_handler, state::PollEventSet, syscalls::*, }; /// ### `epoll_ctl()` /// Modifie...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use wasmer_wasix_types::wasi::{EpollData, EpollEvent, EpollType, SubscriptionClock, Userdata}; use super::*; use crate::{ WasiInodes, fs::{InodeValFilePollGuard, InodeValFilePollGuardJoin}, os::epoll::{EpollFd, drain_ready_events}, state::PollEventSet, syscalls::*, }; const TIMEOUT_F...
fim
wasmerio/wasmer
rust
<|fim_suffix|>ec)) } <|fim_prefix|>use super::*; use crate::syscalls::*; /// ### `fd_dup()` /// Duplicates the file handle /// Inputs: /// - `Fd fd` /// File handle to be cloned /// Outputs: /// - `Fd fd` /// The new file handle that is a duplicate of the original #[instrument(level = "trace", skip_all, fields(%fd...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::syscalls::*; /// ### `fd_fdstat_get()` /// Get metadata of a file descriptor /// Input: /// - `Fd fd` /// The file descriptor whose metadata will be accessed /// Output: /// - `Fdstat *buf` /// The location where the metadata will be written #[instrument(level = "trace", ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>entry = wasi_try_ok!(fd_map.get_mut(fd).ok_or(Errno::Badf)); if !fd_entry.rights.contains(Rights::FD_FDSTAT_SET_FLAGS) { return Ok(Errno::Access); } fd_entry.fd_flags = flags; Ok(Errno::Success) } <|fim_prefix|>use super::*; use crate::syscalls::*; /// ### `fd_fdstat_set_flags()` ...
fim
wasmerio/wasmer
rust
<|fim_suffix|>node, fd, ) .map(|()| fd)? } else { state.fs.create_fd( write_rights, write_rights, Fdflags::empty(), Fdflagsext::empty(), 0, tx_inode, )? }; Ok((read_fd, write_fd))...
fim
wasmerio/wasmer
rust
<|fim_suffix|>wasi_try_mem_ok!(ret_woken.write(&memory, Bool::False)); } } Ok(Errno::Success) } <|fim_prefix|>use std::task::Waker; use super::*; use crate::syscalls::*; /// Poller returns true if its triggered and false if it times out struct FutexPoller { state: Arc<WasiState>, poller_idx: u...
fim
wasmerio/wasmer
rust
<|fim_prefix|>use super::*; use crate::syscalls::*; /// Wake up one thread that's blocked on futex_wait on this futex. /// Returns true if this actually woke up such a thread, /// or f<|fim_suffix|>= field::Empty), ret)] pub fn futex_wake<M: MemorySize>( mut ctx: FunctionEnvMut<'_, WasiEnv>, futex_ptr: WasmPtr...
fim
wasmerio/wasmer
rust
use super::*; use crate::syscalls::*; /// Wake up all threads that are waiting on futex_wait on this futex. /// /// ## Parameters /// /// * `futex` - Memory location that holds a futex that others may be waiting on #[instrument(level = "trace", skip_all, fields(futex_idx = field::Empty, woken = field::Empty), ret)] pu...
fim
wasmerio/wasmer
rust