From 8ba4e92d60acc8a634b2520264d483dd023b146d Mon Sep 17 00:00:00 2001 From: Michael Mikovsky <77305074+Astatin3@users.noreply.github.com> Date: Tue, 19 Aug 2025 08:17:09 -0600 Subject: [PATCH] Work on adding different syscalls --- .modules.order.cmd | 1 - README.md | 8 + src/lib.rs | 12 +- syscall_lib/src/arch_types/mod.rs | 2 + syscall_lib/src/arch_types/x86_64.rs | 23 + syscall_lib/src/create_syscall.rs | 1670 ------------------------- syscall_lib/src/kern_buffers.rs | 33 - syscall_lib/src/lib.rs | 79 +- syscall_lib/src/proxy_list.rs | 2 +- syscall_lib/src/syscall.rs | 1705 -------------------------- syscall_lib/src/syscall/create.rs | 1653 +++++++++++++++++++++++++ syscall_lib/src/syscall/exec.rs | 710 +++++++++++ syscall_lib/src/syscall/mod.rs | 1656 +++++++++++++++++++++++++ syscall_lib/src/syscall_display.rs | 0 syscall_lib/src/syscall_exec.rs | 661 ---------- syscall_lib/src/syscall_num.rs | 380 ------ syscall_lib/src/types.rs | 218 +++- 17 files changed, 4243 insertions(+), 4570 deletions(-) delete mode 100644 .modules.order.cmd create mode 100644 README.md create mode 100644 syscall_lib/src/arch_types/mod.rs create mode 100644 syscall_lib/src/arch_types/x86_64.rs delete mode 100644 syscall_lib/src/create_syscall.rs delete mode 100644 syscall_lib/src/kern_buffers.rs delete mode 100644 syscall_lib/src/syscall.rs create mode 100644 syscall_lib/src/syscall/create.rs create mode 100644 syscall_lib/src/syscall/exec.rs create mode 100644 syscall_lib/src/syscall/mod.rs delete mode 100644 syscall_lib/src/syscall_display.rs delete mode 100644 syscall_lib/src/syscall_exec.rs delete mode 100644 syscall_lib/src/syscall_num.rs diff --git a/.modules.order.cmd b/.modules.order.cmd deleted file mode 100644 index d8f3bee..0000000 --- a/.modules.order.cmd +++ /dev/null @@ -1 +0,0 @@ -savedcmd_modules.order := { echo target/release/libintercept.so; :; } > modules.order diff --git a/README.md b/README.md new file mode 100644 index 0000000..790fedb --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +TODO: +[x] - Intercept syscalls +[x] - Transmit syscalls over network +[x] - Execute syscalls +[x] - Read memory from buffers. +[ ] - Mutate syscalls into Rust +[ ] - Copy memory over network +[ ] - Mutate syscalls back into C diff --git a/src/lib.rs b/src/lib.rs index b99c758..7c0f274 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -111,6 +111,16 @@ extern "C" fn hook( println!("{:?}", syscall); + if let Syscall::Unimplemented(_) = syscall { + unsafe { + set_hook_fn(hook); + } + + return InterceptResult::Forward; + } + + *result = unsafe { syscall.execute_syscall() }; + // unsafe { // #[allow(static_mut_refs)] // if let Some(host) = HOST.as_ref() { @@ -122,5 +132,5 @@ extern "C" fn hook( set_hook_fn(hook); } - InterceptResult::Forward + InterceptResult::Hook } diff --git a/syscall_lib/src/arch_types/mod.rs b/syscall_lib/src/arch_types/mod.rs new file mode 100644 index 0000000..9542349 --- /dev/null +++ b/syscall_lib/src/arch_types/mod.rs @@ -0,0 +1,2 @@ +mod x86_64; +pub use x86_64::*; diff --git a/syscall_lib/src/arch_types/x86_64.rs b/syscall_lib/src/arch_types/x86_64.rs new file mode 100644 index 0000000..479f70f --- /dev/null +++ b/syscall_lib/src/arch_types/x86_64.rs @@ -0,0 +1,23 @@ +use bincode::{Decode, Encode}; + +#[derive(Debug, Encode, Decode)] +pub struct stat { + pub st_dev: libc::dev_t, + pub st_ino: libc::ino_t, + pub st_nlink: libc::nlink_t, + pub st_mode: libc::mode_t, + pub st_uid: libc::uid_t, + pub st_gid: libc::gid_t, + __pad0: libc::c_int, + pub st_rdev: libc::dev_t, + pub st_size: libc::off_t, + pub st_blksize: libc::blksize_t, + pub st_blocks: libc::blkcnt_t, + pub st_atime: libc::time_t, + pub st_atime_nsec: i64, + pub st_mtime: libc::time_t, + pub st_mtime_nsec: i64, + pub st_ctime: libc::time_t, + pub st_ctime_nsec: i64, + __unused: [i64; 3], +} diff --git a/syscall_lib/src/create_syscall.rs b/syscall_lib/src/create_syscall.rs deleted file mode 100644 index 039cc34..0000000 --- a/syscall_lib/src/create_syscall.rs +++ /dev/null @@ -1,1670 +0,0 @@ -use std::mem::transmute; - -use crate::*; - -impl Syscall { - /// Constructs a `Syscall` enum variant from a syscall number and an array of 6 arguments. - /// - /// The `args` array corresponds to the values in the registers `rdi`, `rsi`, - /// `rdx`, `r10`, `r8`, and `r9` at the time of the syscall. - /// - /// Returns an `Err` if the syscall number is unknown. - pub fn from_syscall( - num: libc::c_long, - args: [libc::c_ulong; 6], - ) -> Result { - let s = unsafe { - match num { - libc::SYS_read => Syscall::Read { - fd: args[0] as libc::c_int, - buf: Buf(Ptr::::new(args[1])), - count: args[2] as libc::size_t, - }, - libc::SYS_write => Syscall::Write { - fd: args[0] as libc::c_int, - buf: Buf(Ptr::::new(args[1])), - count: args[2] as libc::size_t, - }, - _ => Syscall::Unimplemented, - } - }; - - Ok(s) - - // let s = match num { - // // NOTE: The correctness of this function relies on the exact type and order of arguments - // // for each syscall on the x86_64 architecture. The arguments are cast from `u64`. - // libc::SYS_read => Syscall::Read { - // fd: args[0] as libc::c_uint, - // buf: args[1] as Ptr, - // count: args[2] as libc::size_t, - // }, - // libc::SYS_write => Syscall::Write { - // fd: args[0] as libc::c_uint, - // buf: args[1] as ConstPtr, - // count: args[2] as libc::size_t, - // }, - // libc::SYS_open => Syscall::Open { - // path: args[0] as ConstPtr, - // flags: args[1] as libc::c_int, - // mode: args[2] as libc::mode_t, - // }, - // libc::SYS_close => Syscall::Close { - // fd: args[0] as libc::c_uint, - // }, - // libc::SYS_stat => Syscall::Stat { - // path: args[0] as ConstPtr, - // statbuf: args[1] as Ptr, - // }, - // libc::SYS_fstat => Syscall::Fstat { - // fd: args[0] as libc::c_uint, - // statbuf: args[1] as Ptr, - // }, - // libc::SYS_lstat => Syscall::Lstat { - // path: args[0] as ConstPtr, - // statbuf: args[1] as Ptr, - // }, - // libc::SYS_poll => Syscall::Poll { - // fds: args[0] as Ptr, - // nfds: args[1] as libc::c_uint, - // timeout: args[2] as libc::c_int, - // }, - // libc::SYS_lseek => Syscall::Lseek { - // fd: args[0] as libc::c_uint, - // offset: args[1] as libc::off_t, - // whence: args[2] as libc::c_uint, - // }, - // libc::SYS_mmap => Syscall::Mmap { - // addr: args[0] as Ptr, - // len: args[1] as libc::size_t, - // prot: args[2] as libc::c_int, - // flags: args[3] as libc::c_int, - // fd: args[4] as libc::c_int, - // offset: args[5] as libc::off_t, - // }, - // libc::SYS_mprotect => Syscall::Mprotect { - // addr: args[0] as Ptr, - // len: args[1] as libc::size_t, - // prot: args[2] as libc::c_int, - // }, - // libc::SYS_munmap => Syscall::Munmap { - // addr: args[0] as Ptr, - // len: args[1] as libc::size_t, - // }, - // libc::SYS_brk => Syscall::Brk { - // addr: args[0] as Ptr, - // }, - // libc::SYS_rt_sigaction => Syscall::RtSigaction { - // sig: args[0] as libc::c_int, - // act: args[1] as ConstPtr, - // oldact: args[2] as Ptr, - // sigsetsize: args[3] as libc::size_t, - // }, - // libc::SYS_rt_sigprocmask => Syscall::RtSigprocmask { - // how: args[0] as libc::c_int, - // set: args[1] as Ptr, - // oldset: args[2] as Ptr, - // sigsetsize: args[3] as libc::size_t, - // }, - // 15 => Syscall::RtSigreturn, // SYS_rt_sigreturn is often not in libc crates - // libc::SYS_ioctl => Syscall::Ioctl { - // fd: args[0] as libc::c_uint, - // cmd: args[1] as libc::c_ulong, - // arg: args[2] as libc::c_ulong, - // }, - // libc::SYS_pread64 => Syscall::Pread64 { - // fd: args[0] as libc::c_uint, - // buf: args[1] as Ptr, - // count: args[2] as libc::size_t, - // pos: args[3] as libc::loff_t, - // }, - // libc::SYS_pwrite64 => Syscall::Pwrite64 { - // fd: args[0] as libc::c_uint, - // buf: args[1] as ConstPtr, - // count: args[2] as libc::size_t, - // pos: args[3] as libc::loff_t, - // }, - // libc::SYS_readv => Syscall::Readv { - // fd: args[0] as libc::c_ulong, - // vec: args[1] as ConstPtr, - // vlen: args[2] as libc::c_ulong, - // }, - // libc::SYS_writev => Syscall::Writev { - // fd: args[0] as libc::c_ulong, - // vec: args[1] as ConstPtr, - // vlen: args[2] as libc::c_ulong, - // }, - // libc::SYS_access => Syscall::Access { - // filename: args[0] as ConstPtr, - // mode: args[1] as libc::c_int, - // }, - // libc::SYS_pipe => Syscall::Pipe { - // fildes: args[0] as Ptr, - // }, - // libc::SYS_select => Syscall::Select { - // n: args[0] as libc::c_int, - // inp: args[1] as Ptr, - // outp: args[2] as Ptr, - // exp: args[3] as Ptr, - // tvp: args[4] as Ptr, - // }, - // libc::SYS_sched_yield => Syscall::SchedYield, - // libc::SYS_mremap => Syscall::Mremap { - // old_addr: args[0] as Ptr, - // old_size: args[1] as libc::size_t, - // new_size: args[2] as libc::size_t, - // flags: args[3] as libc::c_int, - // new_addr: args[4] as Ptr, - // }, - // libc::SYS_msync => Syscall::Msync { - // start: args[0] as Ptr, - // len: args[1] as libc::size_t, - // flags: args[2] as libc::c_int, - // }, - // libc::SYS_mincore => Syscall::Mincore { - // start: args[0] as Ptr, - // len: args[1] as libc::size_t, - // vec: args[2] as Ptr, - // }, - // libc::SYS_madvise => Syscall::Madvise { - // start: args[0] as Ptr, - // len: args[1] as libc::size_t, - // behavior: args[2] as libc::c_int, - // }, - // libc::SYS_shmget => Syscall::Shmget { - // key: args[0] as libc::key_t, - // size: args[1] as libc::size_t, - // shmflg: args[2] as libc::c_int, - // }, - // libc::SYS_shmat => Syscall::Shmat { - // shmid: args[0] as libc::c_int, - // shmaddr: args[1] as ConstPtr, - // shmflg: args[2] as libc::c_int, - // }, - // libc::SYS_shmctl => Syscall::Shmctl { - // shmid: args[0] as libc::c_int, - // cmd: args[1] as libc::c_int, - // buf: args[2] as Ptr, - // }, - // libc::SYS_dup => Syscall::Dup { - // fildes: args[0] as libc::c_uint, - // }, - // libc::SYS_dup2 => Syscall::Dup2 { - // oldfd: args[0] as libc::c_uint, - // newfd: args[1] as libc::c_uint, - // }, - // libc::SYS_pause => Syscall::Pause, - // libc::SYS_nanosleep => Syscall::Nanosleep { - // rqtp: args[0] as ConstPtr, - // rmtp: args[1] as Ptr, - // }, - // libc::SYS_getitimer => Syscall::Getitimer { - // which: args[0] as libc::c_int, - // value: args[1] as Ptr, - // }, - // libc::SYS_alarm => Syscall::Alarm { - // seconds: args[0] as libc::c_uint, - // }, - // libc::SYS_setitimer => Syscall::Setitimer { - // which: args[0] as libc::c_int, - // value: args[1] as ConstPtr, - // ovalue: args[2] as Ptr, - // }, - // libc::SYS_getpid => Syscall::Getpid, - // libc::SYS_sendfile => Syscall::Sendfile { - // out_fd: args[0] as libc::c_int, - // in_fd: args[1] as libc::c_int, - // offset: args[2] as Ptr, - // count: args[3] as libc::size_t, - // }, - // libc::SYS_socket => Syscall::Socket { - // domain: args[0] as libc::c_int, - // ty: args[1] as libc::c_int, - // protocol: args[2] as libc::c_int, - // }, - // libc::SYS_connect => Syscall::Connect { - // fd: args[0] as libc::c_int, - // addr: args[1] as ConstPtr, - // len: args[2] as libc::socklen_t, - // }, - // libc::SYS_accept => Syscall::Accept { - // fd: args[0] as libc::c_int, - // addr: args[1] as Ptr, - // len: args[2] as Ptr, - // }, - // libc::SYS_sendto => Syscall::Sendto { - // fd: args[0] as libc::c_int, - // buf: args[1] as ConstPtr, - // len: args[2] as libc::size_t, - // flags: args[3] as libc::c_int, - // addr: args[4] as ConstPtr, - // addr_len: args[5] as libc::socklen_t, - // }, - // libc::SYS_recvfrom => Syscall::Recvfrom { - // fd: args[0] as libc::c_int, - // buf: args[1] as Ptr, - // len: args[2] as libc::size_t, - // flags: args[3] as libc::c_int, - // addr: args[4] as Ptr, - // addr_len: args[5] as Ptr, - // }, - // libc::SYS_sendmsg => Syscall::Sendmsg { - // fd: args[0] as libc::c_int, - // msg: args[1] as ConstPtr, - // flags: args[2] as libc::c_int, - // }, - // libc::SYS_recvmsg => Syscall::Recvmsg { - // fd: args[0] as libc::c_int, - // msg: args[1] as Ptr, - // flags: args[2] as libc::c_int, - // }, - // libc::SYS_shutdown => Syscall::Shutdown { - // fd: args[0] as libc::c_int, - // how: args[1] as libc::c_int, - // }, - // libc::SYS_bind => Syscall::Bind { - // fd: args[0] as libc::c_int, - // addr: args[1] as ConstPtr, - // len: args[2] as libc::socklen_t, - // }, - // libc::SYS_listen => Syscall::Listen { - // fd: args[0] as libc::c_int, - // backlog: args[1] as libc::c_int, - // }, - // libc::SYS_getsockname => Syscall::Getsockname { - // fd: args[0] as libc::c_int, - // addr: args[1] as Ptr, - // len: args[2] as Ptr, - // }, - // libc::SYS_getpeername => Syscall::Getpeername { - // fd: args[0] as libc::c_int, - // addr: args[1] as Ptr, - // len: args[2] as Ptr, - // }, - // libc::SYS_socketpair => Syscall::Socketpair { - // domain: args[0] as libc::c_int, - // ty: args[1] as libc::c_int, - // protocol: args[2] as libc::c_int, - // fds: args[3] as Ptr, - // }, - // libc::SYS_setsockopt => Syscall::Setsockopt { - // fd: args[0] as libc::c_int, - // level: args[1] as libc::c_int, - // optname: args[2] as libc::c_int, - // optval: args[3] as ConstPtr, - // optlen: args[4] as libc::socklen_t, - // }, - // libc::SYS_getsockopt => Syscall::Getsockopt { - // fd: args[0] as libc::c_int, - // level: args[1] as libc::c_int, - // optname: args[2] as libc::c_int, - // optval: args[3] as Ptr, - // optlen: args[4] as Ptr, - // }, - // libc::SYS_clone => Syscall::Clone { - // flags: args[0] as libc::c_ulong, - // stack: args[1] as Ptr, - // parent_tid: args[2] as Ptr, - // child_tid: args[3] as Ptr, - // tls: args[4] as libc::c_ulong, - // }, - // libc::SYS_fork => Syscall::Fork, - // libc::SYS_vfork => Syscall::Vfork, - // libc::SYS_execve => Syscall::Execve { - // filename: args[0] as ConstPtr, - // argv: args[1] as ConstPtr>, - // envp: args[2] as ConstPtr>, - // }, - // libc::SYS_exit => Syscall::Exit { - // error_code: args[0] as libc::c_int, - // }, - // libc::SYS_wait4 => Syscall::Wait4 { - // pid: args[0] as libc::pid_t, - // stat_addr: args[1] as Ptr, - // options: args[2] as libc::c_int, - // ru: args[3] as Ptr, - // }, - // libc::SYS_kill => Syscall::Kill { - // pid: args[0] as libc::pid_t, - // sig: args[1] as libc::c_int, - // }, - // libc::SYS_uname => Syscall::Uname { - // name: args[0] as Ptr, - // }, - // libc::SYS_semget => Syscall::Semget { - // key: args[0] as libc::key_t, - // nsems: args[1] as libc::c_int, - // semflg: args[2] as libc::c_int, - // }, - // libc::SYS_semop => Syscall::Semop { - // semid: args[0] as libc::c_int, - // sops: args[1] as Ptr, - // nsops: args[2] as libc::size_t, - // }, - // libc::SYS_semctl => Syscall::Semctl { - // semid: args[0] as libc::c_int, - // semnum: args[1] as libc::c_int, - // cmd: args[2] as libc::c_int, - // arg: args[3] as libc::c_ulong, - // }, - // libc::SYS_shmdt => Syscall::Shmdt { - // shmaddr: args[0] as ConstPtr, - // }, - // libc::SYS_msgget => Syscall::Msgget { - // key: args[0] as libc::key_t, - // msgflg: args[1] as libc::c_int, - // }, - // libc::SYS_msgsnd => Syscall::Msgsnd { - // msqid: args[0] as libc::c_int, - // msgp: args[1] as ConstPtr, - // msgsz: args[2] as libc::size_t, - // msgflg: args[3] as libc::c_int, - // }, - // libc::SYS_msgrcv => Syscall::Msgrcv { - // msqid: args[0] as libc::c_int, - // msgp: args[1] as Ptr, - // msgsz: args[2] as libc::size_t, - // msgtyp: args[3] as libc::c_long, - // msgflg: args[4] as libc::c_int, - // }, - // libc::SYS_msgctl => Syscall::Msgctl { - // msqid: args[0] as libc::c_int, - // cmd: args[1] as libc::c_int, - // buf: args[2] as Ptr, - // }, - // libc::SYS_fcntl => Syscall::Fcntl { - // fd: args[0] as libc::c_uint, - // cmd: args[1] as libc::c_uint, - // arg: args[2] as libc::c_ulong, - // }, - // libc::SYS_flock => Syscall::Flock { - // fd: args[0] as libc::c_uint, - // cmd: args[1] as libc::c_uint, - // }, - // libc::SYS_fsync => Syscall::Fsync { - // fd: args[0] as libc::c_uint, - // }, - // libc::SYS_fdatasync => Syscall::Fdatasync { - // fd: args[0] as libc::c_uint, - // }, - // libc::SYS_truncate => Syscall::Truncate { - // path: args[0] as ConstPtr, - // length: args[1] as libc::c_long, - // }, - // libc::SYS_ftruncate => Syscall::Ftruncate { - // fd: args[0] as libc::c_uint, - // length: args[1] as libc::c_long, - // }, - // libc::SYS_getdents => Syscall::Getdents { - // fd: args[0] as libc::c_uint, - // dirent: args[1] as Ptr, - // count: args[2] as libc::c_uint, - // }, - // libc::SYS_getcwd => Syscall::Getcwd { - // buf: args[0] as Ptr, - // size: args[1] as libc::c_ulong, - // }, - // libc::SYS_chdir => Syscall::Chdir { - // filename: args[0] as ConstPtr, - // }, - // libc::SYS_fchdir => Syscall::Fchdir { - // fd: args[0] as libc::c_uint, - // }, - // libc::SYS_rename => Syscall::Rename { - // oldname: args[0] as ConstPtr, - // newname: args[1] as ConstPtr, - // }, - // libc::SYS_mkdir => Syscall::Mkdir { - // pathname: args[0] as ConstPtr, - // mode: args[1] as libc::mode_t, - // }, - // libc::SYS_rmdir => Syscall::Rmdir { - // pathname: args[0] as ConstPtr, - // }, - // libc::SYS_creat => Syscall::Creat { - // pathname: args[0] as ConstPtr, - // mode: args[1] as libc::mode_t, - // }, - // libc::SYS_link => Syscall::Link { - // oldname: args[0] as ConstPtr, - // newname: args[1] as ConstPtr, - // }, - // libc::SYS_unlink => Syscall::Unlink { - // pathname: args[0] as ConstPtr, - // }, - // libc::SYS_symlink => Syscall::Symlink { - // old: args[0] as ConstPtr, - // new: args[1] as ConstPtr, - // }, - // libc::SYS_readlink => Syscall::Readlink { - // path: args[0] as ConstPtr, - // buf: args[1] as Ptr, - // bufsiz: args[2] as libc::c_int, - // }, - // libc::SYS_chmod => Syscall::Chmod { - // filename: args[0] as ConstPtr, - // mode: args[1] as libc::mode_t, - // }, - // libc::SYS_fchmod => Syscall::Fchmod { - // fd: args[0] as libc::c_uint, - // mode: args[1] as libc::mode_t, - // }, - // libc::SYS_chown => Syscall::Chown { - // filename: args[0] as ConstPtr, - // user: args[1] as libc::uid_t, - // group: args[2] as libc::gid_t, - // }, - // libc::SYS_fchown => Syscall::Fchown { - // fd: args[0] as libc::c_uint, - // user: args[1] as libc::uid_t, - // group: args[2] as libc::gid_t, - // }, - // libc::SYS_lchown => Syscall::Lchown { - // filename: args[0] as ConstPtr, - // user: args[1] as libc::uid_t, - // group: args[2] as libc::gid_t, - // }, - // libc::SYS_umask => Syscall::Umask { - // mask: args[0] as libc::c_int, - // }, - // libc::SYS_gettimeofday => Syscall::Gettimeofday { - // tv: args[0] as Ptr, - // tz: args[1] as Ptr, - // }, - // libc::SYS_getrlimit => Syscall::Getrlimit { - // resource: args[0] as libc::c_int, - // rlim: args[1] as Ptr, - // }, - // libc::SYS_getrusage => Syscall::Getrusage { - // who: args[0] as libc::c_int, - // ru: args[1] as Ptr, - // }, - // libc::SYS_sysinfo => Syscall::Sysinfo { - // info: args[0] as Ptr, - // }, - // libc::SYS_times => Syscall::Times { - // tbuf: args[0] as Ptr, - // }, - // libc::SYS_ptrace => Syscall::Ptrace { - // request: args[0] as libc::c_long, - // pid: args[1] as libc::c_long, - // addr: args[2] as libc::c_ulong, - // data: args[3] as libc::c_ulong, - // }, - // libc::SYS_getuid => Syscall::Getuid, - // libc::SYS_syslog => Syscall::Syslog { - // ty: args[0] as libc::c_int, - // buf: args[1] as Ptr, - // len: args[2] as libc::c_int, - // }, - // libc::SYS_getgid => Syscall::Getgid, - // libc::SYS_setuid => Syscall::Setuid { - // uid: args[0] as libc::uid_t, - // }, - // libc::SYS_setgid => Syscall::Setgid { - // gid: args[0] as libc::gid_t, - // }, - // libc::SYS_geteuid => Syscall::Geteuid, - // libc::SYS_getegid => Syscall::Getegid, - // libc::SYS_setpgid => Syscall::Setpgid { - // pid: args[0] as libc::pid_t, - // pgid: args[1] as libc::pid_t, - // }, - // libc::SYS_getppid => Syscall::Getppid, - // libc::SYS_getpgrp => Syscall::Getpgrp, - // libc::SYS_setsid => Syscall::Setsid, - // libc::SYS_setreuid => Syscall::Setreuid { - // ruid: args[0] as libc::uid_t, - // euid: args[1] as libc::uid_t, - // }, - // libc::SYS_setregid => Syscall::Setregid { - // rgid: args[0] as libc::gid_t, - // egid: args[1] as libc::gid_t, - // }, - // libc::SYS_getgroups => Syscall::Getgroups { - // gidsetsize: args[0] as libc::c_int, - // grouplist: args[1] as Ptr, - // }, - // libc::SYS_setgroups => Syscall::Setgroups { - // gidsetsize: args[0] as libc::c_int, - // grouplist: args[1] as ConstPtr, - // }, - // libc::SYS_setresuid => Syscall::Setresuid { - // ruid: args[0] as libc::uid_t, - // euid: args[1] as libc::uid_t, - // suid: args[2] as libc::uid_t, - // }, - // libc::SYS_getresuid => Syscall::Getresuid { - // ruid: args[0] as Ptr, - // euid: args[1] as Ptr, - // suid: args[2] as Ptr, - // }, - // libc::SYS_setresgid => Syscall::Setresgid { - // rgid: args[0] as libc::gid_t, - // egid: args[1] as libc::gid_t, - // sgid: args[2] as libc::gid_t, - // }, - // libc::SYS_getresgid => Syscall::Getresgid { - // rgid: args[0] as Ptr, - // egid: args[1] as Ptr, - // sgid: args[2] as Ptr, - // }, - // libc::SYS_getpgid => Syscall::Getpgid { - // pid: args[0] as libc::pid_t, - // }, - // libc::SYS_setfsuid => Syscall::Setfsuid { - // uid: args[0] as libc::uid_t, - // }, - // libc::SYS_setfsgid => Syscall::Setfsgid { - // gid: args[0] as libc::gid_t, - // }, - // libc::SYS_getsid => Syscall::Getsid { - // pid: args[0] as libc::pid_t, - // }, - // libc::SYS_capget => Syscall::Capget { - // header: args[0] as Ptr, - // dataptr: args[1] as Ptr, - // }, - // libc::SYS_capset => Syscall::Capset { - // header: args[0] as Ptr, - // data: args[1] as ConstPtr, - // }, - // libc::SYS_rt_sigpending => Syscall::RtSigpending { - // set: args[0] as Ptr, - // sigsetsize: args[1] as libc::size_t, - // }, - // libc::SYS_rt_sigtimedwait => Syscall::RtSigtimedwait { - // uthese: args[0] as ConstPtr, - // uinfo: args[1] as Ptr, - // uts: args[2] as ConstPtr, - // sigsetsize: args[3] as libc::size_t, - // }, - // libc::SYS_rt_sigqueueinfo => Syscall::RtSigqueueinfo { - // pid: args[0] as libc::pid_t, - // sig: args[1] as libc::c_int, - // uinfo: args[2] as Ptr, - // }, - // libc::SYS_rt_sigsuspend => Syscall::RtSigsuspend { - // unewset: args[0] as Ptr, - // sigsetsize: args[1] as libc::size_t, - // }, - // libc::SYS_sigaltstack => Syscall::Sigaltstack { - // uss: args[0] as ConstPtr, - // uoss: args[1] as Ptr, - // }, - // libc::SYS_utime => Syscall::Utime { - // filename: args[0] as ConstPtr, - // times: args[1] as Ptr, - // }, - // libc::SYS_mknod => Syscall::Mknod { - // filename: args[0] as ConstPtr, - // mode: args[1] as libc::mode_t, - // dev: args[2] as libc::c_uint, - // }, - // libc::SYS_uselib => Syscall::Uselib { - // library: args[0] as ConstPtr, - // }, - // libc::SYS_personality => Syscall::Personality { - // personality: args[0] as libc::c_uint, - // }, - // libc::SYS_ustat => Syscall::Ustat { - // dev: args[0] as libc::c_uint, - // ubuf: args[1] as Ptr, - // }, - // libc::SYS_statfs => Syscall::Statfs { - // path: args[0] as ConstPtr, - // buf: args[1] as Ptr, - // }, - // libc::SYS_fstatfs => Syscall::Fstatfs { - // fd: args[0] as libc::c_uint, - // buf: args[1] as Ptr, - // }, - // libc::SYS_sysfs => Syscall::Sysfs { - // option: args[0] as libc::c_int, - // arg1: args[1] as libc::c_ulong, - // arg2: args[2] as libc::c_ulong, - // }, - // libc::SYS_getpriority => Syscall::Getpriority { - // which: args[0] as libc::c_int, - // who: args[1] as libc::c_int, - // }, - // libc::SYS_setpriority => Syscall::Setpriority { - // which: args[0] as libc::c_int, - // who: args[1] as libc::c_int, - // niceval: args[2] as libc::c_int, - // }, - // libc::SYS_sched_setparam => Syscall::SchedSetparam { - // pid: args[0] as libc::pid_t, - // param: args[1] as ConstPtr, - // }, - // libc::SYS_sched_getparam => Syscall::SchedGetparam { - // pid: args[0] as libc::pid_t, - // param: args[1] as Ptr, - // }, - // libc::SYS_sched_setscheduler => Syscall::SchedSetscheduler { - // pid: args[0] as libc::pid_t, - // policy: args[1] as libc::c_int, - // param: args[2] as ConstPtr, - // }, - // libc::SYS_sched_getscheduler => Syscall::SchedGetscheduler { - // pid: args[0] as libc::pid_t, - // }, - // libc::SYS_sched_get_priority_max => Syscall::SchedGetPriorityMax { - // policy: args[0] as libc::c_int, - // }, - // libc::SYS_sched_get_priority_min => Syscall::SchedGetPriorityMin { - // policy: args[0] as libc::c_int, - // }, - // libc::SYS_sched_rr_get_interval => Syscall::SchedRrGetInterval { - // pid: args[0] as libc::pid_t, - // interval: args[1] as Ptr, - // }, - // libc::SYS_mlock => Syscall::Mlock { - // start: args[0] as libc::c_ulong, - // len: args[1] as libc::size_t, - // }, - // libc::SYS_munlock => Syscall::Munlock { - // start: args[0] as libc::c_ulong, - // len: args[1] as libc::size_t, - // }, - // libc::SYS_mlockall => Syscall::Mlockall { - // flags: args[0] as libc::c_int, - // }, - // libc::SYS_munlockall => Syscall::Munlockall, - // libc::SYS_vhangup => Syscall::Vhangup, - // libc::SYS_pivot_root => Syscall::PivotRoot { - // new_root: args[0] as ConstPtr, - // put_old: args[1] as ConstPtr, - // }, - // libc::SYS_prctl => Syscall::Prctl { - // option: args[0] as libc::c_int, - // arg2: args[1] as libc::c_ulong, - // arg3: args[2] as libc::c_ulong, - // arg4: args[3] as libc::c_ulong, - // arg5: args[4] as libc::c_ulong, - // }, - // libc::SYS_adjtimex => Syscall::Adjtimex { - // txc_p: args[0] as Ptr, - // }, - // libc::SYS_setrlimit => Syscall::Setrlimit { - // resource: args[0] as libc::c_uint, - // rlim: args[1] as ConstPtr, - // }, - // libc::SYS_chroot => Syscall::Chroot { - // filename: args[0] as ConstPtr, - // }, - // libc::SYS_sync => Syscall::Sync, - // libc::SYS_acct => Syscall::Acct { - // name: args[0] as ConstPtr, - // }, - // libc::SYS_settimeofday => Syscall::Settimeofday { - // tv: args[0] as ConstPtr, - // tz: args[1] as ConstPtr, - // }, - // libc::SYS_mount => Syscall::Mount { - // dev_name: args[0] as ConstPtr, - // dir_name: args[1] as ConstPtr, - // ty: args[2] as ConstPtr, - // flags: args[3] as libc::c_ulong, - // data: args[4] as Ptr, - // }, - // 166 => Syscall::Umount2 { - // name: args[0] as ConstPtr, - // flags: args[1] as libc::c_int, - // }, // SYS_umount2 - // libc::SYS_swapon => Syscall::Swapon { - // specialfile: args[0] as ConstPtr, - // swap_flags: args[1] as libc::c_int, - // }, - // libc::SYS_swapoff => Syscall::Swapoff { - // specialfile: args[0] as ConstPtr, - // }, - // libc::SYS_reboot => Syscall::Reboot { - // magic1: args[0] as libc::c_int, - // magic2: args[1] as libc::c_int, - // cmd: args[2] as libc::c_uint, - // arg: args[3] as Ptr, - // }, - // libc::SYS_sethostname => Syscall::Sethostname { - // name: args[0] as ConstPtr, - // len: args[1] as libc::c_int, - // }, - // libc::SYS_setdomainname => Syscall::Setdomainname { - // name: args[0] as ConstPtr, - // len: args[1] as libc::c_int, - // }, - // libc::SYS_ioperm => Syscall::Ioperm { - // from: args[0] as libc::c_ulong, - // num: args[1] as libc::c_ulong, - // on: args[2] as libc::c_int, - // }, - // libc::SYS_init_module => Syscall::InitModule { - // umod: args[0] as Ptr, - // len: args[1] as libc::c_ulong, - // uargs: args[2] as ConstPtr, - // }, - // libc::SYS_delete_module => Syscall::DeleteModule { - // name_user: args[0] as ConstPtr, - // flags: args[1] as libc::c_uint, - // }, - // libc::SYS_quotactl => Syscall::Quotactl { - // cmd: args[0] as libc::c_uint, - // special: args[1] as ConstPtr, - // id: args[2] as libc::c_int, - // addr: args[3] as Ptr, - // }, - // libc::SYS_gettid => Syscall::Gettid, - // libc::SYS_readahead => Syscall::Readahead { - // fd: args[0] as libc::c_int, - // offset: args[1] as libc::loff_t, - // count: args[2] as libc::size_t, - // }, - // libc::SYS_setxattr => Syscall::Setxattr { - // path: args[0] as ConstPtr, - // name: args[1] as ConstPtr, - // value: args[2] as ConstPtr, - // size: args[3] as libc::size_t, - // flags: args[4] as libc::c_int, - // }, - // libc::SYS_lsetxattr => Syscall::Lsetxattr { - // path: args[0] as ConstPtr, - // name: args[1] as ConstPtr, - // value: args[2] as ConstPtr, - // size: args[3] as libc::size_t, - // flags: args[4] as libc::c_int, - // }, - // libc::SYS_fsetxattr => Syscall::Fsetxattr { - // fd: args[0] as libc::c_int, - // name: args[1] as ConstPtr, - // value: args[2] as ConstPtr, - // size: args[3] as libc::size_t, - // flags: args[4] as libc::c_int, - // }, - // libc::SYS_getxattr => Syscall::Getxattr { - // path: args[0] as ConstPtr, - // name: args[1] as ConstPtr, - // value: args[2] as Ptr, - // size: args[3] as libc::size_t, - // }, - // libc::SYS_lgetxattr => Syscall::Lgetxattr { - // path: args[0] as ConstPtr, - // name: args[1] as ConstPtr, - // value: args[2] as Ptr, - // size: args[3] as libc::size_t, - // }, - // libc::SYS_fgetxattr => Syscall::Fgetxattr { - // fd: args[0] as libc::c_int, - // name: args[1] as ConstPtr, - // value: args[2] as Ptr, - // size: args[3] as libc::size_t, - // }, - // libc::SYS_listxattr => Syscall::Listxattr { - // path: args[0] as ConstPtr, - // list: args[1] as Ptr, - // size: args[2] as libc::size_t, - // }, - // libc::SYS_llistxattr => Syscall::Llistxattr { - // path: args[0] as ConstPtr, - // list: args[1] as Ptr, - // size: args[2] as libc::size_t, - // }, - // libc::SYS_flistxattr => Syscall::Flistxattr { - // fd: args[0] as libc::c_int, - // list: args[1] as Ptr, - // size: args[2] as libc::size_t, - // }, - // libc::SYS_removexattr => Syscall::Removexattr { - // path: args[0] as ConstPtr, - // name: args[1] as ConstPtr, - // }, - // libc::SYS_lremovexattr => Syscall::Lremovexattr { - // path: args[0] as ConstPtr, - // name: args[1] as ConstPtr, - // }, - // libc::SYS_fremovexattr => Syscall::Fremovexattr { - // fd: args[0] as libc::c_int, - // name: args[1] as ConstPtr, - // }, - // libc::SYS_tkill => Syscall::Tkill { - // pid: args[0] as libc::pid_t, - // sig: args[1] as libc::c_int, - // }, - // libc::SYS_time => Syscall::Time { - // tloc: args[0] as Ptr, - // }, - // libc::SYS_futex => Syscall::Futex { - // uaddr: args[0] as Ptr, - // op: args[1] as libc::c_int, - // val: args[2] as u32, - // utime: args[3] as ConstPtr, - // uaddr2: args[4] as Ptr, - // val3: args[5] as u32, - // }, - // libc::SYS_sched_setaffinity => Syscall::SchedSetaffinity { - // pid: args[0] as libc::pid_t, - // len: args[1] as libc::c_uint, - // user_mask_ptr: args[2] as ConstPtr, - // }, - // libc::SYS_sched_getaffinity => Syscall::SchedGetaffinity { - // pid: args[0] as libc::pid_t, - // len: args[1] as libc::c_uint, - // user_mask_ptr: args[2] as Ptr, - // }, - // libc::SYS_io_setup => Syscall::IoSetup { - // nr_reqs: args[0] as libc::c_uint, - // ctx: args[1] as Ptr, - // }, - // libc::SYS_io_destroy => Syscall::IoDestroy { - // ctx: args[0] as Ptr, - // }, - // libc::SYS_io_getevents => Syscall::IoGetevents { - // ctx_id: args[0] as Ptr, - // min_nr: args[1] as libc::c_long, - // nr: args[2] as libc::c_long, - // events: args[3] as Ptr, - // timeout: args[4] as Ptr, - // }, - // libc::SYS_io_submit => Syscall::IoSubmit { - // ctx: args[0] as Ptr, - // nr: args[1] as libc::c_long, - // iocbpp: args[2] as Ptr>, - // }, - // libc::SYS_io_cancel => Syscall::IoCancel { - // ctx_id: args[0] as Ptr, - // iocb: args[1] as Ptr, - // result: args[2] as Ptr, - // }, - // libc::SYS_epoll_create => Syscall::EpollCreate { - // size: args[0] as libc::c_int, - // }, - // libc::SYS_remap_file_pages => Syscall::RemapFilePages { - // start: args[0] as libc::c_ulong, - // size: args[1] as libc::c_ulong, - // prot: args[2] as libc::c_ulong, - // pgoff: args[3] as libc::c_ulong, - // flags: args[4] as libc::c_ulong, - // }, - // libc::SYS_getdents64 => Syscall::Getdents64 { - // fd: args[0] as libc::c_uint, - // dirent: args[1] as Ptr, - // count: args[2] as libc::c_uint, - // }, - // libc::SYS_set_tid_address => Syscall::SetTidAddress { - // tidptr: args[0] as Ptr, - // }, - // libc::SYS_restart_syscall => Syscall::RestartSyscall, - // libc::SYS_semtimedop => Syscall::Semtimedop { - // semid: args[0] as libc::c_int, - // sops: args[1] as Ptr, - // nsops: args[2] as libc::c_uint, - // timeout: args[3] as ConstPtr, - // }, - // libc::SYS_fadvise64 => Syscall::Fadvise64 { - // fd: args[0] as libc::c_int, - // offset: args[1] as libc::loff_t, - // len: args[2] as libc::size_t, - // advice: args[3] as libc::c_int, - // }, - // libc::SYS_timer_create => Syscall::TimerCreate { - // which_clock: args[0] as libc::clockid_t, - // timer_event_spec: args[1] as Ptr, - // created_timer_id: args[2] as Ptr, - // }, - // libc::SYS_timer_settime => Syscall::TimerSettime { - // timer_id: args[0] as libc::timer_t, - // flags: args[1] as libc::c_int, - // new_setting: args[2] as ConstPtr, - // old_setting: args[3] as Ptr, - // }, - // libc::SYS_timer_gettime => Syscall::TimerGettime { - // timer_id: args[0] as libc::timer_t, - // setting: args[1] as Ptr, - // }, - // libc::SYS_timer_getoverrun => Syscall::TimerGetoverrun { - // timer_id: args[0] as libc::timer_t, - // }, - // libc::SYS_timer_delete => Syscall::TimerDelete { - // timer_id: args[0] as libc::timer_t, - // }, - // libc::SYS_clock_settime => Syscall::ClockSettime { - // which_clock: args[0] as libc::clockid_t, - // tp: args[1] as ConstPtr, - // }, - // libc::SYS_clock_gettime => Syscall::ClockGettime { - // which_clock: args[0] as libc::clockid_t, - // tp: args[1] as Ptr, - // }, - // libc::SYS_clock_getres => Syscall::ClockGetres { - // which_clock: args[0] as libc::clockid_t, - // tp: args[1] as Ptr, - // }, - // libc::SYS_clock_nanosleep => Syscall::ClockNanosleep { - // which_clock: args[0] as libc::clockid_t, - // flags: args[1] as libc::c_int, - // rqtp: args[2] as ConstPtr, - // rmtp: args[3] as Ptr, - // }, - // libc::SYS_exit_group => Syscall::ExitGroup { - // error_code: args[0] as libc::c_int, - // }, - // libc::SYS_epoll_wait => Syscall::EpollWait { - // epfd: args[0] as libc::c_int, - // events: args[1] as Ptr, - // maxevents: args[2] as libc::c_int, - // timeout: args[3] as libc::c_int, - // }, - // libc::SYS_epoll_ctl => Syscall::EpollCtl { - // epfd: args[0] as libc::c_int, - // op: args[1] as libc::c_int, - // fd: args[2] as libc::c_int, - // event: args[3] as Ptr, - // }, - // libc::SYS_tgkill => Syscall::Tgkill { - // tgid: args[0] as libc::pid_t, - // pid: args[1] as libc::pid_t, - // sig: args[2] as libc::c_int, - // }, - // libc::SYS_utimes => Syscall::Utimes { - // filename: args[0] as ConstPtr, - // utimes: args[1] as ConstPtr, - // }, - // libc::SYS_mbind => Syscall::Mbind { - // start: args[0] as libc::c_ulong, - // len: args[1] as libc::c_ulong, - // mode: args[2] as libc::c_ulong, - // nmask: args[3] as ConstPtr, - // maxnode: args[4] as libc::c_ulong, - // flags: args[5] as libc::c_uint, - // }, - // libc::SYS_set_mempolicy => Syscall::SetMempolicy { - // mode: args[0] as libc::c_int, - // nmask: args[1] as ConstPtr, - // maxnode: args[2] as libc::c_ulong, - // }, - // libc::SYS_get_mempolicy => Syscall::GetMempolicy { - // policy: args[0] as Ptr, - // nmask: args[1] as Ptr, - // maxnode: args[2] as libc::c_ulong, - // addr: args[3] as libc::c_ulong, - // flags: args[4] as libc::c_ulong, - // }, - // libc::SYS_mq_open => Syscall::MqOpen { - // name: args[0] as ConstPtr, - // oflag: args[1] as libc::c_int, - // mode: args[2] as libc::mode_t, - // attr: args[3] as Ptr, - // }, - // libc::SYS_mq_unlink => Syscall::MqUnlink { - // name: args[0] as ConstPtr, - // }, - // libc::SYS_mq_timedsend => Syscall::MqTimedsend { - // mqdes: args[0] as libc::mqd_t, - // msg_ptr: args[1] as ConstPtr, - // msg_len: args[2] as libc::size_t, - // msg_prio: args[3] as libc::c_uint, - // abs_timeout: args[4] as ConstPtr, - // }, - // libc::SYS_mq_timedreceive => Syscall::MqTimedreceive { - // mqdes: args[0] as libc::mqd_t, - // msg_ptr: args[1] as Ptr, - // msg_len: args[2] as libc::size_t, - // msg_prio: args[3] as Ptr, - // abs_timeout: args[4] as ConstPtr, - // }, - // libc::SYS_mq_notify => Syscall::MqNotify { - // mqdes: args[0] as libc::mqd_t, - // notification: args[1] as ConstPtr, - // }, - // libc::SYS_mq_getsetattr => Syscall::MqGetsetattr { - // mqdes: args[0] as libc::mqd_t, - // mqstat: args[1] as ConstPtr, - // omqstat: args[2] as Ptr, - // }, - // libc::SYS_kexec_load => Syscall::KexecLoad { - // entry: args[0] as libc::c_ulong, - // nr_segments: args[1] as libc::c_ulong, - // segments: args[2] as Ptr, - // flags: args[3] as libc::c_ulong, - // }, - // libc::SYS_waitid => Syscall::Waitid { - // which: args[0] as libc::c_int, - // pid: args[1] as libc::pid_t, - // infop: args[2] as Ptr, - // options: args[3] as libc::c_int, - // ru: args[4] as Ptr, - // }, - // libc::SYS_add_key => Syscall::AddKey { - // _type: args[0] as ConstPtr, - // _description: args[1] as ConstPtr, - // _payload: args[2] as ConstPtr, - // plen: args[3] as libc::size_t, - // destringid: args[4] as libc::key_t, - // }, - // libc::SYS_request_key => Syscall::RequestKey { - // _type: args[0] as ConstPtr, - // _description: args[1] as ConstPtr, - // _callout_info: args[2] as ConstPtr, - // destringid: args[3] as libc::key_t, - // }, - // libc::SYS_keyctl => Syscall::Keyctl { - // cmd: args[0] as libc::c_int, - // arg2: args[1] as libc::c_ulong, - // arg3: args[2] as libc::c_ulong, - // arg4: args[3] as libc::c_ulong, - // arg5: args[4] as libc::c_ulong, - // }, - // libc::SYS_ioprio_set => Syscall::IoprioSet { - // which: args[0] as libc::c_int, - // who: args[1] as libc::c_int, - // ioprio: args[2] as libc::c_int, - // }, - // libc::SYS_ioprio_get => Syscall::IoprioGet { - // which: args[0] as libc::c_int, - // who: args[1] as libc::c_int, - // }, - // libc::SYS_inotify_init => Syscall::InotifyInit, - // libc::SYS_inotify_add_watch => Syscall::InotifyAddWatch { - // fd: args[0] as libc::c_int, - // path: args[1] as ConstPtr, - // mask: args[2] as u32, - // }, - // libc::SYS_inotify_rm_watch => Syscall::InotifyRmWatch { - // fd: args[0] as libc::c_int, - // wd: args[1] as libc::c_int, - // }, - // libc::SYS_migrate_pages => Syscall::MigratePages { - // pid: args[0] as libc::pid_t, - // maxnode: args[1] as libc::c_ulong, - // from: args[2] as ConstPtr, - // to: args[3] as ConstPtr, - // }, - // libc::SYS_openat => Syscall::Openat { - // dfd: args[0] as libc::c_int, - // filename: args[1] as ConstPtr, - // flags: args[2] as libc::c_int, - // mode: args[3] as libc::mode_t, - // }, - // libc::SYS_mkdirat => Syscall::Mkdirat { - // dfd: args[0] as libc::c_int, - // pathname: args[1] as ConstPtr, - // mode: args[2] as libc::mode_t, - // }, - // libc::SYS_mknodat => Syscall::Mknodat { - // dfd: args[0] as libc::c_int, - // filename: args[1] as ConstPtr, - // mode: args[2] as libc::mode_t, - // dev: args[3] as libc::c_uint, - // }, - // libc::SYS_fchownat => Syscall::Fchownat { - // dfd: args[0] as libc::c_int, - // filename: args[1] as ConstPtr, - // user: args[2] as libc::uid_t, - // group: args[3] as libc::gid_t, - // flag: args[4] as libc::c_int, - // }, - // libc::SYS_futimesat => Syscall::Futimesat { - // dfd: args[0] as libc::c_int, - // filename: args[1] as ConstPtr, - // utimes: args[2] as ConstPtr, - // }, - // libc::SYS_newfstatat => Syscall::Newfstatat { - // dfd: args[0] as libc::c_int, - // filename: args[1] as ConstPtr, - // statbuf: args[2] as Ptr, - // flag: args[3] as libc::c_int, - // }, - // libc::SYS_unlinkat => Syscall::Unlinkat { - // dfd: args[0] as libc::c_int, - // pathname: args[1] as ConstPtr, - // flag: args[2] as libc::c_int, - // }, - // libc::SYS_renameat => Syscall::Renameat { - // olddfd: args[0] as libc::c_int, - // oldname: args[1] as ConstPtr, - // newdfd: args[2] as libc::c_int, - // newname: args[3] as ConstPtr, - // }, - // libc::SYS_linkat => Syscall::Linkat { - // olddfd: args[0] as libc::c_int, - // oldname: args[1] as ConstPtr, - // newdfd: args[2] as libc::c_int, - // newname: args[3] as ConstPtr, - // flags: args[4] as libc::c_int, - // }, - // libc::SYS_symlinkat => Syscall::Symlinkat { - // oldname: args[0] as ConstPtr, - // newdfd: args[1] as libc::c_int, - // newname: args[2] as ConstPtr, - // }, - // libc::SYS_readlinkat => Syscall::Readlinkat { - // dfd: args[0] as libc::c_int, - // path: args[1] as ConstPtr, - // buf: args[2] as Ptr, - // bufsiz: args[3] as libc::c_int, - // }, - // libc::SYS_fchmodat => Syscall::Fchmodat { - // dfd: args[0] as libc::c_int, - // filename: args[1] as ConstPtr, - // mode: args[2] as libc::mode_t, - // }, - // libc::SYS_faccessat => Syscall::Faccessat { - // dfd: args[0] as libc::c_int, - // filename: args[1] as ConstPtr, - // mode: args[2] as libc::c_int, - // }, - // libc::SYS_pselect6 => Syscall::Pselect6 { - // n: args[0] as libc::c_int, - // inp: args[1] as Ptr, - // outp: args[2] as Ptr, - // exp: args[3] as Ptr, - // tsp: args[4] as Ptr, - // sig: args[5] as Ptr, - // }, - // libc::SYS_ppoll => Syscall::Ppoll { - // fds: args[0] as Ptr, - // nfds: args[1] as libc::c_uint, - // tsp: args[2] as ConstPtr, - // sset: args[3] as ConstPtr, - // sigsetsize: args[4] as libc::size_t, - // }, - // libc::SYS_unshare => Syscall::Unshare { - // unshare_flags: args[0] as libc::c_ulong, - // }, - // libc::SYS_set_robust_list => Syscall::SetRobustList { - // head: args[0] as Ptr, - // len: args[1] as libc::size_t, - // }, - // libc::SYS_get_robust_list => Syscall::GetRobustList { - // pid: args[0] as libc::c_int, - // head_ptr: args[1] as Ptr>, - // len_ptr: args[2] as Ptr, - // }, - // libc::SYS_splice => Syscall::Splice { - // fd_in: args[0] as libc::c_int, - // off_in: args[1] as Ptr, - // fd_out: args[2] as libc::c_int, - // off_out: args[3] as Ptr, - // len: args[4] as libc::size_t, - // flags: args[5] as libc::c_uint, - // }, - // libc::SYS_tee => Syscall::Tee { - // fdin: args[0] as libc::c_int, - // fdout: args[1] as libc::c_int, - // len: args[2] as libc::size_t, - // flags: args[3] as libc::c_uint, - // }, - // libc::SYS_sync_file_range => Syscall::SyncFileRange { - // fd: args[0] as libc::c_int, - // offset: args[1] as libc::loff_t, - // nbytes: args[2] as libc::loff_t, - // flags: args[3] as libc::c_uint, - // }, - // libc::SYS_vmsplice => Syscall::Vmsplice { - // fd: args[0] as libc::c_int, - // iov: args[1] as ConstPtr, - // nr_segs: args[2] as libc::c_ulong, - // flags: args[3] as libc::c_uint, - // }, - // libc::SYS_move_pages => Syscall::MovePages { - // pid: args[0] as libc::pid_t, - // nr_pages: args[1] as libc::c_ulong, - // pages: args[2] as Ptr>, - // nodes: args[3] as ConstPtr, - // status: args[4] as Ptr, - // flags: args[5] as libc::c_int, - // }, - // libc::SYS_utimensat => Syscall::Utimensat { - // dfd: args[0] as libc::c_int, - // filename: args[1] as ConstPtr, - // utimes: args[2] as ConstPtr, - // flags: args[3] as libc::c_int, - // }, - // libc::SYS_epoll_pwait => Syscall::EpollPwait { - // epfd: args[0] as libc::c_int, - // events: args[1] as Ptr, - // maxevents: args[2] as libc::c_int, - // timeout: args[3] as libc::c_int, - // sigmask: args[4] as ConstPtr, - // sigsetsize: args[5] as libc::size_t, - // }, - // libc::SYS_signalfd => Syscall::Signalfd { - // ufd: args[0] as libc::c_int, - // user_mask: args[1] as Ptr, - // sizemask: args[2] as libc::size_t, - // }, - // libc::SYS_timerfd_create => Syscall::TimerfdCreate { - // clockid: args[0] as libc::c_int, - // flags: args[1] as libc::c_int, - // }, - // libc::SYS_eventfd => Syscall::Eventfd { - // count: args[0] as libc::c_uint, - // }, - // libc::SYS_fallocate => Syscall::Fallocate { - // fd: args[0] as libc::c_int, - // mode: args[1] as libc::c_int, - // offset: args[2] as libc::loff_t, - // len: args[3] as libc::loff_t, - // }, - // libc::SYS_timerfd_settime => Syscall::TimerfdSettime { - // ufd: args[0] as libc::c_int, - // flags: args[1] as libc::c_int, - // utmr: args[2] as ConstPtr, - // otmr: args[3] as Ptr, - // }, - // libc::SYS_timerfd_gettime => Syscall::TimerfdGettime { - // ufd: args[0] as libc::c_int, - // otmr: args[1] as Ptr, - // }, - // libc::SYS_accept4 => Syscall::Accept4 { - // fd: args[0] as libc::c_int, - // addr: args[1] as Ptr, - // len: args[2] as Ptr, - // flags: args[3] as libc::c_int, - // }, - // libc::SYS_signalfd4 => Syscall::Signalfd4 { - // ufd: args[0] as libc::c_int, - // user_mask: args[1] as Ptr, - // sizemask: args[2] as libc::size_t, - // flags: args[3] as libc::c_int, - // }, - // libc::SYS_eventfd2 => Syscall::Eventfd2 { - // count: args[0] as libc::c_uint, - // flags: args[1] as libc::c_int, - // }, - // libc::SYS_epoll_create1 => Syscall::EpollCreate1 { - // flags: args[0] as libc::c_int, - // }, - // libc::SYS_dup3 => Syscall::Dup3 { - // oldfd: args[0] as libc::c_uint, - // newfd: args[1] as libc::c_uint, - // flags: args[2] as libc::c_int, - // }, - // libc::SYS_pipe2 => Syscall::Pipe2 { - // fildes: args[0] as Ptr, - // flags: args[1] as libc::c_int, - // }, - // libc::SYS_inotify_init1 => Syscall::InotifyInit1 { - // flags: args[0] as libc::c_int, - // }, - // libc::SYS_preadv => Syscall::Preadv { - // fd: args[0] as libc::c_ulong, - // vec: args[1] as ConstPtr, - // vlen: args[2] as libc::c_ulong, - // pos_l: args[3] as libc::c_ulong, - // pos_h: args[4] as libc::c_ulong, - // }, - // libc::SYS_pwritev => Syscall::Pwritev { - // fd: args[0] as libc::c_ulong, - // vec: args[1] as ConstPtr, - // vlen: args[2] as libc::c_ulong, - // pos_l: args[3] as libc::c_ulong, - // pos_h: args[4] as libc::c_ulong, - // }, - // libc::SYS_rt_tgsigqueueinfo => Syscall::RtTgsigqueueinfo { - // tgid: args[0] as libc::pid_t, - // pid: args[1] as libc::pid_t, - // sig: args[2] as libc::c_int, - // uinfo: args[3] as Ptr, - // }, - // libc::SYS_perf_event_open => Syscall::PerfEventOpen { - // attr_uptr: args[0] as Ptr, - // pid: args[1] as libc::pid_t, - // cpu: args[2] as libc::c_int, - // group_fd: args[3] as libc::c_int, - // flags: args[4] as libc::c_ulong, - // }, - // libc::SYS_recvmmsg => Syscall::Recvmmsg { - // fd: args[0] as libc::c_int, - // msg: args[1] as Ptr, - // vlen: args[2] as libc::c_uint, - // flags: args[3] as libc::c_uint, - // timeout: args[4] as Ptr, - // }, - // libc::SYS_fanotify_init => Syscall::FanotifyInit { - // flags: args[0] as libc::c_uint, - // event_f_flags: args[1] as libc::c_uint, - // }, - // libc::SYS_fanotify_mark => Syscall::FanotifyMark { - // fanotify_fd: args[0] as libc::c_int, - // flags: args[1] as libc::c_uint, - // mask: args[2] as u64, - // fd: args[3] as libc::c_int, - // pathname: args[4] as ConstPtr, - // }, - // libc::SYS_prlimit64 => Syscall::Prlimit64 { - // pid: args[0] as libc::pid_t, - // resource: args[1] as libc::c_uint, - // new_rlim: args[2] as ConstPtr, - // old_rlim: args[3] as Ptr, - // }, - // libc::SYS_name_to_handle_at => Syscall::NameToHandleAt { - // dfd: args[0] as libc::c_int, - // name: args[1] as ConstPtr, - // handle: args[2] as Ptr, - // mnt_id: args[3] as Ptr, - // flag: args[4] as libc::c_int, - // }, - // libc::SYS_open_by_handle_at => Syscall::OpenByHandleAt { - // mountdirfd: args[0] as libc::c_int, - // handle: args[1] as Ptr, - // flags: args[2] as libc::c_int, - // }, - // libc::SYS_clock_adjtime => Syscall::ClockAdjtime { - // which_clock: args[0] as libc::clockid_t, - // tx: args[1] as Ptr, - // }, - // libc::SYS_syncfs => Syscall::Syncfs { - // fd: args[0] as libc::c_int, - // }, - // libc::SYS_sendmmsg => Syscall::Sendmmsg { - // fd: args[0] as libc::c_int, - // msg: args[1] as Ptr, - // vlen: args[2] as libc::c_uint, - // flags: args[3] as libc::c_uint, - // }, - // libc::SYS_setns => Syscall::Setns { - // fd: args[0] as libc::c_int, - // nstype: args[1] as libc::c_int, - // }, - // libc::SYS_getcpu => Syscall::Getcpu { - // cpu: args[0] as Ptr, - // node: args[1] as Ptr, - // cache: args[2] as Ptr, - // }, - // libc::SYS_process_vm_readv => Syscall::ProcessVmReadv { - // pid: args[0] as libc::pid_t, - // lvec: args[1] as ConstPtr, - // liovcnt: args[2] as libc::c_ulong, - // rvec: args[3] as ConstPtr, - // riovcnt: args[4] as libc::c_ulong, - // flags: args[5] as libc::c_ulong, - // }, - // libc::SYS_process_vm_writev => Syscall::ProcessVmWritev { - // pid: args[0] as libc::pid_t, - // lvec: args[1] as ConstPtr, - // liovcnt: args[2] as libc::c_ulong, - // rvec: args[3] as ConstPtr, - // riovcnt: args[4] as libc::c_ulong, - // flags: args[5] as libc::c_ulong, - // }, - // libc::SYS_kcmp => Syscall::Kcmp { - // pid1: args[0] as libc::pid_t, - // pid2: args[1] as libc::pid_t, - // ty: args[2] as libc::c_int, - // idx1: args[3] as libc::c_ulong, - // idx2: args[4] as libc::c_ulong, - // }, - // libc::SYS_finit_module => Syscall::FinitModule { - // fd: args[0] as libc::c_int, - // uargs: args[1] as ConstPtr, - // flags: args[2] as libc::c_int, - // }, - // libc::SYS_sched_setattr => Syscall::SchedSetattr { - // pid: args[0] as libc::pid_t, - // attr: args[1] as Ptr, - // flags: args[2] as libc::c_uint, - // }, - // libc::SYS_sched_getattr => Syscall::SchedGetattr { - // pid: args[0] as libc::pid_t, - // attr: args[1] as Ptr, - // size: args[2] as libc::c_uint, - // flags: args[3] as libc::c_uint, - // }, - // libc::SYS_renameat2 => Syscall::Renameat2 { - // olddfd: args[0] as libc::c_int, - // oldname: args[1] as ConstPtr, - // newdfd: args[2] as libc::c_int, - // newname: args[3] as ConstPtr, - // flags: args[4] as libc::c_uint, - // }, - // libc::SYS_seccomp => Syscall::Seccomp { - // op: args[0] as libc::c_uint, - // flags: args[1] as libc::c_uint, - // uargs: args[2] as Ptr, - // }, - // libc::SYS_getrandom => Syscall::Getrandom { - // buf: args[0] as Ptr, - // count: args[1] as libc::size_t, - // flags: args[2] as libc::c_uint, - // }, - // libc::SYS_memfd_create => Syscall::MemfdCreate { - // uname_ptr: args[0] as ConstPtr, - // flags: args[1] as libc::c_uint, - // }, - // libc::SYS_kexec_file_load => Syscall::KexecFileLoad { - // kernel_fd: args[0] as libc::c_int, - // initrd_fd: args[1] as libc::c_int, - // cmdline_len: args[2] as libc::c_ulong, - // cmdline_ptr: args[3] as ConstPtr, - // flags: args[4] as libc::c_ulong, - // }, - // libc::SYS_bpf => Syscall::Bpf { - // cmd: args[0] as libc::c_int, - // attr: args[1] as Ptr, - // size: args[2] as libc::c_uint, - // }, - // libc::SYS_execveat => Syscall::Execveat { - // dfd: args[0] as libc::c_int, - // filename: args[1] as ConstPtr, - // argv: args[2] as ConstPtr>, - // envp: args[3] as ConstPtr>, - // flags: args[4] as libc::c_int, - // }, - // libc::SYS_userfaultfd => Syscall::Userfaultfd { - // flags: args[0] as libc::c_int, - // }, - // libc::SYS_membarrier => Syscall::Membarrier { - // cmd: args[0] as libc::c_int, - // flags: args[1] as libc::c_uint, - // }, - // libc::SYS_mlock2 => Syscall::Mlock2 { - // start: args[0] as libc::c_ulong, - // len: args[1] as libc::size_t, - // flags: args[2] as libc::c_int, - // }, - // libc::SYS_copy_file_range => Syscall::CopyFileRange { - // fd_in: args[0] as libc::c_int, - // off_in: args[1] as Ptr, - // fd_out: args[2] as libc::c_int, - // off_out: args[3] as Ptr, - // len: args[4] as libc::size_t, - // flags: args[5] as libc::c_uint, - // }, - // libc::SYS_preadv2 => Syscall::Preadv2 { - // fd: args[0] as libc::c_ulong, - // vec: args[1] as ConstPtr, - // vlen: args[2] as libc::c_ulong, - // pos_l: args[3] as libc::c_ulong, - // pos_h: args[4] as libc::c_ulong, - // flags: args[5] as libc::c_int, - // }, - // libc::SYS_pwritev2 => Syscall::Pwritev2 { - // fd: args[0] as libc::c_ulong, - // vec: args[1] as ConstPtr, - // vlen: args[2] as libc::c_ulong, - // pos_l: args[3] as libc::c_ulong, - // pos_h: args[4] as libc::c_ulong, - // flags: args[5] as libc::c_int, - // }, - // libc::SYS_pkey_mprotect => Syscall::PkeyMprotect { - // start: args[0] as libc::c_ulong, - // len: args[1] as libc::size_t, - // prot: args[2] as libc::c_ulong, - // pkey: args[3] as libc::c_int, - // }, - // libc::SYS_pkey_alloc => Syscall::PkeyAlloc { - // flags: args[0] as libc::c_ulong, - // init_val: args[1] as libc::c_ulong, - // }, - // libc::SYS_pkey_free => Syscall::PkeyFree { - // pkey: args[0] as libc::c_int, - // }, - // libc::SYS_statx => Syscall::Statx { - // dfd: args[0] as libc::c_int, - // path: args[1] as ConstPtr, - // flags: args[2] as libc::c_uint, - // mask: args[3] as libc::c_uint, - // buffer: args[4] as Ptr, - // }, - // libc::SYS_rseq => Syscall::Rseq { - // rseq: args[0] as Ptr, - // rseq_len: args[1] as u32, - // flags: args[2] as libc::c_int, - // sig: args[3] as u32, - // }, - // libc::SYS_pidfd_send_signal => Syscall::PidfdSendSignal { - // pidfd: args[0] as libc::c_int, - // sig: args[1] as libc::c_int, - // info: args[2] as Ptr, - // flags: args[3] as libc::c_uint, - // }, - // libc::SYS_io_uring_setup => Syscall::IoUringSetup { - // entries: args[0] as u32, - // p: args[1] as Ptr, - // }, - // libc::SYS_io_uring_enter => Syscall::IoUringEnter { - // fd: args[0] as libc::c_uint, - // to_submit: args[1] as u32, - // min_complete: args[2] as u32, - // flags: args[3] as u32, - // argp: args[4] as ConstPtr, - // argsz: args[5] as libc::size_t, - // }, - // libc::SYS_io_uring_register => Syscall::IoUringRegister { - // fd: args[0] as libc::c_uint, - // op: args[1] as libc::c_uint, - // arg: args[2] as Ptr, - // nr_args: args[3] as libc::c_uint, - // }, - // libc::SYS_open_tree => Syscall::OpenTree { - // dfd: args[0] as libc::c_int, - // path: args[1] as ConstPtr, - // flags: args[2] as libc::c_uint, - // }, - // libc::SYS_move_mount => Syscall::MoveMount { - // from_dfd: args[0] as libc::c_int, - // from_path: args[1] as ConstPtr, - // to_dfd: args[2] as libc::c_int, - // to_path: args[3] as ConstPtr, - // ms_flags: args[4] as libc::c_uint, - // }, - // libc::SYS_fsopen => Syscall::Fsopen { - // fs_name: args[0] as ConstPtr, - // flags: args[1] as libc::c_uint, - // }, - // libc::SYS_fsconfig => Syscall::Fsconfig { - // fs_fd: args[0] as libc::c_int, - // cmd: args[1] as libc::c_uint, - // key: args[2] as ConstPtr, - // value: args[3] as ConstPtr, - // aux: args[4] as libc::c_int, - // }, - // libc::SYS_fsmount => Syscall::Fsmount { - // fs_fd: args[0] as libc::c_int, - // flags: args[1] as libc::c_uint, - // ms_flags: args[2] as libc::c_uint, - // }, - // libc::SYS_fspick => Syscall::Fspick { - // dfd: args[0] as libc::c_int, - // path: args[1] as ConstPtr, - // flags: args[2] as libc::c_uint, - // }, - // libc::SYS_pidfd_open => Syscall::PidfdOpen { - // pid: args[0] as libc::pid_t, - // flags: args[1] as libc::c_uint, - // }, - // libc::SYS_clone3 => Syscall::Clone3 { - // uargs: args[0] as Ptr, - // size: args[1] as libc::size_t, - // }, - // libc::SYS_close_range => Syscall::CloseRange { - // fd: args[0] as libc::c_uint, - // max_fd: args[1] as libc::c_uint, - // flags: args[2] as libc::c_uint, - // }, - // libc::SYS_openat2 => Syscall::Openat2 { - // dfd: args[0] as libc::c_int, - // filename: args[1] as ConstPtr, - // how: args[2] as Ptr, - // size: args[3] as libc::size_t, - // }, - // libc::SYS_pidfd_getfd => Syscall::PidfdGetfd { - // pidfd: args[0] as libc::c_int, - // fd: args[1] as libc::c_int, - // flags: args[2] as libc::c_uint, - // }, - // libc::SYS_faccessat2 => Syscall::Faccessat2 { - // dfd: args[0] as libc::c_int, - // filename: args[1] as ConstPtr, - // mode: args[2] as libc::c_int, - // flags: args[3] as libc::c_int, - // }, - // libc::SYS_process_madvise => Syscall::ProcessMadvise { - // pidfd: args[0] as libc::c_int, - // vec: args[1] as ConstPtr, - // vlen: args[2] as libc::size_t, - // behavior: args[3] as libc::c_int, - // flags: args[4] as libc::c_uint, - // }, - // libc::SYS_epoll_pwait2 => Syscall::EpollPwait2 { - // epfd: args[0] as libc::c_int, - // events: args[1] as Ptr, - // maxevents: args[2] as libc::c_int, - // timeout: args[3] as ConstPtr, - // sigmask: args[4] as ConstPtr, - // sigsetsize: args[5] as libc::size_t, - // }, - // libc::SYS_mount_setattr => Syscall::MountSetattr { - // dfd: args[0] as libc::c_int, - // path: args[1] as ConstPtr, - // flags: args[2] as libc::c_uint, - // uattr: args[3] as Ptr, - // usize: args[4] as libc::size_t, - // }, - // libc::SYS_quotactl_fd => Syscall::QuotactlFd { - // fd: args[0] as libc::c_uint, - // cmd: args[1] as libc::c_uint, - // id: args[2] as libc::c_int, - // addr: args[3] as Ptr, - // }, - // libc::SYS_landlock_create_ruleset => Syscall::LandlockCreateRuleset { - // attr: args[0] as ConstPtr, - // size: args[1] as libc::size_t, - // flags: args[2] as u32, - // }, - // libc::SYS_landlock_add_rule => Syscall::LandlockAddRule { - // ruleset_fd: args[0] as libc::c_int, - // rule_type: args[1] as libc::c_int, - // rule_attr: args[2] as ConstPtr, - // flags: args[3] as u32, - // }, - // libc::SYS_landlock_restrict_self => Syscall::LandlockRestrictSelf { - // ruleset_fd: args[0] as libc::c_int, - // flags: args[1] as u32, - // }, - // libc::SYS_memfd_secret => Syscall::MemfdSecret { - // flags: args[0] as libc::c_uint, - // }, - // libc::SYS_process_mrelease => Syscall::ProcessMrelease { - // pidfd: args[0] as libc::c_int, - // flags: args[1] as libc::c_uint, - // }, - // libc::SYS_futex_waitv => Syscall::FutexWaitv { - // waiters: args[0] as Ptr, - // nr_futexes: args[1] as libc::c_uint, - // flags: args[2] as libc::c_uint, - // timeout: args[3] as Ptr, - // clockid: args[4] as libc::clockid_t, - // }, - // libc::SYS_set_mempolicy_home_node => Syscall::SetMempolicyHomeNode { - // start: args[0] as libc::c_ulong, - // len: args[1] as libc::c_ulong, - // home_node: args[2] as libc::c_ulong, - // flags: args[3] as libc::c_ulong, - // }, - // // Add other syscalls here... - // _ => return Err("Unknown or unimplemented syscall number."), - // }; - // Ok(s) - } -} diff --git a/syscall_lib/src/kern_buffers.rs b/syscall_lib/src/kern_buffers.rs deleted file mode 100644 index 6bd5c7b..0000000 --- a/syscall_lib/src/kern_buffers.rs +++ /dev/null @@ -1,33 +0,0 @@ -// #[cfg(target_os = "linux")] -// use nix::sys::ptrace; -// #[cfg(target_os = "linux")] -// use nix::unistd::Pid; - -// #[cfg(target_os = "linux")] -// fn read_buffer_with_ptrace( -// pid: i32, -// addr: usize, -// count: usize, -// ) -> Result, Box> { -// let pid = Pid::from_raw(pid); -// let mut buffer = Vec::with_capacity(count); - -// // ptrace reads in word-sized chunks (usually 8 bytes on 64-bit systems) -// let word_size = std::mem::size_of::(); -// let mut current_addr = addr; -// let mut bytes_read = 0; - -// while bytes_read < count { -// let word = ptrace::read(pid, current_addr as ptrace::AddressType)?; -// let word_bytes = word.to_ne_bytes(); - -// let bytes_to_copy = std::cmp::min(word_size, count - bytes_read); -// buffer.extend_from_slice(&word_bytes[..bytes_to_copy]); - -// current_addr += word_size; -// bytes_read += bytes_to_copy; -// } - -// buffer.truncate(count); -// Ok(buffer) -// } diff --git a/syscall_lib/src/lib.rs b/syscall_lib/src/lib.rs index 437503f..ca07bcd 100644 --- a/syscall_lib/src/lib.rs +++ b/syscall_lib/src/lib.rs @@ -1,9 +1,6 @@ -mod create_syscall; -mod kern_buffers; +mod arch_types; mod proxy_list; mod syscall; -mod syscall_exec; -mod syscall_num; mod types; const CONFIG: bincode::config::Configuration = bincode::config::standard(); @@ -17,8 +14,6 @@ use std::{ use bincode::{Decode, Encode}; pub use syscall::Syscall; -pub use syscall_exec::execute_syscall; -pub use syscall_num::Sysno; pub use types::*; // Type aliases for pointers to improve readability. @@ -27,78 +22,6 @@ pub use types::*; // pub type Ptr = T; // pub type ConstPtr = T; -// Placeholder structs for kernel-specific types not present in libc. -// These are defined as opaque types for correct type checking in the enum. -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct AioContext; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct Iocb; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct IoEvent; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct IoUringParams; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct Mmsghdr; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct GetcpuCache; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct RobustListHead; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct FutexWaitv; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct KexecSegment; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct CapUserHeaderT; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct CapUserDataT; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct Rlimit64; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct FileHandle; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct PerfEventAttr; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct SchedAttr; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct CloneArgs; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct BpfAttr; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct Statx; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct Rseq; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct OpenHow; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct MountAttr; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct LandlockRulesetAttr; -// #[repr(C)] -// #[derive(Debug, Clone, Copy)] -// pub struct LandlockRule; - #[derive(Debug, PartialEq, Eq, Encode, Decode)] pub enum Message { RequestMemory(isize), // Request a memory object at a specific address diff --git a/syscall_lib/src/proxy_list.rs b/syscall_lib/src/proxy_list.rs index a03ff9a..ea351cc 100644 --- a/syscall_lib/src/proxy_list.rs +++ b/syscall_lib/src/proxy_list.rs @@ -1,4 +1,4 @@ -use crate::{Syscall, syscall_num::Sysno}; +// use crate::{Syscall, syscall_num::Sysno}; // pub fn syscall_should_proxy(syscall: &Syscall) -> bool { // match syscall { diff --git a/syscall_lib/src/syscall.rs b/syscall_lib/src/syscall.rs deleted file mode 100644 index 66ebcc7..0000000 --- a/syscall_lib/src/syscall.rs +++ /dev/null @@ -1,1705 +0,0 @@ -use bincode::{Decode, Encode}; -use core::fmt::Debug; -use std::mem::transmute; - -use crate::{Buf, BufferLocation, Ptr}; - -// pub type c_uint = libc::c_long; -// pub type c_void = libc::c_long; -// pub type size_t = libc::c_long; -// pub type mode_t = libc::c_long; -// pub type c_char = libc::c_long; -// pub type c_int = libc::c_long; -// pub type off = libc::c_long; -// pub type off_t = libc::c_long; -// pub type stat = libc::c_long; -// pub type pid_t = libc::c_long; -// pub type gid_t = libc::c_long; -// pub type sigaction = libc::c_long; -// pub type sigset_t = libc::c_long; -// pub type iovec = libc::c_long; -// pub type c_long = libc::c_long; -// pub type c_ulong = libc::c_long; - -/// Represents all possible x86_64 system calls and their arguments. -// #[derive(Debug, PartialEq, Eq, Encode, Decode, Clone, Copy)] -#[derive(Encode, Decode, Debug)] -pub enum Syscall { - Read { - fd: libc::c_int, - buf: Buf>, - count: libc::size_t, - }, - Write { - fd: libc::c_int, - buf: Buf>, - count: libc::size_t, - }, - Unimplemented, - /* - Open { - path: ConstPtr, - flags: libc::c_int, - mode: libc::mode_t, - }, - Close { - fd: libc::c_uint, - }, - Stat { - path: ConstPtr, - statbuf: Ptr, - }, - Fstat { - fd: libc::c_uint, - statbuf: Ptr, - }, - Lstat { - path: ConstPtr, - statbuf: Ptr, - }, - Poll { - fds: Ptr, - nfds: libc::c_uint, - timeout: libc::c_int, - }, - Lseek { - fd: libc::c_uint, - offset: libc::off_t, - whence: libc::c_uint, - }, - Mmap { - addr: Ptr, - len: libc::size_t, - prot: libc::c_int, - flags: libc::c_int, - fd: libc::c_int, - offset: libc::off_t, - }, - Mprotect { - addr: Ptr, - len: libc::size_t, - prot: libc::c_int, - }, - Munmap { - addr: Ptr, - len: libc::size_t, - }, - Brk { - addr: Ptr, - }, - RtSigaction { - sig: libc::c_int, - act: ConstPtr, - oldact: Ptr, - sigsetsize: libc::size_t, - }, - RtSigprocmask { - how: libc::c_int, - set: Ptr, - oldset: Ptr, - sigsetsize: libc::size_t, - }, - RtSigreturn, - Ioctl { - fd: libc::c_uint, - cmd: libc::c_ulong, - arg: libc::c_ulong, - }, - Pread64 { - fd: libc::c_uint, - buf: Ptr, - count: libc::size_t, - pos: libc::loff_t, - }, - Pwrite64 { - fd: libc::c_uint, - buf: ConstPtr, - count: libc::size_t, - pos: libc::loff_t, - }, - Readv { - fd: libc::c_ulong, - vec: ConstPtr, - vlen: libc::c_ulong, - }, - Writev { - fd: libc::c_ulong, - vec: ConstPtr, - vlen: libc::c_ulong, - }, - Access { - filename: ConstPtr, - mode: libc::c_int, - }, - Pipe { - fildes: Ptr, - }, - Select { - n: libc::c_int, - inp: Ptr, - outp: Ptr, - exp: Ptr, - tvp: Ptr, - }, - SchedYield, - Mremap { - old_addr: Ptr, - old_size: libc::size_t, - new_size: libc::size_t, - flags: libc::c_int, - new_addr: Ptr, - }, - Msync { - start: Ptr, - len: libc::size_t, - flags: libc::c_int, - }, - Mincore { - start: Ptr, - len: libc::size_t, - vec: Ptr, - }, - Madvise { - start: Ptr, - len: libc::size_t, - behavior: libc::c_int, - }, - Shmget { - key: libc::key_t, - size: libc::size_t, - shmflg: libc::c_int, - }, - Shmat { - shmid: libc::c_int, - shmaddr: ConstPtr, - shmflg: libc::c_int, - }, - Shmctl { - shmid: libc::c_int, - cmd: libc::c_int, - buf: Ptr, - }, - Dup { - fildes: libc::c_uint, - }, - Dup2 { - oldfd: libc::c_uint, - newfd: libc::c_uint, - }, - Pause, - Nanosleep { - rqtp: ConstPtr, - rmtp: Ptr, - }, - Getitimer { - which: libc::c_int, - value: Ptr, - }, - Alarm { - seconds: libc::c_uint, - }, - Setitimer { - which: libc::c_int, - value: ConstPtr, - ovalue: Ptr, - }, - Getpid, - Sendfile { - out_fd: libc::c_int, - in_fd: libc::c_int, - offset: Ptr, - count: libc::size_t, - }, - Socket { - domain: libc::c_int, - ty: libc::c_int, - protocol: libc::c_int, - }, - Connect { - fd: libc::c_int, - addr: ConstPtr, - len: libc::socklen_t, - }, - Accept { - fd: libc::c_int, - addr: Ptr, - len: Ptr, - }, - Sendto { - fd: libc::c_int, - buf: ConstPtr, - len: libc::size_t, - flags: libc::c_int, - addr: ConstPtr, - addr_len: libc::socklen_t, - }, - Recvfrom { - fd: libc::c_int, - buf: Ptr, - len: libc::size_t, - flags: libc::c_int, - addr: Ptr, - addr_len: Ptr, - }, - Sendmsg { - fd: libc::c_int, - msg: ConstPtr, - flags: libc::c_int, - }, - Recvmsg { - fd: libc::c_int, - msg: Ptr, - flags: libc::c_int, - }, - Shutdown { - fd: libc::c_int, - how: libc::c_int, - }, - Bind { - fd: libc::c_int, - addr: ConstPtr, - len: libc::socklen_t, - }, - Listen { - fd: libc::c_int, - backlog: libc::c_int, - }, - Getsockname { - fd: libc::c_int, - addr: Ptr, - len: Ptr, - }, - Getpeername { - fd: libc::c_int, - addr: Ptr, - len: Ptr, - }, - Socketpair { - domain: libc::c_int, - ty: libc::c_int, - protocol: libc::c_int, - fds: Ptr, - }, - Setsockopt { - fd: libc::c_int, - level: libc::c_int, - optname: libc::c_int, - optval: ConstPtr, - optlen: libc::socklen_t, - }, - Getsockopt { - fd: libc::c_int, - level: libc::c_int, - optname: libc::c_int, - optval: Ptr, - optlen: Ptr, - }, - Clone { - flags: libc::c_ulong, - stack: Ptr, - parent_tid: Ptr, - child_tid: Ptr, - tls: libc::c_ulong, - }, - Fork, - Vfork, - Execve { - filename: ConstPtr, - argv: ConstPtr>, - envp: ConstPtr>, - }, - Exit { - error_code: libc::c_int, - }, - Wait4 { - pid: libc::pid_t, - stat_addr: Ptr, - options: libc::c_int, - ru: Ptr, - }, - Kill { - pid: libc::pid_t, - sig: libc::c_int, - }, - Uname { - name: Ptr, - }, - Semget { - key: libc::key_t, - nsems: libc::c_int, - semflg: libc::c_int, - }, - Semop { - semid: libc::c_int, - sops: Ptr, - nsops: libc::size_t, - }, - Semctl { - semid: libc::c_int, - semnum: libc::c_int, - cmd: libc::c_int, - arg: libc::c_ulong, - }, - Shmdt { - shmaddr: ConstPtr, - }, - Msgget { - key: libc::key_t, - msgflg: libc::c_int, - }, - Msgsnd { - msqid: libc::c_int, - msgp: ConstPtr, - msgsz: libc::size_t, - msgflg: libc::c_int, - }, - Msgrcv { - msqid: libc::c_int, - msgp: Ptr, - msgsz: libc::size_t, - msgtyp: libc::c_long, - msgflg: libc::c_int, - }, - Msgctl { - msqid: libc::c_int, - cmd: libc::c_int, - buf: Ptr, - }, - Fcntl { - fd: libc::c_uint, - cmd: libc::c_uint, - arg: libc::c_ulong, - }, - Flock { - fd: libc::c_uint, - cmd: libc::c_uint, - }, - Fsync { - fd: libc::c_uint, - }, - Fdatasync { - fd: libc::c_uint, - }, - Truncate { - path: ConstPtr, - length: libc::c_long, - }, - Ftruncate { - fd: libc::c_uint, - length: libc::c_long, - }, - Getdents { - fd: libc::c_uint, - dirent: Ptr, - count: libc::c_uint, - }, - Getcwd { - buf: Ptr, - size: libc::c_ulong, - }, - Chdir { - filename: ConstPtr, - }, - Fchdir { - fd: libc::c_uint, - }, - Rename { - oldname: ConstPtr, - newname: ConstPtr, - }, - Mkdir { - pathname: ConstPtr, - mode: libc::mode_t, - }, - Rmdir { - pathname: ConstPtr, - }, - Creat { - pathname: ConstPtr, - mode: libc::mode_t, - }, - Link { - oldname: ConstPtr, - newname: ConstPtr, - }, - Unlink { - pathname: ConstPtr, - }, - Symlink { - old: ConstPtr, - new: ConstPtr, - }, - Readlink { - path: ConstPtr, - buf: Ptr, - bufsiz: libc::c_int, - }, - Chmod { - filename: ConstPtr, - mode: libc::mode_t, - }, - Fchmod { - fd: libc::c_uint, - mode: libc::mode_t, - }, - Chown { - filename: ConstPtr, - user: libc::uid_t, - group: libc::gid_t, - }, - Fchown { - fd: libc::c_uint, - user: libc::uid_t, - group: libc::gid_t, - }, - Lchown { - filename: ConstPtr, - user: libc::uid_t, - group: libc::gid_t, - }, - Umask { - mask: libc::c_int, - }, - Gettimeofday { - tv: Ptr, - tz: Ptr, - }, - Getrlimit { - resource: libc::c_int, - rlim: Ptr, - }, - Getrusage { - who: libc::c_int, - ru: Ptr, - }, - Sysinfo { - info: Ptr, - }, - Times { - tbuf: Ptr, - }, - Ptrace { - request: libc::c_long, - pid: libc::c_long, - addr: libc::c_ulong, - data: libc::c_ulong, - }, - Getuid, - Syslog { - ty: libc::c_int, - buf: Ptr, - len: libc::c_int, - }, - Getgid, - Setuid { - uid: libc::uid_t, - }, - Setgid { - gid: libc::gid_t, - }, - Geteuid, - Getegid, - Setpgid { - pid: libc::pid_t, - pgid: libc::pid_t, - }, - Getppid, - Getpgrp, - Setsid, - Setreuid { - ruid: libc::uid_t, - euid: libc::uid_t, - }, - Setregid { - rgid: libc::gid_t, - egid: libc::gid_t, - }, - Getgroups { - gidsetsize: libc::c_int, - grouplist: Ptr, - }, - Setgroups { - gidsetsize: libc::c_int, - grouplist: ConstPtr, - }, - Setresuid { - ruid: libc::uid_t, - euid: libc::uid_t, - suid: libc::uid_t, - }, - Getresuid { - ruid: Ptr, - euid: Ptr, - suid: Ptr, - }, - Setresgid { - rgid: libc::gid_t, - egid: libc::gid_t, - sgid: libc::gid_t, - }, - Getresgid { - rgid: Ptr, - egid: Ptr, - sgid: Ptr, - }, - Getpgid { - pid: libc::pid_t, - }, - Setfsuid { - uid: libc::uid_t, - }, - Setfsgid { - gid: libc::gid_t, - }, - Getsid { - pid: libc::pid_t, - }, - Capget { - header: Ptr, - dataptr: Ptr, - }, - Capset { - header: Ptr, - data: ConstPtr, - }, - RtSigpending { - set: Ptr, - sigsetsize: libc::size_t, - }, - RtSigtimedwait { - uthese: ConstPtr, - uinfo: Ptr, - uts: ConstPtr, - sigsetsize: libc::size_t, - }, - RtSigqueueinfo { - pid: libc::pid_t, - sig: libc::c_int, - uinfo: Ptr, - }, - RtSigsuspend { - unewset: Ptr, - sigsetsize: libc::size_t, - }, - Sigaltstack { - uss: ConstPtr, - uoss: Ptr, - }, - Utime { - filename: ConstPtr, - times: Ptr, - }, - Mknod { - filename: ConstPtr, - mode: libc::mode_t, - dev: libc::c_uint, - }, - Uselib { - library: ConstPtr, - }, - Personality { - personality: libc::c_uint, - }, - Ustat { - dev: libc::c_uint, - ubuf: Ptr, - }, - Statfs { - path: ConstPtr, - buf: Ptr, - }, - Fstatfs { - fd: libc::c_uint, - buf: Ptr, - }, - Sysfs { - option: libc::c_int, - arg1: libc::c_ulong, - arg2: libc::c_ulong, - }, - Getpriority { - which: libc::c_int, - who: libc::c_int, - }, - Setpriority { - which: libc::c_int, - who: libc::c_int, - niceval: libc::c_int, - }, - SchedSetparam { - pid: libc::pid_t, - param: ConstPtr, - }, - SchedGetparam { - pid: libc::pid_t, - param: Ptr, - }, - SchedSetscheduler { - pid: libc::pid_t, - policy: libc::c_int, - param: ConstPtr, - }, - SchedGetscheduler { - pid: libc::pid_t, - }, - SchedGetPriorityMax { - policy: libc::c_int, - }, - SchedGetPriorityMin { - policy: libc::c_int, - }, - SchedRrGetInterval { - pid: libc::pid_t, - interval: Ptr, - }, - Mlock { - start: libc::c_ulong, - len: libc::size_t, - }, - Munlock { - start: libc::c_ulong, - len: libc::size_t, - }, - Mlockall { - flags: libc::c_int, - }, - Munlockall, - Vhangup, - PivotRoot { - new_root: ConstPtr, - put_old: ConstPtr, - }, - Prctl { - option: libc::c_int, - arg2: libc::c_ulong, - arg3: libc::c_ulong, - arg4: libc::c_ulong, - arg5: libc::c_ulong, - }, - Adjtimex { - txc_p: Ptr, - }, - Setrlimit { - resource: libc::c_uint, - rlim: ConstPtr, - }, - Chroot { - filename: ConstPtr, - }, - Sync, - Acct { - name: ConstPtr, - }, - Settimeofday { - tv: ConstPtr, - tz: ConstPtr, - }, - Mount { - dev_name: ConstPtr, - dir_name: ConstPtr, - ty: ConstPtr, - flags: libc::c_ulong, - data: Ptr, - }, - Umount2 { - name: ConstPtr, - flags: libc::c_int, - }, - Swapon { - specialfile: ConstPtr, - swap_flags: libc::c_int, - }, - Swapoff { - specialfile: ConstPtr, - }, - Reboot { - magic1: libc::c_int, - magic2: libc::c_int, - cmd: libc::c_uint, - arg: Ptr, - }, - Sethostname { - name: ConstPtr, - len: libc::c_int, - }, - Setdomainname { - name: ConstPtr, - len: libc::c_int, - }, - Ioperm { - from: libc::c_ulong, - num: libc::c_ulong, - on: libc::c_int, - }, - InitModule { - umod: Ptr, - len: libc::c_ulong, - uargs: ConstPtr, - }, - DeleteModule { - name_user: ConstPtr, - flags: libc::c_uint, - }, - Quotactl { - cmd: libc::c_uint, - special: ConstPtr, - id: libc::c_int, - addr: Ptr, - }, - Gettid, - Readahead { - fd: libc::c_int, - offset: libc::loff_t, - count: libc::size_t, - }, - Setxattr { - path: ConstPtr, - name: ConstPtr, - value: ConstPtr, - size: libc::size_t, - flags: libc::c_int, - }, - Lsetxattr { - path: ConstPtr, - name: ConstPtr, - value: ConstPtr, - size: libc::size_t, - flags: libc::c_int, - }, - Fsetxattr { - fd: libc::c_int, - name: ConstPtr, - value: ConstPtr, - size: libc::size_t, - flags: libc::c_int, - }, - Getxattr { - path: ConstPtr, - name: ConstPtr, - value: Ptr, - size: libc::size_t, - }, - Lgetxattr { - path: ConstPtr, - name: ConstPtr, - value: Ptr, - size: libc::size_t, - }, - Fgetxattr { - fd: libc::c_int, - name: ConstPtr, - value: Ptr, - size: libc::size_t, - }, - Listxattr { - path: ConstPtr, - list: Ptr, - size: libc::size_t, - }, - Llistxattr { - path: ConstPtr, - list: Ptr, - size: libc::size_t, - }, - Flistxattr { - fd: libc::c_int, - list: Ptr, - size: libc::size_t, - }, - Removexattr { - path: ConstPtr, - name: ConstPtr, - }, - Lremovexattr { - path: ConstPtr, - name: ConstPtr, - }, - Fremovexattr { - fd: libc::c_int, - name: ConstPtr, - }, - Tkill { - pid: libc::pid_t, - sig: libc::c_int, - }, - Time { - tloc: Ptr, - }, - Futex { - uaddr: Ptr, - op: libc::c_int, - val: u32, - utime: ConstPtr, - uaddr2: Ptr, - val3: u32, - }, - SchedSetaffinity { - pid: libc::pid_t, - len: libc::c_uint, - user_mask_ptr: ConstPtr, - }, - SchedGetaffinity { - pid: libc::pid_t, - len: libc::c_uint, - user_mask_ptr: Ptr, - }, - IoSetup { - nr_reqs: libc::c_uint, - ctx: Ptr, - }, - IoDestroy { - ctx: Ptr, - }, - IoGetevents { - ctx_id: Ptr, - min_nr: libc::c_long, - nr: libc::c_long, - events: Ptr, - timeout: Ptr, - }, - IoSubmit { - ctx: Ptr, - nr: libc::c_long, - iocbpp: Ptr>, - }, - IoCancel { - ctx_id: Ptr, - iocb: Ptr, - result: Ptr, - }, - EpollCreate { - size: libc::c_int, - }, - RemapFilePages { - start: libc::c_ulong, - size: libc::c_ulong, - prot: libc::c_ulong, - pgoff: libc::c_ulong, - flags: libc::c_ulong, - }, - Getdents64 { - fd: libc::c_uint, - dirent: Ptr, - count: libc::c_uint, - }, - SetTidAddress { - tidptr: Ptr, - }, - RestartSyscall, - Semtimedop { - semid: libc::c_int, - sops: Ptr, - nsops: libc::c_uint, - timeout: ConstPtr, - }, - Fadvise64 { - fd: libc::c_int, - offset: libc::loff_t, - len: libc::size_t, - advice: libc::c_int, - }, - TimerCreate { - which_clock: libc::clockid_t, - timer_event_spec: Ptr, - created_timer_id: Ptr, - }, - TimerSettime { - timer_id: libc::timer_t, - flags: libc::c_int, - new_setting: ConstPtr, - old_setting: Ptr, - }, - TimerGettime { - timer_id: libc::timer_t, - setting: Ptr, - }, - TimerGetoverrun { - timer_id: libc::timer_t, - }, - TimerDelete { - timer_id: libc::timer_t, - }, - ClockSettime { - which_clock: libc::clockid_t, - tp: ConstPtr, - }, - ClockGettime { - which_clock: libc::clockid_t, - tp: Ptr, - }, - ClockGetres { - which_clock: libc::clockid_t, - tp: Ptr, - }, - ClockNanosleep { - which_clock: libc::clockid_t, - flags: libc::c_int, - rqtp: ConstPtr, - rmtp: Ptr, - }, - ExitGroup { - error_code: libc::c_int, - }, - EpollWait { - epfd: libc::c_int, - events: Ptr, - maxevents: libc::c_int, - timeout: libc::c_int, - }, - EpollCtl { - epfd: libc::c_int, - op: libc::c_int, - fd: libc::c_int, - event: Ptr, - }, - Tgkill { - tgid: libc::pid_t, - pid: libc::pid_t, - sig: libc::c_int, - }, - Utimes { - filename: ConstPtr, - utimes: ConstPtr, - }, - Mbind { - start: libc::c_ulong, - len: libc::c_ulong, - mode: libc::c_ulong, - nmask: ConstPtr, - maxnode: libc::c_ulong, - flags: libc::c_uint, - }, - SetMempolicy { - mode: libc::c_int, - nmask: ConstPtr, - maxnode: libc::c_ulong, - }, - GetMempolicy { - policy: Ptr, - nmask: Ptr, - maxnode: libc::c_ulong, - addr: libc::c_ulong, - flags: libc::c_ulong, - }, - MqOpen { - name: ConstPtr, - oflag: libc::c_int, - mode: libc::mode_t, - attr: Ptr, - }, - MqUnlink { - name: ConstPtr, - }, - MqTimedsend { - mqdes: libc::mqd_t, - msg_ptr: ConstPtr, - msg_len: libc::size_t, - msg_prio: libc::c_uint, - abs_timeout: ConstPtr, - }, - MqTimedreceive { - mqdes: libc::mqd_t, - msg_ptr: Ptr, - msg_len: libc::size_t, - msg_prio: Ptr, - abs_timeout: ConstPtr, - }, - MqNotify { - mqdes: libc::mqd_t, - notification: ConstPtr, - }, - MqGetsetattr { - mqdes: libc::mqd_t, - mqstat: ConstPtr, - omqstat: Ptr, - }, - KexecLoad { - entry: libc::c_ulong, - nr_segments: libc::c_ulong, - segments: Ptr, - flags: libc::c_ulong, - }, - Waitid { - which: libc::c_int, - pid: libc::pid_t, - infop: Ptr, - options: libc::c_int, - ru: Ptr, - }, - AddKey { - _type: ConstPtr, - _description: ConstPtr, - _payload: ConstPtr, - plen: libc::size_t, - destringid: libc::key_t, - }, - RequestKey { - _type: ConstPtr, - _description: ConstPtr, - _callout_info: ConstPtr, - destringid: libc::key_t, - }, - Keyctl { - cmd: libc::c_int, - arg2: libc::c_ulong, - arg3: libc::c_ulong, - arg4: libc::c_ulong, - arg5: libc::c_ulong, - }, - IoprioSet { - which: libc::c_int, - who: libc::c_int, - ioprio: libc::c_int, - }, - IoprioGet { - which: libc::c_int, - who: libc::c_int, - }, - InotifyInit, - InotifyAddWatch { - fd: libc::c_int, - path: ConstPtr, - mask: u32, - }, - InotifyRmWatch { - fd: libc::c_int, - wd: libc::c_int, - }, - MigratePages { - pid: libc::pid_t, - maxnode: libc::c_ulong, - from: ConstPtr, - to: ConstPtr, - }, - Openat { - dfd: libc::c_int, - filename: ConstPtr, - flags: libc::c_int, - mode: libc::mode_t, - }, - Mkdirat { - dfd: libc::c_int, - pathname: ConstPtr, - mode: libc::mode_t, - }, - Mknodat { - dfd: libc::c_int, - filename: ConstPtr, - mode: libc::mode_t, - dev: libc::c_uint, - }, - Fchownat { - dfd: libc::c_int, - filename: ConstPtr, - user: libc::uid_t, - group: libc::gid_t, - flag: libc::c_int, - }, - Futimesat { - dfd: libc::c_int, - filename: ConstPtr, - utimes: ConstPtr, - }, - Newfstatat { - dfd: libc::c_int, - filename: ConstPtr, - statbuf: Ptr, - flag: libc::c_int, - }, - Unlinkat { - dfd: libc::c_int, - pathname: ConstPtr, - flag: libc::c_int, - }, - Renameat { - olddfd: libc::c_int, - oldname: ConstPtr, - newdfd: libc::c_int, - newname: ConstPtr, - }, - Linkat { - olddfd: libc::c_int, - oldname: ConstPtr, - newdfd: libc::c_int, - newname: ConstPtr, - flags: libc::c_int, - }, - Symlinkat { - oldname: ConstPtr, - newdfd: libc::c_int, - newname: ConstPtr, - }, - Readlinkat { - dfd: libc::c_int, - path: ConstPtr, - buf: Ptr, - bufsiz: libc::c_int, - }, - Fchmodat { - dfd: libc::c_int, - filename: ConstPtr, - mode: libc::mode_t, - }, - Faccessat { - dfd: libc::c_int, - filename: ConstPtr, - mode: libc::c_int, - }, - Pselect6 { - n: libc::c_int, - inp: Ptr, - outp: Ptr, - exp: Ptr, - tsp: Ptr, - sig: Ptr, - }, - Ppoll { - fds: Ptr, - nfds: libc::c_uint, - tsp: ConstPtr, - sset: ConstPtr, - sigsetsize: libc::size_t, - }, - Unshare { - unshare_flags: libc::c_ulong, - }, - SetRobustList { - head: Ptr, - len: libc::size_t, - }, - GetRobustList { - pid: libc::c_int, - head_ptr: Ptr>, - len_ptr: Ptr, - }, - Splice { - fd_in: libc::c_int, - off_in: Ptr, - fd_out: libc::c_int, - off_out: Ptr, - len: libc::size_t, - flags: libc::c_uint, - }, - Tee { - fdin: libc::c_int, - fdout: libc::c_int, - len: libc::size_t, - flags: libc::c_uint, - }, - SyncFileRange { - fd: libc::c_int, - offset: libc::loff_t, - nbytes: libc::loff_t, - flags: libc::c_uint, - }, - Vmsplice { - fd: libc::c_int, - iov: ConstPtr, - nr_segs: libc::c_ulong, - flags: libc::c_uint, - }, - MovePages { - pid: libc::pid_t, - nr_pages: libc::c_ulong, - pages: Ptr>, - nodes: ConstPtr, - status: Ptr, - flags: libc::c_int, - }, - Utimensat { - dfd: libc::c_int, - filename: ConstPtr, - utimes: ConstPtr, - flags: libc::c_int, - }, - EpollPwait { - epfd: libc::c_int, - events: Ptr, - maxevents: libc::c_int, - timeout: libc::c_int, - sigmask: ConstPtr, - sigsetsize: libc::size_t, - }, - Signalfd { - ufd: libc::c_int, - user_mask: Ptr, - sizemask: libc::size_t, - }, - TimerfdCreate { - clockid: libc::c_int, - flags: libc::c_int, - }, - Eventfd { - count: libc::c_uint, - }, - Fallocate { - fd: libc::c_int, - mode: libc::c_int, - offset: libc::loff_t, - len: libc::loff_t, - }, - TimerfdSettime { - ufd: libc::c_int, - flags: libc::c_int, - utmr: ConstPtr, - otmr: Ptr, - }, - TimerfdGettime { - ufd: libc::c_int, - otmr: Ptr, - }, - Accept4 { - fd: libc::c_int, - addr: Ptr, - len: Ptr, - flags: libc::c_int, - }, - Signalfd4 { - ufd: libc::c_int, - user_mask: Ptr, - sizemask: libc::size_t, - flags: libc::c_int, - }, - Eventfd2 { - count: libc::c_uint, - flags: libc::c_int, - }, - EpollCreate1 { - flags: libc::c_int, - }, - Dup3 { - oldfd: libc::c_uint, - newfd: libc::c_uint, - flags: libc::c_int, - }, - Pipe2 { - fildes: Ptr, - flags: libc::c_int, - }, - InotifyInit1 { - flags: libc::c_int, - }, - Preadv { - fd: libc::c_ulong, - vec: ConstPtr, - vlen: libc::c_ulong, - pos_l: libc::c_ulong, - pos_h: libc::c_ulong, - }, - Pwritev { - fd: libc::c_ulong, - vec: ConstPtr, - vlen: libc::c_ulong, - pos_l: libc::c_ulong, - pos_h: libc::c_ulong, - }, - RtTgsigqueueinfo { - tgid: libc::pid_t, - pid: libc::pid_t, - sig: libc::c_int, - uinfo: Ptr, - }, - PerfEventOpen { - attr_uptr: Ptr, - pid: libc::pid_t, - cpu: libc::c_int, - group_fd: libc::c_int, - flags: libc::c_ulong, - }, - Recvmmsg { - fd: libc::c_int, - msg: Ptr, - vlen: libc::c_uint, - flags: libc::c_uint, - timeout: Ptr, - }, - FanotifyInit { - flags: libc::c_uint, - event_f_flags: libc::c_uint, - }, - FanotifyMark { - fanotify_fd: libc::c_int, - flags: libc::c_uint, - mask: u64, - fd: libc::c_int, - pathname: ConstPtr, - }, - Prlimit64 { - pid: libc::pid_t, - resource: libc::c_uint, - new_rlim: ConstPtr, - old_rlim: Ptr, - }, - NameToHandleAt { - dfd: libc::c_int, - name: ConstPtr, - handle: Ptr, - mnt_id: Ptr, - flag: libc::c_int, - }, - OpenByHandleAt { - mountdirfd: libc::c_int, - handle: Ptr, - flags: libc::c_int, - }, - ClockAdjtime { - which_clock: libc::clockid_t, - tx: Ptr, - }, - Syncfs { - fd: libc::c_int, - }, - Sendmmsg { - fd: libc::c_int, - msg: Ptr, - vlen: libc::c_uint, - flags: libc::c_uint, - }, - Setns { - fd: libc::c_int, - nstype: libc::c_int, - }, - Getcpu { - cpu: Ptr, - node: Ptr, - cache: Ptr, - }, - ProcessVmReadv { - pid: libc::pid_t, - lvec: ConstPtr, - liovcnt: libc::c_ulong, - rvec: ConstPtr, - riovcnt: libc::c_ulong, - flags: libc::c_ulong, - }, - ProcessVmWritev { - pid: libc::pid_t, - lvec: ConstPtr, - liovcnt: libc::c_ulong, - rvec: ConstPtr, - riovcnt: libc::c_ulong, - flags: libc::c_ulong, - }, - Kcmp { - pid1: libc::pid_t, - pid2: libc::pid_t, - ty: libc::c_int, - idx1: libc::c_ulong, - idx2: libc::c_ulong, - }, - FinitModule { - fd: libc::c_int, - uargs: ConstPtr, - flags: libc::c_int, - }, - SchedSetattr { - pid: libc::pid_t, - attr: Ptr, - flags: libc::c_uint, - }, - SchedGetattr { - pid: libc::pid_t, - attr: Ptr, - size: libc::c_uint, - flags: libc::c_uint, - }, - Renameat2 { - olddfd: libc::c_int, - oldname: ConstPtr, - newdfd: libc::c_int, - newname: ConstPtr, - flags: libc::c_uint, - }, - Seccomp { - op: libc::c_uint, - flags: libc::c_uint, - uargs: Ptr, - }, - Getrandom { - buf: Ptr, - count: libc::size_t, - flags: libc::c_uint, - }, - MemfdCreate { - uname_ptr: ConstPtr, - flags: libc::c_uint, - }, - KexecFileLoad { - kernel_fd: libc::c_int, - initrd_fd: libc::c_int, - cmdline_len: libc::c_ulong, - cmdline_ptr: ConstPtr, - flags: libc::c_ulong, - }, - Bpf { - cmd: libc::c_int, - attr: Ptr, - size: libc::c_uint, - }, - Execveat { - dfd: libc::c_int, - filename: ConstPtr, - argv: ConstPtr>, - envp: ConstPtr>, - flags: libc::c_int, - }, - Userfaultfd { - flags: libc::c_int, - }, - Membarrier { - cmd: libc::c_int, - flags: libc::c_uint, - }, - Mlock2 { - start: libc::c_ulong, - len: libc::size_t, - flags: libc::c_int, - }, - CopyFileRange { - fd_in: libc::c_int, - off_in: Ptr, - fd_out: libc::c_int, - off_out: Ptr, - len: libc::size_t, - flags: libc::c_uint, - }, - Preadv2 { - fd: libc::c_ulong, - vec: ConstPtr, - vlen: libc::c_ulong, - pos_l: libc::c_ulong, - pos_h: libc::c_ulong, - flags: libc::c_int, - }, - Pwritev2 { - fd: libc::c_ulong, - vec: ConstPtr, - vlen: libc::c_ulong, - pos_l: libc::c_ulong, - pos_h: libc::c_ulong, - flags: libc::c_int, - }, - PkeyMprotect { - start: libc::c_ulong, - len: libc::size_t, - prot: libc::c_ulong, - pkey: libc::c_int, - }, - PkeyAlloc { - flags: libc::c_ulong, - init_val: libc::c_ulong, - }, - PkeyFree { - pkey: libc::c_int, - }, - Statx { - dfd: libc::c_int, - path: ConstPtr, - flags: libc::c_uint, - mask: libc::c_uint, - buffer: Ptr, - }, - Rseq { - rseq: Ptr, - rseq_len: u32, - flags: libc::c_int, - sig: u32, - }, - PidfdSendSignal { - pidfd: libc::c_int, - sig: libc::c_int, - info: Ptr, - flags: libc::c_uint, - }, - IoUringSetup { - entries: u32, - p: Ptr, - }, - IoUringEnter { - fd: libc::c_uint, - to_submit: u32, - min_complete: u32, - flags: u32, - argp: ConstPtr, - argsz: libc::size_t, - }, - IoUringRegister { - fd: libc::c_uint, - op: libc::c_uint, - arg: Ptr, - nr_args: libc::c_uint, - }, - OpenTree { - dfd: libc::c_int, - path: ConstPtr, - flags: libc::c_uint, - }, - MoveMount { - from_dfd: libc::c_int, - from_path: ConstPtr, - to_dfd: libc::c_int, - to_path: ConstPtr, - ms_flags: libc::c_uint, - }, - Fsopen { - fs_name: ConstPtr, - flags: libc::c_uint, - }, - Fsconfig { - fs_fd: libc::c_int, - cmd: libc::c_uint, - key: ConstPtr, - value: ConstPtr, - aux: libc::c_int, - }, - Fsmount { - fs_fd: libc::c_int, - flags: libc::c_uint, - ms_flags: libc::c_uint, - }, - Fspick { - dfd: libc::c_int, - path: ConstPtr, - flags: libc::c_uint, - }, - PidfdOpen { - pid: libc::pid_t, - flags: libc::c_uint, - }, - Clone3 { - uargs: Ptr, - size: libc::size_t, - }, - CloseRange { - fd: libc::c_uint, - max_fd: libc::c_uint, - flags: libc::c_uint, - }, - Openat2 { - dfd: libc::c_int, - filename: ConstPtr, - how: Ptr, - size: libc::size_t, - }, - PidfdGetfd { - pidfd: libc::c_int, - fd: libc::c_int, - flags: libc::c_uint, - }, - Faccessat2 { - dfd: libc::c_int, - filename: ConstPtr, - mode: libc::c_int, - flags: libc::c_int, - }, - ProcessMadvise { - pidfd: libc::c_int, - vec: ConstPtr, - vlen: libc::size_t, - behavior: libc::c_int, - flags: libc::c_uint, - }, - EpollPwait2 { - epfd: libc::c_int, - events: Ptr, - maxevents: libc::c_int, - timeout: ConstPtr, - sigmask: ConstPtr, - sigsetsize: libc::size_t, - }, - MountSetattr { - dfd: libc::c_int, - path: ConstPtr, - flags: libc::c_uint, - uattr: Ptr, - usize: libc::size_t, - }, - QuotactlFd { - fd: libc::c_uint, - cmd: libc::c_uint, - id: libc::c_int, - addr: Ptr, - }, - LandlockCreateRuleset { - attr: ConstPtr, - size: libc::size_t, - flags: u32, - }, - LandlockAddRule { - ruleset_fd: libc::c_int, - rule_type: libc::c_int, - rule_attr: ConstPtr, - flags: u32, - }, - LandlockRestrictSelf { - ruleset_fd: libc::c_int, - flags: u32, - }, - MemfdSecret { - flags: libc::c_uint, - }, - ProcessMrelease { - pidfd: libc::c_int, - flags: libc::c_uint, - }, - FutexWaitv { - waiters: Ptr, - nr_futexes: libc::c_uint, - flags: libc::c_uint, - timeout: Ptr, - clockid: libc::clockid_t, - }, - SetMempolicyHomeNode { - start: libc::c_ulong, - len: libc::c_ulong, - home_node: libc::c_ulong, - flags: libc::c_ulong, - },*/ -} - -impl Syscall { - pub fn encode(&self) -> Vec { - bincode::encode_to_vec(self, crate::CONFIG).unwrap() - } - - pub fn decode(bytes: &[u8]) -> Option { - if let Ok((decoded, _)) = bincode::decode_from_slice(&bytes[..], crate::CONFIG) { - Some(decoded) - } else { - None - } - } -} - -// impl Debug for Syscall { -// fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -// unsafe { -// match self { -// Self::Read { fd, buf, count } => Ok(()), //f.write_str(&String::from_utf8_lossy( -// // &crate::kern_buffers::read( -// // *fd, -// // buf.get_location() as *mut libc::c_char, -// // *count, -// // ) -// // .unwrap(), -// // )), -// Self::Write { fd, buf, count } => { -// // let a = unsafe { -// // transmute::(buf.get_location()) -// // }; - -// get_buffer_from_kernel(); - -// let data = crate::kern_buffers::printstrn(buf.get_location(), *count, false); - -// f.write_str(format!("Write: {}", data).as_str())?; - -// // f.write_str(a); - -// Ok(()) -// } -// Self::Unimplemented => write!(f, "Unimplemented"), -// } -// } -// } -// } diff --git a/syscall_lib/src/syscall/create.rs b/syscall_lib/src/syscall/create.rs new file mode 100644 index 0000000..268a011 --- /dev/null +++ b/syscall_lib/src/syscall/create.rs @@ -0,0 +1,1653 @@ +use std::mem::transmute; + +use crate::*; + +impl Syscall { + /// Constructs a `Syscall` enum variant from a syscall number and an array of 6 arguments. + /// + /// The `args` array corresponds to the values in the registers `rdi`, `rsi`, + /// `rdx`, `r10`, `r8`, and `r9` at the time of the syscall. + /// + /// Returns an `Err` if the syscall number is unknown. + pub fn from_syscall( + num: libc::c_long, + args: [libc::c_ulong; 6], + ) -> Result { + let s = match num { + libc::SYS_read => Syscall::Read { + fd: args[0] as libc::c_uint, + buf: Buf::::new(args[1]), + len: args[2] as libc::size_t, + }, + libc::SYS_write => Syscall::Write { + fd: args[0] as libc::c_uint, + buf: Buf::::new(args[1]), + len: args[2] as libc::size_t, + }, + + libc::SYS_open => Syscall::Open { + path: StrRef::new(args[0]), + flags: args[1] as libc::c_int, + mode: args[2] as libc::c_int, + }, + libc::SYS_close => Syscall::Close { + fd: args[0] as libc::c_uint, + }, + libc::SYS_stat => Syscall::Stat { + path: StrRef::new(args[0]), + statbuf: Ptr::new(args[1]), + }, + // libc::SYS_fstat => Syscall::Fstat { + // fd: args[0] as libc::c_uint, + // statbuf: Ptr::new(args[1]), + // }, + // libc::SYS_lstat => Syscall::Lstat { + // path: args[0] as ConstPtr, + // statbuf: args[1] as Ptr, + // }, + // libc::SYS_poll => Syscall::Poll { + // fds: args[0] as Ptr, + // nfds: args[1] as libc::c_uint, + // timeout: args[2] as libc::c_int, + // }, + // libc::SYS_lseek => Syscall::Lseek { + // fd: args[0] as libc::c_uint, + // offset: args[1] as libc::off_t, + // whence: args[2] as libc::c_uint, + // }, + libc::SYS_mmap => Syscall::Mmap { + addr: PtrVoid(args[0]), + len: args[1] as libc::size_t, + prot: args[2] as libc::c_int, + flags: args[3] as libc::c_int, + fd: args[4] as libc::c_int, + offset: args[5] as libc::off_t, + }, + // libc::SYS_mprotect => Syscall::Mprotect { + // addr: args[0] as Ptr, + // len: args[1] as libc::size_t, + // prot: args[2] as libc::c_int, + // }, + // libc::SYS_munmap => Syscall::Munmap { + // addr: args[0] as Ptr, + // len: args[1] as libc::size_t, + // }, + // libc::SYS_brk => Syscall::Brk { + // addr: args[0] as Ptr, + // }, + // libc::SYS_rt_sigaction => Syscall::RtSigaction { + // sig: args[0] as libc::c_int, + // act: args[1] as ConstPtr, + // oldact: args[2] as Ptr, + // sigsetsize: args[3] as libc::size_t, + // }, + // libc::SYS_rt_sigprocmask => Syscall::RtSigprocmask { + // how: args[0] as libc::c_int, + // set: args[1] as Ptr, + // oldset: args[2] as Ptr, + // sigsetsize: args[3] as libc::size_t, + // }, + // 15 => Syscall::RtSigreturn, // SYS_rt_sigreturn is often not in libc crates + // libc::SYS_ioctl => Syscall::Ioctl { + // fd: args[0] as libc::c_uint, + // cmd: args[1] as libc::c_ulong, + // arg: args[2] as libc::c_ulong, + // }, + // libc::SYS_pread64 => Syscall::Pread64 { + // fd: args[0] as libc::c_uint, + // buf: args[1] as Ptr, + // count: args[2] as libc::size_t, + // pos: args[3] as libc::loff_t, + // }, + // libc::SYS_pwrite64 => Syscall::Pwrite64 { + // fd: args[0] as libc::c_uint, + // buf: args[1] as ConstPtr, + // count: args[2] as libc::size_t, + // pos: args[3] as libc::loff_t, + // }, + // libc::SYS_readv => Syscall::Readv { + // fd: args[0] as libc::c_ulong, + // vec: args[1] as ConstPtr, + // vlen: args[2] as libc::c_ulong, + // }, + // libc::SYS_writev => Syscall::Writev { + // fd: args[0] as libc::c_ulong, + // vec: args[1] as ConstPtr, + // vlen: args[2] as libc::c_ulong, + // }, + // libc::SYS_access => Syscall::Access { + // filename: args[0] as ConstPtr, + // mode: args[1] as libc::c_int, + // }, + // libc::SYS_pipe => Syscall::Pipe { + // fildes: args[0] as Ptr, + // }, + // libc::SYS_select => Syscall::Select { + // n: args[0] as libc::c_int, + // inp: args[1] as Ptr, + // outp: args[2] as Ptr, + // exp: args[3] as Ptr, + // tvp: args[4] as Ptr, + // }, + // libc::SYS_sched_yield => Syscall::SchedYield, + // libc::SYS_mremap => Syscall::Mremap { + // old_addr: args[0] as Ptr, + // old_size: args[1] as libc::size_t, + // new_size: args[2] as libc::size_t, + // flags: args[3] as libc::c_int, + // new_addr: args[4] as Ptr, + // }, + // libc::SYS_msync => Syscall::Msync { + // start: args[0] as Ptr, + // len: args[1] as libc::size_t, + // flags: args[2] as libc::c_int, + // }, + // libc::SYS_mincore => Syscall::Mincore { + // start: args[0] as Ptr, + // len: args[1] as libc::size_t, + // vec: args[2] as Ptr, + // }, + // libc::SYS_madvise => Syscall::Madvise { + // start: args[0] as Ptr, + // len: args[1] as libc::size_t, + // behavior: args[2] as libc::c_int, + // }, + // libc::SYS_shmget => Syscall::Shmget { + // key: args[0] as libc::key_t, + // size: args[1] as libc::size_t, + // shmflg: args[2] as libc::c_int, + // }, + // libc::SYS_shmat => Syscall::Shmat { + // shmid: args[0] as libc::c_int, + // shmaddr: args[1] as ConstPtr, + // shmflg: args[2] as libc::c_int, + // }, + // libc::SYS_shmctl => Syscall::Shmctl { + // shmid: args[0] as libc::c_int, + // cmd: args[1] as libc::c_int, + // buf: args[2] as Ptr, + // }, + // libc::SYS_dup => Syscall::Dup { + // fildes: args[0] as libc::c_uint, + // }, + // libc::SYS_dup2 => Syscall::Dup2 { + // oldfd: args[0] as libc::c_uint, + // newfd: args[1] as libc::c_uint, + // }, + // libc::SYS_pause => Syscall::Pause, + // libc::SYS_nanosleep => Syscall::Nanosleep { + // rqtp: args[0] as ConstPtr, + // rmtp: args[1] as Ptr, + // }, + // libc::SYS_getitimer => Syscall::Getitimer { + // which: args[0] as libc::c_int, + // value: args[1] as Ptr, + // }, + // libc::SYS_alarm => Syscall::Alarm { + // seconds: args[0] as libc::c_uint, + // }, + // libc::SYS_setitimer => Syscall::Setitimer { + // which: args[0] as libc::c_int, + // value: args[1] as ConstPtr, + // ovalue: args[2] as Ptr, + // }, + // libc::SYS_getpid => Syscall::Getpid, + // libc::SYS_sendfile => Syscall::Sendfile { + // out_fd: args[0] as libc::c_int, + // in_fd: args[1] as libc::c_int, + // offset: args[2] as Ptr, + // count: args[3] as libc::size_t, + // }, + // libc::SYS_socket => Syscall::Socket { + // domain: args[0] as libc::c_int, + // ty: args[1] as libc::c_int, + // protocol: args[2] as libc::c_int, + // }, + // libc::SYS_connect => Syscall::Connect { + // fd: args[0] as libc::c_int, + // addr: args[1] as ConstPtr, + // len: args[2] as libc::socklen_t, + // }, + // libc::SYS_accept => Syscall::Accept { + // fd: args[0] as libc::c_int, + // addr: args[1] as Ptr, + // len: args[2] as Ptr, + // }, + // libc::SYS_sendto => Syscall::Sendto { + // fd: args[0] as libc::c_int, + // buf: args[1] as ConstPtr, + // len: args[2] as libc::size_t, + // flags: args[3] as libc::c_int, + // addr: args[4] as ConstPtr, + // addr_len: args[5] as libc::socklen_t, + // }, + // libc::SYS_recvfrom => Syscall::Recvfrom { + // fd: args[0] as libc::c_int, + // buf: args[1] as Ptr, + // len: args[2] as libc::size_t, + // flags: args[3] as libc::c_int, + // addr: args[4] as Ptr, + // addr_len: args[5] as Ptr, + // }, + // libc::SYS_sendmsg => Syscall::Sendmsg { + // fd: args[0] as libc::c_int, + // msg: args[1] as ConstPtr, + // flags: args[2] as libc::c_int, + // }, + // libc::SYS_recvmsg => Syscall::Recvmsg { + // fd: args[0] as libc::c_int, + // msg: args[1] as Ptr, + // flags: args[2] as libc::c_int, + // }, + // libc::SYS_shutdown => Syscall::Shutdown { + // fd: args[0] as libc::c_int, + // how: args[1] as libc::c_int, + // }, + // libc::SYS_bind => Syscall::Bind { + // fd: args[0] as libc::c_int, + // addr: args[1] as ConstPtr, + // len: args[2] as libc::socklen_t, + // }, + // libc::SYS_listen => Syscall::Listen { + // fd: args[0] as libc::c_int, + // backlog: args[1] as libc::c_int, + // }, + // libc::SYS_getsockname => Syscall::Getsockname { + // fd: args[0] as libc::c_int, + // addr: args[1] as Ptr, + // len: args[2] as Ptr, + // }, + // libc::SYS_getpeername => Syscall::Getpeername { + // fd: args[0] as libc::c_int, + // addr: args[1] as Ptr, + // len: args[2] as Ptr, + // }, + // libc::SYS_socketpair => Syscall::Socketpair { + // domain: args[0] as libc::c_int, + // ty: args[1] as libc::c_int, + // protocol: args[2] as libc::c_int, + // fds: args[3] as Ptr, + // }, + // libc::SYS_setsockopt => Syscall::Setsockopt { + // fd: args[0] as libc::c_int, + // level: args[1] as libc::c_int, + // optname: args[2] as libc::c_int, + // optval: args[3] as ConstPtr, + // optlen: args[4] as libc::socklen_t, + // }, + // libc::SYS_getsockopt => Syscall::Getsockopt { + // fd: args[0] as libc::c_int, + // level: args[1] as libc::c_int, + // optname: args[2] as libc::c_int, + // optval: args[3] as Ptr, + // optlen: args[4] as Ptr, + // }, + // libc::SYS_clone => Syscall::Clone { + // flags: args[0] as libc::c_ulong, + // stack: args[1] as Ptr, + // parent_tid: args[2] as Ptr, + // child_tid: args[3] as Ptr, + // tls: args[4] as libc::c_ulong, + // }, + // libc::SYS_fork => Syscall::Fork, + // libc::SYS_vfork => Syscall::Vfork, + // libc::SYS_execve => Syscall::Execve { + // filename: args[0] as ConstPtr, + // argv: args[1] as ConstPtr>, + // envp: args[2] as ConstPtr>, + // }, + // libc::SYS_exit => Syscall::Exit { + // error_code: args[0] as libc::c_int, + // }, + // libc::SYS_wait4 => Syscall::Wait4 { + // pid: args[0] as libc::pid_t, + // stat_addr: args[1] as Ptr, + // options: args[2] as libc::c_int, + // ru: args[3] as Ptr, + // }, + // libc::SYS_kill => Syscall::Kill { + // pid: args[0] as libc::pid_t, + // sig: args[1] as libc::c_int, + // }, + // libc::SYS_uname => Syscall::Uname { + // name: args[0] as Ptr, + // }, + // libc::SYS_semget => Syscall::Semget { + // key: args[0] as libc::key_t, + // nsems: args[1] as libc::c_int, + // semflg: args[2] as libc::c_int, + // }, + // libc::SYS_semop => Syscall::Semop { + // semid: args[0] as libc::c_int, + // sops: args[1] as Ptr, + // nsops: args[2] as libc::size_t, + // }, + // libc::SYS_semctl => Syscall::Semctl { + // semid: args[0] as libc::c_int, + // semnum: args[1] as libc::c_int, + // cmd: args[2] as libc::c_int, + // arg: args[3] as libc::c_ulong, + // }, + // libc::SYS_shmdt => Syscall::Shmdt { + // shmaddr: args[0] as ConstPtr, + // }, + // libc::SYS_msgget => Syscall::Msgget { + // key: args[0] as libc::key_t, + // msgflg: args[1] as libc::c_int, + // }, + // libc::SYS_msgsnd => Syscall::Msgsnd { + // msqid: args[0] as libc::c_int, + // msgp: args[1] as ConstPtr, + // msgsz: args[2] as libc::size_t, + // msgflg: args[3] as libc::c_int, + // }, + // libc::SYS_msgrcv => Syscall::Msgrcv { + // msqid: args[0] as libc::c_int, + // msgp: args[1] as Ptr, + // msgsz: args[2] as libc::size_t, + // msgtyp: args[3] as libc::c_long, + // msgflg: args[4] as libc::c_int, + // }, + // libc::SYS_msgctl => Syscall::Msgctl { + // msqid: args[0] as libc::c_int, + // cmd: args[1] as libc::c_int, + // buf: args[2] as Ptr, + // }, + // libc::SYS_fcntl => Syscall::Fcntl { + // fd: args[0] as libc::c_uint, + // cmd: args[1] as libc::c_uint, + // arg: args[2] as libc::c_ulong, + // }, + // libc::SYS_flock => Syscall::Flock { + // fd: args[0] as libc::c_uint, + // cmd: args[1] as libc::c_uint, + // }, + // libc::SYS_fsync => Syscall::Fsync { + // fd: args[0] as libc::c_uint, + // }, + // libc::SYS_fdatasync => Syscall::Fdatasync { + // fd: args[0] as libc::c_uint, + // }, + // libc::SYS_truncate => Syscall::Truncate { + // path: args[0] as ConstPtr, + // length: args[1] as libc::c_long, + // }, + // libc::SYS_ftruncate => Syscall::Ftruncate { + // fd: args[0] as libc::c_uint, + // length: args[1] as libc::c_long, + // }, + // libc::SYS_getdents => Syscall::Getdents { + // fd: args[0] as libc::c_uint, + // dirent: args[1] as Ptr, + // count: args[2] as libc::c_uint, + // }, + // libc::SYS_getcwd => Syscall::Getcwd { + // buf: args[0] as Ptr, + // size: args[1] as libc::c_ulong, + // }, + // libc::SYS_chdir => Syscall::Chdir { + // filename: args[0] as ConstPtr, + // }, + // libc::SYS_fchdir => Syscall::Fchdir { + // fd: args[0] as libc::c_uint, + // }, + // libc::SYS_rename => Syscall::Rename { + // oldname: args[0] as ConstPtr, + // newname: args[1] as ConstPtr, + // }, + // libc::SYS_mkdir => Syscall::Mkdir { + // pathname: args[0] as ConstPtr, + // mode: args[1] as libc::mode_t, + // }, + // libc::SYS_rmdir => Syscall::Rmdir { + // pathname: args[0] as ConstPtr, + // }, + // libc::SYS_creat => Syscall::Creat { + // pathname: args[0] as ConstPtr, + // mode: args[1] as libc::mode_t, + // }, + // libc::SYS_link => Syscall::Link { + // oldname: args[0] as ConstPtr, + // newname: args[1] as ConstPtr, + // }, + // libc::SYS_unlink => Syscall::Unlink { + // pathname: args[0] as ConstPtr, + // }, + // libc::SYS_symlink => Syscall::Symlink { + // old: args[0] as ConstPtr, + // new: args[1] as ConstPtr, + // }, + // libc::SYS_readlink => Syscall::Readlink { + // path: args[0] as ConstPtr, + // buf: args[1] as Ptr, + // bufsiz: args[2] as libc::c_int, + // }, + // libc::SYS_chmod => Syscall::Chmod { + // filename: args[0] as ConstPtr, + // mode: args[1] as libc::mode_t, + // }, + // libc::SYS_fchmod => Syscall::Fchmod { + // fd: args[0] as libc::c_uint, + // mode: args[1] as libc::mode_t, + // }, + // libc::SYS_chown => Syscall::Chown { + // filename: args[0] as ConstPtr, + // user: args[1] as libc::uid_t, + // group: args[2] as libc::gid_t, + // }, + // libc::SYS_fchown => Syscall::Fchown { + // fd: args[0] as libc::c_uint, + // user: args[1] as libc::uid_t, + // group: args[2] as libc::gid_t, + // }, + // libc::SYS_lchown => Syscall::Lchown { + // filename: args[0] as ConstPtr, + // user: args[1] as libc::uid_t, + // group: args[2] as libc::gid_t, + // }, + // libc::SYS_umask => Syscall::Umask { + // mask: args[0] as libc::c_int, + // }, + // libc::SYS_gettimeofday => Syscall::Gettimeofday { + // tv: args[0] as Ptr, + // tz: args[1] as Ptr, + // }, + // libc::SYS_getrlimit => Syscall::Getrlimit { + // resource: args[0] as libc::c_int, + // rlim: args[1] as Ptr, + // }, + // libc::SYS_getrusage => Syscall::Getrusage { + // who: args[0] as libc::c_int, + // ru: args[1] as Ptr, + // }, + // libc::SYS_sysinfo => Syscall::Sysinfo { + // info: args[0] as Ptr, + // }, + // libc::SYS_times => Syscall::Times { + // tbuf: args[0] as Ptr, + // }, + // libc::SYS_ptrace => Syscall::Ptrace { + // request: args[0] as libc::c_long, + // pid: args[1] as libc::c_long, + // addr: args[2] as libc::c_ulong, + // data: args[3] as libc::c_ulong, + // }, + // libc::SYS_getuid => Syscall::Getuid, + // libc::SYS_syslog => Syscall::Syslog { + // ty: args[0] as libc::c_int, + // buf: args[1] as Ptr, + // len: args[2] as libc::c_int, + // }, + // libc::SYS_getgid => Syscall::Getgid, + // libc::SYS_setuid => Syscall::Setuid { + // uid: args[0] as libc::uid_t, + // }, + // libc::SYS_setgid => Syscall::Setgid { + // gid: args[0] as libc::gid_t, + // }, + // libc::SYS_geteuid => Syscall::Geteuid, + // libc::SYS_getegid => Syscall::Getegid, + // libc::SYS_setpgid => Syscall::Setpgid { + // pid: args[0] as libc::pid_t, + // pgid: args[1] as libc::pid_t, + // }, + // libc::SYS_getppid => Syscall::Getppid, + // libc::SYS_getpgrp => Syscall::Getpgrp, + // libc::SYS_setsid => Syscall::Setsid, + // libc::SYS_setreuid => Syscall::Setreuid { + // ruid: args[0] as libc::uid_t, + // euid: args[1] as libc::uid_t, + // }, + // libc::SYS_setregid => Syscall::Setregid { + // rgid: args[0] as libc::gid_t, + // egid: args[1] as libc::gid_t, + // }, + // libc::SYS_getgroups => Syscall::Getgroups { + // gidsetsize: args[0] as libc::c_int, + // grouplist: args[1] as Ptr, + // }, + // libc::SYS_setgroups => Syscall::Setgroups { + // gidsetsize: args[0] as libc::c_int, + // grouplist: args[1] as ConstPtr, + // }, + // libc::SYS_setresuid => Syscall::Setresuid { + // ruid: args[0] as libc::uid_t, + // euid: args[1] as libc::uid_t, + // suid: args[2] as libc::uid_t, + // }, + // libc::SYS_getresuid => Syscall::Getresuid { + // ruid: args[0] as Ptr, + // euid: args[1] as Ptr, + // suid: args[2] as Ptr, + // }, + // libc::SYS_setresgid => Syscall::Setresgid { + // rgid: args[0] as libc::gid_t, + // egid: args[1] as libc::gid_t, + // sgid: args[2] as libc::gid_t, + // }, + // libc::SYS_getresgid => Syscall::Getresgid { + // rgid: args[0] as Ptr, + // egid: args[1] as Ptr, + // sgid: args[2] as Ptr, + // }, + // libc::SYS_getpgid => Syscall::Getpgid { + // pid: args[0] as libc::pid_t, + // }, + // libc::SYS_setfsuid => Syscall::Setfsuid { + // uid: args[0] as libc::uid_t, + // }, + // libc::SYS_setfsgid => Syscall::Setfsgid { + // gid: args[0] as libc::gid_t, + // }, + // libc::SYS_getsid => Syscall::Getsid { + // pid: args[0] as libc::pid_t, + // }, + // libc::SYS_capget => Syscall::Capget { + // header: args[0] as Ptr, + // dataptr: args[1] as Ptr, + // }, + // libc::SYS_capset => Syscall::Capset { + // header: args[0] as Ptr, + // data: args[1] as ConstPtr, + // }, + // libc::SYS_rt_sigpending => Syscall::RtSigpending { + // set: args[0] as Ptr, + // sigsetsize: args[1] as libc::size_t, + // }, + // libc::SYS_rt_sigtimedwait => Syscall::RtSigtimedwait { + // uthese: args[0] as ConstPtr, + // uinfo: args[1] as Ptr, + // uts: args[2] as ConstPtr, + // sigsetsize: args[3] as libc::size_t, + // }, + // libc::SYS_rt_sigqueueinfo => Syscall::RtSigqueueinfo { + // pid: args[0] as libc::pid_t, + // sig: args[1] as libc::c_int, + // uinfo: args[2] as Ptr, + // }, + // libc::SYS_rt_sigsuspend => Syscall::RtSigsuspend { + // unewset: args[0] as Ptr, + // sigsetsize: args[1] as libc::size_t, + // }, + // libc::SYS_sigaltstack => Syscall::Sigaltstack { + // uss: args[0] as ConstPtr, + // uoss: args[1] as Ptr, + // }, + // libc::SYS_utime => Syscall::Utime { + // filename: args[0] as ConstPtr, + // times: args[1] as Ptr, + // }, + // libc::SYS_mknod => Syscall::Mknod { + // filename: args[0] as ConstPtr, + // mode: args[1] as libc::mode_t, + // dev: args[2] as libc::c_uint, + // }, + // libc::SYS_uselib => Syscall::Uselib { + // library: args[0] as ConstPtr, + // }, + // libc::SYS_personality => Syscall::Personality { + // personality: args[0] as libc::c_uint, + // }, + // libc::SYS_ustat => Syscall::Ustat { + // dev: args[0] as libc::c_uint, + // ubuf: args[1] as Ptr, + // }, + // libc::SYS_statfs => Syscall::Statfs { + // path: args[0] as ConstPtr, + // buf: args[1] as Ptr, + // }, + // libc::SYS_fstatfs => Syscall::Fstatfs { + // fd: args[0] as libc::c_uint, + // buf: args[1] as Ptr, + // }, + // libc::SYS_sysfs => Syscall::Sysfs { + // option: args[0] as libc::c_int, + // arg1: args[1] as libc::c_ulong, + // arg2: args[2] as libc::c_ulong, + // }, + // libc::SYS_getpriority => Syscall::Getpriority { + // which: args[0] as libc::c_int, + // who: args[1] as libc::c_int, + // }, + // libc::SYS_setpriority => Syscall::Setpriority { + // which: args[0] as libc::c_int, + // who: args[1] as libc::c_int, + // niceval: args[2] as libc::c_int, + // }, + // libc::SYS_sched_setparam => Syscall::SchedSetparam { + // pid: args[0] as libc::pid_t, + // param: args[1] as ConstPtr, + // }, + // libc::SYS_sched_getparam => Syscall::SchedGetparam { + // pid: args[0] as libc::pid_t, + // param: args[1] as Ptr, + // }, + // libc::SYS_sched_setscheduler => Syscall::SchedSetscheduler { + // pid: args[0] as libc::pid_t, + // policy: args[1] as libc::c_int, + // param: args[2] as ConstPtr, + // }, + // libc::SYS_sched_getscheduler => Syscall::SchedGetscheduler { + // pid: args[0] as libc::pid_t, + // }, + // libc::SYS_sched_get_priority_max => Syscall::SchedGetPriorityMax { + // policy: args[0] as libc::c_int, + // }, + // libc::SYS_sched_get_priority_min => Syscall::SchedGetPriorityMin { + // policy: args[0] as libc::c_int, + // }, + // libc::SYS_sched_rr_get_interval => Syscall::SchedRrGetInterval { + // pid: args[0] as libc::pid_t, + // interval: args[1] as Ptr, + // }, + // libc::SYS_mlock => Syscall::Mlock { + // start: args[0] as libc::c_ulong, + // len: args[1] as libc::size_t, + // }, + // libc::SYS_munlock => Syscall::Munlock { + // start: args[0] as libc::c_ulong, + // len: args[1] as libc::size_t, + // }, + // libc::SYS_mlockall => Syscall::Mlockall { + // flags: args[0] as libc::c_int, + // }, + // libc::SYS_munlockall => Syscall::Munlockall, + // libc::SYS_vhangup => Syscall::Vhangup, + // libc::SYS_pivot_root => Syscall::PivotRoot { + // new_root: args[0] as ConstPtr, + // put_old: args[1] as ConstPtr, + // }, + // libc::SYS_prctl => Syscall::Prctl { + // option: args[0] as libc::c_int, + // arg2: args[1] as libc::c_ulong, + // arg3: args[2] as libc::c_ulong, + // arg4: args[3] as libc::c_ulong, + // arg5: args[4] as libc::c_ulong, + // }, + // libc::SYS_adjtimex => Syscall::Adjtimex { + // txc_p: args[0] as Ptr, + // }, + // libc::SYS_setrlimit => Syscall::Setrlimit { + // resource: args[0] as libc::c_uint, + // rlim: args[1] as ConstPtr, + // }, + // libc::SYS_chroot => Syscall::Chroot { + // filename: args[0] as ConstPtr, + // }, + // libc::SYS_sync => Syscall::Sync, + // libc::SYS_acct => Syscall::Acct { + // name: args[0] as ConstPtr, + // }, + // libc::SYS_settimeofday => Syscall::Settimeofday { + // tv: args[0] as ConstPtr, + // tz: args[1] as ConstPtr, + // }, + // libc::SYS_mount => Syscall::Mount { + // dev_name: args[0] as ConstPtr, + // dir_name: args[1] as ConstPtr, + // ty: args[2] as ConstPtr, + // flags: args[3] as libc::c_ulong, + // data: args[4] as Ptr, + // }, + // 166 => Syscall::Umount2 { + // name: args[0] as ConstPtr, + // flags: args[1] as libc::c_int, + // }, // SYS_umount2 + // libc::SYS_swapon => Syscall::Swapon { + // specialfile: args[0] as ConstPtr, + // swap_flags: args[1] as libc::c_int, + // }, + // libc::SYS_swapoff => Syscall::Swapoff { + // specialfile: args[0] as ConstPtr, + // }, + // libc::SYS_reboot => Syscall::Reboot { + // magic1: args[0] as libc::c_int, + // magic2: args[1] as libc::c_int, + // cmd: args[2] as libc::c_uint, + // arg: args[3] as Ptr, + // }, + // libc::SYS_sethostname => Syscall::Sethostname { + // name: args[0] as ConstPtr, + // len: args[1] as libc::c_int, + // }, + // libc::SYS_setdomainname => Syscall::Setdomainname { + // name: args[0] as ConstPtr, + // len: args[1] as libc::c_int, + // }, + // libc::SYS_ioperm => Syscall::Ioperm { + // from: args[0] as libc::c_ulong, + // num: args[1] as libc::c_ulong, + // on: args[2] as libc::c_int, + // }, + // libc::SYS_init_module => Syscall::InitModule { + // umod: args[0] as Ptr, + // len: args[1] as libc::c_ulong, + // uargs: args[2] as ConstPtr, + // }, + // libc::SYS_delete_module => Syscall::DeleteModule { + // name_user: args[0] as ConstPtr, + // flags: args[1] as libc::c_uint, + // }, + // libc::SYS_quotactl => Syscall::Quotactl { + // cmd: args[0] as libc::c_uint, + // special: args[1] as ConstPtr, + // id: args[2] as libc::c_int, + // addr: args[3] as Ptr, + // }, + // libc::SYS_gettid => Syscall::Gettid, + // libc::SYS_readahead => Syscall::Readahead { + // fd: args[0] as libc::c_int, + // offset: args[1] as libc::loff_t, + // count: args[2] as libc::size_t, + // }, + // libc::SYS_setxattr => Syscall::Setxattr { + // path: args[0] as ConstPtr, + // name: args[1] as ConstPtr, + // value: args[2] as ConstPtr, + // size: args[3] as libc::size_t, + // flags: args[4] as libc::c_int, + // }, + // libc::SYS_lsetxattr => Syscall::Lsetxattr { + // path: args[0] as ConstPtr, + // name: args[1] as ConstPtr, + // value: args[2] as ConstPtr, + // size: args[3] as libc::size_t, + // flags: args[4] as libc::c_int, + // }, + // libc::SYS_fsetxattr => Syscall::Fsetxattr { + // fd: args[0] as libc::c_int, + // name: args[1] as ConstPtr, + // value: args[2] as ConstPtr, + // size: args[3] as libc::size_t, + // flags: args[4] as libc::c_int, + // }, + // libc::SYS_getxattr => Syscall::Getxattr { + // path: args[0] as ConstPtr, + // name: args[1] as ConstPtr, + // value: args[2] as Ptr, + // size: args[3] as libc::size_t, + // }, + // libc::SYS_lgetxattr => Syscall::Lgetxattr { + // path: args[0] as ConstPtr, + // name: args[1] as ConstPtr, + // value: args[2] as Ptr, + // size: args[3] as libc::size_t, + // }, + // libc::SYS_fgetxattr => Syscall::Fgetxattr { + // fd: args[0] as libc::c_int, + // name: args[1] as ConstPtr, + // value: args[2] as Ptr, + // size: args[3] as libc::size_t, + // }, + // libc::SYS_listxattr => Syscall::Listxattr { + // path: args[0] as ConstPtr, + // list: args[1] as Ptr, + // size: args[2] as libc::size_t, + // }, + // libc::SYS_llistxattr => Syscall::Llistxattr { + // path: args[0] as ConstPtr, + // list: args[1] as Ptr, + // size: args[2] as libc::size_t, + // }, + // libc::SYS_flistxattr => Syscall::Flistxattr { + // fd: args[0] as libc::c_int, + // list: args[1] as Ptr, + // size: args[2] as libc::size_t, + // }, + // libc::SYS_removexattr => Syscall::Removexattr { + // path: args[0] as ConstPtr, + // name: args[1] as ConstPtr, + // }, + // libc::SYS_lremovexattr => Syscall::Lremovexattr { + // path: args[0] as ConstPtr, + // name: args[1] as ConstPtr, + // }, + // libc::SYS_fremovexattr => Syscall::Fremovexattr { + // fd: args[0] as libc::c_int, + // name: args[1] as ConstPtr, + // }, + // libc::SYS_tkill => Syscall::Tkill { + // pid: args[0] as libc::pid_t, + // sig: args[1] as libc::c_int, + // }, + // libc::SYS_time => Syscall::Time { + // tloc: args[0] as Ptr, + // }, + // libc::SYS_futex => Syscall::Futex { + // uaddr: args[0] as Ptr, + // op: args[1] as libc::c_int, + // val: args[2] as u32, + // utime: args[3] as ConstPtr, + // uaddr2: args[4] as Ptr, + // val3: args[5] as u32, + // }, + // libc::SYS_sched_setaffinity => Syscall::SchedSetaffinity { + // pid: args[0] as libc::pid_t, + // len: args[1] as libc::c_uint, + // user_mask_ptr: args[2] as ConstPtr, + // }, + // libc::SYS_sched_getaffinity => Syscall::SchedGetaffinity { + // pid: args[0] as libc::pid_t, + // len: args[1] as libc::c_uint, + // user_mask_ptr: args[2] as Ptr, + // }, + // libc::SYS_io_setup => Syscall::IoSetup { + // nr_reqs: args[0] as libc::c_uint, + // ctx: args[1] as Ptr, + // }, + // libc::SYS_io_destroy => Syscall::IoDestroy { + // ctx: args[0] as Ptr, + // }, + // libc::SYS_io_getevents => Syscall::IoGetevents { + // ctx_id: args[0] as Ptr, + // min_nr: args[1] as libc::c_long, + // nr: args[2] as libc::c_long, + // events: args[3] as Ptr, + // timeout: args[4] as Ptr, + // }, + // libc::SYS_io_submit => Syscall::IoSubmit { + // ctx: args[0] as Ptr, + // nr: args[1] as libc::c_long, + // iocbpp: args[2] as Ptr>, + // }, + // libc::SYS_io_cancel => Syscall::IoCancel { + // ctx_id: args[0] as Ptr, + // iocb: args[1] as Ptr, + // result: args[2] as Ptr, + // }, + // libc::SYS_epoll_create => Syscall::EpollCreate { + // size: args[0] as libc::c_int, + // }, + // libc::SYS_remap_file_pages => Syscall::RemapFilePages { + // start: args[0] as libc::c_ulong, + // size: args[1] as libc::c_ulong, + // prot: args[2] as libc::c_ulong, + // pgoff: args[3] as libc::c_ulong, + // flags: args[4] as libc::c_ulong, + // }, + // libc::SYS_getdents64 => Syscall::Getdents64 { + // fd: args[0] as libc::c_uint, + // dirent: args[1] as Ptr, + // count: args[2] as libc::c_uint, + // }, + // libc::SYS_set_tid_address => Syscall::SetTidAddress { + // tidptr: args[0] as Ptr, + // }, + // libc::SYS_restart_syscall => Syscall::RestartSyscall, + // libc::SYS_semtimedop => Syscall::Semtimedop { + // semid: args[0] as libc::c_int, + // sops: args[1] as Ptr, + // nsops: args[2] as libc::c_uint, + // timeout: args[3] as ConstPtr, + // }, + // libc::SYS_fadvise64 => Syscall::Fadvise64 { + // fd: args[0] as libc::c_int, + // offset: args[1] as libc::loff_t, + // len: args[2] as libc::size_t, + // advice: args[3] as libc::c_int, + // }, + // libc::SYS_timer_create => Syscall::TimerCreate { + // which_clock: args[0] as libc::clockid_t, + // timer_event_spec: args[1] as Ptr, + // created_timer_id: args[2] as Ptr, + // }, + // libc::SYS_timer_settime => Syscall::TimerSettime { + // timer_id: args[0] as libc::timer_t, + // flags: args[1] as libc::c_int, + // new_setting: args[2] as ConstPtr, + // old_setting: args[3] as Ptr, + // }, + // libc::SYS_timer_gettime => Syscall::TimerGettime { + // timer_id: args[0] as libc::timer_t, + // setting: args[1] as Ptr, + // }, + // libc::SYS_timer_getoverrun => Syscall::TimerGetoverrun { + // timer_id: args[0] as libc::timer_t, + // }, + // libc::SYS_timer_delete => Syscall::TimerDelete { + // timer_id: args[0] as libc::timer_t, + // }, + // libc::SYS_clock_settime => Syscall::ClockSettime { + // which_clock: args[0] as libc::clockid_t, + // tp: args[1] as ConstPtr, + // }, + // libc::SYS_clock_gettime => Syscall::ClockGettime { + // which_clock: args[0] as libc::clockid_t, + // tp: args[1] as Ptr, + // }, + // libc::SYS_clock_getres => Syscall::ClockGetres { + // which_clock: args[0] as libc::clockid_t, + // tp: args[1] as Ptr, + // }, + // libc::SYS_clock_nanosleep => Syscall::ClockNanosleep { + // which_clock: args[0] as libc::clockid_t, + // flags: args[1] as libc::c_int, + // rqtp: args[2] as ConstPtr, + // rmtp: args[3] as Ptr, + // }, + // libc::SYS_exit_group => Syscall::ExitGroup { + // error_code: args[0] as libc::c_int, + // }, + // libc::SYS_epoll_wait => Syscall::EpollWait { + // epfd: args[0] as libc::c_int, + // events: args[1] as Ptr, + // maxevents: args[2] as libc::c_int, + // timeout: args[3] as libc::c_int, + // }, + // libc::SYS_epoll_ctl => Syscall::EpollCtl { + // epfd: args[0] as libc::c_int, + // op: args[1] as libc::c_int, + // fd: args[2] as libc::c_int, + // event: args[3] as Ptr, + // }, + // libc::SYS_tgkill => Syscall::Tgkill { + // tgid: args[0] as libc::pid_t, + // pid: args[1] as libc::pid_t, + // sig: args[2] as libc::c_int, + // }, + // libc::SYS_utimes => Syscall::Utimes { + // filename: args[0] as ConstPtr, + // utimes: args[1] as ConstPtr, + // }, + // libc::SYS_mbind => Syscall::Mbind { + // start: args[0] as libc::c_ulong, + // len: args[1] as libc::c_ulong, + // mode: args[2] as libc::c_ulong, + // nmask: args[3] as ConstPtr, + // maxnode: args[4] as libc::c_ulong, + // flags: args[5] as libc::c_uint, + // }, + // libc::SYS_set_mempolicy => Syscall::SetMempolicy { + // mode: args[0] as libc::c_int, + // nmask: args[1] as ConstPtr, + // maxnode: args[2] as libc::c_ulong, + // }, + // libc::SYS_get_mempolicy => Syscall::GetMempolicy { + // policy: args[0] as Ptr, + // nmask: args[1] as Ptr, + // maxnode: args[2] as libc::c_ulong, + // addr: args[3] as libc::c_ulong, + // flags: args[4] as libc::c_ulong, + // }, + // libc::SYS_mq_open => Syscall::MqOpen { + // name: args[0] as ConstPtr, + // oflag: args[1] as libc::c_int, + // mode: args[2] as libc::mode_t, + // attr: args[3] as Ptr, + // }, + // libc::SYS_mq_unlink => Syscall::MqUnlink { + // name: args[0] as ConstPtr, + // }, + // libc::SYS_mq_timedsend => Syscall::MqTimedsend { + // mqdes: args[0] as libc::mqd_t, + // msg_ptr: args[1] as ConstPtr, + // msg_len: args[2] as libc::size_t, + // msg_prio: args[3] as libc::c_uint, + // abs_timeout: args[4] as ConstPtr, + // }, + // libc::SYS_mq_timedreceive => Syscall::MqTimedreceive { + // mqdes: args[0] as libc::mqd_t, + // msg_ptr: args[1] as Ptr, + // msg_len: args[2] as libc::size_t, + // msg_prio: args[3] as Ptr, + // abs_timeout: args[4] as ConstPtr, + // }, + // libc::SYS_mq_notify => Syscall::MqNotify { + // mqdes: args[0] as libc::mqd_t, + // notification: args[1] as ConstPtr, + // }, + // libc::SYS_mq_getsetattr => Syscall::MqGetsetattr { + // mqdes: args[0] as libc::mqd_t, + // mqstat: args[1] as ConstPtr, + // omqstat: args[2] as Ptr, + // }, + // libc::SYS_kexec_load => Syscall::KexecLoad { + // entry: args[0] as libc::c_ulong, + // nr_segments: args[1] as libc::c_ulong, + // segments: args[2] as Ptr, + // flags: args[3] as libc::c_ulong, + // }, + // libc::SYS_waitid => Syscall::Waitid { + // which: args[0] as libc::c_int, + // pid: args[1] as libc::pid_t, + // infop: args[2] as Ptr, + // options: args[3] as libc::c_int, + // ru: args[4] as Ptr, + // }, + // libc::SYS_add_key => Syscall::AddKey { + // _type: args[0] as ConstPtr, + // _description: args[1] as ConstPtr, + // _payload: args[2] as ConstPtr, + // plen: args[3] as libc::size_t, + // destringid: args[4] as libc::key_t, + // }, + // libc::SYS_request_key => Syscall::RequestKey { + // _type: args[0] as ConstPtr, + // _description: args[1] as ConstPtr, + // _callout_info: args[2] as ConstPtr, + // destringid: args[3] as libc::key_t, + // }, + // libc::SYS_keyctl => Syscall::Keyctl { + // cmd: args[0] as libc::c_int, + // arg2: args[1] as libc::c_ulong, + // arg3: args[2] as libc::c_ulong, + // arg4: args[3] as libc::c_ulong, + // arg5: args[4] as libc::c_ulong, + // }, + // libc::SYS_ioprio_set => Syscall::IoprioSet { + // which: args[0] as libc::c_int, + // who: args[1] as libc::c_int, + // ioprio: args[2] as libc::c_int, + // }, + // libc::SYS_ioprio_get => Syscall::IoprioGet { + // which: args[0] as libc::c_int, + // who: args[1] as libc::c_int, + // }, + // libc::SYS_inotify_init => Syscall::InotifyInit, + // libc::SYS_inotify_add_watch => Syscall::InotifyAddWatch { + // fd: args[0] as libc::c_int, + // path: args[1] as ConstPtr, + // mask: args[2] as u32, + // }, + // libc::SYS_inotify_rm_watch => Syscall::InotifyRmWatch { + // fd: args[0] as libc::c_int, + // wd: args[1] as libc::c_int, + // }, + // libc::SYS_migrate_pages => Syscall::MigratePages { + // pid: args[0] as libc::pid_t, + // maxnode: args[1] as libc::c_ulong, + // from: args[2] as ConstPtr, + // to: args[3] as ConstPtr, + // }, + libc::SYS_openat => Syscall::Openat { + dfd: args[0] as libc::c_int, + filename: StrRef::new(args[1]), + flags: args[2] as libc::c_int, + mode: args[3] as libc::mode_t, + }, + // libc::SYS_mkdirat => Syscall::Mkdirat { + // dfd: args[0] as libc::c_int, + // pathname: args[1] as ConstPtr, + // mode: args[2] as libc::mode_t, + // }, + // libc::SYS_mknodat => Syscall::Mknodat { + // dfd: args[0] as libc::c_int, + // filename: args[1] as ConstPtr, + // mode: args[2] as libc::mode_t, + // dev: args[3] as libc::c_uint, + // }, + // libc::SYS_fchownat => Syscall::Fchownat { + // dfd: args[0] as libc::c_int, + // filename: args[1] as ConstPtr, + // user: args[2] as libc::uid_t, + // group: args[3] as libc::gid_t, + // flag: args[4] as libc::c_int, + // }, + // libc::SYS_futimesat => Syscall::Futimesat { + // dfd: args[0] as libc::c_int, + // filename: args[1] as ConstPtr, + // utimes: args[2] as ConstPtr, + // }, + // libc::SYS_newfstatat => Syscall::Newfstatat { + // dfd: args[0] as libc::c_int, + // filename: args[1] as ConstPtr, + // statbuf: args[2] as Ptr, + // flag: args[3] as libc::c_int, + // }, + // libc::SYS_unlinkat => Syscall::Unlinkat { + // dfd: args[0] as libc::c_int, + // pathname: args[1] as ConstPtr, + // flag: args[2] as libc::c_int, + // }, + // libc::SYS_renameat => Syscall::Renameat { + // olddfd: args[0] as libc::c_int, + // oldname: args[1] as ConstPtr, + // newdfd: args[2] as libc::c_int, + // newname: args[3] as ConstPtr, + // }, + // libc::SYS_linkat => Syscall::Linkat { + // olddfd: args[0] as libc::c_int, + // oldname: args[1] as ConstPtr, + // newdfd: args[2] as libc::c_int, + // newname: args[3] as ConstPtr, + // flags: args[4] as libc::c_int, + // }, + // libc::SYS_symlinkat => Syscall::Symlinkat { + // oldname: args[0] as ConstPtr, + // newdfd: args[1] as libc::c_int, + // newname: args[2] as ConstPtr, + // }, + // libc::SYS_readlinkat => Syscall::Readlinkat { + // dfd: args[0] as libc::c_int, + // path: args[1] as ConstPtr, + // buf: args[2] as Ptr, + // bufsiz: args[3] as libc::c_int, + // }, + // libc::SYS_fchmodat => Syscall::Fchmodat { + // dfd: args[0] as libc::c_int, + // filename: args[1] as ConstPtr, + // mode: args[2] as libc::mode_t, + // }, + // libc::SYS_faccessat => Syscall::Faccessat { + // dfd: args[0] as libc::c_int, + // filename: args[1] as ConstPtr, + // mode: args[2] as libc::c_int, + // }, + // libc::SYS_pselect6 => Syscall::Pselect6 { + // n: args[0] as libc::c_int, + // inp: args[1] as Ptr, + // outp: args[2] as Ptr, + // exp: args[3] as Ptr, + // tsp: args[4] as Ptr, + // sig: args[5] as Ptr, + // }, + // libc::SYS_ppoll => Syscall::Ppoll { + // fds: args[0] as Ptr, + // nfds: args[1] as libc::c_uint, + // tsp: args[2] as ConstPtr, + // sset: args[3] as ConstPtr, + // sigsetsize: args[4] as libc::size_t, + // }, + // libc::SYS_unshare => Syscall::Unshare { + // unshare_flags: args[0] as libc::c_ulong, + // }, + // libc::SYS_set_robust_list => Syscall::SetRobustList { + // head: args[0] as Ptr, + // len: args[1] as libc::size_t, + // }, + // libc::SYS_get_robust_list => Syscall::GetRobustList { + // pid: args[0] as libc::c_int, + // head_ptr: args[1] as Ptr>, + // len_ptr: args[2] as Ptr, + // }, + // libc::SYS_splice => Syscall::Splice { + // fd_in: args[0] as libc::c_int, + // off_in: args[1] as Ptr, + // fd_out: args[2] as libc::c_int, + // off_out: args[3] as Ptr, + // len: args[4] as libc::size_t, + // flags: args[5] as libc::c_uint, + // }, + // libc::SYS_tee => Syscall::Tee { + // fdin: args[0] as libc::c_int, + // fdout: args[1] as libc::c_int, + // len: args[2] as libc::size_t, + // flags: args[3] as libc::c_uint, + // }, + // libc::SYS_sync_file_range => Syscall::SyncFileRange { + // fd: args[0] as libc::c_int, + // offset: args[1] as libc::loff_t, + // nbytes: args[2] as libc::loff_t, + // flags: args[3] as libc::c_uint, + // }, + // libc::SYS_vmsplice => Syscall::Vmsplice { + // fd: args[0] as libc::c_int, + // iov: args[1] as ConstPtr, + // nr_segs: args[2] as libc::c_ulong, + // flags: args[3] as libc::c_uint, + // }, + // libc::SYS_move_pages => Syscall::MovePages { + // pid: args[0] as libc::pid_t, + // nr_pages: args[1] as libc::c_ulong, + // pages: args[2] as Ptr>, + // nodes: args[3] as ConstPtr, + // status: args[4] as Ptr, + // flags: args[5] as libc::c_int, + // }, + // libc::SYS_utimensat => Syscall::Utimensat { + // dfd: args[0] as libc::c_int, + // filename: args[1] as ConstPtr, + // utimes: args[2] as ConstPtr, + // flags: args[3] as libc::c_int, + // }, + // libc::SYS_epoll_pwait => Syscall::EpollPwait { + // epfd: args[0] as libc::c_int, + // events: args[1] as Ptr, + // maxevents: args[2] as libc::c_int, + // timeout: args[3] as libc::c_int, + // sigmask: args[4] as ConstPtr, + // sigsetsize: args[5] as libc::size_t, + // }, + // libc::SYS_signalfd => Syscall::Signalfd { + // ufd: args[0] as libc::c_int, + // user_mask: args[1] as Ptr, + // sizemask: args[2] as libc::size_t, + // }, + // libc::SYS_timerfd_create => Syscall::TimerfdCreate { + // clockid: args[0] as libc::c_int, + // flags: args[1] as libc::c_int, + // }, + // libc::SYS_eventfd => Syscall::Eventfd { + // count: args[0] as libc::c_uint, + // }, + // libc::SYS_fallocate => Syscall::Fallocate { + // fd: args[0] as libc::c_int, + // mode: args[1] as libc::c_int, + // offset: args[2] as libc::loff_t, + // len: args[3] as libc::loff_t, + // }, + // libc::SYS_timerfd_settime => Syscall::TimerfdSettime { + // ufd: args[0] as libc::c_int, + // flags: args[1] as libc::c_int, + // utmr: args[2] as ConstPtr, + // otmr: args[3] as Ptr, + // }, + // libc::SYS_timerfd_gettime => Syscall::TimerfdGettime { + // ufd: args[0] as libc::c_int, + // otmr: args[1] as Ptr, + // }, + // libc::SYS_accept4 => Syscall::Accept4 { + // fd: args[0] as libc::c_int, + // addr: args[1] as Ptr, + // len: args[2] as Ptr, + // flags: args[3] as libc::c_int, + // }, + // libc::SYS_signalfd4 => Syscall::Signalfd4 { + // ufd: args[0] as libc::c_int, + // user_mask: args[1] as Ptr, + // sizemask: args[2] as libc::size_t, + // flags: args[3] as libc::c_int, + // }, + // libc::SYS_eventfd2 => Syscall::Eventfd2 { + // count: args[0] as libc::c_uint, + // flags: args[1] as libc::c_int, + // }, + // libc::SYS_epoll_create1 => Syscall::EpollCreate1 { + // flags: args[0] as libc::c_int, + // }, + // libc::SYS_dup3 => Syscall::Dup3 { + // oldfd: args[0] as libc::c_uint, + // newfd: args[1] as libc::c_uint, + // flags: args[2] as libc::c_int, + // }, + // libc::SYS_pipe2 => Syscall::Pipe2 { + // fildes: args[0] as Ptr, + // flags: args[1] as libc::c_int, + // }, + // libc::SYS_inotify_init1 => Syscall::InotifyInit1 { + // flags: args[0] as libc::c_int, + // }, + // libc::SYS_preadv => Syscall::Preadv { + // fd: args[0] as libc::c_ulong, + // vec: args[1] as ConstPtr, + // vlen: args[2] as libc::c_ulong, + // pos_l: args[3] as libc::c_ulong, + // pos_h: args[4] as libc::c_ulong, + // }, + // libc::SYS_pwritev => Syscall::Pwritev { + // fd: args[0] as libc::c_ulong, + // vec: args[1] as ConstPtr, + // vlen: args[2] as libc::c_ulong, + // pos_l: args[3] as libc::c_ulong, + // pos_h: args[4] as libc::c_ulong, + // }, + // libc::SYS_rt_tgsigqueueinfo => Syscall::RtTgsigqueueinfo { + // tgid: args[0] as libc::pid_t, + // pid: args[1] as libc::pid_t, + // sig: args[2] as libc::c_int, + // uinfo: args[3] as Ptr, + // }, + // libc::SYS_perf_event_open => Syscall::PerfEventOpen { + // attr_uptr: args[0] as Ptr, + // pid: args[1] as libc::pid_t, + // cpu: args[2] as libc::c_int, + // group_fd: args[3] as libc::c_int, + // flags: args[4] as libc::c_ulong, + // }, + // libc::SYS_recvmmsg => Syscall::Recvmmsg { + // fd: args[0] as libc::c_int, + // msg: args[1] as Ptr, + // vlen: args[2] as libc::c_uint, + // flags: args[3] as libc::c_uint, + // timeout: args[4] as Ptr, + // }, + // libc::SYS_fanotify_init => Syscall::FanotifyInit { + // flags: args[0] as libc::c_uint, + // event_f_flags: args[1] as libc::c_uint, + // }, + // libc::SYS_fanotify_mark => Syscall::FanotifyMark { + // fanotify_fd: args[0] as libc::c_int, + // flags: args[1] as libc::c_uint, + // mask: args[2] as u64, + // fd: args[3] as libc::c_int, + // pathname: args[4] as ConstPtr, + // }, + // libc::SYS_prlimit64 => Syscall::Prlimit64 { + // pid: args[0] as libc::pid_t, + // resource: args[1] as libc::c_uint, + // new_rlim: args[2] as ConstPtr, + // old_rlim: args[3] as Ptr, + // }, + // libc::SYS_name_to_handle_at => Syscall::NameToHandleAt { + // dfd: args[0] as libc::c_int, + // name: args[1] as ConstPtr, + // handle: args[2] as Ptr, + // mnt_id: args[3] as Ptr, + // flag: args[4] as libc::c_int, + // }, + // libc::SYS_open_by_handle_at => Syscall::OpenByHandleAt { + // mountdirfd: args[0] as libc::c_int, + // handle: args[1] as Ptr, + // flags: args[2] as libc::c_int, + // }, + // libc::SYS_clock_adjtime => Syscall::ClockAdjtime { + // which_clock: args[0] as libc::clockid_t, + // tx: args[1] as Ptr, + // }, + // libc::SYS_syncfs => Syscall::Syncfs { + // fd: args[0] as libc::c_int, + // }, + // libc::SYS_sendmmsg => Syscall::Sendmmsg { + // fd: args[0] as libc::c_int, + // msg: args[1] as Ptr, + // vlen: args[2] as libc::c_uint, + // flags: args[3] as libc::c_uint, + // }, + // libc::SYS_setns => Syscall::Setns { + // fd: args[0] as libc::c_int, + // nstype: args[1] as libc::c_int, + // }, + // libc::SYS_getcpu => Syscall::Getcpu { + // cpu: args[0] as Ptr, + // node: args[1] as Ptr, + // cache: args[2] as Ptr, + // }, + // libc::SYS_process_vm_readv => Syscall::ProcessVmReadv { + // pid: args[0] as libc::pid_t, + // lvec: args[1] as ConstPtr, + // liovcnt: args[2] as libc::c_ulong, + // rvec: args[3] as ConstPtr, + // riovcnt: args[4] as libc::c_ulong, + // flags: args[5] as libc::c_ulong, + // }, + // libc::SYS_process_vm_writev => Syscall::ProcessVmWritev { + // pid: args[0] as libc::pid_t, + // lvec: args[1] as ConstPtr, + // liovcnt: args[2] as libc::c_ulong, + // rvec: args[3] as ConstPtr, + // riovcnt: args[4] as libc::c_ulong, + // flags: args[5] as libc::c_ulong, + // }, + // libc::SYS_kcmp => Syscall::Kcmp { + // pid1: args[0] as libc::pid_t, + // pid2: args[1] as libc::pid_t, + // ty: args[2] as libc::c_int, + // idx1: args[3] as libc::c_ulong, + // idx2: args[4] as libc::c_ulong, + // }, + // libc::SYS_finit_module => Syscall::FinitModule { + // fd: args[0] as libc::c_int, + // uargs: args[1] as ConstPtr, + // flags: args[2] as libc::c_int, + // }, + // libc::SYS_sched_setattr => Syscall::SchedSetattr { + // pid: args[0] as libc::pid_t, + // attr: args[1] as Ptr, + // flags: args[2] as libc::c_uint, + // }, + // libc::SYS_sched_getattr => Syscall::SchedGetattr { + // pid: args[0] as libc::pid_t, + // attr: args[1] as Ptr, + // size: args[2] as libc::c_uint, + // flags: args[3] as libc::c_uint, + // }, + // libc::SYS_renameat2 => Syscall::Renameat2 { + // olddfd: args[0] as libc::c_int, + // oldname: args[1] as ConstPtr, + // newdfd: args[2] as libc::c_int, + // newname: args[3] as ConstPtr, + // flags: args[4] as libc::c_uint, + // }, + // libc::SYS_seccomp => Syscall::Seccomp { + // op: args[0] as libc::c_uint, + // flags: args[1] as libc::c_uint, + // uargs: args[2] as Ptr, + // }, + // libc::SYS_getrandom => Syscall::Getrandom { + // buf: args[0] as Ptr, + // count: args[1] as libc::size_t, + // flags: args[2] as libc::c_uint, + // }, + // libc::SYS_memfd_create => Syscall::MemfdCreate { + // uname_ptr: args[0] as ConstPtr, + // flags: args[1] as libc::c_uint, + // }, + // libc::SYS_kexec_file_load => Syscall::KexecFileLoad { + // kernel_fd: args[0] as libc::c_int, + // initrd_fd: args[1] as libc::c_int, + // cmdline_len: args[2] as libc::c_ulong, + // cmdline_ptr: args[3] as ConstPtr, + // flags: args[4] as libc::c_ulong, + // }, + // libc::SYS_bpf => Syscall::Bpf { + // cmd: args[0] as libc::c_int, + // attr: args[1] as Ptr, + // size: args[2] as libc::c_uint, + // }, + // libc::SYS_execveat => Syscall::Execveat { + // dfd: args[0] as libc::c_int, + // filename: args[1] as ConstPtr, + // argv: args[2] as ConstPtr>, + // envp: args[3] as ConstPtr>, + // flags: args[4] as libc::c_int, + // }, + // libc::SYS_userfaultfd => Syscall::Userfaultfd { + // flags: args[0] as libc::c_int, + // }, + // libc::SYS_membarrier => Syscall::Membarrier { + // cmd: args[0] as libc::c_int, + // flags: args[1] as libc::c_uint, + // }, + // libc::SYS_mlock2 => Syscall::Mlock2 { + // start: args[0] as libc::c_ulong, + // len: args[1] as libc::size_t, + // flags: args[2] as libc::c_int, + // }, + // libc::SYS_copy_file_range => Syscall::CopyFileRange { + // fd_in: args[0] as libc::c_int, + // off_in: args[1] as Ptr, + // fd_out: args[2] as libc::c_int, + // off_out: args[3] as Ptr, + // len: args[4] as libc::size_t, + // flags: args[5] as libc::c_uint, + // }, + // libc::SYS_preadv2 => Syscall::Preadv2 { + // fd: args[0] as libc::c_ulong, + // vec: args[1] as ConstPtr, + // vlen: args[2] as libc::c_ulong, + // pos_l: args[3] as libc::c_ulong, + // pos_h: args[4] as libc::c_ulong, + // flags: args[5] as libc::c_int, + // }, + // libc::SYS_pwritev2 => Syscall::Pwritev2 { + // fd: args[0] as libc::c_ulong, + // vec: args[1] as ConstPtr, + // vlen: args[2] as libc::c_ulong, + // pos_l: args[3] as libc::c_ulong, + // pos_h: args[4] as libc::c_ulong, + // flags: args[5] as libc::c_int, + // }, + // libc::SYS_pkey_mprotect => Syscall::PkeyMprotect { + // start: args[0] as libc::c_ulong, + // len: args[1] as libc::size_t, + // prot: args[2] as libc::c_ulong, + // pkey: args[3] as libc::c_int, + // }, + // libc::SYS_pkey_alloc => Syscall::PkeyAlloc { + // flags: args[0] as libc::c_ulong, + // init_val: args[1] as libc::c_ulong, + // }, + // libc::SYS_pkey_free => Syscall::PkeyFree { + // pkey: args[0] as libc::c_int, + // }, + // libc::SYS_statx => Syscall::Statx { + // dfd: args[0] as libc::c_int, + // path: args[1] as ConstPtr, + // flags: args[2] as libc::c_uint, + // mask: args[3] as libc::c_uint, + // buffer: args[4] as Ptr, + // }, + // libc::SYS_rseq => Syscall::Rseq { + // rseq: args[0] as Ptr, + // rseq_len: args[1] as u32, + // flags: args[2] as libc::c_int, + // sig: args[3] as u32, + // }, + // libc::SYS_pidfd_send_signal => Syscall::PidfdSendSignal { + // pidfd: args[0] as libc::c_int, + // sig: args[1] as libc::c_int, + // info: args[2] as Ptr, + // flags: args[3] as libc::c_uint, + // }, + // libc::SYS_io_uring_setup => Syscall::IoUringSetup { + // entries: args[0] as u32, + // p: args[1] as Ptr, + // }, + // libc::SYS_io_uring_enter => Syscall::IoUringEnter { + // fd: args[0] as libc::c_uint, + // to_submit: args[1] as u32, + // min_complete: args[2] as u32, + // flags: args[3] as u32, + // argp: args[4] as ConstPtr, + // argsz: args[5] as libc::size_t, + // }, + // libc::SYS_io_uring_register => Syscall::IoUringRegister { + // fd: args[0] as libc::c_uint, + // op: args[1] as libc::c_uint, + // arg: args[2] as Ptr, + // nr_args: args[3] as libc::c_uint, + // }, + // libc::SYS_open_tree => Syscall::OpenTree { + // dfd: args[0] as libc::c_int, + // path: args[1] as ConstPtr, + // flags: args[2] as libc::c_uint, + // }, + // libc::SYS_move_mount => Syscall::MoveMount { + // from_dfd: args[0] as libc::c_int, + // from_path: args[1] as ConstPtr, + // to_dfd: args[2] as libc::c_int, + // to_path: args[3] as ConstPtr, + // ms_flags: args[4] as libc::c_uint, + // }, + // libc::SYS_fsopen => Syscall::Fsopen { + // fs_name: args[0] as ConstPtr, + // flags: args[1] as libc::c_uint, + // }, + // libc::SYS_fsconfig => Syscall::Fsconfig { + // fs_fd: args[0] as libc::c_int, + // cmd: args[1] as libc::c_uint, + // key: args[2] as ConstPtr, + // value: args[3] as ConstPtr, + // aux: args[4] as libc::c_int, + // }, + // libc::SYS_fsmount => Syscall::Fsmount { + // fs_fd: args[0] as libc::c_int, + // flags: args[1] as libc::c_uint, + // ms_flags: args[2] as libc::c_uint, + // }, + // libc::SYS_fspick => Syscall::Fspick { + // dfd: args[0] as libc::c_int, + // path: args[1] as ConstPtr, + // flags: args[2] as libc::c_uint, + // }, + // libc::SYS_pidfd_open => Syscall::PidfdOpen { + // pid: args[0] as libc::pid_t, + // flags: args[1] as libc::c_uint, + // }, + // libc::SYS_clone3 => Syscall::Clone3 { + // uargs: args[0] as Ptr, + // size: args[1] as libc::size_t, + // }, + // libc::SYS_close_range => Syscall::CloseRange { + // fd: args[0] as libc::c_uint, + // max_fd: args[1] as libc::c_uint, + // flags: args[2] as libc::c_uint, + // }, + // libc::SYS_openat2 => Syscall::Openat2 { + // dfd: args[0] as libc::c_int, + // filename: args[1] as ConstPtr, + // how: args[2] as Ptr, + // size: args[3] as libc::size_t, + // }, + // libc::SYS_pidfd_getfd => Syscall::PidfdGetfd { + // pidfd: args[0] as libc::c_int, + // fd: args[1] as libc::c_int, + // flags: args[2] as libc::c_uint, + // }, + // libc::SYS_faccessat2 => Syscall::Faccessat2 { + // dfd: args[0] as libc::c_int, + // filename: args[1] as ConstPtr, + // mode: args[2] as libc::c_int, + // flags: args[3] as libc::c_int, + // }, + // libc::SYS_process_madvise => Syscall::ProcessMadvise { + // pidfd: args[0] as libc::c_int, + // vec: args[1] as ConstPtr, + // vlen: args[2] as libc::size_t, + // behavior: args[3] as libc::c_int, + // flags: args[4] as libc::c_uint, + // }, + // libc::SYS_epoll_pwait2 => Syscall::EpollPwait2 { + // epfd: args[0] as libc::c_int, + // events: args[1] as Ptr, + // maxevents: args[2] as libc::c_int, + // timeout: args[3] as ConstPtr, + // sigmask: args[4] as ConstPtr, + // sigsetsize: args[5] as libc::size_t, + // }, + // libc::SYS_mount_setattr => Syscall::MountSetattr { + // dfd: args[0] as libc::c_int, + // path: args[1] as ConstPtr, + // flags: args[2] as libc::c_uint, + // uattr: args[3] as Ptr, + // usize: args[4] as libc::size_t, + // }, + // libc::SYS_quotactl_fd => Syscall::QuotactlFd { + // fd: args[0] as libc::c_uint, + // cmd: args[1] as libc::c_uint, + // id: args[2] as libc::c_int, + // addr: args[3] as Ptr, + // }, + // libc::SYS_landlock_create_ruleset => Syscall::LandlockCreateRuleset { + // attr: args[0] as ConstPtr, + // size: args[1] as libc::size_t, + // flags: args[2] as u32, + // }, + // libc::SYS_landlock_add_rule => Syscall::LandlockAddRule { + // ruleset_fd: args[0] as libc::c_int, + // rule_type: args[1] as libc::c_int, + // rule_attr: args[2] as ConstPtr, + // flags: args[3] as u32, + // }, + // libc::SYS_landlock_restrict_self => Syscall::LandlockRestrictSelf { + // ruleset_fd: args[0] as libc::c_int, + // flags: args[1] as u32, + // }, + // libc::SYS_memfd_secret => Syscall::MemfdSecret { + // flags: args[0] as libc::c_uint, + // }, + // libc::SYS_process_mrelease => Syscall::ProcessMrelease { + // pidfd: args[0] as libc::c_int, + // flags: args[1] as libc::c_uint, + // }, + // libc::SYS_futex_waitv => Syscall::FutexWaitv { + // waiters: args[0] as Ptr, + // nr_futexes: args[1] as libc::c_uint, + // flags: args[2] as libc::c_uint, + // timeout: args[3] as Ptr, + // clockid: args[4] as libc::clockid_t, + // }, + // libc::SYS_set_mempolicy_home_node => Syscall::SetMempolicyHomeNode { + // start: args[0] as libc::c_ulong, + // len: args[1] as libc::c_ulong, + // home_node: args[2] as libc::c_ulong, + // flags: args[3] as libc::c_ulong, + // }, + // // Add other syscalls here... + // _ => return Err("Unknown or unimplemented syscall number."), + _ => Syscall::Unimplemented(num), + }; + + Ok(s) + } +} diff --git a/syscall_lib/src/syscall/exec.rs b/syscall_lib/src/syscall/exec.rs new file mode 100644 index 0000000..2f2fc08 --- /dev/null +++ b/syscall_lib/src/syscall/exec.rs @@ -0,0 +1,710 @@ +use crate::{AsPtr, Syscall}; +use syscaller::{syscall0, syscall1, syscall2, syscall3, syscall4, syscall5, syscall6}; + +// fn syscall0(number: isize) -> isize { +// unsafe { syscaller::syscall0(number as usize) } +// } + +// fn syscall1(number: isize, arg0: isize) -> isize { +// unsafe { syscaller::syscall1(number as usize, arg0 as usize) } +// } + +// fn syscall2(number: isize, arg0: isize, arg1: isize) -> isize { +// unsafe { syscaller::syscall2(number as usize, arg0 as usize, arg1 as usize) } +// } + +// fn syscall3(number: isize, arg0: isize, arg1: isize, arg2: isize) -> isize { +// unsafe { syscaller::syscall3(number as usize, arg0 as usize, arg1 as usize, arg2 as usize) } +// } + +// fn syscall4(number: isize, arg0: isize, arg1: isize, arg2: isize, arg3: isize) -> isize { +// unsafe { +// syscaller::syscall4( +// number as usize, +// arg0 as usize, +// arg1 as usize, +// arg2 as usize, +// arg3 as usize, +// ) +// } +// } + +// fn syscall5( +// number: isize, +// arg0: isize, +// arg1: isize, +// arg2: isize, +// arg3: isize, +// arg4: isize, +// ) -> isize { +// unsafe { +// syscaller::syscall5( +// number as usize, +// arg0 as usize, +// arg1 as usize, +// arg2 as usize, +// arg3 as usize, +// arg4 as usize, +// ) +// } +// } + +// fn syscall6( +// number: isize, +// arg0: isize, +// arg1: isize, +// arg2: isize, +// arg3: isize, +// arg4: isize, +// arg5: isize, +// ) -> isize { +// unsafe { +// syscaller::syscall6( +// number as usize, +// arg0 as usize, +// arg1 as usize, +// arg2 as usize, +// arg3 as usize, +// arg4 as usize, +// arg5 as usize, +// ) +// } +// } + +use libc::{c_long, c_ulong}; + +// The Syscall enum and type aliases from the previous response are assumed to be present here. +#[allow(unused_unsafe, unsafe_op_in_unsafe_fn)] +impl Syscall { + pub unsafe fn execute_syscall(&self) -> isize { + match self { + Syscall::Read { fd, buf, len } => syscall3( + libc::SYS_read as usize, + *fd as usize, + buf.as_ptr(), + *len as usize, + ), + Syscall::Write { fd, buf, len } => syscall3( + libc::SYS_write as usize, + *fd as usize, + buf.as_ptr(), + *len as usize, + ), + Syscall::Open { path, flags, mode } => syscall3( + libc::SYS_read as usize, + path.as_ptr(), + *flags as usize, + *mode as usize, + ), + Syscall::Close { fd } => syscall1(libc::SYS_read as usize, *fd as usize), + Syscall::Stat { path, statbuf } => { + syscall2(libc::SYS_stat as usize, path.as_ptr(), statbuf.as_ptr()) + } + Syscall::Fstat { fd, statbuf } => { + syscall2(libc::SYS_stat as usize, *fd as usize, statbuf.as_ptr()) + } + // Syscall::Fstat(arg0, arg1) => unsafe { syscall2(5, arg0, arg1) }, + // Syscall::Lstat(arg0, arg1) => unsafe { syscall2(6, arg0, arg1) }, + // Syscall::Poll(arg0, arg1, arg2) => unsafe { syscall3(7, arg0, arg1, arg2) }, + // Syscall::Lseek(arg0, arg1, arg2) => unsafe { syscall3(8, arg0, arg1, arg2) }, + Syscall::Mmap { + addr, + len, + prot, + flags, + fd, + offset, + } => syscall6( + libc::SYS_mmap as usize, + addr.as_ptr(), + *len as usize, + *prot as usize, + *flags as usize, + *fd as usize, + *offset as usize, + ), + // Syscall::Mmap(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { + // syscall6(9, arg0, arg1, arg2, arg3, arg4, arg5) + // }, + // Syscall::Mprotect(arg0, arg1, arg2) => unsafe { syscall3(10, arg0, arg1, arg2) }, + // Syscall::Munmap(arg0, arg1) => unsafe { syscall2(11, arg0, arg1) }, + // Syscall::Brk(arg0) => unsafe { syscall1(12, arg0) }, + // Syscall::RtSigaction(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(13, arg0, arg1, arg2, arg3) + // }, + // Syscall::RtSigprocmask(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(14, arg0, arg1, arg2, arg3) + // }, + // Syscall::RtSigreturn => unsafe { syscall0(15) }, + // Syscall::Ioctl(arg0, arg1, arg2) => unsafe { syscall3(16, arg0, arg1, arg2) }, + // Syscall::Pread64(arg0, arg1, arg2, arg3) => unsafe { syscall4(17, arg0, arg1, arg2, arg3) }, + // Syscall::Pwrite64(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(18, arg0, arg1, arg2, arg3) + // }, + // Syscall::Readv(arg0, arg1, arg2) => unsafe { syscall3(19, arg0, arg1, arg2) }, + // Syscall::Writev(arg0, arg1, arg2) => unsafe { syscall3(20, arg0, arg1, arg2) }, + // Syscall::Access(arg0, arg1) => unsafe { syscall2(21, arg0, arg1) }, + // Syscall::Pipe(arg0) => unsafe { syscall1(22, arg0) }, + // Syscall::Select(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(23, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::SchedYield => unsafe { syscall0(24) }, + // Syscall::Mremap(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(25, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Msync(arg0, arg1, arg2) => unsafe { syscall3(26, arg0, arg1, arg2) }, + // Syscall::Mincore(arg0, arg1, arg2) => unsafe { syscall3(27, arg0, arg1, arg2) }, + // Syscall::Madvise(arg0, arg1, arg2) => unsafe { syscall3(28, arg0, arg1, arg2) }, + // Syscall::Shmget(arg0, arg1, arg2) => unsafe { syscall3(29, arg0, arg1, arg2) }, + // Syscall::Shmat(arg0, arg1, arg2) => unsafe { syscall3(30, arg0, arg1, arg2) }, + // Syscall::Shmctl(arg0, arg1, arg2) => unsafe { syscall3(31, arg0, arg1, arg2) }, + // Syscall::Dup(arg0) => unsafe { syscall1(32, arg0) }, + // Syscall::Dup2(arg0, arg1) => unsafe { syscall2(33, arg0, arg1) }, + // Syscall::Pause => unsafe { syscall0(34) }, + // Syscall::Nanosleep(arg0, arg1) => unsafe { syscall2(35, arg0, arg1) }, + // Syscall::Getitimer(arg0, arg1) => unsafe { syscall2(36, arg0, arg1) }, + // Syscall::Alarm(arg0) => unsafe { syscall1(37, arg0) }, + // Syscall::Setitimer(arg0, arg1, arg2) => unsafe { syscall3(38, arg0, arg1, arg2) }, + // Syscall::Getpid => unsafe { syscall0(39) }, + // Syscall::Sendfile(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(40, arg0, arg1, arg2, arg3) + // }, + // Syscall::Socket(arg0, arg1, arg2) => unsafe { syscall3(41, arg0, arg1, arg2) }, + // Syscall::Connect(arg0, arg1, arg2) => unsafe { syscall3(42, arg0, arg1, arg2) }, + // Syscall::Accept(arg0, arg1, arg2) => unsafe { syscall3(43, arg0, arg1, arg2) }, + // Syscall::Sendto(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { + // syscall6(44, arg0, arg1, arg2, arg3, arg4, arg5) + // }, + // Syscall::Recvfrom(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { + // syscall6(45, arg0, arg1, arg2, arg3, arg4, arg5) + // }, + // Syscall::Sendmsg(arg0, arg1, arg2) => unsafe { syscall3(46, arg0, arg1, arg2) }, + // Syscall::Recvmsg(arg0, arg1, arg2) => unsafe { syscall3(47, arg0, arg1, arg2) }, + // Syscall::Shutdown(arg0, arg1) => unsafe { syscall2(48, arg0, arg1) }, + // Syscall::Bind(arg0, arg1, arg2) => unsafe { syscall3(49, arg0, arg1, arg2) }, + // Syscall::Listen(arg0, arg1) => unsafe { syscall2(50, arg0, arg1) }, + // Syscall::Getsockname(arg0, arg1, arg2) => unsafe { syscall3(51, arg0, arg1, arg2) }, + // Syscall::Getpeername(arg0, arg1, arg2) => unsafe { syscall3(52, arg0, arg1, arg2) }, + // Syscall::Socketpair(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(53, arg0, arg1, arg2, arg3) + // }, + // Syscall::Setsockopt(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(54, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Getsockopt(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(55, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Clone(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(56, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Fork => unsafe { syscall0(57) }, + // Syscall::Vfork => unsafe { syscall0(58) }, + // Syscall::Execve(arg0, arg1, arg2) => unsafe { syscall3(59, arg0, arg1, arg2) }, + // Syscall::Exit(arg0) => unsafe { syscall1(60, arg0) }, + // Syscall::Wait4(arg0, arg1, arg2, arg3) => unsafe { syscall4(61, arg0, arg1, arg2, arg3) }, + // Syscall::Kill(arg0, arg1) => unsafe { syscall2(62, arg0, arg1) }, + // Syscall::Uname(arg0) => unsafe { syscall1(63, arg0) }, + // Syscall::Semget(arg0, arg1, arg2) => unsafe { syscall3(64, arg0, arg1, arg2) }, + // Syscall::Semop(arg0, arg1, arg2) => unsafe { syscall3(65, arg0, arg1, arg2) }, + // Syscall::Semctl(arg0, arg1, arg2, arg3) => unsafe { syscall4(66, arg0, arg1, arg2, arg3) }, + // Syscall::Shmdt(arg0) => unsafe { syscall1(67, arg0) }, + // Syscall::Msgget(arg0, arg1) => unsafe { syscall2(68, arg0, arg1) }, + // Syscall::Msgsnd(arg0, arg1, arg2, arg3) => unsafe { syscall4(69, arg0, arg1, arg2, arg3) }, + // Syscall::Msgrcv(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(70, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Msgctl(arg0, arg1, arg2) => unsafe { syscall3(71, arg0, arg1, arg2) }, + // Syscall::Fcntl(arg0, arg1, arg2) => unsafe { syscall3(72, arg0, arg1, arg2) }, + // Syscall::Flock(arg0, arg1) => unsafe { syscall2(73, arg0, arg1) }, + // Syscall::Fsync(arg0) => unsafe { syscall1(74, arg0) }, + // Syscall::Fdatasync(arg0) => unsafe { syscall1(75, arg0) }, + // Syscall::Truncate(arg0, arg1) => unsafe { syscall2(76, arg0, arg1) }, + // Syscall::Ftruncate(arg0, arg1) => unsafe { syscall2(77, arg0, arg1) }, + // Syscall::Getdents(arg0, arg1, arg2) => unsafe { syscall3(78, arg0, arg1, arg2) }, + // Syscall::Getcwd(arg0, arg1) => unsafe { syscall2(79, arg0, arg1) }, + // Syscall::Chdir(arg0) => unsafe { syscall1(80, arg0) }, + // Syscall::Fchdir(arg0) => unsafe { syscall1(81, arg0) }, + // Syscall::Rename(arg0, arg1) => unsafe { syscall2(82, arg0, arg1) }, + // Syscall::Mkdir(arg0, arg1) => unsafe { syscall2(83, arg0, arg1) }, + // Syscall::Rmdir(arg0) => unsafe { syscall1(84, arg0) }, + // Syscall::Creat(arg0, arg1) => unsafe { syscall2(85, arg0, arg1) }, + // Syscall::Link(arg0, arg1) => unsafe { syscall2(86, arg0, arg1) }, + // Syscall::Unlink(arg0) => unsafe { syscall1(87, arg0) }, + // Syscall::Symlink(arg0, arg1) => unsafe { syscall2(88, arg0, arg1) }, + // Syscall::Readlink(arg0, arg1, arg2) => unsafe { syscall3(89, arg0, arg1, arg2) }, + // Syscall::Chmod(arg0, arg1) => unsafe { syscall2(90, arg0, arg1) }, + // Syscall::Fchmod(arg0, arg1) => unsafe { syscall2(91, arg0, arg1) }, + // Syscall::Chown(arg0, arg1, arg2) => unsafe { syscall3(92, arg0, arg1, arg2) }, + // Syscall::Fchown(arg0, arg1, arg2) => unsafe { syscall3(93, arg0, arg1, arg2) }, + // Syscall::Lchown(arg0, arg1, arg2) => unsafe { syscall3(94, arg0, arg1, arg2) }, + // Syscall::Umask(arg0) => unsafe { syscall1(95, arg0) }, + // Syscall::Gettimeofday(arg0, arg1) => unsafe { syscall2(96, arg0, arg1) }, + // Syscall::Getrlimit(arg0, arg1) => unsafe { syscall2(97, arg0, arg1) }, + // Syscall::Getrusage(arg0, arg1) => unsafe { syscall2(98, arg0, arg1) }, + // Syscall::Sysinfo(arg0) => unsafe { syscall1(99, arg0) }, + // Syscall::Times(arg0) => unsafe { syscall1(100, arg0) }, + // Syscall::Ptrace(arg0, arg1, arg2, arg3) => unsafe { syscall4(101, arg0, arg1, arg2, arg3) }, + // Syscall::Getuid => unsafe { syscall0(102) }, + // Syscall::Syslog(arg0, arg1, arg2) => unsafe { syscall3(103, arg0, arg1, arg2) }, + // Syscall::Getgid => unsafe { syscall0(104) }, + // Syscall::Setuid(arg0) => unsafe { syscall1(105, arg0) }, + // Syscall::Setgid(arg0) => unsafe { syscall1(106, arg0) }, + // Syscall::Geteuid => unsafe { syscall0(107) }, + // Syscall::Getegid => unsafe { syscall0(108) }, + // Syscall::Setpgid(arg0, arg1) => unsafe { syscall2(109, arg0, arg1) }, + // Syscall::Getppid => unsafe { syscall0(110) }, + // Syscall::Getpgrp => unsafe { syscall0(111) }, + // Syscall::Setsid => unsafe { syscall0(112) }, + // Syscall::Setreuid(arg0, arg1) => unsafe { syscall2(113, arg0, arg1) }, + // Syscall::Setregid(arg0, arg1) => unsafe { syscall2(114, arg0, arg1) }, + // Syscall::Getgroups(arg0, arg1) => unsafe { syscall2(115, arg0, arg1) }, + // Syscall::Setgroups(arg0, arg1) => unsafe { syscall2(116, arg0, arg1) }, + // Syscall::Setresuid(arg0, arg1, arg2) => unsafe { syscall3(117, arg0, arg1, arg2) }, + // Syscall::Getresuid(arg0, arg1, arg2) => unsafe { syscall3(118, arg0, arg1, arg2) }, + // Syscall::Setresgid(arg0, arg1, arg2) => unsafe { syscall3(119, arg0, arg1, arg2) }, + // Syscall::Getresgid(arg0, arg1, arg2) => unsafe { syscall3(120, arg0, arg1, arg2) }, + // Syscall::Getpgid(arg0) => unsafe { syscall1(121, arg0) }, + // Syscall::Setfsuid(arg0) => unsafe { syscall1(122, arg0) }, + // Syscall::Setfsgid(arg0) => unsafe { syscall1(123, arg0) }, + // Syscall::Getsid(arg0) => unsafe { syscall1(124, arg0) }, + // Syscall::Capget(arg0, arg1) => unsafe { syscall2(125, arg0, arg1) }, + // Syscall::Capset(arg0, arg1) => unsafe { syscall2(126, arg0, arg1) }, + // Syscall::RtSigpending(arg0, arg1) => unsafe { syscall2(127, arg0, arg1) }, + // Syscall::RtSigtimedwait(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(128, arg0, arg1, arg2, arg3) + // }, + // Syscall::RtSigqueueinfo(arg0, arg1, arg2) => unsafe { syscall3(129, arg0, arg1, arg2) }, + // Syscall::RtSigsuspend(arg0, arg1) => unsafe { syscall2(130, arg0, arg1) }, + // Syscall::Sigaltstack(arg0, arg1) => unsafe { syscall2(131, arg0, arg1) }, + // Syscall::Utime(arg0, arg1) => unsafe { syscall2(132, arg0, arg1) }, + // Syscall::Mknod(arg0, arg1, arg2) => unsafe { syscall3(133, arg0, arg1, arg2) }, + // Syscall::Uselib(arg0) => unsafe { syscall1(134, arg0) }, + // Syscall::Personality(arg0) => unsafe { syscall1(135, arg0) }, + // Syscall::Ustat(arg0, arg1) => unsafe { syscall2(136, arg0, arg1) }, + // Syscall::Statfs(arg0, arg1) => unsafe { syscall2(137, arg0, arg1) }, + // Syscall::Fstatfs(arg0, arg1) => unsafe { syscall2(138, arg0, arg1) }, + // Syscall::Sysfs(arg0, arg1, arg2) => unsafe { syscall3(139, arg0, arg1, arg2) }, + // Syscall::Getpriority(arg0, arg1) => unsafe { syscall2(140, arg0, arg1) }, + // Syscall::Setpriority(arg0, arg1, arg2) => unsafe { syscall3(141, arg0, arg1, arg2) }, + // Syscall::SchedSetparam(arg0, arg1) => unsafe { syscall2(142, arg0, arg1) }, + // Syscall::SchedGetparam(arg0, arg1) => unsafe { syscall2(143, arg0, arg1) }, + // Syscall::SchedSetscheduler(arg0, arg1, arg2) => unsafe { syscall3(144, arg0, arg1, arg2) }, + // Syscall::SchedGetscheduler(arg0) => unsafe { syscall1(145, arg0) }, + // Syscall::SchedGetPriorityMax(arg0) => unsafe { syscall1(146, arg0) }, + // Syscall::SchedGetPriorityMin(arg0) => unsafe { syscall1(147, arg0) }, + // Syscall::SchedRrGetInterval(arg0, arg1) => unsafe { syscall2(148, arg0, arg1) }, + // Syscall::Mlock(arg0, arg1) => unsafe { syscall2(149, arg0, arg1) }, + // Syscall::Munlock(arg0, arg1) => unsafe { syscall2(150, arg0, arg1) }, + // Syscall::Mlockall(arg0) => unsafe { syscall1(151, arg0) }, + // Syscall::Munlockall => unsafe { syscall0(152) }, + // Syscall::Vhangup => unsafe { syscall0(153) }, + // Syscall::ModifyLdt(arg0, arg1, arg2) => unsafe { syscall3(154, arg0, arg1, arg2) }, + // Syscall::PivotRoot(arg0, arg1) => unsafe { syscall2(155, arg0, arg1) }, + // Syscall::_Sysctl(arg0) => unsafe { syscall1(156, arg0) }, + // Syscall::Prctl(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(157, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::ArchPrctl(arg0, arg1) => unsafe { syscall2(158, arg0, arg1) }, + // Syscall::Adjtimex(arg0) => unsafe { syscall1(159, arg0) }, + // Syscall::Setrlimit(arg0, arg1) => unsafe { syscall2(160, arg0, arg1) }, + // Syscall::Chroot(arg0) => unsafe { syscall1(161, arg0) }, + // Syscall::Sync => unsafe { syscall0(162) }, + // Syscall::Acct(arg0) => unsafe { syscall1(163, arg0) }, + // Syscall::Settimeofday(arg0, arg1) => unsafe { syscall2(164, arg0, arg1) }, + // Syscall::Mount(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(165, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Umount2(arg0, arg1) => unsafe { syscall2(166, arg0, arg1) }, + // Syscall::Swapon(arg0, arg1) => unsafe { syscall2(167, arg0, arg1) }, + // Syscall::Swapoff(arg0) => unsafe { syscall1(168, arg0) }, + // Syscall::Reboot(arg0, arg1, arg2, arg3) => unsafe { syscall4(169, arg0, arg1, arg2, arg3) }, + // Syscall::Sethostname(arg0, arg1) => unsafe { syscall2(170, arg0, arg1) }, + // Syscall::Setdomainname(arg0, arg1) => unsafe { syscall2(171, arg0, arg1) }, + // Syscall::Iopl(arg0) => unsafe { syscall1(172, arg0) }, + // Syscall::Ioperm(arg0, arg1, arg2) => unsafe { syscall3(173, arg0, arg1, arg2) }, + // Syscall::CreateModule(arg0, arg1) => unsafe { syscall2(174, arg0, arg1) }, + // Syscall::InitModule(arg0, arg1, arg2) => unsafe { syscall3(175, arg0, arg1, arg2) }, + // Syscall::DeleteModule(arg0, arg1) => unsafe { syscall2(176, arg0, arg1) }, + // Syscall::GetKernelSyms(arg0) => unsafe { syscall1(177, arg0) }, + // Syscall::QueryModule(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(178, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Quotactl(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(179, arg0, arg1, arg2, arg3) + // }, + // Syscall::Nfsservctl(arg0, arg1, arg2) => unsafe { syscall3(180, arg0, arg1, arg2) }, + // Syscall::Getpmsg => unsafe { syscall0(181) }, + // Syscall::Putpmsg => unsafe { syscall0(182) }, + // Syscall::AfsSyscall => unsafe { syscall0(183) }, + // Syscall::Tuxcall => unsafe { syscall0(184) }, + // Syscall::Security => unsafe { syscall0(185) }, + // Syscall::Gettid => unsafe { syscall0(186) }, + // Syscall::Readahead(arg0, arg1, arg2) => unsafe { syscall3(187, arg0, arg1, arg2) }, + // Syscall::Setxattr(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(188, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Lsetxattr(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(189, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Fsetxattr(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(190, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Getxattr(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(191, arg0, arg1, arg2, arg3) + // }, + // Syscall::Lgetxattr(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(192, arg0, arg1, arg2, arg3) + // }, + // Syscall::Fgetxattr(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(193, arg0, arg1, arg2, arg3) + // }, + // Syscall::Listxattr(arg0, arg1, arg2) => unsafe { syscall3(194, arg0, arg1, arg2) }, + // Syscall::Llistxattr(arg0, arg1, arg2) => unsafe { syscall3(195, arg0, arg1, arg2) }, + // Syscall::Flistxattr(arg0, arg1, arg2) => unsafe { syscall3(196, arg0, arg1, arg2) }, + // Syscall::Removexattr(arg0, arg1) => unsafe { syscall2(197, arg0, arg1) }, + // Syscall::Lremovexattr(arg0, arg1) => unsafe { syscall2(198, arg0, arg1) }, + // Syscall::Fremovexattr(arg0, arg1) => unsafe { syscall2(199, arg0, arg1) }, + // Syscall::Tkill(arg0, arg1) => unsafe { syscall2(200, arg0, arg1) }, + // Syscall::Time(arg0) => unsafe { syscall1(201, arg0) }, + // Syscall::Futex(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { + // syscall6(202, arg0, arg1, arg2, arg3, arg4, arg5) + // }, + // Syscall::SchedSetaffinity(arg0, arg1, arg2) => unsafe { syscall3(203, arg0, arg1, arg2) }, + // Syscall::SchedGetaffinity(arg0, arg1, arg2) => unsafe { syscall3(204, arg0, arg1, arg2) }, + // Syscall::SetThreadArea(arg0) => unsafe { syscall1(205, arg0) }, + // Syscall::IoSetup(arg0, arg1) => unsafe { syscall2(206, arg0, arg1) }, + // Syscall::IoDestroy(arg0) => unsafe { syscall1(207, arg0) }, + // Syscall::IoGetevents(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(208, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::IoSubmit(arg0, arg1, arg2) => unsafe { syscall3(209, arg0, arg1, arg2) }, + // Syscall::IoCancel(arg0, arg1, arg2) => unsafe { syscall3(210, arg0, arg1, arg2) }, + // Syscall::GetThreadArea(arg0) => unsafe { syscall1(211, arg0) }, + // Syscall::LookupDcookie(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(212, arg0, arg1, arg2, arg3) + // }, + // Syscall::EpollCreate(arg0) => unsafe { syscall1(213, arg0) }, + // Syscall::EpollCtlOld => unsafe { syscall0(214) }, + // Syscall::EpollWaitOld => unsafe { syscall0(215) }, + // Syscall::RemapFilePages(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(216, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Getdents64(arg0, arg1, arg2) => unsafe { syscall3(217, arg0, arg1, arg2) }, + // Syscall::SetTidAddress(arg0) => unsafe { syscall1(218, arg0) }, + // Syscall::RestartSyscall => unsafe { syscall0(219) }, + // Syscall::Semtimedop(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(220, arg0, arg1, arg2, arg3) + // }, + // Syscall::Fadvise64(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(221, arg0, arg1, arg2, arg3) + // }, + // Syscall::TimerCreate(arg0, arg1, arg2) => unsafe { syscall3(222, arg0, arg1, arg2) }, + // Syscall::TimerSettime(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(223, arg0, arg1, arg2, arg3) + // }, + // Syscall::TimerGettime(arg0, arg1) => unsafe { syscall2(224, arg0, arg1) }, + // Syscall::TimerGetoverrun(arg0) => unsafe { syscall1(225, arg0) }, + // Syscall::TimerDelete(arg0) => unsafe { syscall1(226, arg0) }, + // Syscall::ClockSettime(arg0, arg1) => unsafe { syscall2(227, arg0, arg1) }, + // Syscall::ClockGettime(arg0, arg1) => unsafe { syscall2(228, arg0, arg1) }, + // Syscall::ClockGetres(arg0, arg1) => unsafe { syscall2(229, arg0, arg1) }, + // Syscall::ClockNanosleep(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(230, arg0, arg1, arg2, arg3) + // }, + // Syscall::ExitGroup(arg0) => unsafe { syscall1(231, arg0) }, + // Syscall::EpollWait(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(232, arg0, arg1, arg2, arg3) + // }, + // Syscall::EpollCtl(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(233, arg0, arg1, arg2, arg3) + // }, + // Syscall::Tgkill(arg0, arg1, arg2) => unsafe { syscall3(234, arg0, arg1, arg2) }, + // Syscall::Utimes(arg0, arg1) => unsafe { syscall2(235, arg0, arg1) }, + // Syscall::Vserver => unsafe { syscall0(236) }, + // Syscall::Mbind(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { + // syscall6(237, arg0, arg1, arg2, arg3, arg4, arg5) + // }, + // Syscall::SetMempolicy(arg0, arg1, arg2) => unsafe { syscall3(238, arg0, arg1, arg2) }, + // Syscall::GetMempolicy(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(239, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::MqOpen(arg0, arg1, arg2, arg3) => unsafe { syscall4(240, arg0, arg1, arg2, arg3) }, + // Syscall::MqUnlink(arg0) => unsafe { syscall1(241, arg0) }, + // Syscall::MqTimedsend(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(242, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::MqTimedreceive(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(243, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::MqNotify(arg0, arg1) => unsafe { syscall2(244, arg0, arg1) }, + // Syscall::MqGetsetattr(arg0, arg1, arg2) => unsafe { syscall3(245, arg0, arg1, arg2) }, + // Syscall::KexecLoad(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(246, arg0, arg1, arg2, arg3) + // }, + // Syscall::Waitid(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(247, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::AddKey(arg0, arg1, arg2, arg3) => unsafe { syscall4(248, arg0, arg1, arg2, arg3) }, + // Syscall::RequestKey(arg0, arg1, arg2) => unsafe { syscall3(249, arg0, arg1, arg2) }, + // Syscall::Keyctl(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(250, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::IoprioSet(arg0, arg1, arg2) => unsafe { syscall3(251, arg0, arg1, arg2) }, + // Syscall::IoprioGet(arg0, arg1) => unsafe { syscall2(252, arg0, arg1) }, + // Syscall::InotifyInit => unsafe { syscall0(253) }, + // Syscall::InotifyAddWatch(arg0, arg1, arg2) => unsafe { syscall3(254, arg0, arg1, arg2) }, + // Syscall::InotifyRmWatch(arg0, arg1) => unsafe { syscall2(255, arg0, arg1) }, + // Syscall::MigratePages(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(256, arg0, arg1, arg2, arg3) + // }, + Syscall::Openat { + dfd, + filename, + flags, + mode, + } => syscall4( + libc::SYS_openat as usize, + *dfd as usize, + filename.as_ptr(), + *flags as usize, + *mode as usize, + ), + // Syscall::Openat(arg0, arg1, arg2, arg3) => unsafe { syscall4(257, arg0, arg1, arg2, arg3) }, + // Syscall::Mkdirat(arg0, arg1, arg2) => unsafe { syscall3(258, arg0, arg1, arg2) }, + // Syscall::Mknodat(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(259, arg0, arg1, arg2, arg3) + // }, + // Syscall::Fchownat(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(260, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Futimesat(arg0, arg1, arg2) => unsafe { syscall3(261, arg0, arg1, arg2) }, + // Syscall::Newfstatat(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(262, arg0, arg1, arg2, arg3) + // }, + // Syscall::Unlinkat(arg0, arg1, arg2) => unsafe { syscall3(263, arg0, arg1, arg2) }, + // Syscall::Renameat(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(264, arg0, arg1, arg2, arg3) + // }, + // Syscall::Linkat(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(265, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Symlinkat(arg0, arg1, arg2) => unsafe { syscall3(266, arg0, arg1, arg2) }, + // Syscall::Readlinkat(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(267, arg0, arg1, arg2, arg3) + // }, + // Syscall::Fchmodat(arg0, arg1, arg2) => unsafe { syscall3(268, arg0, arg1, arg2) }, + // Syscall::Faccessat(arg0, arg1, arg2) => unsafe { syscall3(269, arg0, arg1, arg2) }, + // Syscall::Pselect6(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { + // syscall6(270, arg0, arg1, arg2, arg3, arg4, arg5) + // }, + // Syscall::Ppoll(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(271, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Unshare(arg0) => unsafe { syscall1(272, arg0) }, + // Syscall::SetRobustList(arg0, arg1) => unsafe { syscall2(273, arg0, arg1) }, + // Syscall::GetRobustList(arg0, arg1, arg2) => unsafe { syscall3(274, arg0, arg1, arg2) }, + // Syscall::Splice(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { + // syscall6(275, arg0, arg1, arg2, arg3, arg4, arg5) + // }, + // Syscall::Tee(arg0, arg1, arg2, arg3) => unsafe { syscall4(276, arg0, arg1, arg2, arg3) }, + // Syscall::SyncFileRange(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(277, arg0, arg1, arg2, arg3) + // }, + // Syscall::Vmsplice(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(278, arg0, arg1, arg2, arg3) + // }, + // Syscall::MovePages(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { + // syscall6(279, arg0, arg1, arg2, arg3, arg4, arg5) + // }, + // Syscall::Utimensat(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(280, arg0, arg1, arg2, arg3) + // }, + // Syscall::EpollPwait(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { + // syscall6(281, arg0, arg1, arg2, arg3, arg4, arg5) + // }, + // Syscall::Signalfd(arg0, arg1, arg2) => unsafe { syscall3(282, arg0, arg1, arg2) }, + // Syscall::TimerfdCreate(arg0, arg1) => unsafe { syscall2(283, arg0, arg1) }, + // Syscall::Eventfd(arg0, arg1) => unsafe { syscall2(284, arg0, arg1) }, + // Syscall::Fallocate(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(285, arg0, arg1, arg2, arg3) + // }, + // Syscall::TimerfdSettime(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(286, arg0, arg1, arg2, arg3) + // }, + // Syscall::TimerfdGettime(arg0, arg1) => unsafe { syscall2(287, arg0, arg1) }, + // Syscall::Accept4(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(288, arg0, arg1, arg2, arg3) + // }, + // Syscall::Signalfd4(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(289, arg0, arg1, arg2, arg3) + // }, + // Syscall::Eventfd2(arg0, arg1) => unsafe { syscall2(290, arg0, arg1) }, + // Syscall::EpollCreate1(arg0) => unsafe { syscall1(291, arg0) }, + // Syscall::Dup3(arg0, arg1, arg2) => unsafe { syscall3(292, arg0, arg1, arg2) }, + // Syscall::Pipe2(arg0, arg1) => unsafe { syscall2(293, arg0, arg1) }, + // Syscall::InotifyInit1(arg0) => unsafe { syscall1(294, arg0) }, + // Syscall::Preadv(arg0, arg1, arg2, arg3) => unsafe { syscall4(295, arg0, arg1, arg2, arg3) }, + // Syscall::Pwritev(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(296, arg0, arg1, arg2, arg3) + // }, + // Syscall::RtTgsigqueueinfo(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(297, arg0, arg1, arg2, arg3) + // }, + // Syscall::PerfEventOpen(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(298, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Recvmmsg(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(299, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::FanotifyInit(arg0, arg1) => unsafe { syscall2(300, arg0, arg1) }, + // Syscall::FanotifyMark(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(301, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Prlimit64(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(302, arg0, arg1, arg2, arg3) + // }, + // Syscall::NameToHandleAt(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(303, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::OpenByHandleAt(arg0, arg1, arg2) => unsafe { syscall3(304, arg0, arg1, arg2) }, + // Syscall::ClockAdjtime(arg0, arg1) => unsafe { syscall2(305, arg0, arg1) }, + // Syscall::Syncfs(arg0) => unsafe { syscall1(306, arg0) }, + // Syscall::Sendmmsg(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(307, arg0, arg1, arg2, arg3) + // }, + // Syscall::Setns(arg0, arg1) => unsafe { syscall2(308, arg0, arg1) }, + // Syscall::Getcpu(arg0, arg1, arg2) => unsafe { syscall3(309, arg0, arg1, arg2) }, + // Syscall::ProcessVmReadv(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { + // syscall6(310, arg0, arg1, arg2, arg3, arg4, arg5) + // }, + // Syscall::ProcessVmWritev(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { + // syscall6(311, arg0, arg1, arg2, arg3, arg4, arg5) + // }, + // Syscall::Kcmp(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(312, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::FinitModule(arg0, arg1, arg2) => unsafe { syscall3(313, arg0, arg1, arg2) }, + // Syscall::SchedSetattr(arg0, arg1, arg2) => unsafe { syscall3(314, arg0, arg1, arg2) }, + // Syscall::SchedGetattr(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(315, arg0, arg1, arg2, arg3) + // }, + // Syscall::Renameat2(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(316, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Seccomp(arg0, arg1, arg2) => unsafe { syscall3(317, arg0, arg1, arg2) }, + // Syscall::Getrandom(arg0, arg1, arg2) => unsafe { syscall3(318, arg0, arg1, arg2) }, + // Syscall::MemfdCreate(arg0, arg1) => unsafe { syscall2(319, arg0, arg1) }, + // Syscall::KexecFileLoad(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(320, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Bpf(arg0, arg1, arg2) => unsafe { syscall3(321, arg0, arg1, arg2) }, + // Syscall::Execveat(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(322, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Userfaultfd(arg0) => unsafe { syscall1(323, arg0) }, + // Syscall::Membarrier(arg0, arg1) => unsafe { syscall2(324, arg0, arg1) }, + // Syscall::Mlock2(arg0, arg1, arg2) => unsafe { syscall3(325, arg0, arg1, arg2) }, + // Syscall::CopyFileRange(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { + // syscall6(326, arg0, arg1, arg2, arg3, arg4, arg5) + // }, + // Syscall::Preadv2(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(327, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Pwritev2(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(328, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::PkeyMprotect(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(329, arg0, arg1, arg2, arg3) + // }, + // Syscall::PkeyAlloc(arg0, arg1) => unsafe { syscall2(330, arg0, arg1) }, + // Syscall::PkeyFree(arg0) => unsafe { syscall1(331, arg0) }, + // Syscall::Statx(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(332, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::IoPgetevents(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { + // syscall6(333, arg0, arg1, arg2, arg3, arg4, arg5) + // }, + // Syscall::Rseq(arg0, arg1, arg2, arg3) => unsafe { syscall4(334, arg0, arg1, arg2, arg3) }, + // Syscall::PidfdSendSignal(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(424, arg0, arg1, arg2, arg3) + // }, + // Syscall::IoUringSetup(arg0, arg1) => unsafe { syscall2(425, arg0, arg1) }, + // Syscall::IoUringEnter(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(426, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::IoUringRegister(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(427, arg0, arg1, arg2, arg3) + // }, + // Syscall::OpenTree(arg0, arg1, arg2) => unsafe { syscall3(428, arg0, arg1, arg2) }, + // Syscall::MoveMount(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(429, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Fsopen(arg0, arg1, arg2) => unsafe { syscall3(430, arg0, arg1, arg2) }, + // Syscall::Fsconfig(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(431, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Fsmount(arg0, arg1, arg2) => unsafe { syscall3(432, arg0, arg1, arg2) }, + // Syscall::Fspick(arg0, arg1, arg2) => unsafe { syscall3(433, arg0, arg1, arg2) }, + // Syscall::PidfdOpen(arg0, arg1) => unsafe { syscall2(434, arg0, arg1) }, + // Syscall::Clone3(arg0, arg1) => unsafe { syscall2(435, arg0, arg1) }, + // Syscall::CloseRange(arg0, arg1, arg2) => unsafe { syscall3(436, arg0, arg1, arg2) }, + // Syscall::Openat2(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(437, arg0, arg1, arg2, arg3) + // }, + // Syscall::PidfdGetfd(arg0, arg1, arg2) => unsafe { syscall3(438, arg0, arg1, arg2) }, + // Syscall::Faccessat2(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(439, arg0, arg1, arg2, arg3) + // }, + // Syscall::ProcessMadvise(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(440, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::EpollPwait2(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(441, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::MountSetattr(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(442, arg0, arg1, arg2, arg3) + // }, + // Syscall::QuotactlFd(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(443, arg0, arg1, arg2, arg3) + // }, + // Syscall::LandlockCreateRuleset(arg0, arg1, arg2) => unsafe { + // syscall3(444, arg0, arg1, arg2) + // }, + // Syscall::LandlockAddRule(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(445, arg0, arg1, arg2, arg3) + // }, + // Syscall::LandlockRestrictSelf(arg0, arg1) => unsafe { syscall2(446, arg0, arg1) }, + // Syscall::MemfdSecret(arg0) => unsafe { syscall1(447, arg0) }, + // Syscall::ProcessMrelease(arg0, arg1) => unsafe { syscall2(448, arg0, arg1) }, + // Syscall::FutexWaitv(arg0, arg1, arg2) => unsafe { syscall3(449, arg0, arg1, arg2) }, + // Syscall::SetMempolicyHomeNode(arg0, arg1, arg2) => unsafe { + // syscall3(450, arg0, arg1, arg2) + // }, + // Syscall::Cachestat(arg0, arg1, arg2, arg3, arg4) => unsafe { + // syscall5(451, arg0, arg1, arg2, arg3, arg4) + // }, + // Syscall::Fchmodat2(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(452, arg0, arg1, arg2, arg3) + // }, + // Syscall::MapShadowStack(arg0, arg1) => unsafe { syscall2(453, arg0, arg1) }, + // Syscall::FutexWake(arg0, arg1, arg2) => unsafe { syscall3(454, arg0, arg1, arg2) }, + // Syscall::FutexWait(arg0, arg1, arg2) => unsafe { syscall3(455, arg0, arg1, arg2) }, + // Syscall::FutexRequeue(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(456, arg0, arg1, arg2, arg3) + // }, + // Syscall::Statmount(arg0, arg1, arg2) => unsafe { syscall3(457, arg0, arg1, arg2) }, + // Syscall::Listmount(arg0, arg1, arg2) => unsafe { syscall3(458, arg0, arg1, arg2) }, + // Syscall::LsmGetSelfAttr(arg0, arg1, arg2, arg3) => unsafe { + // syscall4(459, arg0, arg1, arg2, arg3) + // }, + // Syscall::LsmSetSelfAttr(arg0, arg1, arg2) => unsafe { syscall3(460, arg0, arg1, arg2) }, + // Syscall::LsmListModules(arg0, arg1) => unsafe { syscall2(461, arg0, arg1) }, + // Syscall::Unknown(syscall_num, args) => match args { + // [arg0, arg1, arg2, arg3, arg4, arg5] => unsafe { + // syscall6(syscall_num, arg0, arg1, arg2, arg3, arg4, arg5) + // }, + _ => unreachable!(), + // }, + } + } +} diff --git a/syscall_lib/src/syscall/mod.rs b/syscall_lib/src/syscall/mod.rs new file mode 100644 index 0000000..4372faa --- /dev/null +++ b/syscall_lib/src/syscall/mod.rs @@ -0,0 +1,1656 @@ +use bincode::{Decode, Encode}; + +use crate::{arch_types, types::*}; + +mod create; +mod exec; + +impl Syscall { + pub fn encode(&self) -> Vec { + bincode::encode_to_vec(self, crate::CONFIG).unwrap() + } + + pub fn decode(bytes: &[u8]) -> Option { + if let Ok((decoded, _)) = bincode::decode_from_slice(&bytes[..], crate::CONFIG) { + Some(decoded) + } else { + None + } + } +} + +/// Represents all possible x86_64 system calls and their arguments. +#[derive(Encode, Decode, Debug)] +// #[derive(Encode, Decode)] +pub enum Syscall { + Unimplemented(libc::c_long), + + Read { + fd: libc::c_uint, + buf: Buf, + len: libc::size_t, + }, + Write { + fd: libc::c_uint, + buf: Buf, + len: libc::size_t, + }, + Open { + path: StrRef, + flags: libc::c_int, + mode: libc::c_int, + }, + Close { + fd: libc::c_uint, + }, + Stat { + path: StrRef, + statbuf: Ptr, + }, + Fstat { + fd: libc::c_uint, + statbuf: Ptr, + }, + // Lstat { + // path: Buf, + // statbuf: Ptr, + // }, + // Poll { + // fds: Ptr, + // nfds: libc::c_uint, + // timeout: libc::c_int, + // }, + // Lseek { + // fd: libc::c_uint, + // offset: libc::off_t, + // whence: libc::c_uint, + // }, + Mmap { + addr: PtrVoid, + len: libc::size_t, + prot: libc::c_int, + flags: libc::c_int, + fd: libc::c_int, + offset: libc::off_t, + }, + // Mprotect { + // addr: Ptr, + // len: libc::size_t, + // prot: libc::c_int, + // }, + // Munmap { + // addr: Ptr, + // len: libc::size_t, + // }, + // Brk { + // addr: Ptr, + // }, + // RtSigaction { + // sig: libc::c_int, + // act: Ptr, + // oldact: Ptr, + // sigsetsize: libc::size_t, + // }, + // RtSigprocmask { + // how: libc::c_int, + // set: Ptr, + // oldset: Ptr, + // sigsetsize: libc::size_t, + // }, + // RtSigreturn, + // Ioctl { + // fd: libc::c_uint, + // cmd: libc::c_ulong, + // arg: libc::c_ulong, + // }, + // Pread64 { + // fd: libc::c_uint, + // buf: Ptr, + // count: libc::size_t, + // pos: libc::loff_t, + // }, + // Pwrite64 { + // fd: libc::c_uint, + // buf: Ptr, + // count: libc::size_t, + // pos: libc::loff_t, + // }, + // Readv { + // fd: libc::c_ulong, + // vec: Ptr, + // vlen: libc::c_ulong, + // }, + // Writev { + // fd: libc::c_ulong, + // vec: Ptr, + // vlen: libc::c_ulong, + // }, + // Access { + // filename: Buf, + // mode: libc::c_int, + // }, + // Pipe { + // fildes: Ptr, + // }, + // Select { + // n: libc::c_int, + // inp: Ptr, + // outp: Ptr, + // exp: Ptr, + // tvp: Ptr, + // }, + // SchedYield, + // Mremap { + // old_addr: Ptr, + // old_size: libc::size_t, + // new_size: libc::size_t, + // flags: libc::c_int, + // new_addr: Ptr, + // }, + // Msync { + // start: Ptr, + // len: libc::size_t, + // flags: libc::c_int, + // }, + // Mincore { + // start: Ptr, + // len: libc::size_t, + // vec: Ptr, + // }, + // Madvise { + // start: Ptr, + // len: libc::size_t, + // behavior: libc::c_int, + // }, + // Shmget { + // key: libc::key_t, + // size: libc::size_t, + // shmflg: libc::c_int, + // }, + // Shmat { + // shmid: libc::c_int, + // shmaddr: Ptr, + // shmflg: libc::c_int, + // }, + // Shmctl { + // shmid: libc::c_int, + // cmd: libc::c_int, + // buf: Ptr, + // }, + // Dup { + // fildes: libc::c_uint, + // }, + // Dup2 { + // oldfd: libc::c_uint, + // newfd: libc::c_uint, + // }, + // Pause, + // Nanosleep { + // rqtp: Ptr, + // rmtp: Ptr, + // }, + // Getitimer { + // which: libc::c_int, + // value: Ptr, + // }, + // Alarm { + // seconds: libc::c_uint, + // }, + // Setitimer { + // which: libc::c_int, + // value: Ptr, + // ovalue: Ptr, + // }, + // Getpid, + // Sendfile { + // out_fd: libc::c_int, + // in_fd: libc::c_int, + // offset: Ptr, + // count: libc::size_t, + // }, + // Socket { + // domain: libc::c_int, + // ty: libc::c_int, + // protocol: libc::c_int, + // }, + // Connect { + // fd: libc::c_int, + // addr: Ptr, + // len: libc::socklen_t, + // }, + // Accept { + // fd: libc::c_int, + // addr: Ptr, + // len: Ptr, + // }, + // Sendto { + // fd: libc::c_int, + // buf: Ptr, + // len: libc::size_t, + // flags: libc::c_int, + // addr: Ptr, + // addr_len: libc::socklen_t, + // }, + // Recvfrom { + // fd: libc::c_int, + // buf: Ptr, + // len: libc::size_t, + // flags: libc::c_int, + // addr: Ptr, + // addr_len: Ptr, + // }, + // Sendmsg { + // fd: libc::c_int, + // msg: Ptr, + // flags: libc::c_int, + // }, + // Recvmsg { + // fd: libc::c_int, + // msg: Ptr, + // flags: libc::c_int, + // }, + // Shutdown { + // fd: libc::c_int, + // how: libc::c_int, + // }, + // Bind { + // fd: libc::c_int, + // addr: Ptr, + // len: libc::socklen_t, + // }, + // Listen { + // fd: libc::c_int, + // backlog: libc::c_int, + // }, + // Getsockname { + // fd: libc::c_int, + // addr: Ptr, + // len: Ptr, + // }, + // Getpeername { + // fd: libc::c_int, + // addr: Ptr, + // len: Ptr, + // }, + // Socketpair { + // domain: libc::c_int, + // ty: libc::c_int, + // protocol: libc::c_int, + // fds: Ptr, + // }, + // Setsockopt { + // fd: libc::c_int, + // level: libc::c_int, + // optname: libc::c_int, + // optval: Ptr, + // optlen: libc::socklen_t, + // }, + // Getsockopt { + // fd: libc::c_int, + // level: libc::c_int, + // optname: libc::c_int, + // optval: Ptr, + // optlen: Ptr, + // }, + // Clone { + // flags: libc::c_ulong, + // stack: Ptr, + // parent_tid: Ptr, + // child_tid: Ptr, + // tls: libc::c_ulong, + // }, + // Fork, + // Vfork, + // Execve { + // filename: Buf, + // argv: Ptr>, + // envp: Ptr>, + // }, + // Exit { + // error_code: libc::c_int, + // }, + // Wait4 { + // pid: libc::pid_t, + // stat_addr: Ptr, + // options: libc::c_int, + // ru: Ptr, + // }, + // Kill { + // pid: libc::pid_t, + // sig: libc::c_int, + // }, + // Uname { + // name: Ptr, + // }, + // Semget { + // key: libc::key_t, + // nsems: libc::c_int, + // semflg: libc::c_int, + // }, + // Semop { + // semid: libc::c_int, + // sops: Ptr, + // nsops: libc::size_t, + // }, + // Semctl { + // semid: libc::c_int, + // semnum: libc::c_int, + // cmd: libc::c_int, + // arg: libc::c_ulong, + // }, + // Shmdt { + // shmaddr: Ptr, + // }, + // Msgget { + // key: libc::key_t, + // msgflg: libc::c_int, + // }, + // Msgsnd { + // msqid: libc::c_int, + // msgp: Ptr, + // msgsz: libc::size_t, + // msgflg: libc::c_int, + // }, + // Msgrcv { + // msqid: libc::c_int, + // msgp: Ptr, + // msgsz: libc::size_t, + // msgtyp: libc::c_long, + // msgflg: libc::c_int, + // }, + // Msgctl { + // msqid: libc::c_int, + // cmd: libc::c_int, + // buf: Ptr, + // }, + // Fcntl { + // fd: libc::c_uint, + // cmd: libc::c_uint, + // arg: libc::c_ulong, + // }, + // Flock { + // fd: libc::c_uint, + // cmd: libc::c_uint, + // }, + // Fsync { + // fd: libc::c_uint, + // }, + // Fdatasync { + // fd: libc::c_uint, + // }, + // Truncate { + // path: Buf, + // length: libc::c_long, + // }, + // Ftruncate { + // fd: libc::c_uint, + // length: libc::c_long, + // }, + // Getdents { + // fd: libc::c_uint, + // dirent: Ptr, + // count: libc::c_uint, + // }, + // Getcwd { + // buf: Buf, + // size: libc::c_ulong, + // }, + // Chdir { + // filename: Buf, + // }, + // Fchdir { + // fd: libc::c_uint, + // }, + // Rename { + // oldname: Buf, + // newname: Buf, + // }, + // Mkdir { + // pathname: Buf, + // mode: libc::mode_t, + // }, + // Rmdir { + // pathname: Buf, + // }, + // Creat { + // pathname: Buf, + // mode: libc::mode_t, + // }, + // Link { + // oldname: Buf, + // newname: Buf, + // }, + // Unlink { + // pathname: Buf, + // }, + // Symlink { + // old: Buf, + // new: Buf, + // }, + // Readlink { + // path: Buf, + // buf: Buf, + // bufsiz: libc::c_int, + // }, + // Chmod { + // filename: Buf, + // mode: libc::mode_t, + // }, + // Fchmod { + // fd: libc::c_uint, + // mode: libc::mode_t, + // }, + // Chown { + // filename: Buf, + // user: libc::uid_t, + // group: libc::gid_t, + // }, + // Fchown { + // fd: libc::c_uint, + // user: libc::uid_t, + // group: libc::gid_t, + // }, + // Lchown { + // filename: Buf, + // user: libc::uid_t, + // group: libc::gid_t, + // }, + // Umask { + // mask: libc::c_int, + // }, + // Gettimeofday { + // tv: Ptr, + // tz: Ptr, + // }, + // Getrlimit { + // resource: libc::c_int, + // rlim: Ptr, + // }, + // Getrusage { + // who: libc::c_int, + // ru: Ptr, + // }, + // Sysinfo { + // info: Ptr, + // }, + // Times { + // tbuf: Ptr, + // }, + // Ptrace { + // request: libc::c_long, + // pid: libc::c_long, + // addr: libc::c_ulong, + // data: libc::c_ulong, + // }, + // Getuid, + // Syslog { + // ty: libc::c_int, + // buf: Buf, + // len: libc::c_int, + // }, + // Getgid, + // Setuid { + // uid: libc::uid_t, + // }, + // Setgid { + // gid: libc::gid_t, + // }, + // Geteuid, + // Getegid, + // Setpgid { + // pid: libc::pid_t, + // pgid: libc::pid_t, + // }, + // Getppid, + // Getpgrp, + // Setsid, + // Setreuid { + // ruid: libc::uid_t, + // euid: libc::uid_t, + // }, + // Setregid { + // rgid: libc::gid_t, + // egid: libc::gid_t, + // }, + // Getgroups { + // gidsetsize: libc::c_int, + // grouplist: Ptr, + // }, + // Setgroups { + // gidsetsize: libc::c_int, + // grouplist: Ptr, + // }, + // Setresuid { + // ruid: libc::uid_t, + // euid: libc::uid_t, + // suid: libc::uid_t, + // }, + // Getresuid { + // ruid: Ptr, + // euid: Ptr, + // suid: Ptr, + // }, + // Setresgid { + // rgid: libc::gid_t, + // egid: libc::gid_t, + // sgid: libc::gid_t, + // }, + // Getresgid { + // rgid: Ptr, + // egid: Ptr, + // sgid: Ptr, + // }, + // Getpgid { + // pid: libc::pid_t, + // }, + // Setfsuid { + // uid: libc::uid_t, + // }, + // Setfsgid { + // gid: libc::gid_t, + // }, + // Getsid { + // pid: libc::pid_t, + // }, + // Capget { + // header: Ptr, + // dataptr: Ptr, + // }, + // Capset { + // header: Ptr, + // data: Ptr, + // }, + // RtSigpending { + // set: Ptr, + // sigsetsize: libc::size_t, + // }, + // RtSigtimedwait { + // uthese: Ptr, + // uinfo: Ptr, + // uts: Ptr, + // sigsetsize: libc::size_t, + // }, + // RtSigqueueinfo { + // pid: libc::pid_t, + // sig: libc::c_int, + // uinfo: Ptr, + // }, + // RtSigsuspend { + // unewset: Ptr, + // sigsetsize: libc::size_t, + // }, + // Sigaltstack { + // uss: Ptr, + // uoss: Ptr, + // }, + // Utime { + // filename: Buf, + // times: Ptr, + // }, + // Mknod { + // filename: Buf, + // mode: libc::mode_t, + // dev: libc::c_uint, + // }, + // Uselib { + // library: Buf, + // }, + // Personality { + // personality: libc::c_uint, + // }, + // Ustat { + // dev: libc::c_uint, + // ubuf: Ptr, + // }, + // Statfs { + // path: Buf, + // buf: Ptr, + // }, + // Fstatfs { + // fd: libc::c_uint, + // buf: Ptr, + // }, + // Sysfs { + // option: libc::c_int, + // arg1: libc::c_ulong, + // arg2: libc::c_ulong, + // }, + // Getpriority { + // which: libc::c_int, + // who: libc::c_int, + // }, + // Setpriority { + // which: libc::c_int, + // who: libc::c_int, + // niceval: libc::c_int, + // }, + // SchedSetparam { + // pid: libc::pid_t, + // param: Ptr, + // }, + // SchedGetparam { + // pid: libc::pid_t, + // param: Ptr, + // }, + // SchedSetscheduler { + // pid: libc::pid_t, + // policy: libc::c_int, + // param: Ptr, + // }, + // SchedGetscheduler { + // pid: libc::pid_t, + // }, + // SchedGetPriorityMax { + // policy: libc::c_int, + // }, + // SchedGetPriorityMin { + // policy: libc::c_int, + // }, + // SchedRrGetInterval { + // pid: libc::pid_t, + // interval: Ptr, + // }, + // Mlock { + // start: libc::c_ulong, + // len: libc::size_t, + // }, + // Munlock { + // start: libc::c_ulong, + // len: libc::size_t, + // }, + // Mlockall { + // flags: libc::c_int, + // }, + // Munlockall, + // Vhangup, + // PivotRoot { + // new_root: Buf, + // put_old: Buf, + // }, + // Prctl { + // option: libc::c_int, + // arg2: libc::c_ulong, + // arg3: libc::c_ulong, + // arg4: libc::c_ulong, + // arg5: libc::c_ulong, + // }, + // Adjtimex { + // txc_p: Ptr, + // }, + // Setrlimit { + // resource: libc::c_uint, + // rlim: Ptr, + // }, + // Chroot { + // filename: Buf, + // }, + // Sync, + // Acct { + // name: Buf, + // }, + // Settimeofday { + // tv: Ptr, + // tz: Ptr, + // }, + // Mount { + // dev_name: Buf, + // dir_name: Buf, + // ty: Buf, + // flags: libc::c_ulong, + // data: Ptr, + // }, + // Umount2 { + // name: Buf, + // flags: libc::c_int, + // }, + // Swapon { + // specialfile: Buf, + // swap_flags: libc::c_int, + // }, + // Swapoff { + // specialfile: Buf, + // }, + // Reboot { + // magic1: libc::c_int, + // magic2: libc::c_int, + // cmd: libc::c_uint, + // arg: Ptr, + // }, + // Sethostname { + // name: Buf, + // len: libc::c_int, + // }, + // Setdomainname { + // name: Buf, + // len: libc::c_int, + // }, + // Ioperm { + // from: libc::c_ulong, + // num: libc::c_ulong, + // on: libc::c_int, + // }, + // InitModule { + // umod: Ptr, + // len: libc::c_ulong, + // uargs: Buf, + // }, + // DeleteModule { + // name_user: Buf, + // flags: libc::c_uint, + // }, + // Quotactl { + // cmd: libc::c_uint, + // special: Buf, + // id: libc::c_int, + // addr: Ptr, + // }, + // Gettid, + // Readahead { + // fd: libc::c_int, + // offset: libc::loff_t, + // count: libc::size_t, + // }, + // Setxattr { + // path: Buf, + // name: Buf, + // value: Ptr, + // size: libc::size_t, + // flags: libc::c_int, + // }, + // Lsetxattr { + // path: Buf, + // name: Buf, + // value: Ptr, + // size: libc::size_t, + // flags: libc::c_int, + // }, + // Fsetxattr { + // fd: libc::c_int, + // name: Buf, + // value: Ptr, + // size: libc::size_t, + // flags: libc::c_int, + // }, + // Getxattr { + // path: Buf, + // name: Buf, + // value: Ptr, + // size: libc::size_t, + // }, + // Lgetxattr { + // path: Buf, + // name: Buf, + // value: Ptr, + // size: libc::size_t, + // }, + // Fgetxattr { + // fd: libc::c_int, + // name: Buf, + // value: Ptr, + // size: libc::size_t, + // }, + // Listxattr { + // path: Buf, + // list: Buf, + // size: libc::size_t, + // }, + // Llistxattr { + // path: Buf, + // list: Buf, + // size: libc::size_t, + // }, + // Flistxattr { + // fd: libc::c_int, + // list: Buf, + // size: libc::size_t, + // }, + // Removexattr { + // path: Buf, + // name: Buf, + // }, + // Lremovexattr { + // path: Buf, + // name: Buf, + // }, + // Fremovexattr { + // fd: libc::c_int, + // name: Buf, + // }, + // Tkill { + // pid: libc::pid_t, + // sig: libc::c_int, + // }, + // Time { + // tloc: Ptr, + // }, + // Futex { + // uaddr: Ptr, + // op: libc::c_int, + // val: u32, + // utime: Ptr, + // uaddr2: Ptr, + // val3: u32, + // }, + // SchedSetaffinity { + // pid: libc::pid_t, + // len: libc::c_uint, + // user_mask_ptr: Ptr, + // }, + // SchedGetaffinity { + // pid: libc::pid_t, + // len: libc::c_uint, + // user_mask_ptr: Ptr, + // }, + // IoSetup { + // nr_reqs: libc::c_uint, + // ctx: Ptr, + // }, + // IoDestroy { + // ctx: Ptr, + // }, + // IoGetevents { + // ctx_id: Ptr, + // min_nr: libc::c_long, + // nr: libc::c_long, + // events: Ptr, + // timeout: Ptr, + // }, + // IoSubmit { + // ctx: Ptr, + // nr: libc::c_long, + // iocbpp: Ptr>, + // }, + // IoCancel { + // ctx_id: Ptr, + // iocb: Ptr, + // result: Ptr, + // }, + // EpollCreate { + // size: libc::c_int, + // }, + // RemapFilePages { + // start: libc::c_ulong, + // size: libc::c_ulong, + // prot: libc::c_ulong, + // pgoff: libc::c_ulong, + // flags: libc::c_ulong, + // }, + // Getdents64 { + // fd: libc::c_uint, + // dirent: Ptr, + // count: libc::c_uint, + // }, + // SetTidAddress { + // tidptr: Ptr, + // }, + // RestartSyscall, + // Semtimedop { + // semid: libc::c_int, + // sops: Ptr, + // nsops: libc::c_uint, + // timeout: Ptr, + // }, + // Fadvise64 { + // fd: libc::c_int, + // offset: libc::loff_t, + // len: libc::size_t, + // advice: libc::c_int, + // }, + // TimerCreate { + // which_clock: libc::clockid_t, + // timer_event_spec: Ptr, + // created_timer_id: Ptr, + // }, + // TimerSettime { + // timer_id: libc::timer_t, + // flags: libc::c_int, + // new_setting: Ptr, + // old_setting: Ptr, + // }, + // TimerGettime { + // timer_id: libc::timer_t, + // setting: Ptr, + // }, + // TimerGetoverrun { + // timer_id: libc::timer_t, + // }, + // TimerDelete { + // timer_id: libc::timer_t, + // }, + // ClockSettime { + // which_clock: libc::clockid_t, + // tp: Ptr, + // }, + // ClockGettime { + // which_clock: libc::clockid_t, + // tp: Ptr, + // }, + // ClockGetres { + // which_clock: libc::clockid_t, + // tp: Ptr, + // }, + // ClockNanosleep { + // which_clock: libc::clockid_t, + // flags: libc::c_int, + // rqtp: Ptr, + // rmtp: Ptr, + // }, + // ExitGroup { + // error_code: libc::c_int, + // }, + // EpollWait { + // epfd: libc::c_int, + // events: Ptr, + // maxevents: libc::c_int, + // timeout: libc::c_int, + // }, + // EpollCtl { + // epfd: libc::c_int, + // op: libc::c_int, + // fd: libc::c_int, + // event: Ptr, + // }, + // Tgkill { + // tgid: libc::pid_t, + // pid: libc::pid_t, + // sig: libc::c_int, + // }, + // Utimes { + // filename: Buf, + // utimes: Ptr, + // }, + // Mbind { + // start: libc::c_ulong, + // len: libc::c_ulong, + // mode: libc::c_ulong, + // nmask: Ptr, + // maxnode: libc::c_ulong, + // flags: libc::c_uint, + // }, + // SetMempolicy { + // mode: libc::c_int, + // nmask: Ptr, + // maxnode: libc::c_ulong, + // }, + // GetMempolicy { + // policy: Ptr, + // nmask: Ptr, + // maxnode: libc::c_ulong, + // addr: libc::c_ulong, + // flags: libc::c_ulong, + // }, + // MqOpen { + // name: Buf, + // oflag: libc::c_int, + // mode: libc::mode_t, + // attr: Ptr, + // }, + // MqUnlink { + // name: Buf, + // }, + // MqTimedsend { + // mqdes: libc::mqd_t, + // msg_ptr: Buf, + // msg_len: libc::size_t, + // msg_prio: libc::c_uint, + // abs_timeout: Ptr, + // }, + // MqTimedreceive { + // mqdes: libc::mqd_t, + // msg_ptr: Buf, + // msg_len: libc::size_t, + // msg_prio: Ptr, + // abs_timeout: Ptr, + // }, + // MqNotify { + // mqdes: libc::mqd_t, + // notification: Ptr, + // }, + // MqGetsetattr { + // mqdes: libc::mqd_t, + // mqstat: Ptr, + // omqstat: Ptr, + // }, + // KexecLoad { + // entry: libc::c_ulong, + // nr_segments: libc::c_ulong, + // segments: Ptr, + // flags: libc::c_ulong, + // }, + // Waitid { + // which: libc::c_int, + // pid: libc::pid_t, + // infop: Ptr, + // options: libc::c_int, + // ru: Ptr, + // }, + // AddKey { + // _type: Buf, + // _description: Buf, + // _payload: Ptr, + // plen: libc::size_t, + // destringid: libc::key_t, + // }, + // RequestKey { + // _type: Buf, + // _description: Buf, + // _callout_info: Buf, + // destringid: libc::key_t, + // }, + // Keyctl { + // cmd: libc::c_int, + // arg2: libc::c_ulong, + // arg3: libc::c_ulong, + // arg4: libc::c_ulong, + // arg5: libc::c_ulong, + // }, + // IoprioSet { + // which: libc::c_int, + // who: libc::c_int, + // ioprio: libc::c_int, + // }, + // IoprioGet { + // which: libc::c_int, + // who: libc::c_int, + // }, + // InotifyInit, + // InotifyAddWatch { + // fd: libc::c_int, + // path: Buf, + // mask: u32, + // }, + // InotifyRmWatch { + // fd: libc::c_int, + // wd: libc::c_int, + // }, + // MigratePages { + // pid: libc::pid_t, + // maxnode: libc::c_ulong, + // from: Ptr, + // to: Ptr, + // }, + Openat { + dfd: libc::c_int, + filename: StrRef, + flags: libc::c_int, + mode: libc::mode_t, + }, + // Mkdirat { + // dfd: libc::c_int, + // pathname: Buf, + // mode: libc::mode_t, + // }, + // Mknodat { + // dfd: libc::c_int, + // filename: Buf, + // mode: libc::mode_t, + // dev: libc::c_uint, + // }, + // Fchownat { + // dfd: libc::c_int, + // filename: Buf, + // user: libc::uid_t, + // group: libc::gid_t, + // flag: libc::c_int, + // }, + // Futimesat { + // dfd: libc::c_int, + // filename: Buf, + // utimes: Ptr, + // }, + // Newfstatat { + // dfd: libc::c_int, + // filename: Buf, + // statbuf: Ptr, + // flag: libc::c_int, + // }, + // Unlinkat { + // dfd: libc::c_int, + // pathname: Buf, + // flag: libc::c_int, + // }, + // Renameat { + // olddfd: libc::c_int, + // oldname: Buf, + // newdfd: libc::c_int, + // newname: Buf, + // }, + // Linkat { + // olddfd: libc::c_int, + // oldname: Buf, + // newdfd: libc::c_int, + // newname: Buf, + // flags: libc::c_int, + // }, + // Symlinkat { + // oldname: Buf, + // newdfd: libc::c_int, + // newname: Buf, + // }, + // Readlinkat { + // dfd: libc::c_int, + // path: Buf, + // buf: Buf, + // bufsiz: libc::c_int, + // }, + // Fchmodat { + // dfd: libc::c_int, + // filename: Buf, + // mode: libc::mode_t, + // }, + // Faccessat { + // dfd: libc::c_int, + // filename: Buf, + // mode: libc::c_int, + // }, + // Pselect6 { + // n: libc::c_int, + // inp: Ptr, + // outp: Ptr, + // exp: Ptr, + // tsp: Ptr, + // sig: Ptr, + // }, + // Ppoll { + // fds: Ptr, + // nfds: libc::c_uint, + // tsp: Ptr, + // sset: Ptr, + // sigsetsize: libc::size_t, + // }, + // Unshare { + // unshare_flags: libc::c_ulong, + // }, + // SetRobustList { + // head: Ptr, + // len: libc::size_t, + // }, + // GetRobustList { + // pid: libc::c_int, + // head_ptr: Ptr>, + // len_ptr: Ptr, + // }, + // Splice { + // fd_in: libc::c_int, + // off_in: Ptr, + // fd_out: libc::c_int, + // off_out: Ptr, + // len: libc::size_t, + // flags: libc::c_uint, + // }, + // Tee { + // fdin: libc::c_int, + // fdout: libc::c_int, + // len: libc::size_t, + // flags: libc::c_uint, + // }, + // SyncFileRange { + // fd: libc::c_int, + // offset: libc::loff_t, + // nbytes: libc::loff_t, + // flags: libc::c_uint, + // }, + // Vmsplice { + // fd: libc::c_int, + // iov: Ptr, + // nr_segs: libc::c_ulong, + // flags: libc::c_uint, + // }, + // MovePages { + // pid: libc::pid_t, + // nr_pages: libc::c_ulong, + // pages: Ptr>, + // nodes: Ptr, + // status: Ptr, + // flags: libc::c_int, + // }, + // Utimensat { + // dfd: libc::c_int, + // filename: Buf, + // utimes: Ptr, + // flags: libc::c_int, + // }, + // EpollPwait { + // epfd: libc::c_int, + // events: Ptr, + // maxevents: libc::c_int, + // timeout: libc::c_int, + // sigmask: Ptr, + // sigsetsize: libc::size_t, + // }, + // Signalfd { + // ufd: libc::c_int, + // user_mask: Ptr, + // sizemask: libc::size_t, + // }, + // TimerfdCreate { + // clockid: libc::c_int, + // flags: libc::c_int, + // }, + // Eventfd { + // count: libc::c_uint, + // }, + // Fallocate { + // fd: libc::c_int, + // mode: libc::c_int, + // offset: libc::loff_t, + // len: libc::loff_t, + // }, + // TimerfdSettime { + // ufd: libc::c_int, + // flags: libc::c_int, + // utmr: Ptr, + // otmr: Ptr, + // }, + // TimerfdGettime { + // ufd: libc::c_int, + // otmr: Ptr, + // }, + // Accept4 { + // fd: libc::c_int, + // addr: Ptr, + // len: Ptr, + // flags: libc::c_int, + // }, + // Signalfd4 { + // ufd: libc::c_int, + // user_mask: Ptr, + // sizemask: libc::size_t, + // flags: libc::c_int, + // }, + // Eventfd2 { + // count: libc::c_uint, + // flags: libc::c_int, + // }, + // EpollCreate1 { + // flags: libc::c_int, + // }, + // Dup3 { + // oldfd: libc::c_uint, + // newfd: libc::c_uint, + // flags: libc::c_int, + // }, + // Pipe2 { + // fildes: Ptr, + // flags: libc::c_int, + // }, + // InotifyInit1 { + // flags: libc::c_int, + // }, + // Preadv { + // fd: libc::c_ulong, + // vec: Ptr, + // vlen: libc::c_ulong, + // pos_l: libc::c_ulong, + // pos_h: libc::c_ulong, + // }, + // Pwritev { + // fd: libc::c_ulong, + // vec: Ptr, + // vlen: libc::c_ulong, + // pos_l: libc::c_ulong, + // pos_h: libc::c_ulong, + // }, + // RtTgsigqueueinfo { + // tgid: libc::pid_t, + // pid: libc::pid_t, + // sig: libc::c_int, + // uinfo: Ptr, + // }, + // PerfEventOpen { + // attr_uptr: Ptr, + // pid: libc::pid_t, + // cpu: libc::c_int, + // group_fd: libc::c_int, + // flags: libc::c_ulong, + // }, + // Recvmmsg { + // fd: libc::c_int, + // msg: Ptr, + // vlen: libc::c_uint, + // flags: libc::c_uint, + // timeout: Ptr, + // }, + // FanotifyInit { + // flags: libc::c_uint, + // event_f_flags: libc::c_uint, + // }, + // FanotifyMark { + // fanotify_fd: libc::c_int, + // flags: libc::c_uint, + // mask: u64, + // fd: libc::c_int, + // pathname: Buf, + // }, + // Prlimit64 { + // pid: libc::pid_t, + // resource: libc::c_uint, + // new_rlim: Ptr, + // old_rlim: Ptr, + // }, + // NameToHandleAt { + // dfd: libc::c_int, + // name: Buf, + // handle: Ptr, + // mnt_id: Ptr, + // flag: libc::c_int, + // }, + // OpenByHandleAt { + // mountdirfd: libc::c_int, + // handle: Ptr, + // flags: libc::c_int, + // }, + // ClockAdjtime { + // which_clock: libc::clockid_t, + // tx: Ptr, + // }, + // Syncfs { + // fd: libc::c_int, + // }, + // Sendmmsg { + // fd: libc::c_int, + // msg: Ptr, + // vlen: libc::c_uint, + // flags: libc::c_uint, + // }, + // Setns { + // fd: libc::c_int, + // nstype: libc::c_int, + // }, + // Getcpu { + // cpu: Ptr, + // node: Ptr, + // cache: Ptr, + // }, + // ProcessVmReadv { + // pid: libc::pid_t, + // lvec: Ptr, + // liovcnt: libc::c_ulong, + // rvec: Ptr, + // riovcnt: libc::c_ulong, + // flags: libc::c_ulong, + // }, + // ProcessVmWritev { + // pid: libc::pid_t, + // lvec: Ptr, + // liovcnt: libc::c_ulong, + // rvec: Ptr, + // riovcnt: libc::c_ulong, + // flags: libc::c_ulong, + // }, + // Kcmp { + // pid1: libc::pid_t, + // pid2: libc::pid_t, + // ty: libc::c_int, + // idx1: libc::c_ulong, + // idx2: libc::c_ulong, + // }, + // FinitModule { + // fd: libc::c_int, + // uargs: Buf, + // flags: libc::c_int, + // }, + // SchedSetattr { + // pid: libc::pid_t, + // attr: Ptr, + // flags: libc::c_uint, + // }, + // SchedGetattr { + // pid: libc::pid_t, + // attr: Ptr, + // size: libc::c_uint, + // flags: libc::c_uint, + // }, + // Renameat2 { + // olddfd: libc::c_int, + // oldname: Buf, + // newdfd: libc::c_int, + // newname: Buf, + // flags: libc::c_uint, + // }, + // Seccomp { + // op: libc::c_uint, + // flags: libc::c_uint, + // uargs: Ptr, + // }, + // Getrandom { + // buf: Buf, + // count: libc::size_t, + // flags: libc::c_uint, + // }, + // MemfdCreate { + // uname_ptr: Buf, + // flags: libc::c_uint, + // }, + // KexecFileLoad { + // kernel_fd: libc::c_int, + // initrd_fd: libc::c_int, + // cmdline_len: libc::c_ulong, + // cmdline_ptr: Buf, + // flags: libc::c_ulong, + // }, + // Bpf { + // cmd: libc::c_int, + // attr: Ptr, + // size: libc::c_uint, + // }, + // Execveat { + // dfd: libc::c_int, + // filename: Buf, + // argv: Ptr>, + // envp: Ptr>, + // flags: libc::c_int, + // }, + // Userfaultfd { + // flags: libc::c_int, + // }, + // Membarrier { + // cmd: libc::c_int, + // flags: libc::c_uint, + // }, + // Mlock2 { + // start: libc::c_ulong, + // len: libc::size_t, + // flags: libc::c_int, + // }, + // CopyFileRange { + // fd_in: libc::c_int, + // off_in: Ptr, + // fd_out: libc::c_int, + // off_out: Ptr, + // len: libc::size_t, + // flags: libc::c_uint, + // }, + // Preadv2 { + // fd: libc::c_ulong, + // vec: Ptr, + // vlen: libc::c_ulong, + // pos_l: libc::c_ulong, + // pos_h: libc::c_ulong, + // flags: libc::c_int, + // }, + // Pwritev2 { + // fd: libc::c_ulong, + // vec: Ptr, + // vlen: libc::c_ulong, + // pos_l: libc::c_ulong, + // pos_h: libc::c_ulong, + // flags: libc::c_int, + // }, + // PkeyMprotect { + // start: libc::c_ulong, + // len: libc::size_t, + // prot: libc::c_ulong, + // pkey: libc::c_int, + // }, + // PkeyAlloc { + // flags: libc::c_ulong, + // init_val: libc::c_ulong, + // }, + // PkeyFree { + // pkey: libc::c_int, + // }, + // Statx { + // dfd: libc::c_int, + // path: Buf, + // flags: libc::c_uint, + // mask: libc::c_uint, + // buffer: Ptr, + // }, + // Rseq { + // rseq: Ptr, + // rseq_len: u32, + // flags: libc::c_int, + // sig: u32, + // }, + // PidfdSendSignal { + // pidfd: libc::c_int, + // sig: libc::c_int, + // info: Ptr, + // flags: libc::c_uint, + // }, + // IoUringSetup { + // entries: u32, + // p: Ptr, + // }, + // IoUringEnter { + // fd: libc::c_uint, + // to_submit: u32, + // min_complete: u32, + // flags: u32, + // argp: Ptr, + // argsz: libc::size_t, + // }, + // IoUringRegister { + // fd: libc::c_uint, + // op: libc::c_uint, + // arg: Ptr, + // nr_args: libc::c_uint, + // }, + // OpenTree { + // dfd: libc::c_int, + // path: Buf, + // flags: libc::c_uint, + // }, + // MoveMount { + // from_dfd: libc::c_int, + // from_path: Buf, + // to_dfd: libc::c_int, + // to_path: Buf, + // ms_flags: libc::c_uint, + // }, + // Fsopen { + // fs_name: Buf, + // flags: libc::c_uint, + // }, + // Fsconfig { + // fs_fd: libc::c_int, + // cmd: libc::c_uint, + // key: Buf, + // value: Ptr, + // aux: libc::c_int, + // }, + // Fsmount { + // fs_fd: libc::c_int, + // flags: libc::c_uint, + // ms_flags: libc::c_uint, + // }, + // Fspick { + // dfd: libc::c_int, + // path: Buf, + // flags: libc::c_uint, + // }, + // PidfdOpen { + // pid: libc::pid_t, + // flags: libc::c_uint, + // }, + // Clone3 { + // uargs: Ptr, + // size: libc::size_t, + // }, + // CloseRange { + // fd: libc::c_uint, + // max_fd: libc::c_uint, + // flags: libc::c_uint, + // }, + // Openat2 { + // dfd: libc::c_int, + // filename: Buf, + // how: Ptr, + // size: libc::size_t, + // }, + // PidfdGetfd { + // pidfd: libc::c_int, + // fd: libc::c_int, + // flags: libc::c_uint, + // }, + // Faccessat2 { + // dfd: libc::c_int, + // filename: Buf, + // mode: libc::c_int, + // flags: libc::c_int, + // }, + // ProcessMadvise { + // pidfd: libc::c_int, + // vec: Ptr, + // vlen: libc::size_t, + // behavior: libc::c_int, + // flags: libc::c_uint, + // }, + // EpollPwait2 { + // epfd: libc::c_int, + // events: Ptr, + // maxevents: libc::c_int, + // timeout: Ptr, + // sigmask: Ptr, + // sigsetsize: libc::size_t, + // }, + // MountSetattr { + // dfd: libc::c_int, + // path: Buf, + // flags: libc::c_uint, + // uattr: Ptr, + // usize: libc::size_t, + // }, + // QuotactlFd { + // fd: libc::c_uint, + // cmd: libc::c_uint, + // id: libc::c_int, + // addr: Ptr, + // }, + // LandlockCreateRuleset { + // attr: Ptr, + // size: libc::size_t, + // flags: u32, + // }, + // LandlockAddRule { + // ruleset_fd: libc::c_int, + // rule_type: libc::c_int, + // rule_attr: Ptr, + // flags: u32, + // }, + // LandlockRestrictSelf { + // ruleset_fd: libc::c_int, + // flags: u32, + // }, + // MemfdSecret { + // flags: libc::c_uint, + // }, + // ProcessMrelease { + // pidfd: libc::c_int, + // flags: libc::c_uint, + // }, + // FutexWaitv { + // waiters: Ptr, + // nr_futexes: libc::c_uint, + // flags: libc::c_uint, + // timeout: Ptr, + // clockid: libc::clockid_t, + // }, + // SetMempolicyHomeNode { + // start: libc::c_ulong, + // len: libc::c_ulong, + // home_node: libc::c_ulong, + // flags: libc::c_ulong, + // }, +} diff --git a/syscall_lib/src/syscall_display.rs b/syscall_lib/src/syscall_display.rs deleted file mode 100644 index e69de29..0000000 diff --git a/syscall_lib/src/syscall_exec.rs b/syscall_lib/src/syscall_exec.rs deleted file mode 100644 index 2d0d754..0000000 --- a/syscall_lib/src/syscall_exec.rs +++ /dev/null @@ -1,661 +0,0 @@ -use crate::Syscall; -use syscaller::{syscall0, syscall1, syscall2, syscall3, syscall4, syscall5, syscall6}; - -// fn syscall0(number: isize) -> isize { -// unsafe { syscaller::syscall0(number as usize) } -// } - -// fn syscall1(number: isize, arg0: isize) -> isize { -// unsafe { syscaller::syscall1(number as usize, arg0 as usize) } -// } - -// fn syscall2(number: isize, arg0: isize, arg1: isize) -> isize { -// unsafe { syscaller::syscall2(number as usize, arg0 as usize, arg1 as usize) } -// } - -// fn syscall3(number: isize, arg0: isize, arg1: isize, arg2: isize) -> isize { -// unsafe { syscaller::syscall3(number as usize, arg0 as usize, arg1 as usize, arg2 as usize) } -// } - -// fn syscall4(number: isize, arg0: isize, arg1: isize, arg2: isize, arg3: isize) -> isize { -// unsafe { -// syscaller::syscall4( -// number as usize, -// arg0 as usize, -// arg1 as usize, -// arg2 as usize, -// arg3 as usize, -// ) -// } -// } - -// fn syscall5( -// number: isize, -// arg0: isize, -// arg1: isize, -// arg2: isize, -// arg3: isize, -// arg4: isize, -// ) -> isize { -// unsafe { -// syscaller::syscall5( -// number as usize, -// arg0 as usize, -// arg1 as usize, -// arg2 as usize, -// arg3 as usize, -// arg4 as usize, -// ) -// } -// } - -// fn syscall6( -// number: isize, -// arg0: isize, -// arg1: isize, -// arg2: isize, -// arg3: isize, -// arg4: isize, -// arg5: isize, -// ) -> isize { -// unsafe { -// syscaller::syscall6( -// number as usize, -// arg0 as usize, -// arg1 as usize, -// arg2 as usize, -// arg3 as usize, -// arg4 as usize, -// arg5 as usize, -// ) -// } -// } - -use libc::{c_long, c_ulong}; - -// The Syscall enum and type aliases from the previous response are assumed to be present here. -#[allow(unused_unsafe)] -pub fn execute_syscall(syscall_obj: Syscall) -> isize { - todo!(); - // match syscall_obj { - // Syscall::Read(arg0, arg1, arg2) => unsafe { syscall3(libc::SYS_read, arg0, arg1, arg2) }, - // Syscall::Write(arg0, arg1, arg2) => unsafe { syscall3(1, arg0, arg1, arg2) }, - // Syscall::Open(arg0, arg1, arg2) => unsafe { syscall3(2, arg0, arg1, arg2) }, - // Syscall::Close(arg0) => unsafe { syscall1(3, arg0) }, - // Syscall::Stat(arg0, arg1) => unsafe { syscall2(4, arg0, arg1) }, - // Syscall::Fstat(arg0, arg1) => unsafe { syscall2(5, arg0, arg1) }, - // Syscall::Lstat(arg0, arg1) => unsafe { syscall2(6, arg0, arg1) }, - // Syscall::Poll(arg0, arg1, arg2) => unsafe { syscall3(7, arg0, arg1, arg2) }, - // Syscall::Lseek(arg0, arg1, arg2) => unsafe { syscall3(8, arg0, arg1, arg2) }, - // Syscall::Mmap(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { - // syscall6(9, arg0, arg1, arg2, arg3, arg4, arg5) - // }, - // Syscall::Mprotect(arg0, arg1, arg2) => unsafe { syscall3(10, arg0, arg1, arg2) }, - // Syscall::Munmap(arg0, arg1) => unsafe { syscall2(11, arg0, arg1) }, - // Syscall::Brk(arg0) => unsafe { syscall1(12, arg0) }, - // Syscall::RtSigaction(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(13, arg0, arg1, arg2, arg3) - // }, - // Syscall::RtSigprocmask(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(14, arg0, arg1, arg2, arg3) - // }, - // Syscall::RtSigreturn => unsafe { syscall0(15) }, - // Syscall::Ioctl(arg0, arg1, arg2) => unsafe { syscall3(16, arg0, arg1, arg2) }, - // Syscall::Pread64(arg0, arg1, arg2, arg3) => unsafe { syscall4(17, arg0, arg1, arg2, arg3) }, - // Syscall::Pwrite64(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(18, arg0, arg1, arg2, arg3) - // }, - // Syscall::Readv(arg0, arg1, arg2) => unsafe { syscall3(19, arg0, arg1, arg2) }, - // Syscall::Writev(arg0, arg1, arg2) => unsafe { syscall3(20, arg0, arg1, arg2) }, - // Syscall::Access(arg0, arg1) => unsafe { syscall2(21, arg0, arg1) }, - // Syscall::Pipe(arg0) => unsafe { syscall1(22, arg0) }, - // Syscall::Select(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(23, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::SchedYield => unsafe { syscall0(24) }, - // Syscall::Mremap(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(25, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Msync(arg0, arg1, arg2) => unsafe { syscall3(26, arg0, arg1, arg2) }, - // Syscall::Mincore(arg0, arg1, arg2) => unsafe { syscall3(27, arg0, arg1, arg2) }, - // Syscall::Madvise(arg0, arg1, arg2) => unsafe { syscall3(28, arg0, arg1, arg2) }, - // Syscall::Shmget(arg0, arg1, arg2) => unsafe { syscall3(29, arg0, arg1, arg2) }, - // Syscall::Shmat(arg0, arg1, arg2) => unsafe { syscall3(30, arg0, arg1, arg2) }, - // Syscall::Shmctl(arg0, arg1, arg2) => unsafe { syscall3(31, arg0, arg1, arg2) }, - // Syscall::Dup(arg0) => unsafe { syscall1(32, arg0) }, - // Syscall::Dup2(arg0, arg1) => unsafe { syscall2(33, arg0, arg1) }, - // Syscall::Pause => unsafe { syscall0(34) }, - // Syscall::Nanosleep(arg0, arg1) => unsafe { syscall2(35, arg0, arg1) }, - // Syscall::Getitimer(arg0, arg1) => unsafe { syscall2(36, arg0, arg1) }, - // Syscall::Alarm(arg0) => unsafe { syscall1(37, arg0) }, - // Syscall::Setitimer(arg0, arg1, arg2) => unsafe { syscall3(38, arg0, arg1, arg2) }, - // Syscall::Getpid => unsafe { syscall0(39) }, - // Syscall::Sendfile(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(40, arg0, arg1, arg2, arg3) - // }, - // Syscall::Socket(arg0, arg1, arg2) => unsafe { syscall3(41, arg0, arg1, arg2) }, - // Syscall::Connect(arg0, arg1, arg2) => unsafe { syscall3(42, arg0, arg1, arg2) }, - // Syscall::Accept(arg0, arg1, arg2) => unsafe { syscall3(43, arg0, arg1, arg2) }, - // Syscall::Sendto(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { - // syscall6(44, arg0, arg1, arg2, arg3, arg4, arg5) - // }, - // Syscall::Recvfrom(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { - // syscall6(45, arg0, arg1, arg2, arg3, arg4, arg5) - // }, - // Syscall::Sendmsg(arg0, arg1, arg2) => unsafe { syscall3(46, arg0, arg1, arg2) }, - // Syscall::Recvmsg(arg0, arg1, arg2) => unsafe { syscall3(47, arg0, arg1, arg2) }, - // Syscall::Shutdown(arg0, arg1) => unsafe { syscall2(48, arg0, arg1) }, - // Syscall::Bind(arg0, arg1, arg2) => unsafe { syscall3(49, arg0, arg1, arg2) }, - // Syscall::Listen(arg0, arg1) => unsafe { syscall2(50, arg0, arg1) }, - // Syscall::Getsockname(arg0, arg1, arg2) => unsafe { syscall3(51, arg0, arg1, arg2) }, - // Syscall::Getpeername(arg0, arg1, arg2) => unsafe { syscall3(52, arg0, arg1, arg2) }, - // Syscall::Socketpair(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(53, arg0, arg1, arg2, arg3) - // }, - // Syscall::Setsockopt(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(54, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Getsockopt(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(55, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Clone(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(56, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Fork => unsafe { syscall0(57) }, - // Syscall::Vfork => unsafe { syscall0(58) }, - // Syscall::Execve(arg0, arg1, arg2) => unsafe { syscall3(59, arg0, arg1, arg2) }, - // Syscall::Exit(arg0) => unsafe { syscall1(60, arg0) }, - // Syscall::Wait4(arg0, arg1, arg2, arg3) => unsafe { syscall4(61, arg0, arg1, arg2, arg3) }, - // Syscall::Kill(arg0, arg1) => unsafe { syscall2(62, arg0, arg1) }, - // Syscall::Uname(arg0) => unsafe { syscall1(63, arg0) }, - // Syscall::Semget(arg0, arg1, arg2) => unsafe { syscall3(64, arg0, arg1, arg2) }, - // Syscall::Semop(arg0, arg1, arg2) => unsafe { syscall3(65, arg0, arg1, arg2) }, - // Syscall::Semctl(arg0, arg1, arg2, arg3) => unsafe { syscall4(66, arg0, arg1, arg2, arg3) }, - // Syscall::Shmdt(arg0) => unsafe { syscall1(67, arg0) }, - // Syscall::Msgget(arg0, arg1) => unsafe { syscall2(68, arg0, arg1) }, - // Syscall::Msgsnd(arg0, arg1, arg2, arg3) => unsafe { syscall4(69, arg0, arg1, arg2, arg3) }, - // Syscall::Msgrcv(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(70, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Msgctl(arg0, arg1, arg2) => unsafe { syscall3(71, arg0, arg1, arg2) }, - // Syscall::Fcntl(arg0, arg1, arg2) => unsafe { syscall3(72, arg0, arg1, arg2) }, - // Syscall::Flock(arg0, arg1) => unsafe { syscall2(73, arg0, arg1) }, - // Syscall::Fsync(arg0) => unsafe { syscall1(74, arg0) }, - // Syscall::Fdatasync(arg0) => unsafe { syscall1(75, arg0) }, - // Syscall::Truncate(arg0, arg1) => unsafe { syscall2(76, arg0, arg1) }, - // Syscall::Ftruncate(arg0, arg1) => unsafe { syscall2(77, arg0, arg1) }, - // Syscall::Getdents(arg0, arg1, arg2) => unsafe { syscall3(78, arg0, arg1, arg2) }, - // Syscall::Getcwd(arg0, arg1) => unsafe { syscall2(79, arg0, arg1) }, - // Syscall::Chdir(arg0) => unsafe { syscall1(80, arg0) }, - // Syscall::Fchdir(arg0) => unsafe { syscall1(81, arg0) }, - // Syscall::Rename(arg0, arg1) => unsafe { syscall2(82, arg0, arg1) }, - // Syscall::Mkdir(arg0, arg1) => unsafe { syscall2(83, arg0, arg1) }, - // Syscall::Rmdir(arg0) => unsafe { syscall1(84, arg0) }, - // Syscall::Creat(arg0, arg1) => unsafe { syscall2(85, arg0, arg1) }, - // Syscall::Link(arg0, arg1) => unsafe { syscall2(86, arg0, arg1) }, - // Syscall::Unlink(arg0) => unsafe { syscall1(87, arg0) }, - // Syscall::Symlink(arg0, arg1) => unsafe { syscall2(88, arg0, arg1) }, - // Syscall::Readlink(arg0, arg1, arg2) => unsafe { syscall3(89, arg0, arg1, arg2) }, - // Syscall::Chmod(arg0, arg1) => unsafe { syscall2(90, arg0, arg1) }, - // Syscall::Fchmod(arg0, arg1) => unsafe { syscall2(91, arg0, arg1) }, - // Syscall::Chown(arg0, arg1, arg2) => unsafe { syscall3(92, arg0, arg1, arg2) }, - // Syscall::Fchown(arg0, arg1, arg2) => unsafe { syscall3(93, arg0, arg1, arg2) }, - // Syscall::Lchown(arg0, arg1, arg2) => unsafe { syscall3(94, arg0, arg1, arg2) }, - // Syscall::Umask(arg0) => unsafe { syscall1(95, arg0) }, - // Syscall::Gettimeofday(arg0, arg1) => unsafe { syscall2(96, arg0, arg1) }, - // Syscall::Getrlimit(arg0, arg1) => unsafe { syscall2(97, arg0, arg1) }, - // Syscall::Getrusage(arg0, arg1) => unsafe { syscall2(98, arg0, arg1) }, - // Syscall::Sysinfo(arg0) => unsafe { syscall1(99, arg0) }, - // Syscall::Times(arg0) => unsafe { syscall1(100, arg0) }, - // Syscall::Ptrace(arg0, arg1, arg2, arg3) => unsafe { syscall4(101, arg0, arg1, arg2, arg3) }, - // Syscall::Getuid => unsafe { syscall0(102) }, - // Syscall::Syslog(arg0, arg1, arg2) => unsafe { syscall3(103, arg0, arg1, arg2) }, - // Syscall::Getgid => unsafe { syscall0(104) }, - // Syscall::Setuid(arg0) => unsafe { syscall1(105, arg0) }, - // Syscall::Setgid(arg0) => unsafe { syscall1(106, arg0) }, - // Syscall::Geteuid => unsafe { syscall0(107) }, - // Syscall::Getegid => unsafe { syscall0(108) }, - // Syscall::Setpgid(arg0, arg1) => unsafe { syscall2(109, arg0, arg1) }, - // Syscall::Getppid => unsafe { syscall0(110) }, - // Syscall::Getpgrp => unsafe { syscall0(111) }, - // Syscall::Setsid => unsafe { syscall0(112) }, - // Syscall::Setreuid(arg0, arg1) => unsafe { syscall2(113, arg0, arg1) }, - // Syscall::Setregid(arg0, arg1) => unsafe { syscall2(114, arg0, arg1) }, - // Syscall::Getgroups(arg0, arg1) => unsafe { syscall2(115, arg0, arg1) }, - // Syscall::Setgroups(arg0, arg1) => unsafe { syscall2(116, arg0, arg1) }, - // Syscall::Setresuid(arg0, arg1, arg2) => unsafe { syscall3(117, arg0, arg1, arg2) }, - // Syscall::Getresuid(arg0, arg1, arg2) => unsafe { syscall3(118, arg0, arg1, arg2) }, - // Syscall::Setresgid(arg0, arg1, arg2) => unsafe { syscall3(119, arg0, arg1, arg2) }, - // Syscall::Getresgid(arg0, arg1, arg2) => unsafe { syscall3(120, arg0, arg1, arg2) }, - // Syscall::Getpgid(arg0) => unsafe { syscall1(121, arg0) }, - // Syscall::Setfsuid(arg0) => unsafe { syscall1(122, arg0) }, - // Syscall::Setfsgid(arg0) => unsafe { syscall1(123, arg0) }, - // Syscall::Getsid(arg0) => unsafe { syscall1(124, arg0) }, - // Syscall::Capget(arg0, arg1) => unsafe { syscall2(125, arg0, arg1) }, - // Syscall::Capset(arg0, arg1) => unsafe { syscall2(126, arg0, arg1) }, - // Syscall::RtSigpending(arg0, arg1) => unsafe { syscall2(127, arg0, arg1) }, - // Syscall::RtSigtimedwait(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(128, arg0, arg1, arg2, arg3) - // }, - // Syscall::RtSigqueueinfo(arg0, arg1, arg2) => unsafe { syscall3(129, arg0, arg1, arg2) }, - // Syscall::RtSigsuspend(arg0, arg1) => unsafe { syscall2(130, arg0, arg1) }, - // Syscall::Sigaltstack(arg0, arg1) => unsafe { syscall2(131, arg0, arg1) }, - // Syscall::Utime(arg0, arg1) => unsafe { syscall2(132, arg0, arg1) }, - // Syscall::Mknod(arg0, arg1, arg2) => unsafe { syscall3(133, arg0, arg1, arg2) }, - // Syscall::Uselib(arg0) => unsafe { syscall1(134, arg0) }, - // Syscall::Personality(arg0) => unsafe { syscall1(135, arg0) }, - // Syscall::Ustat(arg0, arg1) => unsafe { syscall2(136, arg0, arg1) }, - // Syscall::Statfs(arg0, arg1) => unsafe { syscall2(137, arg0, arg1) }, - // Syscall::Fstatfs(arg0, arg1) => unsafe { syscall2(138, arg0, arg1) }, - // Syscall::Sysfs(arg0, arg1, arg2) => unsafe { syscall3(139, arg0, arg1, arg2) }, - // Syscall::Getpriority(arg0, arg1) => unsafe { syscall2(140, arg0, arg1) }, - // Syscall::Setpriority(arg0, arg1, arg2) => unsafe { syscall3(141, arg0, arg1, arg2) }, - // Syscall::SchedSetparam(arg0, arg1) => unsafe { syscall2(142, arg0, arg1) }, - // Syscall::SchedGetparam(arg0, arg1) => unsafe { syscall2(143, arg0, arg1) }, - // Syscall::SchedSetscheduler(arg0, arg1, arg2) => unsafe { syscall3(144, arg0, arg1, arg2) }, - // Syscall::SchedGetscheduler(arg0) => unsafe { syscall1(145, arg0) }, - // Syscall::SchedGetPriorityMax(arg0) => unsafe { syscall1(146, arg0) }, - // Syscall::SchedGetPriorityMin(arg0) => unsafe { syscall1(147, arg0) }, - // Syscall::SchedRrGetInterval(arg0, arg1) => unsafe { syscall2(148, arg0, arg1) }, - // Syscall::Mlock(arg0, arg1) => unsafe { syscall2(149, arg0, arg1) }, - // Syscall::Munlock(arg0, arg1) => unsafe { syscall2(150, arg0, arg1) }, - // Syscall::Mlockall(arg0) => unsafe { syscall1(151, arg0) }, - // Syscall::Munlockall => unsafe { syscall0(152) }, - // Syscall::Vhangup => unsafe { syscall0(153) }, - // Syscall::ModifyLdt(arg0, arg1, arg2) => unsafe { syscall3(154, arg0, arg1, arg2) }, - // Syscall::PivotRoot(arg0, arg1) => unsafe { syscall2(155, arg0, arg1) }, - // Syscall::_Sysctl(arg0) => unsafe { syscall1(156, arg0) }, - // Syscall::Prctl(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(157, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::ArchPrctl(arg0, arg1) => unsafe { syscall2(158, arg0, arg1) }, - // Syscall::Adjtimex(arg0) => unsafe { syscall1(159, arg0) }, - // Syscall::Setrlimit(arg0, arg1) => unsafe { syscall2(160, arg0, arg1) }, - // Syscall::Chroot(arg0) => unsafe { syscall1(161, arg0) }, - // Syscall::Sync => unsafe { syscall0(162) }, - // Syscall::Acct(arg0) => unsafe { syscall1(163, arg0) }, - // Syscall::Settimeofday(arg0, arg1) => unsafe { syscall2(164, arg0, arg1) }, - // Syscall::Mount(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(165, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Umount2(arg0, arg1) => unsafe { syscall2(166, arg0, arg1) }, - // Syscall::Swapon(arg0, arg1) => unsafe { syscall2(167, arg0, arg1) }, - // Syscall::Swapoff(arg0) => unsafe { syscall1(168, arg0) }, - // Syscall::Reboot(arg0, arg1, arg2, arg3) => unsafe { syscall4(169, arg0, arg1, arg2, arg3) }, - // Syscall::Sethostname(arg0, arg1) => unsafe { syscall2(170, arg0, arg1) }, - // Syscall::Setdomainname(arg0, arg1) => unsafe { syscall2(171, arg0, arg1) }, - // Syscall::Iopl(arg0) => unsafe { syscall1(172, arg0) }, - // Syscall::Ioperm(arg0, arg1, arg2) => unsafe { syscall3(173, arg0, arg1, arg2) }, - // Syscall::CreateModule(arg0, arg1) => unsafe { syscall2(174, arg0, arg1) }, - // Syscall::InitModule(arg0, arg1, arg2) => unsafe { syscall3(175, arg0, arg1, arg2) }, - // Syscall::DeleteModule(arg0, arg1) => unsafe { syscall2(176, arg0, arg1) }, - // Syscall::GetKernelSyms(arg0) => unsafe { syscall1(177, arg0) }, - // Syscall::QueryModule(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(178, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Quotactl(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(179, arg0, arg1, arg2, arg3) - // }, - // Syscall::Nfsservctl(arg0, arg1, arg2) => unsafe { syscall3(180, arg0, arg1, arg2) }, - // Syscall::Getpmsg => unsafe { syscall0(181) }, - // Syscall::Putpmsg => unsafe { syscall0(182) }, - // Syscall::AfsSyscall => unsafe { syscall0(183) }, - // Syscall::Tuxcall => unsafe { syscall0(184) }, - // Syscall::Security => unsafe { syscall0(185) }, - // Syscall::Gettid => unsafe { syscall0(186) }, - // Syscall::Readahead(arg0, arg1, arg2) => unsafe { syscall3(187, arg0, arg1, arg2) }, - // Syscall::Setxattr(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(188, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Lsetxattr(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(189, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Fsetxattr(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(190, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Getxattr(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(191, arg0, arg1, arg2, arg3) - // }, - // Syscall::Lgetxattr(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(192, arg0, arg1, arg2, arg3) - // }, - // Syscall::Fgetxattr(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(193, arg0, arg1, arg2, arg3) - // }, - // Syscall::Listxattr(arg0, arg1, arg2) => unsafe { syscall3(194, arg0, arg1, arg2) }, - // Syscall::Llistxattr(arg0, arg1, arg2) => unsafe { syscall3(195, arg0, arg1, arg2) }, - // Syscall::Flistxattr(arg0, arg1, arg2) => unsafe { syscall3(196, arg0, arg1, arg2) }, - // Syscall::Removexattr(arg0, arg1) => unsafe { syscall2(197, arg0, arg1) }, - // Syscall::Lremovexattr(arg0, arg1) => unsafe { syscall2(198, arg0, arg1) }, - // Syscall::Fremovexattr(arg0, arg1) => unsafe { syscall2(199, arg0, arg1) }, - // Syscall::Tkill(arg0, arg1) => unsafe { syscall2(200, arg0, arg1) }, - // Syscall::Time(arg0) => unsafe { syscall1(201, arg0) }, - // Syscall::Futex(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { - // syscall6(202, arg0, arg1, arg2, arg3, arg4, arg5) - // }, - // Syscall::SchedSetaffinity(arg0, arg1, arg2) => unsafe { syscall3(203, arg0, arg1, arg2) }, - // Syscall::SchedGetaffinity(arg0, arg1, arg2) => unsafe { syscall3(204, arg0, arg1, arg2) }, - // Syscall::SetThreadArea(arg0) => unsafe { syscall1(205, arg0) }, - // Syscall::IoSetup(arg0, arg1) => unsafe { syscall2(206, arg0, arg1) }, - // Syscall::IoDestroy(arg0) => unsafe { syscall1(207, arg0) }, - // Syscall::IoGetevents(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(208, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::IoSubmit(arg0, arg1, arg2) => unsafe { syscall3(209, arg0, arg1, arg2) }, - // Syscall::IoCancel(arg0, arg1, arg2) => unsafe { syscall3(210, arg0, arg1, arg2) }, - // Syscall::GetThreadArea(arg0) => unsafe { syscall1(211, arg0) }, - // Syscall::LookupDcookie(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(212, arg0, arg1, arg2, arg3) - // }, - // Syscall::EpollCreate(arg0) => unsafe { syscall1(213, arg0) }, - // Syscall::EpollCtlOld => unsafe { syscall0(214) }, - // Syscall::EpollWaitOld => unsafe { syscall0(215) }, - // Syscall::RemapFilePages(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(216, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Getdents64(arg0, arg1, arg2) => unsafe { syscall3(217, arg0, arg1, arg2) }, - // Syscall::SetTidAddress(arg0) => unsafe { syscall1(218, arg0) }, - // Syscall::RestartSyscall => unsafe { syscall0(219) }, - // Syscall::Semtimedop(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(220, arg0, arg1, arg2, arg3) - // }, - // Syscall::Fadvise64(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(221, arg0, arg1, arg2, arg3) - // }, - // Syscall::TimerCreate(arg0, arg1, arg2) => unsafe { syscall3(222, arg0, arg1, arg2) }, - // Syscall::TimerSettime(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(223, arg0, arg1, arg2, arg3) - // }, - // Syscall::TimerGettime(arg0, arg1) => unsafe { syscall2(224, arg0, arg1) }, - // Syscall::TimerGetoverrun(arg0) => unsafe { syscall1(225, arg0) }, - // Syscall::TimerDelete(arg0) => unsafe { syscall1(226, arg0) }, - // Syscall::ClockSettime(arg0, arg1) => unsafe { syscall2(227, arg0, arg1) }, - // Syscall::ClockGettime(arg0, arg1) => unsafe { syscall2(228, arg0, arg1) }, - // Syscall::ClockGetres(arg0, arg1) => unsafe { syscall2(229, arg0, arg1) }, - // Syscall::ClockNanosleep(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(230, arg0, arg1, arg2, arg3) - // }, - // Syscall::ExitGroup(arg0) => unsafe { syscall1(231, arg0) }, - // Syscall::EpollWait(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(232, arg0, arg1, arg2, arg3) - // }, - // Syscall::EpollCtl(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(233, arg0, arg1, arg2, arg3) - // }, - // Syscall::Tgkill(arg0, arg1, arg2) => unsafe { syscall3(234, arg0, arg1, arg2) }, - // Syscall::Utimes(arg0, arg1) => unsafe { syscall2(235, arg0, arg1) }, - // Syscall::Vserver => unsafe { syscall0(236) }, - // Syscall::Mbind(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { - // syscall6(237, arg0, arg1, arg2, arg3, arg4, arg5) - // }, - // Syscall::SetMempolicy(arg0, arg1, arg2) => unsafe { syscall3(238, arg0, arg1, arg2) }, - // Syscall::GetMempolicy(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(239, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::MqOpen(arg0, arg1, arg2, arg3) => unsafe { syscall4(240, arg0, arg1, arg2, arg3) }, - // Syscall::MqUnlink(arg0) => unsafe { syscall1(241, arg0) }, - // Syscall::MqTimedsend(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(242, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::MqTimedreceive(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(243, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::MqNotify(arg0, arg1) => unsafe { syscall2(244, arg0, arg1) }, - // Syscall::MqGetsetattr(arg0, arg1, arg2) => unsafe { syscall3(245, arg0, arg1, arg2) }, - // Syscall::KexecLoad(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(246, arg0, arg1, arg2, arg3) - // }, - // Syscall::Waitid(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(247, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::AddKey(arg0, arg1, arg2, arg3) => unsafe { syscall4(248, arg0, arg1, arg2, arg3) }, - // Syscall::RequestKey(arg0, arg1, arg2) => unsafe { syscall3(249, arg0, arg1, arg2) }, - // Syscall::Keyctl(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(250, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::IoprioSet(arg0, arg1, arg2) => unsafe { syscall3(251, arg0, arg1, arg2) }, - // Syscall::IoprioGet(arg0, arg1) => unsafe { syscall2(252, arg0, arg1) }, - // Syscall::InotifyInit => unsafe { syscall0(253) }, - // Syscall::InotifyAddWatch(arg0, arg1, arg2) => unsafe { syscall3(254, arg0, arg1, arg2) }, - // Syscall::InotifyRmWatch(arg0, arg1) => unsafe { syscall2(255, arg0, arg1) }, - // Syscall::MigratePages(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(256, arg0, arg1, arg2, arg3) - // }, - // Syscall::Openat(arg0, arg1, arg2, arg3) => unsafe { syscall4(257, arg0, arg1, arg2, arg3) }, - // Syscall::Mkdirat(arg0, arg1, arg2) => unsafe { syscall3(258, arg0, arg1, arg2) }, - // Syscall::Mknodat(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(259, arg0, arg1, arg2, arg3) - // }, - // Syscall::Fchownat(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(260, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Futimesat(arg0, arg1, arg2) => unsafe { syscall3(261, arg0, arg1, arg2) }, - // Syscall::Newfstatat(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(262, arg0, arg1, arg2, arg3) - // }, - // Syscall::Unlinkat(arg0, arg1, arg2) => unsafe { syscall3(263, arg0, arg1, arg2) }, - // Syscall::Renameat(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(264, arg0, arg1, arg2, arg3) - // }, - // Syscall::Linkat(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(265, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Symlinkat(arg0, arg1, arg2) => unsafe { syscall3(266, arg0, arg1, arg2) }, - // Syscall::Readlinkat(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(267, arg0, arg1, arg2, arg3) - // }, - // Syscall::Fchmodat(arg0, arg1, arg2) => unsafe { syscall3(268, arg0, arg1, arg2) }, - // Syscall::Faccessat(arg0, arg1, arg2) => unsafe { syscall3(269, arg0, arg1, arg2) }, - // Syscall::Pselect6(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { - // syscall6(270, arg0, arg1, arg2, arg3, arg4, arg5) - // }, - // Syscall::Ppoll(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(271, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Unshare(arg0) => unsafe { syscall1(272, arg0) }, - // Syscall::SetRobustList(arg0, arg1) => unsafe { syscall2(273, arg0, arg1) }, - // Syscall::GetRobustList(arg0, arg1, arg2) => unsafe { syscall3(274, arg0, arg1, arg2) }, - // Syscall::Splice(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { - // syscall6(275, arg0, arg1, arg2, arg3, arg4, arg5) - // }, - // Syscall::Tee(arg0, arg1, arg2, arg3) => unsafe { syscall4(276, arg0, arg1, arg2, arg3) }, - // Syscall::SyncFileRange(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(277, arg0, arg1, arg2, arg3) - // }, - // Syscall::Vmsplice(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(278, arg0, arg1, arg2, arg3) - // }, - // Syscall::MovePages(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { - // syscall6(279, arg0, arg1, arg2, arg3, arg4, arg5) - // }, - // Syscall::Utimensat(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(280, arg0, arg1, arg2, arg3) - // }, - // Syscall::EpollPwait(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { - // syscall6(281, arg0, arg1, arg2, arg3, arg4, arg5) - // }, - // Syscall::Signalfd(arg0, arg1, arg2) => unsafe { syscall3(282, arg0, arg1, arg2) }, - // Syscall::TimerfdCreate(arg0, arg1) => unsafe { syscall2(283, arg0, arg1) }, - // Syscall::Eventfd(arg0, arg1) => unsafe { syscall2(284, arg0, arg1) }, - // Syscall::Fallocate(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(285, arg0, arg1, arg2, arg3) - // }, - // Syscall::TimerfdSettime(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(286, arg0, arg1, arg2, arg3) - // }, - // Syscall::TimerfdGettime(arg0, arg1) => unsafe { syscall2(287, arg0, arg1) }, - // Syscall::Accept4(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(288, arg0, arg1, arg2, arg3) - // }, - // Syscall::Signalfd4(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(289, arg0, arg1, arg2, arg3) - // }, - // Syscall::Eventfd2(arg0, arg1) => unsafe { syscall2(290, arg0, arg1) }, - // Syscall::EpollCreate1(arg0) => unsafe { syscall1(291, arg0) }, - // Syscall::Dup3(arg0, arg1, arg2) => unsafe { syscall3(292, arg0, arg1, arg2) }, - // Syscall::Pipe2(arg0, arg1) => unsafe { syscall2(293, arg0, arg1) }, - // Syscall::InotifyInit1(arg0) => unsafe { syscall1(294, arg0) }, - // Syscall::Preadv(arg0, arg1, arg2, arg3) => unsafe { syscall4(295, arg0, arg1, arg2, arg3) }, - // Syscall::Pwritev(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(296, arg0, arg1, arg2, arg3) - // }, - // Syscall::RtTgsigqueueinfo(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(297, arg0, arg1, arg2, arg3) - // }, - // Syscall::PerfEventOpen(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(298, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Recvmmsg(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(299, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::FanotifyInit(arg0, arg1) => unsafe { syscall2(300, arg0, arg1) }, - // Syscall::FanotifyMark(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(301, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Prlimit64(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(302, arg0, arg1, arg2, arg3) - // }, - // Syscall::NameToHandleAt(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(303, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::OpenByHandleAt(arg0, arg1, arg2) => unsafe { syscall3(304, arg0, arg1, arg2) }, - // Syscall::ClockAdjtime(arg0, arg1) => unsafe { syscall2(305, arg0, arg1) }, - // Syscall::Syncfs(arg0) => unsafe { syscall1(306, arg0) }, - // Syscall::Sendmmsg(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(307, arg0, arg1, arg2, arg3) - // }, - // Syscall::Setns(arg0, arg1) => unsafe { syscall2(308, arg0, arg1) }, - // Syscall::Getcpu(arg0, arg1, arg2) => unsafe { syscall3(309, arg0, arg1, arg2) }, - // Syscall::ProcessVmReadv(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { - // syscall6(310, arg0, arg1, arg2, arg3, arg4, arg5) - // }, - // Syscall::ProcessVmWritev(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { - // syscall6(311, arg0, arg1, arg2, arg3, arg4, arg5) - // }, - // Syscall::Kcmp(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(312, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::FinitModule(arg0, arg1, arg2) => unsafe { syscall3(313, arg0, arg1, arg2) }, - // Syscall::SchedSetattr(arg0, arg1, arg2) => unsafe { syscall3(314, arg0, arg1, arg2) }, - // Syscall::SchedGetattr(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(315, arg0, arg1, arg2, arg3) - // }, - // Syscall::Renameat2(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(316, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Seccomp(arg0, arg1, arg2) => unsafe { syscall3(317, arg0, arg1, arg2) }, - // Syscall::Getrandom(arg0, arg1, arg2) => unsafe { syscall3(318, arg0, arg1, arg2) }, - // Syscall::MemfdCreate(arg0, arg1) => unsafe { syscall2(319, arg0, arg1) }, - // Syscall::KexecFileLoad(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(320, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Bpf(arg0, arg1, arg2) => unsafe { syscall3(321, arg0, arg1, arg2) }, - // Syscall::Execveat(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(322, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Userfaultfd(arg0) => unsafe { syscall1(323, arg0) }, - // Syscall::Membarrier(arg0, arg1) => unsafe { syscall2(324, arg0, arg1) }, - // Syscall::Mlock2(arg0, arg1, arg2) => unsafe { syscall3(325, arg0, arg1, arg2) }, - // Syscall::CopyFileRange(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { - // syscall6(326, arg0, arg1, arg2, arg3, arg4, arg5) - // }, - // Syscall::Preadv2(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(327, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Pwritev2(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(328, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::PkeyMprotect(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(329, arg0, arg1, arg2, arg3) - // }, - // Syscall::PkeyAlloc(arg0, arg1) => unsafe { syscall2(330, arg0, arg1) }, - // Syscall::PkeyFree(arg0) => unsafe { syscall1(331, arg0) }, - // Syscall::Statx(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(332, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::IoPgetevents(arg0, arg1, arg2, arg3, arg4, arg5) => unsafe { - // syscall6(333, arg0, arg1, arg2, arg3, arg4, arg5) - // }, - // Syscall::Rseq(arg0, arg1, arg2, arg3) => unsafe { syscall4(334, arg0, arg1, arg2, arg3) }, - // Syscall::PidfdSendSignal(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(424, arg0, arg1, arg2, arg3) - // }, - // Syscall::IoUringSetup(arg0, arg1) => unsafe { syscall2(425, arg0, arg1) }, - // Syscall::IoUringEnter(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(426, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::IoUringRegister(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(427, arg0, arg1, arg2, arg3) - // }, - // Syscall::OpenTree(arg0, arg1, arg2) => unsafe { syscall3(428, arg0, arg1, arg2) }, - // Syscall::MoveMount(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(429, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Fsopen(arg0, arg1, arg2) => unsafe { syscall3(430, arg0, arg1, arg2) }, - // Syscall::Fsconfig(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(431, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Fsmount(arg0, arg1, arg2) => unsafe { syscall3(432, arg0, arg1, arg2) }, - // Syscall::Fspick(arg0, arg1, arg2) => unsafe { syscall3(433, arg0, arg1, arg2) }, - // Syscall::PidfdOpen(arg0, arg1) => unsafe { syscall2(434, arg0, arg1) }, - // Syscall::Clone3(arg0, arg1) => unsafe { syscall2(435, arg0, arg1) }, - // Syscall::CloseRange(arg0, arg1, arg2) => unsafe { syscall3(436, arg0, arg1, arg2) }, - // Syscall::Openat2(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(437, arg0, arg1, arg2, arg3) - // }, - // Syscall::PidfdGetfd(arg0, arg1, arg2) => unsafe { syscall3(438, arg0, arg1, arg2) }, - // Syscall::Faccessat2(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(439, arg0, arg1, arg2, arg3) - // }, - // Syscall::ProcessMadvise(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(440, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::EpollPwait2(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(441, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::MountSetattr(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(442, arg0, arg1, arg2, arg3) - // }, - // Syscall::QuotactlFd(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(443, arg0, arg1, arg2, arg3) - // }, - // Syscall::LandlockCreateRuleset(arg0, arg1, arg2) => unsafe { - // syscall3(444, arg0, arg1, arg2) - // }, - // Syscall::LandlockAddRule(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(445, arg0, arg1, arg2, arg3) - // }, - // Syscall::LandlockRestrictSelf(arg0, arg1) => unsafe { syscall2(446, arg0, arg1) }, - // Syscall::MemfdSecret(arg0) => unsafe { syscall1(447, arg0) }, - // Syscall::ProcessMrelease(arg0, arg1) => unsafe { syscall2(448, arg0, arg1) }, - // Syscall::FutexWaitv(arg0, arg1, arg2) => unsafe { syscall3(449, arg0, arg1, arg2) }, - // Syscall::SetMempolicyHomeNode(arg0, arg1, arg2) => unsafe { - // syscall3(450, arg0, arg1, arg2) - // }, - // Syscall::Cachestat(arg0, arg1, arg2, arg3, arg4) => unsafe { - // syscall5(451, arg0, arg1, arg2, arg3, arg4) - // }, - // Syscall::Fchmodat2(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(452, arg0, arg1, arg2, arg3) - // }, - // Syscall::MapShadowStack(arg0, arg1) => unsafe { syscall2(453, arg0, arg1) }, - // Syscall::FutexWake(arg0, arg1, arg2) => unsafe { syscall3(454, arg0, arg1, arg2) }, - // Syscall::FutexWait(arg0, arg1, arg2) => unsafe { syscall3(455, arg0, arg1, arg2) }, - // Syscall::FutexRequeue(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(456, arg0, arg1, arg2, arg3) - // }, - // Syscall::Statmount(arg0, arg1, arg2) => unsafe { syscall3(457, arg0, arg1, arg2) }, - // Syscall::Listmount(arg0, arg1, arg2) => unsafe { syscall3(458, arg0, arg1, arg2) }, - // Syscall::LsmGetSelfAttr(arg0, arg1, arg2, arg3) => unsafe { - // syscall4(459, arg0, arg1, arg2, arg3) - // }, - // Syscall::LsmSetSelfAttr(arg0, arg1, arg2) => unsafe { syscall3(460, arg0, arg1, arg2) }, - // Syscall::LsmListModules(arg0, arg1) => unsafe { syscall2(461, arg0, arg1) }, - // Syscall::Unknown(syscall_num, args) => match args { - // [arg0, arg1, arg2, arg3, arg4, arg5] => unsafe { - // syscall6(syscall_num, arg0, arg1, arg2, arg3, arg4, arg5) - // }, - // _ => unreachable!(), - // }, - // } -} diff --git a/syscall_lib/src/syscall_num.rs b/syscall_lib/src/syscall_num.rs deleted file mode 100644 index ae2a93e..0000000 --- a/syscall_lib/src/syscall_num.rs +++ /dev/null @@ -1,380 +0,0 @@ -///https://docs.rs/syscalls/latest/syscalls/x86_64/enum.Sysno.html -#[non_exhaustive] -#[repr(i64)] -#[derive(Debug, PartialEq, Eq)] -#[allow(non_camel_case_types)] -pub enum Sysno { - read = libc::SYS_read, - write = libc::SYS_write, - open = libc::SYS_open, - close = libc::SYS_close, - stat = libc::SYS_stat, - fstat = libc::SYS_fstat, - lstat = libc::SYS_lstat, - poll = libc::SYS_poll, - lseek = libc::SYS_lseek, - mmap = libc::SYS_mmap, - mprotect = libc::SYS_mprotect, - munmap = libc::SYS_munmap, - brk = libc::SYS_brk, - rt_sigaction = libc::SYS_rt_sigaction, - rt_sigprocmask = libc::SYS_rt_sigprocmask, - rt_sigreturn = libc::SYS_rt_sigreturn, - ioctl = libc::SYS_ioctl, - pread64 = libc::SYS_pread64, - pwrite64 = libc::SYS_pwrite64, - readv = libc::SYS_readv, - writev = libc::SYS_writev, - access = libc::SYS_access, - pipe = libc::SYS_pipe, - select = libc::SYS_select, - sched_yield = libc::SYS_sched_yield, - mremap = libc::SYS_mremap, - msync = libc::SYS_msync, - mincore = libc::SYS_mincore, - madvise = libc::SYS_madvise, - shmget = libc::SYS_shmget, - shmat = libc::SYS_shmat, - shmctl = libc::SYS_shmctl, - dup = libc::SYS_dup, - dup2 = libc::SYS_dup2, - pause = libc::SYS_pause, - nanosleep = libc::SYS_nanosleep, - getitimer = libc::SYS_getitimer, - alarm = libc::SYS_alarm, - setitimer = libc::SYS_setitimer, - getpid = libc::SYS_getpid, - sendfile = libc::SYS_sendfile, - socket = libc::SYS_socket, - connect = libc::SYS_connect, - accept = libc::SYS_accept, - sendto = libc::SYS_sendto, - recvfrom = libc::SYS_recvfrom, - sendmsg = libc::SYS_sendmsg, - recvmsg = libc::SYS_recvmsg, - shutdown = libc::SYS_shutdown, - bind = libc::SYS_bind, - listen = libc::SYS_listen, - getsockname = libc::SYS_getsockname, - getpeername = libc::SYS_getpeername, - socketpair = libc::SYS_socketpair, - setsockopt = libc::SYS_setsockopt, - getsockopt = libc::SYS_getsockopt, - clone = libc::SYS_clone, - fork = libc::SYS_fork, - vfork = libc::SYS_vfork, - execve = libc::SYS_execve, - exit = libc::SYS_exit, - wait4 = libc::SYS_wait4, - kill = libc::SYS_kill, - uname = libc::SYS_uname, - semget = libc::SYS_semget, - semop = libc::SYS_semop, - semctl = libc::SYS_semctl, - shmdt = libc::SYS_shmdt, - msgget = libc::SYS_msgget, - msgsnd = libc::SYS_msgsnd, - msgrcv = libc::SYS_msgrcv, - msgctl = libc::SYS_msgctl, - fcntl = libc::SYS_fcntl, - flock = libc::SYS_flock, - fsync = libc::SYS_fsync, - fdatasync = libc::SYS_fdatasync, - truncate = libc::SYS_truncate, - ftruncate = libc::SYS_ftruncate, - getdents = libc::SYS_getdents, - getcwd = libc::SYS_getcwd, - chdir = libc::SYS_chdir, - fchdir = libc::SYS_fchdir, - rename = libc::SYS_rename, - mkdir = libc::SYS_mkdir, - rmdir = libc::SYS_rmdir, - creat = libc::SYS_creat, - link = libc::SYS_link, - unlink = libc::SYS_unlink, - symlink = libc::SYS_symlink, - readlink = libc::SYS_readlink, - chmod = libc::SYS_chmod, - fchmod = libc::SYS_fchmod, - chown = libc::SYS_chown, - fchown = libc::SYS_fchown, - lchown = libc::SYS_lchown, - umask = libc::SYS_umask, - gettimeofday = libc::SYS_gettimeofday, - getrlimit = libc::SYS_getrlimit, - getrusage = libc::SYS_getrusage, - sysinfo = libc::SYS_sysinfo, - times = libc::SYS_times, - ptrace = libc::SYS_ptrace, - getuid = libc::SYS_getuid, - syslog = libc::SYS_syslog, - getgid = libc::SYS_getgid, - setuid = libc::SYS_setuid, - setgid = libc::SYS_setgid, - geteuid = libc::SYS_geteuid, - getegid = libc::SYS_getegid, - setpgid = libc::SYS_setpgid, - getppid = libc::SYS_getppid, - getpgrp = libc::SYS_getpgrp, - setsid = libc::SYS_setsid, - setreuid = libc::SYS_setreuid, - setregid = libc::SYS_setregid, - getgroups = libc::SYS_getgroups, - setgroups = libc::SYS_setgroups, - setresuid = libc::SYS_setresuid, - getresuid = libc::SYS_getresuid, - setresgid = libc::SYS_setresgid, - getresgid = libc::SYS_getresgid, - getpgid = libc::SYS_getpgid, - setfsuid = libc::SYS_setfsuid, - setfsgid = libc::SYS_setfsgid, - getsid = libc::SYS_getsid, - capget = libc::SYS_capget, - capset = libc::SYS_capset, - rt_sigpending = libc::SYS_rt_sigpending, - rt_sigtimedwait = 128, - rt_sigqueueinfo = 129, - rt_sigsuspend = 130, - sigaltstack = 131, - utime = 132, - mknod = 133, - uselib = 134, - personality = 135, - ustat = 136, - statfs = 137, - fstatfs = 138, - sysfs = 139, - getpriority = 140, - setpriority = 141, - sched_setparam = 142, - sched_getparam = 143, - sched_setscheduler = 144, - sched_getscheduler = 145, - sched_get_priority_max = 146, - sched_get_priority_min = 147, - sched_rr_get_interval = 148, - mlock = 149, - munlock = 150, - mlockall = 151, - munlockall = 152, - vhangup = 153, - modify_ldt = 154, - pivot_root = 155, - _sysctl = 156, - prctl = 157, - arch_prctl = 158, - adjtimex = 159, - setrlimit = 160, - chroot = 161, - sync = 162, - acct = 163, - settimeofday = 164, - mount = 165, - umount2 = 166, - swapon = 167, - swapoff = 168, - reboot = 169, - sethostname = 170, - setdomainname = 171, - iopl = 172, - ioperm = 173, - create_module = 174, - init_module = 175, - delete_module = 176, - get_kernel_syms = 177, - query_module = 178, - quotactl = 179, - nfsservctl = 180, - getpmsg = 181, - putpmsg = 182, - afs_syscall = 183, - tuxcall = 184, - security = 185, - gettid = 186, - readahead = 187, - setxattr = 188, - lsetxattr = 189, - fsetxattr = 190, - getxattr = 191, - lgetxattr = 192, - fgetxattr = 193, - listxattr = 194, - llistxattr = 195, - flistxattr = 196, - removexattr = 197, - lremovexattr = 198, - fremovexattr = 199, - tkill = 200, - time = 201, - futex = 202, - sched_setaffinity = 203, - sched_getaffinity = 204, - set_thread_area = 205, - io_setup = 206, - io_destroy = 207, - io_getevents = 208, - io_submit = 209, - io_cancel = 210, - get_thread_area = 211, - lookup_dcookie = 212, - epoll_create = 213, - epoll_ctl_old = 214, - epoll_wait_old = 215, - remap_file_pages = 216, - getdents64 = 217, - set_tid_address = 218, - restart_syscall = 219, - semtimedop = 220, - fadvise64 = 221, - timer_create = 222, - timer_settime = 223, - timer_gettime = 224, - timer_getoverrun = 225, - timer_delete = 226, - clock_settime = 227, - clock_gettime = 228, - clock_getres = 229, - clock_nanosleep = 230, - exit_group = 231, - epoll_wait = 232, - epoll_ctl = 233, - tgkill = 234, - utimes = 235, - vserver = 236, - mbind = 237, - set_mempolicy = 238, - get_mempolicy = 239, - mq_open = 240, - mq_unlink = 241, - mq_timedsend = 242, - mq_timedreceive = 243, - mq_notify = 244, - mq_getsetattr = 245, - kexec_load = 246, - waitid = 247, - add_key = 248, - request_key = 249, - keyctl = 250, - ioprio_set = 251, - ioprio_get = 252, - inotify_init = 253, - inotify_add_watch = 254, - inotify_rm_watch = 255, - migrate_pages = 256, - openat = 257, - mkdirat = 258, - mknodat = 259, - fchownat = 260, - futimesat = 261, - newfstatat = 262, - unlinkat = 263, - renameat = 264, - linkat = 265, - symlinkat = 266, - readlinkat = 267, - fchmodat = 268, - faccessat = 269, - pselect6 = 270, - ppoll = 271, - unshare = 272, - set_robust_list = 273, - get_robust_list = 274, - splice = 275, - tee = 276, - sync_file_range = 277, - vmsplice = 278, - move_pages = 279, - utimensat = 280, - epoll_pwait = 281, - signalfd = 282, - timerfd_create = 283, - eventfd = 284, - fallocate = 285, - timerfd_settime = 286, - timerfd_gettime = 287, - accept4 = 288, - signalfd4 = 289, - eventfd2 = 290, - epoll_create1 = 291, - dup3 = 292, - pipe2 = 293, - inotify_init1 = 294, - preadv = 295, - pwritev = 296, - rt_tgsigqueueinfo = 297, - perf_event_open = 298, - recvmmsg = 299, - fanotify_init = 300, - fanotify_mark = 301, - prlimit64 = 302, - name_to_handle_at = 303, - open_by_handle_at = 304, - clock_adjtime = 305, - syncfs = 306, - sendmmsg = 307, - setns = 308, - getcpu = 309, - process_vm_readv = 310, - process_vm_writev = 311, - kcmp = 312, - finit_module = 313, - sched_setattr = 314, - sched_getattr = 315, - renameat2 = 316, - seccomp = 317, - getrandom = 318, - memfd_create = 319, - kexec_file_load = 320, - bpf = 321, - execveat = 322, - userfaultfd = 323, - membarrier = 324, - mlock2 = 325, - copy_file_range = 326, - preadv2 = 327, - pwritev2 = 328, - pkey_mprotect = 329, - pkey_alloc = 330, - pkey_free = 331, - statx = 332, - io_pgetevents = 333, - rseq = 334, - pidfd_send_signal = 424, - io_uring_setup = 425, - io_uring_enter = 426, - io_uring_register = 427, - open_tree = 428, - move_mount = 429, - fsopen = 430, - fsconfig = 431, - fsmount = 432, - fspick = 433, - pidfd_open = 434, - clone3 = 435, - close_range = 436, - openat2 = 437, - pidfd_getfd = 438, - faccessat2 = 439, - process_madvise = 440, - epoll_pwait2 = 441, - mount_setattr = 442, - quotactl_fd = 443, - landlock_create_ruleset = 444, - landlock_add_rule = 445, - landlock_restrict_self = 446, - memfd_secret = 447, - process_mrelease = 448, - futex_waitv = 449, - set_mempolicy_home_node = 450, - cachestat = 451, - fchmodat2 = 452, - map_shadow_stack = 453, - futex_wake = 454, - futex_wait = 455, - futex_requeue = 456, - statmount = 457, - listmount = 458, - lsm_get_self_attr = 459, - lsm_set_self_attr = 460, - lsm_list_modules = 461, -} diff --git a/syscall_lib/src/types.rs b/syscall_lib/src/types.rs index b6d29f9..0c14406 100644 --- a/syscall_lib/src/types.rs +++ b/syscall_lib/src/types.rs @@ -1,10 +1,19 @@ +use core::slice; +use std::any::{self, Any, TypeId}; +use std::ffi::CStr; use std::marker::PhantomData; use std::{fmt::Debug, mem::transmute}; use bincode::{Decode, Encode}; +const MAX_STR_LEN: usize = 30; + +pub trait AsPtr { + fn as_ptr(&self) -> usize; +} + #[derive(Encode, Decode)] -pub struct Ptr(libc::c_ulong, PhantomData); +pub struct Ptr(pub libc::c_ulong, PhantomData); impl Ptr where @@ -20,53 +29,182 @@ impl Debug for Ptr { unsafe { let ptr = transmute::(self.0); - // *(ptr as *mut u64) = 1; - // println!("{}", *ptr); - - // let ptr = std::mem::transmute::(self.0); - // let value = core::ptr::read::(ptr); - f.write_str(format!("0x{:X} -> {:?}", self.0, *ptr).as_str()) } - // Ok(()) } } -impl BufferLocation for Ptr { - fn get_location(&self) -> libc::c_char { - unsafe { core::ptr::read::(self.0 as *const libc::c_char) } +impl AsPtr for Ptr { + fn as_ptr(&self) -> usize { + self.0 as usize } } -pub trait BufferLocation { - fn get_location(&self) -> libc::c_char; -} +#[derive(Encode, Decode)] +pub struct PtrVoid(pub libc::c_ulong); -#[derive(Encode, Decode, Debug)] -pub struct Buf(pub T); - -// impl Buf { -// pub fn -// } - -// impl Debug for Buf { -// fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -// unsafe { -// // let addr = self.0.get_location(); -// // let data = -// // &crate::kern_buffers::create_and_use_kernel_buffer(addr as *const libc::c_char) -// // .unwrap(); - -// // f.write_str(data)? -// // "F" -// }; - -// Ok(()) -// } -// } - -impl BufferLocation for Buf { - fn get_location(&self) -> libc::c_char { - self.0.get_location() +impl PtrVoid { + pub fn new(location: libc::c_ulong) -> Self { + Self(location) // ooo } } + +impl Debug for PtrVoid { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(format!("0x{:X} -> void", self.0).as_str()) + } +} + +impl AsPtr for PtrVoid { + fn as_ptr(&self) -> usize { + self.0 as usize + } +} + +fn trunc(str: &str) -> String { + let mut out_str = str[0..MAX_STR_LEN.min(str.len())].to_string(); + + if str.len() > MAX_STR_LEN { + out_str += "..."; + } + + out_str +} + +#[derive(Encode, Decode)] +pub struct Buf(pub libc::c_ulong, PhantomData); + +impl Buf { + pub fn new(ptr: libc::c_ulong) -> Self { + Self(ptr, PhantomData) + } + pub fn read(&self, len: usize) -> &[T] { + // Convert the address to a raw pointer + let ptr = self.0 as *const T; + + // Create a slice from the raw pointer and length + let slice = unsafe { slice::from_raw_parts::(ptr, len) }; + + // Copy the data into a Vec to return owned data + slice + } +} + +impl Debug for Buf { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(format!("Buf<{}>", any::type_name::()).as_str()) + // f.debug_tuple("Buf").field(self.read().len()).finish() + } +} + +impl AsPtr for Buf { + fn as_ptr(&self) -> usize { + self.0 as usize + } +} + +#[derive(Encode, Decode)] +pub struct StrRef(pub libc::c_ulong); + +impl StrRef { + pub fn new(ptr: libc::c_ulong) -> Self { + Self(ptr) + } + pub fn read(&self) -> String { + let ptr = self.0 as *const libc::c_char; + + let c_str = unsafe { CStr::from_ptr(ptr) }; + + c_str.to_string_lossy().to_string() + } +} + +impl Debug for StrRef { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(format!("\"{}\"", trunc(self.read().as_str())).as_str()) + // f.debug_tuple("Buf").field(self.read().len()).finish() + } +} + +impl AsPtr for StrRef { + fn as_ptr(&self) -> usize { + self.0 as usize + } +} + +#[repr(u8)] +#[derive(Encode, Decode)] +pub enum Void { + __variant1, + __variant2, +} + +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct AioContext; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct Iocb; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct IoEvent; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct IoUringParams; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct Mmsghdr; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct GetcpuCache; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct RobustListHead; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct FutexWaitv; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct KexecSegment; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct CapUserHeaderT; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct CapUserDataT; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct Rlimit64; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct FileHandle; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct PerfEventAttr; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct SchedAttr; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct CloneArgs; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct BpfAttr; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct Statx; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct Rseq; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct OpenHow; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct MountAttr; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct LandlockRulesetAttr; +#[repr(C)] +#[derive(Debug, Clone, Copy, Encode, Decode)] +pub struct LandlockRule;