feature: add execve() system call
This commit is contained in:
@@ -405,6 +405,12 @@ impl Process {
|
||||
unsafe {
|
||||
SCHED.hack_current_pid(lock.id);
|
||||
}
|
||||
} else {
|
||||
// Invalidate user ASID
|
||||
let input = (lock.id.asid() as usize) << 48;
|
||||
unsafe {
|
||||
asm!("tlbi aside1, {}", in(reg) input);
|
||||
}
|
||||
}
|
||||
|
||||
let new_space = Space::alloc_empty()?;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use crate::arch::platform::exception::ExceptionFrame;
|
||||
use crate::debug::Level;
|
||||
use crate::proc::{wait, Pid, Process};
|
||||
use crate::proc::{elf, wait, Pid, Process};
|
||||
use core::mem::size_of;
|
||||
use core::time::Duration;
|
||||
use error::Errno;
|
||||
@@ -91,6 +91,20 @@ pub fn syscall(num: usize, args: &[usize]) -> Result<usize, Errno> {
|
||||
io.close_file(fd)?;
|
||||
Ok(0)
|
||||
}
|
||||
abi::SYS_EXECVE => {
|
||||
let node = {
|
||||
let proc = Process::current();
|
||||
let mut io = proc.io.lock();
|
||||
let filename = validate_user_str(args[0], args[1])?;
|
||||
// TODO argv, envp array passing ABI?
|
||||
let node = io.ioctx().find(None, filename, true)?;
|
||||
drop(io);
|
||||
node
|
||||
};
|
||||
let mut file = node.open(OpenFlags::O_RDONLY)?;
|
||||
Process::execve(|space| elf::load_elf(space, &mut file), 0).unwrap();
|
||||
panic!();
|
||||
}
|
||||
|
||||
// Extra system calls
|
||||
abi::SYS_EX_DEBUG_TRACE => {
|
||||
|
||||
Reference in New Issue
Block a user