add LOG info in sys_exec and new_user, add env var in run_user_shell

master
chyyuu 6 years ago
parent d8147bd955
commit 0d790f2dc5

@ -195,8 +195,8 @@ impl Thread {
args.insert(0, loader_path.into());
args.insert(1, exec_path.into());
args.remove(2);
info!("loader args: {:?}", args);
info!("loader envs: {:?}", envs);
//info!("loader args: {:?}", args);
//info!("loader envs: {:?}", envs);
return Thread::new_user(buf.as_slice(), exec_path, args, envs);
} else {
warn!("loader specified as {} but failed to read", &loader_path);

@ -14,7 +14,7 @@ pub fn run_user_shell() {
data.as_slice(),
"busybox",
vec!["busybox".into(), "sh".into()],
Vec::new(),
vec!["PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/x86_64-alpine-linux-musl/bin".into()],
));
} else {
processor().manager().add(Thread::new_kernel(shell, 0));

@ -129,7 +129,7 @@ pub fn sys_exec(
envp: *const *const u8,
tf: &mut TrapFrame,
) -> SysResult {
info!("exec: name: {:?}, argv: {:?}, envp: {:?}", name, argv, envp);
info!("exec:BEG: name: {:?}, argv: {:?}, envp: {:?}", name, argv, envp);
let proc = process();
let exec_name = if name.is_null() {
String::from("")
@ -138,6 +138,7 @@ pub fn sys_exec(
};
if argv.is_null() {
info!("exec:END:ERR1: exec_name: {:?}, name: {:?}, argv: is NULL", exec_name, name);
return Err(SysError::EINVAL);
}
// Check and copy args to kernel
@ -147,6 +148,7 @@ pub fn sys_exec(
proc.vm.check_read_ptr(current_argv)?;
while !(*current_argv).is_null() {
let arg = proc.vm.check_and_clone_cstr(*current_argv)?;
info!(" arg: {}",arg);
args.push(arg);
current_argv = current_argv.add(1);
}
@ -159,6 +161,7 @@ pub fn sys_exec(
proc.vm.check_read_ptr(current_env)?;
while !(*current_env).is_null() {
let env = proc.vm.check_and_clone_cstr(*current_env)?;
info!(" env: {}",env);
envs.push(env);
current_env = current_env.add(1);
}
@ -166,12 +169,13 @@ pub fn sys_exec(
}
if args.is_empty() {
info!("exec:END:ERR2: exec_name: {:?}, name: {:?}, args is empty", exec_name, name);
return Err(SysError::EINVAL);
}
info!(
"exec: name: {:?}, args: {:?}, envp: {:?}",
exec_name, args, envs
"exec:STEP2: exec_name: {:?}, name{:?}, args: {:?}, envp: {:?}",
exec_name, name, args, envs
);
// Read program file
@ -196,6 +200,10 @@ pub fn sys_exec(
::core::mem::swap(&mut current_thread().kstack, &mut thread.kstack);
::core::mem::swap(current_thread(), &mut *thread);
info!(
"exec:END: exec_name: {:?}",
exec_name
);
Ok(0)
}

Loading…
Cancel
Save