change args from Iter to Vec<String>

master
WangRunji 6 years ago
parent 0ff24fe589
commit 520bb2d957

@ -158,15 +158,12 @@ impl Thread {
}
/// Make a new user process from ELF `data`
pub fn new_user<'a, Iter>(
pub fn new_user(
data: &[u8],
exec_path: &str,
args: Iter,
mut args: Vec<String>,
envs: Vec<String>,
) -> Box<Thread>
where
Iter: Iterator<Item = &'a str>,
{
) -> Box<Thread> {
// Parse ELF
let elf = ElfFile::new(data).expect("failed to read elf");
@ -185,12 +182,11 @@ impl Thread {
debug!("using loader {}", &loader_path);
// Elf loader should not have INTERP
// No infinite loop
let mut new_args: Vec<&str> = args.collect();
new_args.insert(0, loader_path);
new_args.insert(1, exec_path);
new_args.remove(2);
warn!("loader args: {:?}", new_args);
return Thread::new_user(buf.as_slice(), exec_path, new_args.into_iter(), envs);
args.insert(0, loader_path.into());
args.insert(1, exec_path.into());
args.remove(2);
warn!("loader args: {:?}", args);
return Thread::new_user(buf.as_slice(), exec_path, args, envs);
} else {
warn!("loader specified as {} but failed to read", &loader_path);
}
@ -219,7 +215,7 @@ impl Thread {
// Make init info
let init_info = ProcInitInfo {
args: args.map(|s| String::from(s)).collect(),
args,
envs,
auxv: {
let mut map = BTreeMap::new();

@ -13,7 +13,7 @@ pub fn run_user_shell() {
processor().manager().add(Thread::new_user(
data.as_slice(),
"rust/sh",
"sh".split(' '),
vec!["sh".into()],
Vec::new(),
));
} else {
@ -28,7 +28,7 @@ pub fn run_user_shell() {
let data = inode.read_as_vec().unwrap();
processor().manager().add(Thread::new_user(
data.as_slice(),
cmdline.split(' '),
cmdline.split(' ').map(|s| s.into()).collect(),
Vec::new(),
));
}
@ -50,7 +50,7 @@ pub extern "C" fn shell(_arg: usize) -> ! {
let _pid = processor().manager().add(Thread::new_user(
data.as_slice(),
&cmd,
cmd.split(' '),
cmd.split(' ').map(|s| s.into()).collect(),
Vec::new(),
));
// TODO: wait until process exits, or use user land shell completely

@ -176,8 +176,7 @@ pub fn sys_exec(
let buf = inode.read_as_vec()?;
// Make new Thread
let args_iter = args.iter().map(|s| s.as_str());
let mut thread = Thread::new_user(buf.as_slice(), exec_path, args_iter, envs);
let mut thread = Thread::new_user(buf.as_slice(), exec_path, args, envs);
thread.proc.lock().clone_for_exec(&proc);
// Activate new page table

Loading…
Cancel
Save