Load app from sdcard on K210, but panicked on qemu.

This commit is contained in:
Yifan Wu 2020-12-20 00:52:14 +08:00
parent 760de97155
commit a3802a4b91
18 changed files with 177 additions and 142 deletions

View file

@ -10,7 +10,11 @@ use crate::mm::{
translated_str,
translated_refmut,
};
use crate::loader::get_app_data_by_name;
use crate::fs::{
OSInode,
open_file,
OpenFlags,
};
use alloc::sync::Arc;
pub fn sys_exit(exit_code: i32) -> ! {
@ -48,9 +52,10 @@ pub fn sys_fork() -> isize {
pub fn sys_exec(path: *const u8) -> isize {
let token = current_user_token();
let path = translated_str(token, path);
if let Some(data) = get_app_data_by_name(path.as_str()) {
if let Some(app_inode) = open_file(path.as_str(), OpenFlags::RDONLY) {
let all_data = app_inode.read_all();
let task = current_task().unwrap();
task.exec(data);
task.exec(all_data.as_slice());
0
} else {
-1