feature: passing args to execve()

This commit is contained in:
2021-11-24 15:16:34 +02:00
parent 7f939543fe
commit 47b67fa93c
13 changed files with 228 additions and 53 deletions
+4 -2
View File
@@ -204,12 +204,14 @@ pub unsafe fn sys_fork() -> Result<Option<Pid>, Errno> {
///
/// System call
#[inline(always)]
pub fn sys_execve(pathname: &str) -> Result<(), Errno> {
pub fn sys_execve(pathname: &str, argv: &[&str]) -> Result<(), Errno> {
Errno::from_syscall_unit(unsafe {
syscall!(
SystemCall::Exec,
argp!(pathname.as_ptr()),
argn!(pathname.len())
argn!(pathname.len()),
argp!(argv.as_ptr()),
argn!(argv.len())
)
})
}
+8
View File
@@ -15,6 +15,14 @@ pub mod stat;
pub mod termios;
pub mod traits;
#[derive(Debug)]
pub struct ProgramArgs {
pub argv: usize,
pub argc: usize,
pub storage: usize,
pub size: usize
}
#[cfg(feature = "user")]
pub mod calls;
#[cfg(feature = "user")]
+1 -1
View File
@@ -13,7 +13,7 @@ pub fn read_le16(src: &[u8]) -> u16 {
/// Unsafe: writes to arbitrary memory locations, performs no pointer
/// validation.
#[no_mangle]
pub unsafe extern "C" fn memcpy(dst: *mut u8, src: *mut u8, mut len: usize) -> *mut u8 {
pub unsafe extern "C" fn memcpy(dst: *mut u8, src: *const u8, mut len: usize) -> *mut u8 {
while len != 0 {
len -= 1;
*dst.add(len) = *src.add(len);