feature: passing args to execve()
This commit is contained in:
+4
-2
@@ -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())
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user