Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR for Rawposix(dispatcher.rs, fs_call.rs, misc.rs) #47

Merged
merged 41 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3953794
integrated into lind-wasm
qianxichen233 Sep 16, 2024
519e828
futex implementation
qianxichen233 Sep 16, 2024
190cd40
update dispatcher.rs
Sep 20, 2024
fb549df
clone impl inside rawposix
qianxichen233 Sep 22, 2024
48f34e7
moved clone impl into wasmtime
qianxichen233 Sep 23, 2024
9e3e03d
update
Sep 23, 2024
b80df72
resolve conflict
qianxichen233 Sep 24, 2024
cdac30d
resolved conflict
qianxichen233 Sep 24, 2024
c7e46ee
fixed merged version
qianxichen233 Sep 24, 2024
9fe1d73
add some syscalls
qianxichen233 Sep 24, 2024
adce7bd
support more syscalls for lind-wasm
qianxichen233 Sep 24, 2024
0d51b64
fixed librawposix
qianxichen233 Sep 25, 2024
55be5f8
fixed sleep
Sep 30, 2024
48d2477
delete some reference
Oct 1, 2024
db9fbc4
delete repeat recv
Oct 1, 2024
8d36a35
delete repeat exit exec
Oct 1, 2024
0300e71
some cleanup
qianxichen233 Oct 1, 2024
e778e3b
restore signal
qianxichen233 Oct 1, 2024
fe740a5
merged from main
qianxichen233 Oct 1, 2024
e51cbef
move futex and nanosleep from misc.rs to fs_call.rs
Oct 1, 2024
dbd4a0a
merged from main
qianxichen233 Oct 1, 2024
504f7cc
delete misc.rs line 28
Oct 1, 2024
112476b
delete comment for disrpatcher.rs
Oct 2, 2024
78f3b5f
delete comment for src/lib.rs
Oct 2, 2024
1288f49
add newline to mod.rs
Oct 2, 2024
6f94013
add comment for nanosleep_time64 syscall
Oct 2, 2024
e50487e
change type function from union to u64
Oct 21, 2024
eb7121c
clean up & resolve comments
qianxichen233 Oct 22, 2024
ef50f3b
clean up lib.rs
qianxichen233 Oct 27, 2024
e9a2bb2
comment and new name for type.rs
Oct 30, 2024
9714a5b
long comment for type.rs
Oct 30, 2024
77f8f07
delete u64 to string function and use another function from type.rs
Oct 31, 2024
ee2801d
add newline
Nov 4, 2024
79cac84
clean up lib.rs
qianxichen233 Nov 4, 2024
39d14a3
add author name and clean up
Nov 6, 2024
40416fe
comment for lind_syscall_api function
Nov 6, 2024
2751d62
delete comment for types.rs
Nov 6, 2024
7346874
add name
Nov 6, 2024
de3b35a
update comment for lind_syscall_api
qianxichen233 Nov 7, 2024
b9376f1
delete macro and unsafe
Nov 11, 2024
538e1a3
resolve conflict
Nov 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "rustposix"
name = "rawposix"
version = "0.1.0"
authors = ["Nicholas Smith Renner <[email protected]>", "Jonathan Eli Singer <[email protected]>", "Tristan J. Brigham <[email protected]>"]
robinyuan1002 marked this conversation as resolved.
Show resolved Hide resolved
edition = "2018"
Expand Down
1 change: 1 addition & 0 deletions mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod rawposix;
robinyuan1002 marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion src/interface/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,4 +641,4 @@ pub fn kernel_select(
};

return result;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still needs newline

10 changes: 9 additions & 1 deletion src/interface/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub use std::sync::atomic::{
pub use std::sync::Arc as RustRfc;
pub use std::thread::spawn as helper_thread;

use libc::{mmap, pthread_exit, pthread_kill, pthread_self, sched_yield};
use libc::{mmap, pthread_exit, pthread_kill, pthread_self, sched_yield, syscall, SYS_clock_nanosleep, SYS_futex};
robinyuan1002 marked this conversation as resolved.
Show resolved Hide resolved
use std::ffi::c_void;

pub use serde::{Deserialize as SerdeDeserialize, Serialize as SerdeSerialize};
Expand Down Expand Up @@ -306,6 +306,14 @@ pub fn lind_kill_from_id(cage_id: u64, sig: i32) {
}
}

