#![allow(unused_variables)]
use crate::UserFd;
use wasi::*;
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_advise(arg0: i32, arg1: i64, arg2: i64, arg3: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"fd_advise(fd: {}, offset: {}, len: {}, advice: {})\n",
arg0, arg1, arg2, arg3
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_advise(arg0, arg1, arg2, arg3);
};
{
match crate::wasi_snapshot_preview1::fd_advise(
fs,
arg0 as UserFd,
arg1 as u64,
arg2 as u64,
arg3,
) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_advise", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_allocate(arg0: i32, arg1: i64, arg2: i64) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"fd_allocate(fd: {}, offset: {}, len: {})\n",
arg0, arg1, arg2
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_allocate(arg0, arg1, arg2);
};
{
match crate::wasi_snapshot_preview1::fd_allocate(
fs,
arg0 as UserFd,
arg1 as u64,
arg2 as u64,
) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_allocate", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_close(arg0: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!("fd_close(fd: {})\n", arg0));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_close(arg0);
};
{
match crate::wasi_snapshot_preview1::fd_close(fs, arg0 as UserFd) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_close", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_datasync(arg0: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!("fd_datasync(fd: {})\n", arg0));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_datasync(arg0);
};
{
match crate::wasi_snapshot_preview1::fd_datasync(fs, arg0 as UserFd) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_datasync", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_fdstat_get(arg0: i32, arg1: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!("fd_fdstat_get(fd: {})\n", arg0));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_fdstat_get(arg0, arg1);
};
{
match crate::wasi_snapshot_preview1::fd_fdstat_get(fs, arg0 as UserFd) {
Ok(e) => {
core::ptr::write(arg1 as *mut Fdstat, e);
wasi::ERRNO_SUCCESS.raw() as i32
}
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_fdstat_get", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_fdstat_set_flags(arg0: i32, arg1: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"fd_fdstat_set_flags(fd: {}, flags: {})\n",
arg0, arg1
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_fdstat_set_flags(arg0, arg1);
};
{
match crate::wasi_snapshot_preview1::fd_fdstat_set_flags(
fs,
arg0 as UserFd,
arg1 as Fdflags,
) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_fdstat_set_flags", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_fdstat_set_rights(arg0: i32, arg1: i64, arg2: i64) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"fd_fdstat_set_rights(fd: {}, fs_rights_base: {}, fs_rights_inheriting: {})\n",
arg0, arg1, arg2
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_fdstat_set_rights(arg0, arg1, arg2);
};
{
match crate::wasi_snapshot_preview1::fd_fdstat_set_rights(
fs,
arg0 as UserFd,
arg1 as Rights,
arg2 as Rights,
) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_fdstat_set_rights", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_filestat_get(arg0: i32, arg1: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!("fd_filestat_get(fd: {})\n", arg0));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_filestat_get(arg0, arg1);
};
{
match crate::wasi_snapshot_preview1::fd_filestat_get(fs, arg0 as UserFd) {
Ok(e) => {
core::ptr::write(arg1 as *mut Filestat, e);
wasi::ERRNO_SUCCESS.raw() as i32
}
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_filestat_get", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_filestat_set_size(arg0: i32, arg1: i64) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"fd_filestat_set_size(fd: {}, size: {})\n",
arg0, arg1
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_filestat_set_size(arg0, arg1);
};
{
match crate::wasi_snapshot_preview1::fd_filestat_set_size(fs, arg0 as UserFd, arg1 as u64) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_filestat_set_size", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_filestat_set_times(
arg0: i32,
arg1: i64,
arg2: i64,
arg3: i32,
) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"fd_filestat_set_times(fd: {}, atim: {}, mtim: {}, fst_flags: {})\n",
arg0, arg1, arg2, arg3
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_filestat_set_times(arg0, arg1, arg2, arg3);
};
{
match crate::wasi_snapshot_preview1::fd_filestat_set_times(
fs,
arg0 as UserFd,
arg1 as u64,
arg2 as u64,
arg3 as Fstflags,
) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_filestat_set_times", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_pread(
arg0: i32,
arg1: i32,
arg2: i32,
arg3: i64,
arg4: i32,
) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"fd_pread(fd: {}, iovs: {}, iovs_len: {}, offset: {})\n",
arg0, arg1, arg2, arg3
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_pread(arg0, arg1, arg2, arg3, arg4);
};
{
match crate::wasi_snapshot_preview1::fd_pread(
fs,
arg0 as UserFd,
core::slice::from_raw_parts(arg1 as *const Iovec, arg2 as usize),
arg3 as u64,
) {
Ok(e) => {
core::ptr::write(arg4 as *mut Size, e);
wasi::ERRNO_SUCCESS.raw() as i32
}
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_pread", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_prestat_get(arg0: i32, arg1: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!("fd_prestat_get(fd: {})\n", arg0));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_prestat_get(arg0, arg1);
};
{
match crate::wasi_snapshot_preview1::fd_prestat_get(fs, arg0 as UserFd) {
Ok(e) => {
core::ptr::write(arg1 as *mut Prestat, e);
wasi::ERRNO_SUCCESS.raw() as i32
}
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_prestat_get", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_prestat_dir_name(arg0: i32, arg1: i32, arg2: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"fd_prestat_dir_name(fd: {}, path: {}, path_len: {})\n",
arg0, arg1, arg2
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_prestat_dir_name(arg0, arg1, arg2);
};
{
match crate::wasi_snapshot_preview1::fd_prestat_dir_name(
fs,
arg0 as UserFd,
arg1 as *mut u8,
arg2 as u32,
) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_prestat_dir_name", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_pwrite(
arg0: i32,
arg1: i32,
arg2: i32,
arg3: i64,
arg4: i32,
) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"fd_pwrite(fd: {}, iovs: {}, iovs_len: {}, offset: {})\n",
arg0, arg1, arg2, arg3
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_pwrite(arg0, arg1, arg2, arg3, arg4);
};
{
match crate::wasi_snapshot_preview1::fd_pwrite(
fs,
arg0 as UserFd,
core::slice::from_raw_parts(arg1 as *const Ciovec, arg2 as usize),
arg3 as u64,
) {
Ok(e) => {
core::ptr::write(arg4 as *mut Size, e);
wasi::ERRNO_SUCCESS.raw() as i32
}
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_pwrite", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_read(arg0: i32, arg1: i32, arg2: i32, arg3: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"fd_read(fd: {}, iovs: {}, iovs_len: {})\n",
arg0, arg1, arg2
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_read(arg0, arg1, arg2, arg3);
};
{
match crate::wasi_snapshot_preview1::fd_read(
fs,
arg0 as UserFd,
core::slice::from_raw_parts(arg1 as *const Iovec, arg2 as usize),
) {
Ok(e) => {
core::ptr::write(arg3 as *mut Size, e);
wasi::ERRNO_SUCCESS.raw() as i32
}
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_read", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_readdir(
arg0: i32,
arg1: i32,
arg2: i32,
arg3: i64,
arg4: i32,
) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"fd_readdir(fd: {}, buf: {}, buf_len: {}, cookie: {})\n",
arg0, arg1, arg2, arg3
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_readdir(arg0, arg1, arg2, arg3, arg4);
};
{
match crate::wasi_snapshot_preview1::fd_readdir(
fs,
arg0 as UserFd,
arg1 as *mut u8,
arg2 as u32,
arg3 as u64,
) {
Ok(e) => {
core::ptr::write(arg4 as *mut Size, e);
wasi::ERRNO_SUCCESS.raw() as i32
}
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_readdir", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_renumber(arg0: i32, arg1: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!("fd_renumber(fd: {}, to: {})\n", arg0, arg1));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_renumber(arg0, arg1);
};
{
match crate::wasi_snapshot_preview1::fd_renumber(fs, arg0 as UserFd, arg1 as UserFd) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_renumber", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_seek(arg0: i32, arg1: i64, arg2: i32, arg3: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"fd_seek(fd: {}, offset: {}, whence: {})\n",
arg0, arg1, arg2
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_seek(arg0, arg1, arg2, arg3);
};
{
match crate::wasi_snapshot_preview1::fd_seek(fs, arg0 as UserFd, arg1 as i64, arg2) {
Ok(e) => {
core::ptr::write(arg3 as *mut Filesize, e);
wasi::ERRNO_SUCCESS.raw() as i32
}
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_seek", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_sync(arg0: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!("fd_sync(fd: {})\n", arg0));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_sync(arg0);
};
{
match crate::wasi_snapshot_preview1::fd_sync(fs, arg0 as UserFd) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_sync", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_tell(arg0: i32, arg1: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!("fd_tell(fd: {})\n", arg0));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_tell(arg0, arg1);
};
{
match crate::wasi_snapshot_preview1::fd_tell(fs, arg0 as UserFd) {
Ok(e) => {
core::ptr::write(arg1 as *mut Filesize, e);
wasi::ERRNO_SUCCESS.raw() as i32
}
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_tell", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_fd_write(arg0: i32, arg1: i32, arg2: i32, arg3: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"fd_write(fd: {}, iovs: {}, iovs_len: {})\n",
arg0, arg1, arg2
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::fd_write(arg0, arg1, arg2, arg3);
};
{
match crate::wasi_snapshot_preview1::fd_write(
fs,
arg0 as UserFd,
core::slice::from_raw_parts(arg1 as *const Ciovec, arg2 as usize),
) {
Ok(e) => {
core::ptr::write(arg3 as *mut Size, e);
wasi::ERRNO_SUCCESS.raw() as i32
}
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("fd_write", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_path_create_directory(arg0: i32, arg1: i32, arg2: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"path_create_directory(fd: {}, path: {}, path_len: {})\n",
arg0, arg1, arg2
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::path_create_directory(arg0, arg1, arg2);
};
{
match crate::wasi_snapshot_preview1::path_create_directory(fs, arg0 as UserFd, {
let str_bytes = core::slice::from_raw_parts(arg1 as *const u8, (arg2 + 1) as usize);
std::ffi::CStr::from_bytes_with_nul_unchecked(str_bytes)
}) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("path_create_directory", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_path_filestat_get(
arg0: i32,
arg1: i32,
arg2: i32,
arg3: i32,
arg4: i32,
) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"path_filestat_get(fd: {}, flags: {}, path: {}, path_len: {})\n",
arg0, arg1, arg2, arg3
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::path_filestat_get(arg0, arg1, arg2, arg3, arg4);
};
{
match crate::wasi_snapshot_preview1::path_filestat_get(
fs,
arg0 as UserFd,
arg1 as Lookupflags,
{
let str_bytes = core::slice::from_raw_parts(arg2 as *const u8, (arg3 + 1) as usize);
std::ffi::CStr::from_bytes_with_nul_unchecked(str_bytes)
},
) {
Ok(e) => {
core::ptr::write(arg4 as *mut Filestat, e);
wasi::ERRNO_SUCCESS.raw() as i32
}
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("path_filestat_get", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_path_filestat_set_times(
arg0: i32,
arg1: i32,
arg2: i32,
arg3: i32,
arg4: i64,
arg5: i64,
arg6: i32,
) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!("path_filestat_set_times(fd: {}, flags: {}, path: {}, path_len: {}, atim: {}, mtim: {}, fst_flags: {})\n", arg0, arg1, arg2, arg3, arg4, arg5, arg6));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::path_filestat_set_times(
arg0, arg1, arg2, arg3, arg4, arg5, arg6,
);
};
{
match crate::wasi_snapshot_preview1::path_filestat_set_times(
fs,
arg0 as UserFd,
arg1 as Lookupflags,
{
let str_bytes = core::slice::from_raw_parts(arg2 as *const u8, (arg3 + 1) as usize);
std::ffi::CStr::from_bytes_with_nul_unchecked(str_bytes)
},
arg4 as u64,
arg5 as u64,
arg6 as Fstflags,
) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("path_filestat_set_times", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_path_link(
arg0: i32,
arg1: i32,
arg2: i32,
arg3: i32,
arg4: i32,
arg5: i32,
arg6: i32,
) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!("path_link(old_fd: {}, old_flags: {}, old_path: {}, old_path_len: {}, new_fd: {}, new_path: {}, new_path_len: {})\n", arg0, arg1, arg2, arg3, arg4, arg5, arg6));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::path_link(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
};
{
match crate::wasi_snapshot_preview1::path_link(
fs,
arg0 as UserFd,
arg1 as Lookupflags,
{
let str_bytes = core::slice::from_raw_parts(arg2 as *const u8, (arg3 + 1) as usize);
std::ffi::CStr::from_bytes_with_nul_unchecked(str_bytes)
},
arg4 as UserFd,
{
let str_bytes = core::slice::from_raw_parts(arg5 as *const u8, (arg6 + 1) as usize);
std::ffi::CStr::from_bytes_with_nul_unchecked(str_bytes)
},
) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("path_link", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_path_open(
arg0: i32,
arg1: i32,
arg2: i32,
arg3: i32,
arg4: i32,
arg5: i64,
arg6: i64,
arg7: i32,
arg8: i32,
) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!("path_open(fd: {}, dirflags: {}, path: {}, path_len: {}, oflags: {}, fs_rights_base: {}, fs_rights_inheriting: {}, fdflags: {})\n", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::path_open(
arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8,
);
};
{
match crate::wasi_snapshot_preview1::path_open(
fs,
arg0 as UserFd,
arg1 as Lookupflags,
{
let str_bytes = core::slice::from_raw_parts(arg2 as *const u8, (arg3 + 1) as usize);
std::ffi::CStr::from_bytes_with_nul_unchecked(str_bytes)
},
arg4 as Oflags,
arg5 as Rights,
arg6 as Rights,
arg7 as Fdflags,
) {
Ok(e) => {
core::ptr::write(arg8 as *mut Fd, e);
wasi::ERRNO_SUCCESS.raw() as i32
}
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("path_open", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_path_readlink(
arg0: i32,
arg1: i32,
arg2: i32,
arg3: i32,
arg4: i32,
arg5: i32,
) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"path_readlink(fd: {}, path: {}, path_len: {}, buf: {}, buf_len: {})\n",
arg0, arg1, arg2, arg3, arg4
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::path_readlink(arg0, arg1, arg2, arg3, arg4, arg5);
};
{
match crate::wasi_snapshot_preview1::path_readlink(
fs,
arg0 as UserFd,
{
let str_bytes = core::slice::from_raw_parts(arg1 as *const u8, (arg2 + 1) as usize);
std::ffi::CStr::from_bytes_with_nul_unchecked(str_bytes)
},
arg3 as *mut u8,
arg4 as u32,
) {
Ok(e) => {
core::ptr::write(arg5 as *mut Size, e);
wasi::ERRNO_SUCCESS.raw() as i32
}
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("path_readlink", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_path_remove_directory(arg0: i32, arg1: i32, arg2: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"path_remove_directory(fd: {}, path: {}, path_len: {})\n",
arg0, arg1, arg2
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::path_remove_directory(arg0, arg1, arg2);
};
{
match crate::wasi_snapshot_preview1::path_remove_directory(fs, arg0 as UserFd, {
let str_bytes = core::slice::from_raw_parts(arg1 as *const u8, (arg2 + 1) as usize);
std::ffi::CStr::from_bytes_with_nul_unchecked(str_bytes)
}) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("path_remove_directory", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_path_rename(
arg0: i32,
arg1: i32,
arg2: i32,
arg3: i32,
arg4: i32,
arg5: i32,
) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!("path_rename(fd: {}, old_path: {}, old_path_len: {}, new_fd: {}, new_path: {}, new_path_len: {})\n", arg0, arg1, arg2, arg3, arg4, arg5));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::path_rename(arg0, arg1, arg2, arg3, arg4, arg5);
};
{
match crate::wasi_snapshot_preview1::path_rename(
fs,
arg0 as UserFd,
{
let str_bytes = core::slice::from_raw_parts(arg1 as *const u8, (arg2 + 1) as usize);
std::ffi::CStr::from_bytes_with_nul_unchecked(str_bytes)
},
arg3 as UserFd,
{
let str_bytes = core::slice::from_raw_parts(arg4 as *const u8, (arg5 + 1) as usize);
std::ffi::CStr::from_bytes_with_nul_unchecked(str_bytes)
},
) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("path_rename", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_path_symlink(
arg0: i32,
arg1: i32,
arg2: i32,
arg3: i32,
arg4: i32,
) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"path_symlink(old_path: {}, old_path_len: {}, fd: {}, new_path: {}, new_path_len: {})\n",
arg0, arg1, arg2, arg3, arg4
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::path_symlink(arg0, arg1, arg2, arg3, arg4);
};
{
match crate::wasi_snapshot_preview1::path_symlink(
fs,
{
let str_bytes = core::slice::from_raw_parts(arg0 as *const u8, (arg1 + 1) as usize);
std::ffi::CStr::from_bytes_with_nul_unchecked(str_bytes)
},
arg2 as UserFd,
{
let str_bytes = core::slice::from_raw_parts(arg3 as *const u8, (arg4 + 1) as usize);
std::ffi::CStr::from_bytes_with_nul_unchecked(str_bytes)
},
) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("path_symlink", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_path_unlink_file(arg0: i32, arg1: i32, arg2: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"path_unlink_file(fd: {}, path: {}, path_len: {})\n",
arg0, arg1, arg2
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::path_unlink_file(arg0, arg1, arg2);
};
{
match crate::wasi_snapshot_preview1::path_unlink_file(fs, arg0 as UserFd, {
let str_bytes = core::slice::from_raw_parts(arg1 as *const u8, (arg2 + 1) as usize);
std::ffi::CStr::from_bytes_with_nul_unchecked(str_bytes)
}) {
Ok(e) => wasi::ERRNO_SUCCESS.raw() as i32,
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("path_unlink_file", e.clone());
e.raw() as i32
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasi_vfs_poll_oneoff(arg0: i32, arg1: i32, arg2: i32, arg3: i32) -> i32 {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_entry(format_args!(
"poll_oneoff(in: {}, out: {}, nsubscriptions: {})\n",
arg0, arg1, arg2
));
let fs = if let Some(fs) = crate::GLOBAL_STATE.overlay_fs.as_mut() {
fs
} else {
return wasi::wasi_snapshot_preview1::poll_oneoff(arg0, arg1, arg2, arg3);
};
{
match crate::wasi_snapshot_preview1::poll_oneoff(
fs,
arg0 as *const Subscription,
arg1 as *mut Event,
arg2 as u32,
) {
Ok(e) => {
core::ptr::write(arg3 as *mut Size, e);
wasi::ERRNO_SUCCESS.raw() as i32
}
Err(e) => {
#[cfg(feature = "trace-syscall")]
crate::trace::trace_syscall_error("poll_oneoff", e.clone());
e.raw() as i32
}
}
}
}