mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-22 16:16:16 +04:00
Do not panic when exec file is invalid
This commit is contained in:
parent
60cdea81d9
commit
bd158e4e74
@ -30,12 +30,9 @@ pub fn add_user_shell() {
|
||||
let init_args = vec!["busybox".into(), "ash".into()];
|
||||
|
||||
if let Ok(inode) = ROOT_INODE.lookup(init_shell) {
|
||||
processor().manager().add(Thread::new_user(
|
||||
&inode,
|
||||
init_shell,
|
||||
init_args,
|
||||
init_envs,
|
||||
));
|
||||
processor()
|
||||
.manager()
|
||||
.add(Thread::new_user(&inode, init_shell, init_args, init_envs));
|
||||
} else {
|
||||
processor().manager().add(Thread::new_kernel(shell, 0));
|
||||
}
|
||||
|
@ -174,19 +174,25 @@ pub fn sys_exec(
|
||||
let inode = proc.lookup_inode(&path)?;
|
||||
|
||||
// Make new Thread
|
||||
let (mut vm, entry_addr, ustack_top) = Thread::new_user_vm(&inode, &path, args, envs).unwrap();
|
||||
match Thread::new_user_vm(&inode, &path, args, envs) {
|
||||
Ok((mut vm, entry_addr, ustack_top)) => {
|
||||
// Activate new page table
|
||||
core::mem::swap(&mut proc.vm, &mut vm);
|
||||
unsafe {
|
||||
proc.vm.activate();
|
||||
}
|
||||
|
||||
// Activate new page table
|
||||
core::mem::swap(&mut proc.vm, &mut vm);
|
||||
unsafe {
|
||||
proc.vm.activate();
|
||||
// Modify the TrapFrame
|
||||
*tf = TrapFrame::new_user_thread(entry_addr, ustack_top);
|
||||
|
||||
info!("exec:END: path: {:?}", path);
|
||||
Ok(0)
|
||||
}
|
||||
Err(err) => {
|
||||
info!("exec failed with {}", err);
|
||||
Err(SysError::EINVAL)
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the TrapFrame
|
||||
*tf = TrapFrame::new_user_thread(entry_addr, ustack_top);
|
||||
|
||||
info!("exec:END: path: {:?}", path);
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
pub fn sys_yield() -> SysResult {
|
||||
|
Loading…
Reference in New Issue
Block a user