pub fn libc_futex(uaddr: u64, futex_op: u32, val: u32, val2: u32, uaddr2: u32, val3: u32) -> i32 {
unsafe { syscall(SYS_futex, uaddr, futex_op, val, val2, uaddr2, val3) as i32 }
}

pub fn libc_nanosleep_time64(clockid: u32, flags: i32, req: usize, rem: usize) -> i32 {
unsafe { syscall(SYS_clock_nanosleep, clockid, flags, req, rem) as i32 }
}

Yaxuan-w marked this conversation as resolved.
Show resolved Hide resolved
#[derive(Debug)]
pub struct AdvisoryLock {
//0 signifies unlocked, -1 signifies locked exclusively, positive number signifies that many shared lock holders
Expand Down
35 changes: 32 additions & 3 deletions src/interface/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ pub struct Rlimit {
pub rlim_max: u64,
}

#[derive(Eq, PartialEq, Default, Copy, Clone)]
#[derive(Eq, PartialEq, Default, Copy, Clone, Debug)]
#[repr(C)]
pub struct PipeArray {
pub readfd: i32,
pub writefd: i32,
}

#[derive(Eq, PartialEq, Default, Copy, Clone)]
#[derive(Eq, PartialEq, Default, Copy, Clone, Debug)]
#[repr(C)]
pub struct SockPair {
pub sock1: i32,
Expand Down Expand Up @@ -229,6 +229,7 @@ pub union Arg {
// pub dispatch_structsem: *mut sem_t,
// pub dispatch_ifaddrs: *mut ifaddrs,
pub dispatch_constiovecstruct: *const interface::IovecStruct,
pub dispatch_cloneargs: *mut interface::CloneArgStruct
}

use std::mem::size_of;
Expand All @@ -241,6 +242,22 @@ pub struct ClippedDirent {
pub d_reclen: u16,
}

#[derive(Copy, Clone, Default, Debug)]
#[repr(C)]
pub struct CloneArgStruct {
pub flags: u64, // Flags that control the behavior of the child process
pub pidfd: u64, // File descriptor to receive the child's PID
pub child_tid: u64, // Pointer to a memory location where the child TID will be stored
pub parent_tid: u64, // Pointer to a memory location where the parent's TID will be stored
pub exit_signal: u64, // Signal to be sent when the child process exits
pub stack: u64, // Address of the stack for the child process
pub stack_size: u64, // Size of the stack for the child process
pub tls: u64, // Thread-Local Storage (TLS) descriptor for the child thread
pub set_tid: u64, // Pointer to an array of TIDs to be set in the child
pub set_tid_size: u64, // Number of TIDs in the `set_tid` array
pub cgroup: u64, // File descriptor for the cgroup to which the child process should be attached
}

pub const CLIPPED_DIRENT_SIZE: u32 = size_of::<interface::ClippedDirent>() as u32;

pub fn get_int(union_argument: Arg) -> Result<i32, i32> {
Expand Down Expand Up @@ -478,6 +495,17 @@ pub fn get_ioctlptrunion<'a>(union_argument: Arg) -> Result<&'a mut u8, i32> {
));
}

pub fn get_cloneargs<'a>(clone_args: Arg) -> Result<&'a mut CloneArgStruct, i32> {
let pointer = unsafe { clone_args.dispatch_cloneargs };
if !pointer.is_null() {
return Ok(unsafe { &mut *pointer });
}
return Err(syscall_error(
Errno::EFAULT,
"dispatcher",
"input data not valid",
));
}

// pub fn get_ioctlptrunion(union_argument: Arg) -> Result<IoctlPtrUnion, i32> {
robinyuan1002 marked this conversation as resolved.
Show resolved Hide resolved
// return Ok(unsafe { union_argument.dispatch_ioctlptrunion });
Expand Down Expand Up @@ -631,7 +659,8 @@ pub fn get_sockaddr(union_argument: Arg, addrlen: u32) -> Result<interface::GenS
let v6_ptr = pointer as *const interface::SockaddrV6;
return Ok(interface::GenSockaddr::V6(unsafe { *v6_ptr }));
}
_ => {
val => {
println!("val: {}", val);
return Err(syscall_error(
Errno::EOPNOTSUPP,
"dispatcher",
Expand Down
Loading
Loading